# Kling Video Generation

OpenAI compatible: `POST /v1/video/generations`. Official 3.0 / Omni native paths: `POST /text-to-video/${model_id}`, `POST /image-to-video/${model_id}`, `POST /omni-video/${model_id}`.

* **Submit**: `POST /v1/video/generations` or official routes `POST /text-to-video/${model_id}`, `POST /image-to-video/${model_id}`, `POST /omni-video/${model_id}`
* **Query**: Official 3.0 route `GET /tasks?task_ids=${task_id}`; compatible routes `GET /v1/video/generations/{task_id}` or `/v1/tasks/{task_id}`

---

## 1. Video Generation Task Request Examples (POST)

* **HTTP Method**: `POST`
* **Request Path**: `https://www.tokenpad.ai/v1/video/generations`
* **Auth Header**: `Authorization: Bearer sk-your_token`

### A. Classic Text-to-Video
```bash
curl -X POST https://www.tokenpad.ai/v1/video/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-v3-omni",
    "prompt": "Rainy night under bustling city neon lights, a pedestrian holding an umbrella walking slowly along wet streets, realistic cinematic style, dappled light and shadow",
    "negative_prompt": "blurry frame, low quality, distorted limbs, watermark",
    "resolution": "1080p",
    "ratio": "16:9",
    "duration": 5
  }'
```

### B. Classic Image-to-Video (Start & End Frame Control)
Pass 2 image URLs: the first as the start frame and the second as the end frame, generating a smooth transition between them.
```bash
curl -X POST https://www.tokenpad.ai/v1/video/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-v3-omni",
    "prompt": "Smoothly transition from the smiling person in the first image to the surprised expression in the second image, realistic and natural motion",
    "images": [
      "https://example.com/smile_face.png",
      "https://example.com/surprised_face.png"
    ],
    "duration": 5
  }'
```

### C. Multi-Image Blended Reference (Exclusive to Kling-v3-omni)
`kling-v3-omni` supports multi-image reference. Use objects to specify a `role` for each image (such as `first_frame`, `reference_image`).
```bash
curl -X POST https://www.tokenpad.ai/v1/video/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-v3-omni",
    "prompt": "Using the female lead from image 1 and the vintage cafe scene from image 2, generate a smooth crane camera shot",
    "images": [
      {
        "url": "https://example.com/character.png",
        "role": "first_frame"
      },
      {
        "url": "https://example.com/coffee_shop.png",
        "role": "reference_image"
      }
    ],
    "duration": 5
  }'
```

### D. Image Reference + Video Reference Multimodal Generation (Exclusive to Kling-v3-omni)
Pass both images and videos as references simultaneously. Use `role` (or equivalent `type`) to precisely specify each image's purpose.
```bash
curl -X POST https://www.tokenpad.ai/v1/video/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-v3-omni",
    "prompt": "Use the person in image 1 as the main subject, accurately replicating the Tai Chi movements from video 2, fluid motion, HD realistic style",
    "images": [
      {
        "url": "https://example.com/my_character.png",
        "role": "reference_image"
      }
    ],
    "videos": [
      "https://example.com/taichi_motion.mp4"
    ],
    "duration": 5
  }'
```

---

## 2. Polling Task Results (GET)

* **Request Path**: `/v1/video/generations/{task_id}` or `/v1/tasks/{task_id}`
* **Request Example**:
```bash
curl -X GET https://www.tokenpad.ai/v1/video/generations/video_task_xyz789 \
  -H "Authorization: Bearer sk-your_token_here"
```

---

## 3. Parameter Dictionary

| OpenAI Param | Type | Required | Default | Description & Constraints |
| :--- | :--- | :--- | :--- | :--- |
| `model` | `string` | **Yes** | - | Video generation model name; pass `kling-v3-omni`. |
| `prompt` | `string` | **Yes** | - | Scene motion description, up to 2,000 characters. |
| `negative_prompt` | `string` | No | - | Negative prompt to exclude unwanted visual elements or quality artifacts. |
| `images` / `image_urls` | `array` | No | - | Array of image reference URLs or objects. Default: 1 image = first frame, 2 images = start & end frames. Objects can specify `role` or `type`: `"first_frame"`, `"middle_frame"`, `"last_frame"`, or `"refer_image"`. |
| `videos` | `array` | No | - | **(Exclusive to v3-omni)** Array of video reference URLs or objects. |
| `resolution` | `string` | No | `"720p"` | Video resolution, e.g., `"720p"`, `"1080p"`, `"4k"`. |
| `ratio` | `string` | No | `"16:9"` | Video aspect ratio. Options: `"16:9"`, `"9:16"`, `"1:1"`. |
| `duration` | `integer` | No | `5` | Generation duration (seconds). |
| `generate_audio` | `boolean` | No | `false` | Whether to generate matching sound effects simultaneously. |
| `camera_control` | `object` | No | - | Camera movement control. Can include `pan`, `tilt`, `zoom`, `roll`, etc. |

---

## 4. Response Examples (200 OK)

* **Submit Task Response**:
```json
{
  "id": "video_task_xyz789",
  "task_id": "video_task_xyz789",
  "status": "pending",
  "message": "Task submitted successfully"
}
```

* **Query Result Response (Completed)**:
```json
{
  "id": "video_task_xyz789",
  "task_id": "video_task_xyz789",
  "status": "completed",
  "data": [
    {
      "url": "https://example.com/output/generated_video.mp4"
    }
  ]
}
```



### 5. Common Error Codes & Troubleshooting

HTTP codes, error body format, and troubleshooting are **maintained in one dedicated page** (not duplicated under each example).

👉 **[Gateway Error Codes & Troubleshooting](/docs/errors/error-codes)**

**Quick reference**:

| Code | Meaning |
| :---: | :--- |
| **400** | Invalid parameters / content moderation or copyright block |
| **402** | Insufficient account balance (**not** 429) |
| **429** | RPS/RPM limits or in-flight task cap (low balance) |
| **403** | Token / IP / model permission (balance → 402; content filter → 400) |
| **200 + `status: failed`** | Async video/long-task business failure on poll |

HTTP status matches call log `status_code` for traceability by `log_id`.

> **Maintenance**: update the `error-codes` article only; this appendix links to it.
