Skip to content

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.

ModelCapabilityReference price
veo-3.1Text-to-video$0.029 / second
veo-3.1-fastFast text-to-video$0.014 / second
veo-3.1-i2vImage-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 ​

StepMethod and pathNotes
1. Create a taskPOST /v1/videosReturns the task id and a queued status right away
2. Check the taskGET /v1/videos/{id}Poll every 10–15 seconds
3. Get the videovideo_url in the responseDownload 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 ​

bash
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.

bash
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 ​

ParameterTypeRequiredDescription
modelstringYesA Veo model name from the table above
promptstringYesDescribe the content, camera work and style
secondsstringNoClip length. Test with the minimum, "4", first
sizestringNoe.g. 1280x720
input_referencestringRequired for image-to-videoPublic image URL or data: base64
generate_audiobooleanNoWhether 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.

json
{
  "id": "task_fq3rMylJDGbVr0JmXJioKZoekVVc7ZHj",
  "task_id": "task_fq3rMylJDGbVr0JmXJioKZoekVVc7ZHj",
  "object": "",
  "model": "veo-3.1-fast",
  "status": "queued",
  "progress": 0,
  "created_at": 1786456082
}

Check a task ​

bash
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:

json
{
  "id": "task_...",
  "model": "veo-3.1-fast",
  "status": "processing"
}

Once done, the response includes video_url:

json
{
  "id": "task_fq3rMylJDGbVr0JmXJioKZoekVVc7ZHj",
  "model": "veo-3.1-fast",
  "status": "completed",
  "video_url": "https://example-cdn.com/generated-video.mp4",
  "created_at": 1786456082
}
StatusMeaning
queuedIn the queue
processing / in_progressRendering
completedDone. Read video_url
failedGeneration failed. Check error.message

Full Python example ​

python
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_url from the polling response once the task completes. Don't rely on /v1/videos/{id}/content for now.
  • video_url may be a short-lived presigned URL, so download or re-host the file promptly.

Next steps ​

One base URL for GPT, Claude and Gemini