Wan 3.0 Video API
Wan 3.0 All-in-One exposes text-to-video, first/last-frame animation, multimodal reference generation, document understanding, and public web-page input through one public model: wan-3.0-video.
This integration uses Alibaba Bailian's invited Beijing Workspace API. The documented output tiers are 480p, 720p, and 1080p; this API does not advertise unverified native 4K output. See the official Wan 3.0 documentation and Alibaba Cloud model pricing.
Pricing
| Resolution | Credits per billable second | 5-second text-only request |
|---|---|---|
480p | 12 | 60 credits |
720p | 24 | 120 credits |
1080p | 48 | 240 credits |
Without reference video, billable seconds equal the requested output duration. With video_urls, billing is:
(detected input video seconds + requested output seconds) × resolution rate
Images, audio, files, and web pages do not add input-video seconds. For example, 4.5 seconds of reference video plus 5 seconds of 720p output costs (4.5 + 5) × 24 = 228 credits.
Create a task
POST https://api.aivideoapi.ai/v1/videos/generations
Request body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Fixed value: wan-3.0-video |
input | object | Yes | Prompt, media, and output controls |
callback_url | string | No | Public callback URL for terminal task notifications |
input.prompt and the media fields are optional individually, but at least one prompt or media value is required.
Input fields
| Field | Type | Default | Description |
|---|---|---|---|
prompt | string | — | Up to 20,000 characters |
first_frame_url | string | — | Public HTTP(S) first-frame image URL |
last_frame_url | string | — | Public HTTP(S) last-frame URL; requires first_frame_url |
image_urls | string[] | [] | Up to 10 reference images |
video_urls | string[] | [] | Up to 5 MP4/MOV references; each 1–15s, 15s total |
audio_urls | string[] | [] | Up to 5 MP3/WAV references; each 1–15s, 15s total |
file_url | string | — | One public document URL |
link_url | string | — | One public, login-free web page URL |
resolution | string | 1080p | 480p, 720p, or 1080p |
aspect_ratio | string | adaptive | adaptive, 16:9, 4:3, 1:1, 3:4, or 9:16 |
duration | integer | 5 | 2–30 output seconds; -1 is not accepted |
audio | boolean | true | Include an audio track |
seed | integer | — | 0–2147483647 |
watermark | boolean | false | Add a watermark |
Only public HTTP(S) URLs are accepted. Base64 data, OSS URIs, credentials in URLs, localhost, and private network addresses are outside the public contract.
Mode and duration rules
- First/last-frame mode cannot be combined with
image_urls,video_urls,audio_urls,file_url, orlink_url. last_frame_urlcannot be sent withoutfirst_frame_url.file_urlandlink_urlare mutually exclusive.- Reference media remain in their array order. In prompts, images, videos, and audio are numbered independently.
- Input video duration plus output duration cannot exceed 30 seconds.
- Automatic
duration=-1is rejected because the platform pre-charges an exact estimate.
Create response
HTTP 200 returns the platform task ID immediately. Use data.taskId with the task-query endpoint.
{
"code": 200,
"msg": "success",
"data": {
"taskId": "cbf6b69d-4f03-4817-8ed7-94c0292184a8"
}
}
Examples
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": "wan-3.0-video",
"callback_url": "https://your-server.com/webhook",
"input": {
"prompt": "A cat runs across a moonlit rooftop above a neon city, cinematic camera motion",
"resolution": "1080p",
"aspect_ratio": "16:9",
"duration": 5,
"audio": true
}
}'
First and last frames
{
"model": "wan-3.0-video",
"input": {
"prompt": "The expression changes from a smile to laughter as warm light fills the room",
"first_frame_url": "https://example.com/first.jpg",
"last_frame_url": "https://example.com/last.jpg",
"duration": 6
}
}
Mixed references
{
"model": "wan-3.0-video",
"input": {
"prompt": "Video 1 supplies the camera move, Image 1 supplies the character, and Audio 1 guides the music",
"image_urls": ["https://example.com/character.png"],
"video_urls": ["https://example.com/camera.mp4"],
"audio_urls": ["https://example.com/music.mp3"],
"resolution": "720p",
"duration": 5
}
}
Use file_url for a supported public document or link_url for a public page. Do not send both in one request.
Query task status
curl https://api.aivideoapi.ai/v1/tasks/{taskId} \
-H "Authorization: Bearer sk-your-api-key"
Task statuses are pending, processing, completed, and failed. Confirmed failures refund the pre-charge once. Completed tasks are never refunded. An expired upstream UNKNOWN record becomes a non-refundable failed task for manual reconciliation. Wan 3.0 tasks do not support cancellation.
Pending response
{
"id": "cbf6b69d-4f03-4817-8ed7-94c0292184a8",
"status": "pending",
"model": "wan-3.0-video",
"credits_consumed": 0,
"created_at": 1786330800,
"estimated_seconds": 300
}
Processing response
{
"id": "cbf6b69d-4f03-4817-8ed7-94c0292184a8",
"status": "processing",
"model": "wan-3.0-video",
"credits_consumed": 0,
"created_at": 1786330800,
"progress": null
}
Completed response
{
"id": "cbf6b69d-4f03-4817-8ed7-94c0292184a8",
"status": "completed",
"model": "wan-3.0-video",
"credits_consumed": 240,
"created_at": 1786330800,
"completed_at": 1786330928,
"output": {
"urls": [
"https://dashscope-result.oss-cn-beijing.aliyuncs.com/example.mp4"
],
"metadata": {
"usage": {
"duration": 5,
"input_video_duration": 0,
"output_video_duration": 5,
"video_count": 1,
"fps": 24,
"SR": 1080,
"ratio": "16:9"
}
}
},
"usage": {
"total_seconds": 5,
"input_seconds": 0,
"output_seconds": 5,
"video_count": 1,
"fps": 24,
"resolution": 1080,
"ratio": "16:9"
}
}
credits_consumed is 0 while the task is in progress and after a confirmed failure has been refunded. On success it contains the final charge. usage is returned on successful WAN 3.0 tasks when the provider supplies the corresponding values.
Failed response
{
"id": "cbf6b69d-4f03-4817-8ed7-94c0292184a8",
"status": "failed",
"model": "wan-3.0-video",
"credits_consumed": 0,
"created_at": 1786330800,
"error": {
"code": "upstream_error",
"message": "The request failed because an input parameter was rejected."
}
}
For an expired upstream UNKNOWN record, the response is also failed, but credits_consumed retains the pre-charge because that state is not automatically refundable. If callback_url was supplied, completed and failed callbacks use the same terminal payload shape shown above.
Successful upstream result URLs expire after approximately 24 hours. If your account has Bailian R2 mirroring enabled, the platform stores the result; otherwise download the provider URL promptly.
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.