Veo 3.1
Google Veo 3.1 video generation model. Supports text-to-video, image-to-video, first-and-last-frame, and reference-based generation, with background music included.
Model
| Model Name | Modes | Aspect Ratios |
|---|---|---|
veo-3 | fast (default), quality | 16:9, 9:16, Auto |
Pricing
Per-mode billing:
| Mode | Credits | Price |
|---|---|---|
| fast | 40 credits | $0.20 |
| quality | 300 credits | $1.50 |
Create Task
curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3",
"input": {
"prompt": "A dog playing in a park, cinematic lighting",
"mode": "fast",
"aspect_ratio": "16:9"
}
}'
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Must be veo-3 |
input | object | Yes | Generation parameters, see below |
callback_url | string | No | URL to receive task completion/failure notifications |
Input Object
| Field | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Text description |
mode | string | No | fast (default) or quality |
aspect_ratio | string | No | 16:9 (default), 9:16, or Auto |
generation_type | string | No | Generation mode, see Generation Type |
image_urls | string[] | No | Image URLs for image-to-video modes |
seeds | integer | No | Random seed (10000-99999) for controlling randomness |
watermark | string | No | Watermark text |
Generation Type
| Value | Description |
|---|---|
TEXT_2_VIDEO | Text-to-video (default when no images provided) |
FIRST_AND_LAST_FRAMES_2_VIDEO | First/last frame mode. 1 image = first frame, 2 images = first + last frame |
REFERENCE_2_VIDEO | Reference-based generation. 1-3 reference images. mode=fast only |
When
generation_typeis not specified, the system auto-detects based on whetherimage_urlsis provided.
Example: Text-to-Video
curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3",
"input": {
"prompt": "A drone shot flying over mountains at sunset, cinematic lighting",
"mode": "fast",
"aspect_ratio": "16:9"
}
}'
Example: First and Last Frames
curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3",
"input": {
"prompt": "A person walks from the park to the city center",
"generation_type": "FIRST_AND_LAST_FRAMES_2_VIDEO",
"image_urls": [
"https://example.com/start.jpg",
"https://example.com/end.jpg"
],
"aspect_ratio": "16:9"
}
}'
Example: Reference-Based Generation
curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3",
"input": {
"prompt": "Create a product showcase video based on these reference images",
"generation_type": "REFERENCE_2_VIDEO",
"mode": "fast",
"image_urls": [
"https://example.com/ref1.jpg",
"https://example.com/ref2.jpg"
],
"aspect_ratio": "16:9"
}
}'
Response
{
"code": 200,
"msg": "success",
"data": {
"taskId": "cbf6b69d-4f03-4817-8ed7-94c0292184a8"
}
}
Query Task
curl https://api.aivideoapi.ai/v1/tasks/{taskId} \
-H "Authorization: Bearer sk-your-api-key"
Status transitions: pending -> processing -> completed or failed.
Processing
{
"id": "e717a5ee-2ed4-47f4-8cc3-53394f1abb35",
"status": "processing",
"model": "veo-3",
"created_at": 1774706165,
"progress": null
}
Completed
{
"id": "7d89c51e-9430-410e-909e-df347131ebaa",
"status": "completed",
"model": "veo-3",
"created_at": 1774790227,
"completed_at": 1774796529,
"output": {
"urls": [
"https://file.aivideoapi.ai/videos/2026/04/02/abc123.mp4"
],
"metadata": {
"resolution": "720p"
}
}
}
Video URLs are permanent. All videos include background music by default.
Failed
{
"id": "57c8772c-f834-46f3-9b7d-81f92e104050",
"status": "failed",
"model": "veo-3",
"created_at": 1774793758,
"error": {
"code": "upstream_error",
"message": "Video generation failed"
}
}
When a task fails, pre-charged credits are automatically refunded.
Callback
Pass callback_url when creating the task. The system will automatically send a POST request to your URL when the task completes or fails. The format matches the query task response.
Video Extension
Use extend_task_id to extend a completed video:
curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3-extend",
"input": {
"prompt": "Continue the scene, camera slowly zooms out",
"extend_task_id": "upstream task id of the original video"
}
}'
Error Codes
When a request fails, the API returns a JSON error response:
{
"error": {
"code": "insufficient_credits",
"message": "Your credit balance is too low. Please top up.",
"type": "billing_error"
}
}
Error Reference
| HTTP Status | Code | Type | Description |
|---|---|---|---|
| 400 | invalid_request | invalid_request_error | Missing or invalid parameters |
| 401 | invalid_api_key | authentication_error | API key is invalid, disabled, or deleted |
| 402 | insufficient_credits | billing_error | Credit balance too low, please top up |
| 403 | ip_not_allowed | permission_error | Request IP not in the key's allowlist |
| 404 | model_not_found | invalid_request_error | Model does not exist or is inactive |
| 404 | task_not_found | invalid_request_error | Task ID does not exist |
| 429 | rate_limit_exceeded | rate_limit_error | Too many requests, please slow down |
| 429 | spend_limit_exceeded | billing_error | Key spend limit reached (hourly/daily/total) |
| 500 | internal_error | api_error | Unexpected server error |
| 503 | upstream_error | upstream_error | Upstream AI provider returned an error |
Common Scenarios
invalid_request (400)
Returned when required fields are missing or invalid.
{
"error": {
"code": "invalid_request",
"message": "'model' is required.",
"type": "invalid_request_error"
}
}
insufficient_credits (402)
Your balance is too low. Check your balance with GET /v1/credits and top up in Dashboard > Billing.
invalid_api_key (401)
Possible causes:
- The key does not start with
sk- - The key has been disabled or deleted
- The user account has been banned
upstream_error (503)
The upstream AI provider returned an error. This may happen when:
- The input contains sensitive or prohibited content
- The provider is temporarily unavailable
- The request parameters are not supported by the provider
Credits are automatically refunded when a task fails due to upstream errors.