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

# Create a video

> Starts a video generation task. The price is duration times the per-second rate for the chosen resolution and draft mode.



## OpenAPI

````yaml /openapi.json post /v1/videos/generations
openapi: 3.1.0
info:
  title: one-api.ai
  version: 1.0.0
  description: Image and video generation tasks.
servers:
  - url: https://one-api.ai
security:
  - bearerAuth: []
tags:
  - name: Generate
    description: Start an image or video task.
  - name: Tasks
    description: Read task status and results.
paths:
  /v1/videos/generations:
    post:
      tags:
        - Generate
      summary: Create a video
      description: >-
        Starts a video generation task. The price is duration times the
        per-second rate for the chosen resolution and draft mode.
      operationId: createVideo
      parameters:
        - name: wait
          in: query
          required: false
          description: >-
            Hold the call open until the task finishes, for at most this many
            seconds. `Prefer: wait=<seconds>` does the same.
          schema:
            type: integer
            minimum: 0
            maximum: 60
            default: 0
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VideoRequest'
            example:
              model: p-video
              prompt: a kitten walking across a rooftop at night
              duration: 5
              draft: true
      responses:
        '200':
          description: >-
            The task was accepted. Without `wait`, the entry holds the task id
            and `submitted`. With `wait`, it also holds the task as it stood
            when the wait ended.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatedResponse'
              examples:
                submitted:
                  summary: Without wait
                  value:
                    code: 200
                    data:
                      - task_id: task_0a17552fb8dbea3a74bc42048e5212e1
                        status: submitted
        '400':
          description: A field is missing, out of range, or not supported by the model.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: The API key is missing, wrong or revoked.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: The balance does not cover the task. Nothing was started.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: The model is not offered on this route.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Too many requests, or five tasks are already unfinished.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    VideoRequest:
      type: object
      additionalProperties: false
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          enum:
            - p-video
        prompt:
          type: string
          minLength: 1
          maxLength: 2500
          description: What to film.
        duration:
          type: integer
          minimum: 1
          maximum: 20
          default: 5
          description: Length in seconds.
        resolution:
          type: string
          enum:
            - 720p
            - 1080p
          default: 720p
        aspect_ratio:
          type: string
          enum:
            - '16:9'
            - '9:16'
            - '4:3'
            - '3:4'
            - '3:2'
            - '2:3'
            - '1:1'
          default: '16:9'
        draft:
          type: boolean
          default: false
          description: A faster, lower-quality preview at a quarter of the price.
        seed:
          type: integer
          description: Seed for a reproducible result.
    CreatedResponse:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          examples:
            - 200
        data:
          type: array
          minItems: 1
          maxItems: 1
          items:
            $ref: '#/components/schemas/CreatedTask'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              enum:
                - bad_request
                - unauthorized
                - insufficient_credits
                - not_found
                - method_not_allowed
                - rate_limited
                - bad_gateway
            message:
              type: string
    CreatedTask:
      type: object
      required:
        - task_id
        - status
      description: >-
        Always holds `task_id` and `status`. When the call waited, the other
        task fields are included as well.
      properties:
        task_id:
          type: string
        status:
          type: string
          enum:
            - submitted
            - pending
            - processing
            - completed
            - failed
      additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Your one-api.ai API key.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.