Veo video generation
The Veo 3.1 family handles text-to-video and image-to-video. Renders take a while, so use the async flow everywhere: create a task, save its id, then poll the task status.
Before you start
Use the dedicated group
When you create the API key, pick the Image & Video group (图片视频专用分组). Video bills per generated second, so estimate cost from the model's rate and seconds.
| Model | Capability | Reference price |
|---|---|---|
veo-3.1 | Text-to-video | $0.029 / second |
veo-3.1-fast | Fast text-to-video | $0.014 / second |
veo-3.1-i2v | Image-to-video | $0.029 / second |
For example, a 4-second clip with veo-3.1-fast costs about $0.057. Models and prices may change. The console and live pricing are the source of truth.
Async flow
| Step | Method and path | Notes |
|---|---|---|
| 1. Create a task | POST /v1/videos | Returns the task id and a queued status right away |
| 2. Check the task | GET /v1/videos/{id} | Poll every 10–15 seconds |
| 3. Get the video | video_url in the response | Download it once the status is completed |
POST /v1/video/generations also creates tasks and returns the same shape as /v1/videos. New projects should stick to /v1/videos.
Why async
Video generation usually takes a few minutes. Setting wait: true on the create request doesn't guarantee a synchronous wait and may still return queued immediately, so your client should always save the task ID and poll.
Text-to-video
curl https://ai.flashapi.top/v1/videos \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3.1-fast",
"prompt": "a tiny red ball rolling across a wooden table, cinematic light",
"size": "1280x720",
"seconds": "4",
"generate_audio": false
}'Image-to-video
Use veo-3.1-i2v and pass a publicly reachable image URL or a data: base64 string in input_reference.
curl https://ai.flashapi.top/v1/videos \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3.1-i2v",
"prompt": "slow zoom in, gentle movement, keep the original composition",
"size": "1280x720",
"seconds": "4",
"input_reference": "https://example.com/reference.png"
}'Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | A Veo model name from the table above |
prompt | string | Yes | Describe the content, camera work and style |
seconds | string | No | Clip length. Test with the minimum, "4", first |
size | string | No | e.g. 1280x720 |
input_reference | string | Required for image-to-video | Public image URL or data: base64 |
generate_audio | boolean | No | Whether to generate audio. Defaults to true |
Create-task response
A successful create returns the task right away. Veo create responses don't guarantee that seconds and size are echoed back, so rely only on fields that are actually present, such as id, model and status.
{
"id": "task_fq3rMylJDGbVr0JmXJioKZoekVVc7ZHj",
"task_id": "task_fq3rMylJDGbVr0JmXJioKZoekVVc7ZHj",
"object": "",
"model": "veo-3.1-fast",
"status": "queued",
"progress": 0,
"created_at": 1786456082
}Check a task
curl https://ai.flashapi.top/v1/videos/task_fq3rMylJDGbVr0JmXJioKZoekVVc7ZHj \
-H "Authorization: Bearer YOUR_API_KEY"While processing, Veo tasks may return only the status, without progress:
{
"id": "task_...",
"model": "veo-3.1-fast",
"status": "processing"
}Once done, the response includes video_url:
{
"id": "task_fq3rMylJDGbVr0JmXJioKZoekVVc7ZHj",
"model": "veo-3.1-fast",
"status": "completed",
"video_url": "https://example-cdn.com/generated-video.mp4",
"created_at": 1786456082
}| Status | Meaning |
|---|---|
queued | In the queue |
processing / in_progress | Rendering |
completed | Done. Read video_url |
failed | Generation failed. Check error.message |
Full Python example
import os
import time
import requests
api_key = os.environ["FLASH_API_KEY"]
base_url = "https://ai.flashapi.top"
headers = {"Authorization": f"Bearer {api_key}"}
created = requests.post(
f"{base_url}/v1/videos",
headers=headers,
json={
"model": "veo-3.1-fast",
"prompt": "a tiny red ball rolling across a wooden table",
"size": "1280x720",
"seconds": "4",
"generate_audio": False,
},
timeout=60,
)
created.raise_for_status()
task_id = created.json()["id"]
deadline = time.monotonic() + 15 * 60
while time.monotonic() < deadline:
try:
response = requests.get(
f"{base_url}/v1/videos/{task_id}", headers=headers, timeout=30
)
response.raise_for_status()
task = response.json()
except requests.RequestException:
time.sleep(12)
continue
if task["status"] == "completed":
video = requests.get(task["video_url"], timeout=120)
video.raise_for_status()
with open(f"{task_id}.mp4", "wb") as file:
file.write(video.content)
break
if task["status"] == "failed":
raise RuntimeError(task.get("error", "Video generation failed"))
time.sleep(12)
else:
raise TimeoutError(f"Task {task_id} didn't finish within 15 minutes; you can keep polling later")Notes
- Give your client an overall timeout of at least 15 minutes.
- Reference images must be directly reachable from the public internet. Hotlink-protected URLs may fail to download.
- Use the
video_urlfrom the polling response once the task completes. Don't rely on/v1/videos/{id}/contentfor now. video_urlmay be a short-lived presigned URL, so download or re-host the file promptly.