# Vidu Q4

> Vidu Q4 API on PoYo. Turn a start image or up to 12 reference images and 3 voice clips into 3-16 second cinematic videos with native audio, multi-shot storytelling and 540p to 4K output. From 9 credits ($0.045) per second.

## Overview

- Submit: `https://api.poyo.ai/api/generate/submit`
- Status: `https://api.poyo.ai/api/generate/status/{task_id}`
- Page: https://poyo.ai/models/vidu-q4
- Model page ID: `vidu-q4`
- API model ID: `vidu-q4`
- Category: Video
- Auth: `Authorization: Bearer $POYO_API_KEY`
- Create a key at https://poyo.ai/dashboard/api-key

This model uses PoYo's unified async API. POST the JSON body below, then poll status with the returned `task_id` or receive a webhook on `callback_url`. Failed tasks are not charged.

## Pricing

- 540p: 9 credits ($0.045) per second
- 720p: 19 credits ($0.095) per second
- 1080p: 24 credits ($0.120) per second
- 2K: 38 credits ($0.190) per second
- 4K: 78 credits ($0.390) per second

For more details, see https://poyo.ai/models/vidu-q4.

## API Information

The request envelope is always `{ model, input, callback_url? }`. Input fields below are nested under `input`.

### Request envelope

- `model` (`ModelEnum`, required):
  Public model identifier.
  - Options: `"vidu-q4"`
- `callback_url` (`string`, optional):
  Optional webhook URL for task completion or failure notifications.

### Input Schema

Provide one image_urls starting frame, or a prompt with 1-12 reference_image_urls. Reference audio is optional and requires reference images.

The API accepts the following `input` parameters:

- `prompt` (`string`, optional):
  Video instructions, up to 5,000 characters. Required and non-empty for reference-to-video; optional for image-to-video.
  - Length: 0 to 5000 characters
- `image_urls` (`list`, optional):
  Exactly one starting-frame image for image-to-video. Cannot be combined with reference_image_urls or reference_audio_urls. Use publicly accessible HTTP or HTTPS URLs.
  - Array of string
  - Length: 1 to 1
- `reference_image_urls` (`list`, optional):
  Required for reference-to-video. Provide 1-12 reference images. Cannot be combined with image_urls. Use publicly accessible HTTP or HTTPS URLs.
  - Array of string
  - Length: 1 to 12
- `reference_audio_urls` (`list`, optional):
  Optional reference audio accompanying reference_image_urls. Supports up to 3 MP3 files, each 3-12 seconds long. Audio cannot be used without reference images. Use publicly accessible HTTP or HTTPS URLs.
  - Array of string
  - Length: 1 to 3
- `duration` (`integer`, optional):
  Output duration in whole seconds.
  - Default: `5`
  - Range: `3` to `16`
- `resolution` (`ResolutionEnum`, optional):
  Output video resolution.
  - Default: `"720p"`
  - Options: `"540p"`, `"720p"`, `"1080p"`, `"2k"`, `"4k"`
- `aspect_ratio` (`AspectRatioEnum`, optional):
  Output aspect ratio for reference-to-video. Do not send this field for image-to-video.
  - Default: `"16:9"`
  - Options: `"16:9"`, `"9:16"`, `"4:3"`, `"3:4"`, `"1:1"`
- `generate_audio` (`boolean`, optional):
  Generate an audio track for reference-to-video. Do not send this field for image-to-video.
  - Default: `false`
- `enable_safety_checker` (`boolean`, optional):
  Enable content safety checks.
  - Default: `true`

Required Parameters Example:

```json
{
  "model": "vidu-q4",
  "input": {
    "image_urls": [
      "https://example.com/start-frame.png"
    ]
  }
}
```

Full Example:

```json
{
  "model": "vidu-q4",
  "input": {
    "image_urls": [
      "https://example.com/start-frame.png"
    ],
    "duration": 5,
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "enable_safety_checker": true
  }
}
```

Video guided by reference images and audio:

```json
{
  "model": "vidu-q4",
  "input": {
    "prompt": "Animate the character from the reference image with movement guided by the reference audio.",
    "reference_image_urls": [
      "https://example.com/character.png"
    ],
    "reference_audio_urls": [
      "https://example.com/reference.mp3"
    ],
    "duration": 5,
    "resolution": "720p"
  }
}
```

### Output Schema

Submit returns a `task_id`. Poll `GET /api/generate/status/{task_id}` until `status` is `finished` or `failed`. Completed media is in `data.files`.

Response fields:

- `code` (`integer`, required):
  - Examples: `200`
- `data` (`object`, required):

Example Response:

```json
{
  "code": 200,
  "data": {
    "task_id": "task_example",
    "status": "finished",
    "files": [
      {
        "file_url": "",
        "file_type": "file"
      }
    ]
  }
}
```

## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://api.poyo.ai/api/generate/submit \
  --header "Authorization: Bearer $POYO_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"model":"vidu-q4","input":{"image_urls":["https://example.com/start-frame.png"]}}'
```

### Python

```python
import json
import os
import time
import requests

API = "https://api.poyo.ai"
headers = {
    "Authorization": f"Bearer {os.environ['POYO_API_KEY']}",
    "Content-Type": "application/json",
}
payload = json.loads("{\n  \"model\": \"vidu-q4\",\n  \"input\": {\n    \"image_urls\": [\n      \"https://example.com/start-frame.png\"\n    ]\n  }\n}")

submit = requests.post(f"{API}/api/generate/submit", headers=headers, json=payload)
submit.raise_for_status()
task_id = submit.json()["data"]["task_id"]

while True:
    status = requests.get(f"{API}/api/generate/status/{task_id}", headers=headers)
    status.raise_for_status()
    data = status.json()["data"]
    if data["status"] in ("finished", "failed"):
        print(data)
        break
    time.sleep(2)
```

### JavaScript

```javascript
const headers = {
  Authorization: `Bearer ${process.env.POYO_API_KEY}`,
  "Content-Type": "application/json",
};

const submit = await fetch("https://api.poyo.ai/api/generate/submit", {
  method: "POST",
  headers,
  body: JSON.stringify({
  "model": "vidu-q4",
  "input": {
    "image_urls": [
      "https://example.com/start-frame.png"
    ]
  }
}),
});

const submitted = await submit.json();
const taskId = submitted.data.task_id;

while (true) {
  const statusResponse = await fetch(`https://api.poyo.ai/api/generate/status/${taskId}`, { headers });
  const status = await statusResponse.json();
  if (["finished", "failed"].includes(status.data.status)) {
    console.log(status.data);
    break;
  }
  await new Promise((resolve) => setTimeout(resolve, 2000));
}
```

## Additional Resources

### Documentation

- [Model Playground](https://poyo.ai/models/vidu-q4)
- [API Documentation](https://docs.poyo.ai/api-manual/video-series/vidu-q4)
- [API Documentation (Markdown)](https://docs.poyo.ai/api-manual/video-series/vidu-q4.md)
- [Task status](https://docs.poyo.ai/api-manual/task-management/query-task-status)
- [Webhooks](https://docs.poyo.ai/api-manual/task-management/webhooks)

### Other agent-readable surfaces

- [Platform overview](https://poyo.ai/llms.txt)
- [Documentation index](https://docs.poyo.ai/llms.txt)
- [Full documentation text](https://docs.poyo.ai/llms-full.txt)
- Any other model: `https://poyo.ai/models/<model-id>/llms.txt`
