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

# Generate Video

> Generate AI videos from text prompts or images using 40+ models including Veo 3.1, Kling 3.0, Sora 2, Hailuo, and more.

Video generation is asynchronous — the response returns a video ID immediately. Use the [Get Video](/api-reference/endpoint/get-video) endpoint to poll for the result.

**Input types:**
- **Text-to-video** — Provide only a `prompt`
- **Image-to-video** — Provide both `prompt` and `image` URL

**Note:** Video generation requires a paid plan.

## Workflow

Video generation is asynchronous. Here's the typical flow:

1. **Submit** a video generation request using this endpoint
2. **Save** the `id` from the response
3. **Poll** the [Get Video](/api-reference/endpoint/get-video) endpoint every 15–30 seconds until `status` is `completed`
4. **Download** the video from the `url` field

<Note>
  Video generation typically takes **1–5 minutes** depending on the model, duration, and resolution. A paid plan is required.
</Note>

## Input types

The `model` value must **exactly match** one of the titles in the `model` enum, and each mode is a **separate model variant** — the title's suffix tells you which image inputs it accepts:

* **Text-to-video** — Provide only a `prompt` (no image fields). Use the base title, e.g. `Seedance 2.0`, `Veo 3.1`.
* **Image-to-video (first frame)** — Provide `prompt` + `image` (a start-frame URL). Use a title ending in **"Image"**, e.g. `Seedance 2.0 Image`, `Veo 3.1 Fast Image`, `Kling 3.0 Pro Image`.
* **First & last frame** — Provide `prompt` + `image` (first) + `tailImage` (last). Use a **"First-Last Frame"** title (e.g. `Veo 3.1 First-Last Frame`), or `Seedance 2.0 Image`, which also accepts a `tailImage` end frame.
* **Reference-to-video (multiple references)** — Provide `prompt` + `referenceImages` (an array of `{ "url": ... }`, up to 9) to keep characters/objects/style consistent. Use a title ending in **"Reference"**, e.g. `Seedance 2.0 Reference`, `Kling O1 Reference`, `Kling O3 Reference`.

<Note>
  For Seedance 2.0 these are distinct models: `Seedance 2.0` (text), `Seedance 2.0 Image` (first frame, optional last frame), and `Seedance 2.0 Reference` (up to 9 reference images). A single request cannot combine a start frame **and** reference images — pick the variant that matches your input.
</Note>

Image URLs for `image`, `tailImage`, and `referenceImages[].url` do not need to be hosted on Easy-Peasy, but they **must be downloadable server-side by our video provider**. Some hosts (e.g. Wikimedia, or sites that block hotlinking / non-browser requests) return **HTTP 403** to automated downloads — these fail with a `Could not download the input (HTTP 403)` error. If in doubt, host the image on your own public CDN/bucket or on Easy-Peasy.

### First frame (image-to-video)

```bash theme={null}
curl -X POST https://easy-peasy.ai/api/generate-video \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "The subject slowly turns toward the camera, cinematic lighting",
    "model": "Seedance 2.0 Image",
    "image": "https://yourcdn.com/first-frame.png",
    "duration": "5",
    "aspectRatio": "16:9",
    "resolution": "1080p"
  }'
```

Add `"tailImage": "https://yourcdn.com/last-frame.png"` to interpolate between a first and last frame.

### Multiple reference images (reference-to-video)

```bash theme={null}
curl -X POST https://easy-peasy.ai/api/generate-video \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "The character walks through a neon-lit market at night",
    "model": "Seedance 2.0 Reference",
    "referenceImages": [
      { "url": "https://yourcdn.com/character.png" },
      { "url": "https://yourcdn.com/outfit.png" },
      { "url": "https://yourcdn.com/environment.png" }
    ],
    "duration": "5",
    "aspectRatio": "16:9",
    "resolution": "1080p"
  }'
```

<Note>
  `referenceImages[].type` (`character` / `object` / `style`) is optional and only used by the Kling O1/O3 Reference models to separate character/object references from style references. Seedance 2.0 Reference treats every entry as a general reference, so you can send just `{ "url": ... }`.
</Note>

## Polling example

