Wan 2.7

Wan 2.7 is Alibaba's video generation and editing model. It supports text-to-video, image-to-video (first/last frame), reference-to-video, and instruction-based video editing, with synced audio and 720p or 1080p output.

Models

Model NameMode
wan-2.7-text-to-videoText-to-video
wan-2.7-image-to-videoImage-to-video, first/last frame based
wan-2.7-reference-to-videoReference-to-video with reference images and videos
wan-2.7-video-editVideo editing

Pricing

Billed per second × resolution:

ResolutionCredits/sec
720p24
1080p40

Video edit billing: when duration is 0 (default), the output equals the full input video length and is billed by the input video's actual duration; when duration is 2-10, billing follows that value.

Create Task

POST https://api.aivideoapi.ai/v1/videos/generations

Request Body

FieldTypeRequiredDescription
modelstringYesOne of the model names above
inputobjectYesGeneration or editing parameters
callback_urlstringNoURL to receive task completion/failure notifications

Common Input

FieldTypeRequiredDescription
promptstringVariesText prompt, max 5000 characters
negative_promptstringNoNegative prompt, max 500 characters
resolutionstringNo720p or 1080p
prompt_extendbooleanNoEnable prompt rewriting, default true
watermarkbooleanNoAdd a watermark, default false
seedintegerNoInteger between 0 and 2147483647

Text-to-Video Input

FieldTypeRequiredDescription
promptstringYesText prompt
aspect_ratiostringNo16:9, 9:16, 1:1, 4:3, or 3:4; default 16:9
durationintegerNo2-15 seconds, default 5
audio_urlsstring[]NoReference audio URL(s); the first is used

Default resolution is 1080p.

Image-to-Video Input

FieldTypeRequiredDescription
promptstringYesText prompt
image_urlsstring[]Yes1-2 image URLs (JPEG/PNG/WEBP). The first is the first frame; an optional second is the last frame.
first_clip_urlstringNoGuiding video clip URL (MP4/MOV/MKV)
audio_urlsstring[]NoDriving audio URL(s); the first is used
durationintegerNo2-15 seconds, default 5

Output aspect ratio follows the first-frame image. Default resolution is 1080p.

Reference-to-Video Input

FieldTypeRequiredDescription
promptstringYesText prompt; use [Image 1], [Image 2], etc. to refer to image_urls by order
image_urlsstring[]No*Reference image URLs (JPEG/PNG/WEBP)
video_urlsstring[]No*Reference video URLs (MP4/MOV)
first_frame_urlstringNoFirst-frame image URL; output follows its aspect ratio
audio_urlsstring[]NoReference voice URL(s) to set the main character's voice; the first is used
aspect_ratiostringNo16:9, 9:16, 1:1, 4:3, or 3:4; default 16:9
durationintegerNo2-10 seconds, default 5

* At least one of image_urls or video_urls is required, and their combined count cannot exceed 5. Default resolution is 1080p.

Video Edit Input

FieldTypeRequiredDescription
video_urlsstring[]YesExactly 1 source video URL (MP4/MOV)
promptstringNoEditing instruction
image_urlsstring[]NoReference image URL(s); the first is used
aspect_ratiostringNo16:9, 9:16, 1:1, 4:3, or 3:4; default 16:9
audio_settingstringNoauto (model decides) or origin (keep source audio); default auto
durationintegerNo0 (full input length) or 2-10 (clip length); default 0

Default resolution is 720p. Billing uses the input video's actual duration when duration is 0.

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-2.7-text-to-video",
    "callback_url": "https://your-server.com/webhook",
    "input": {
      "prompt": "A cinematic tracking shot through a rainy neon street at night",
      "aspect_ratio": "16:9",
      "resolution": "1080p",
      "duration": 5
    }
  }'

Image-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-2.7-image-to-video",
    "callback_url": "https://your-server.com/webhook",
    "input": {
      "prompt": "The girl slowly turns her head and the camera gently pushes in",
      "image_urls": ["https://example.com/first.png", "https://example.com/last.png"],
      "resolution": "1080p",
      "duration": 5
    }
  }'

Reference-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-2.7-reference-to-video",
    "callback_url": "https://your-server.com/webhook",
    "input": {
      "prompt": "[Image 1] picks up a folding fan, the camera slowly pushes in.",
      "image_urls": ["https://example.com/ref.jpg"],
      "video_urls": ["https://example.com/ref.mp4"],
      "aspect_ratio": "16:9",
      "resolution": "1080p",
      "duration": 9
    }
  }'

Video Edit

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-2.7-video-edit",
    "callback_url": "https://your-server.com/webhook",
    "input": {
      "prompt": "Change the vase to pink.",
      "video_urls": ["https://example.com/input.mp4"],
      "resolution": "720p",
      "duration": 0,
      "audio_setting": "auto"
    }
  }'

Response

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "8b6a5162-5c91-4a42-8e80-4c8ef5486f24"
  }
}

Query Task

curl https://api.aivideoapi.ai/v1/tasks/{taskId} \
  -H "Authorization: Bearer sk-your-api-key"

Status transitions: pending -> processing -> completed or failed.

When a task fails, pre-charged credits are automatically refunded.


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 StatusCodeTypeDescription
400invalid_requestinvalid_request_errorMissing or invalid parameters
401invalid_api_keyauthentication_errorAPI key is invalid, disabled, or deleted
402insufficient_creditsbilling_errorCredit balance too low, please top up
403ip_not_allowedpermission_errorRequest IP not in the key's allowlist
404model_not_foundinvalid_request_errorModel does not exist or is inactive
404task_not_foundinvalid_request_errorTask ID does not exist
429rate_limit_exceededrate_limit_errorToo many requests, please slow down
429spend_limit_exceededbilling_errorKey spend limit reached (hourly/daily/total)
500internal_errorapi_errorUnexpected server error
503upstream_errorupstream_errorUpstream 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.