> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ai-stats.phaseo.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Video generation (Beta)

> Creates an async video generation job. Poll the returned `polling_url` every 20 seconds until the job reaches a terminal status.

Creates an asynchronous video generation job and returns a job record immediately.

Related collection endpoints:

* `GET /v1/videos` to review recent owned jobs
* `GET /v1/videos/models` to inspect active public video model capabilities

The initial response is a `video` object with fields such as:

* `id`
* `status`
* `polling_url`
* `provider`
* `model`
* `poll_after_seconds`
* optional `billing`, `content_url`, `download_url`, and `outputs` fields when available

After creating a job:

* `GET /v1/videos/{video_id}` for status updates.
* `GET /v1/videos/{video_id}/content` when the job is complete.
* `POST /v1/videos/{video_id}/download_url` when you need a short-lived signed download link.

## Lifecycle notes

* Video generation is async by design. Do not expect binary video data in the create response.
* The gateway can hold funds up front and later settle or void them when the provider reaches a terminal state.
* Terminal states include `completed`, `failed`, `cancelled`, and `expired`.
* Webhook configuration can be included in the create request when you want lifecycle notifications instead of pure polling.


## OpenAPI

````yaml POST /videos
openapi: 3.0.3
info:
  title: AI Stats Gateway API
  description: >-
    A gateway API for accessing various AI models with OpenAI-compatible
    endpoints.
  version: 1.0.0
  contact:
    name: AI Stats
    url: https://docs.ai-stats.phaseo.app
    email: danielbutler500@gmail.com
servers:
  - url: https://api.phaseo.app/v1
security:
  - BearerAuth: []
tags:
  - name: Gateway
    description: Core AI Stats Gateway operations.
paths:
  /videos:
    post:
      tags:
        - Gateway
      summary: Create video
      description: >-
        Creates an async video generation job. Poll the returned `polling_url`
        every 20 seconds until the job reaches a terminal status.
      operationId: createVideo
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VideoGenerationRequest'
      responses:
        '202':
          description: Video response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoGenerationResponse'
components:
  schemas:
    VideoGenerationRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
        prompt:
          type: string
        duration:
          type: integer
          description: Desired duration in seconds (provider/model dependent).
        size:
          type: string
          description: >-
            Explicit dimensions (for example 1280x720). Cannot be combined with
            resolution or aspect_ratio.
        resolution:
          type: string
          description: >-
            480p, 720p, 1080p, 1K, 2K, 4K. Can be combined with aspect_ratio.
            Cannot be combined with size.
        aspect_ratio:
          type: string
          description: >-
            Aspect ratio such as 16:9, 9:16, 1:1. Can be combined with
            resolution. Cannot be combined with size.
        seed:
          type: integer
        sample_count:
          type: integer
        negative_prompt:
          type: string
        generate_audio:
          type: boolean
        enhance_prompt:
          type: boolean
        compression_quality:
          type: integer
        person_generation:
          type: string
        resize_mode:
          type: string
        input_references:
          type: array
          items:
            $ref: '#/components/schemas/VideoInputReference'
        provider_params:
          type: object
          additionalProperties: true
        output:
          $ref: '#/components/schemas/VideoOutputConfig'
        webhook:
          type: object
          properties:
            url:
              type: string
              format: uri
            secret:
              type: string
            events:
              type: array
              items:
                type: string
        provider:
          $ref: '#/components/schemas/ProviderRoutingOptions'
    VideoGenerationResponse:
      type: object
      properties:
        id:
          type: string
        polling_url:
          type: string
        model:
          type: string
        request_id:
          type: string
        session_id:
          type: string
        status:
          type: string
          enum:
            - queued
            - processing
            - completed
            - failed
            - cancelled
            - expired
        output_access:
          type: string
          enum:
            - bytes
            - signed_url
            - both
        generation_id:
          type: string
          nullable: true
        created_at:
          oneOf:
            - type: integer
            - type: string
        started_at:
          nullable: true
          oneOf:
            - type: integer
            - type: string
        completed_at:
          nullable: true
          oneOf:
            - type: integer
            - type: string
        object:
          type: string
          example: video
        poll_after_seconds:
          type: integer
          example: 20
        provider:
          type: string
        seconds:
          type: number
        size:
          type: string
        audio:
          type: boolean
        content_url:
          type: string
          description: Present when output_access includes bytes (authenticated endpoint).
        download_url:
          type: string
          nullable: true
          description: Signed first-party URL for direct download when status is completed.
        expires_at:
          type: integer
          nullable: true
          description: Unix timestamp (seconds) when the signed download_url expires.
        progress:
          type: integer
          nullable: true
        progress_source:
          type: string
        asset:
          type: object
          nullable: true
          properties:
            id:
              type: string
            mime_type:
              type: string
            bytes:
              type: integer
            sha256:
              type: string
            width:
              type: integer
            height:
              type: integer
            duration_seconds:
              type: number
        outputs:
          type: array
          items:
            $ref: '#/components/schemas/VideoOutput'
        billing:
          type: object
          additionalProperties: true
        usage:
          type: object
          properties:
            cost:
              type: number
            is_byok:
              type: boolean
          additionalProperties: true
        error:
          nullable: true
    VideoInputReference:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - image_url
        role:
          type: string
          enum:
            - first_frame
            - last_frame
            - reference
            - source
            - mask
        reference_type:
          type: string
        image_url:
          type: object
          required:
            - url
          properties:
            url:
              type: string
    VideoOutputConfig:
      type: object
      properties:
        access:
          type: string
          enum:
            - bytes
            - signed_url
            - both
          default: both
          description: >-
            bytes=authenticated content_url only, signed_url=signed download
            links only, both=include both.
    ProviderRoutingOptions:
      type: object
      description: Provider routing preferences for gateway selection.
      properties:
        order:
          type: array
          items:
            type: string
        only:
          type: array
          items:
            type: string
        ignore:
          type: array
          items:
            type: string
        include_alpha:
          type: boolean
          description: Include alpha providers in routing (off by default).
    VideoOutput:
      type: object
      properties:
        index:
          type: integer
        mime_type:
          type: string
        bytes_available:
          type: boolean
        content_url:
          type: string
          description: Present when output_access includes bytes.
        download_url:
          type: string
          description: Signed first-party URL for this output.
        expires_at:
          type: integer
          description: Unix timestamp (seconds) when this output URL expires.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication

````