```javascript theme={null}
async function waitForVideo(videoId, apiKey) {
  const maxAttempts = 40; // ~10 minutes max

  for (let i = 0; i < maxAttempts; i++) {
    const response = await fetch(
      `https://easy-peasy.ai/api/get-video?video_id=${videoId}`,
      {
        headers: { 'x-api-key': apiKey },
      }
    );

    const data = await response.json();

    if (data.video.status === 'completed') {
      return data.video.url; // Video URL is ready!
    }

    await new Promise(resolve => setTimeout(resolve, 15000));
  }

  throw new Error('Video generation timeout');
}
```


## OpenAPI

````yaml POST /api/generate-video
openapi: 3.0.1
info:
  title: Easy-Peasy.AI API
  description: >-
    OpenAPI Specifications for the Easy-Peasy.AI API.


    All API requests must be authenticated with an API key. Include the
    `x-api-key` API key in the request header with all requests. You can get the
    API key [here](https://easy-peasy.ai/settings/api).
  version: 1.0.4
servers:
  - url: https://easy-peasy.ai
security:
  - apiKeyAuth: []
paths:
  /api/generate-video:
    post:
      summary: Generate Video
      description: >-
        Generate AI videos from text prompts or images using 40+ models
        including Veo 3.1, Kling 3.0, Sora 2, Hailuo, and more.


        Video generation is asynchronous — the response returns a video ID
        immediately. Use the [Get Video](/api-reference/endpoint/get-video)
        endpoint to poll for the result.


        **Input types:**

        - **Text-to-video** — Provide only a `prompt`

        - **Image-to-video** — Provide both `prompt` and `image` URL


        **Note:** Video generation requires a paid plan.
      operationId: generateVideo
      parameters:
        - name: x-api-key
          in: header
          required: true
          schema:
            type: string
          description: Your API key
          example: 27feb2bb-aeb4-4a83-9fb6-8f3f2a15885e
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateVideoRequest'
            examples:
              text_to_video:
                summary: Text-to-video
                value:
                  prompt: A cat walking on the beach at sunset, cinematic lighting
                  model: Veo 3.1 Fast
                  duration: '5'
                  aspectRatio: '16:9'
              image_to_video:
                summary: Image-to-video
                value:
                  prompt: The subject slowly turns and smiles at the camera
                  image: https://example.com/photo.jpg
                  model: Kling 3.0 Pro Image
                  duration: '5'
                  aspectRatio: '16:9'
      responses:
        '200':
          description: Video generation started
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateVideoResponse'
              example:
                id: 12345
                prompt: A cat walking on the beach at sunset
                image_url: ''
                model: Veo 3.1 Fast
                is_video: true
                created_at: '2025-01-15T10:30:00.000Z'
        '400':
          description: Bad request — invalid model, duration, aspect ratio, or input type
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Invalid model selected
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Invalid API key
        '403':
          description: Plan limit reached or free plan
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: >-
                  Video generation is not available on the Free plan. Please
                  upgrade to a paid plan to generate videos.
components:
  schemas:
    GenerateVideoRequest:
      type: object
      required:
        - prompt
        - model
      properties:
        prompt:
          type: string
          description: Text prompt describing the video to generate.
          example: A cat walking on the beach at sunset, cinematic lighting
        image:
          type: string
          format: uri
          description: >-
            URL of a start/first-frame image for image-to-video generation. Use
            a model whose title ends in "Image" (e.g. "Seedance 2.0 Image", "Veo
            3.1 Image"). If omitted, text-to-video mode is used. Any publicly
            reachable URL is accepted.
        model:
          type: string
          description: >-
            The video model to use (required). The value must exactly match one
            of the enum titles below. Titles ending in "Image" take a
            start-frame `image`; titles ending in "Reference" take
            `referenceImages`; "First-Last Frame" titles take both `image` and
            `tailImage`; all others are text-to-video.
          enum:
            - Veo 3.1 Fast
            - Grok Imagine
            - Grok Imagine Reference
            - Seedance 2.0 Fast
            - Seedance 2.0 Turbo
            - Seedance 2.0
            - Seedance 2.0 Mini
            - Seedance 2.0 Reference
            - Seedance 2.0 Fast Reference
            - Seedance 2.0 Mini Reference
            - Kling 2.6 Pro
            - Veo 3.1 Lite
            - Veo 3.1 Lite Image
            - Veo 3.1 Fast Image
            - Grok Imagine Image
            - Grok Imagine 1.5
            - Seedance 2.0 Image
            - Seedance 2.0 Fast Image
            - Seedance 2.0 Turbo Image
            - Seedance 2.0 Mini Image
            - Happy Horse
            - Happy Horse Image
            - Happy Horse Reference
            - Kling 2.6 Pro Image
            - Kling 3.0 Pro
            - Kling 3.0 Pro Image
            - Kling 3.0 Standard
            - Kling 3.0 Standard Image
            - Kling O3 Pro
            - Kling O3 Pro Image
            - Kling O3 Standard
            - Kling O3 Standard Image
            - Kling O3 Reference
            - Seedance 1.5 Pro
            - Seedance 1.5 Pro Image
            - Kling Motion Control Pro
            - Kling Motion Control
            - Kling O1 Image
            - Kling O1 Reference
            - Kling 2.5 Turbo Pro Image
            - Kling 2.5 Turbo Pro
            - Kling 2.5 Turbo Standard
            - Seedance 1.5 Pro First-Last Frame
            - Veo 3.1
            - LTX-2 Pro
            - LTX-2 Fast
            - Veo 3.1 Image
            - Veo 3.1 First-Last Frame
            - Veo 3.1 Fast First-Last Frame
            - LTX-2 Pro Image
            - LTX-2 Fast Image
            - Sora 2
            - Sora 2 Pro
            - Hailuo 2.0
            - Hailuo 2.0 Pro
            - Hailuo 2.3
            - Hailuo 2.3 Pro
            - Hailuo 2.3 Image
            - Hailuo 2.3 Pro Image
            - Hailuo 2.3-Fast Pro Image
            - Seedance v1 Pro Fast
            - Pixverse v5.5
            - Wan 2.5
            - Wan v2.2 Turbo
            - Wan v2.2
            - Sora 2 Image
            - Sora 2 Pro Image
            - Hailuo 2.0 Image
            - Hailuo 2.0 Pro Image
            - Seedance 1.0 Pro Fast
            - Pixverse v5.5 Image
            - Wan 2.5 Image
            - Wan v2.2 Turbo Image
            - Wan-2.2 Image
        duration:
          type: string
          default: '5'
          description: >-
            Duration of the video in seconds. Available values depend on the
            model.
          example: '5'
        aspectRatio:
          type: string
          default: '16:9'
          description: Aspect ratio of the video.
          enum:
            - '16:9'
            - '9:16'
            - '1:1'
            - '4:3'
            - '3:4'
            - '21:9'
            - '9:21'
            - '3:2'
            - '2:3'
        resolution:
          type: string
          description: >-
            Video resolution. Allowed values depend on the model (e.g. Seedance
            2.0 supports 480p–4k; Veo 3.1 supports 720p/1080p).
          enum:
            - 480p
            - 720p
            - 1080p
            - 4k
        generateAudio:
          type: boolean
          description: >-
            Whether to generate audio along with the video (supported by some
            models like Veo 3.1, Kling 3.0, Seedance 2.0).
        tailImage:
          type: string
          format: uri
          description: >-
            URL of an end/last-frame image. Only used by models that support a
            tail frame — the "First-Last Frame" titles and "Seedance 2.0 Image"
            (paired with `image` as the first frame). Any publicly reachable URL
            is accepted.
        referenceImages:
          type: array
          description: >-
            Reference images for reference-to-video models (titles ending in
            "Reference", e.g. "Seedance 2.0 Reference", "Kling O1 Reference",
            "Kling O3 Reference"). Used to keep characters/objects/style
            consistent across the generated video. Seedance 2.0 Reference
            accepts up to 9 images. Not used by text-to-video or image-to-video
            models.
          items:
            type: object
            required:
              - url
            properties:
              url:
                type: string
                format: uri
                description: Publicly reachable image URL.
              type:
                type: string
                enum:
                  - character
                  - object
                  - style
                description: >-
                  Reference role. Used by Kling O1/O3 to distinguish
                  character/object references (as `elements`) from style
                  references. Seedance 2.0 treats every entry as a general
                  reference, so `type` is optional for it.
    GenerateVideoResponse:
      type: object
      properties:
        id:
          type: integer
          description: >-
            Video ID. Use this to poll for the result with the Get Video
            endpoint.
        prompt:
          type: string
          description: The prompt used for generation
        image_url:
          type: string
          description: Video URL. Empty string while processing.
        model:
          type: string
          description: The model used for generation
        is_video:
          type: boolean
        created_at:
          type: string
          format: date-time
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message
          example: Invalid API key
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key for authentication. Get yours at
        https://easy-peasy.ai/settings/api

````