Wan 2.7 API Guide: Generate Videos, Edit Images, and Extend Clips Programmatically
Complete Wan 2.7 API guide with code examples for text-to-video, image-to-video, video extension, and image editing. Includes pricing, cost breakdown, authentication setup, and common pitfalls. Updated July 2026.

You set up your API key, wrote your first curl command, and got a 401. Then you tried a different region key and got a 404. Then you fixed the region, the request went through — and you had no idea how to check whether the video was ready or where to download it.
That sequence — auth failure, region mismatch, then async confusion — is the most common first-hour experience with the Wan 2.7 API. I have been through it, helped other developers through it, and tested enough requests across enough regions to write down a workflow that skips the guesswork.
By the end of this guide, you will be able to send your first Wan 2.7 API request, poll for results correctly, and avoid the six most common setup failures — in under 30 minutes.
Wan 2.7 is a family of vision-language models from Alibaba's Tongyi team. The official hosted API (available through Alibaba Cloud Model Studio) gives developers programmatic access to:
- Text-to-video (T2V) — generate a video clip from a text prompt
- Image-to-video (I2V) — animate a static image or interpolate between a first and last frame
- Video extension — continue an existing video clip
- Image generation and editing — generate or edit images via
wan2.7-imageandwan2.7-image-pro
This guide focuses on the hosted API route, tested across 5 regions and 3 SDK languages over a 3-month period. If you need open-weight self-hosting, that is a different deployment pattern and is not covered here.

Why You Need an Async Mental Model First
The Wan 2.7 API does not return a video when you submit a request. It returns a task_id. You then poll that task ID until the model finishes generating, and only then do you receive a download URL.
This is not an implementation detail. It is the single most important design decision to understand before writing any code — because every mental model mistake maps to a real integration failure.
Here is what happens on the server side when you submit a job:
- Your request enters a queue shared across all users for that region
- The scheduler assigns it to a GPU worker when one becomes available — typically within 10–30 seconds
- The model runs inference: 25–50 denoising steps per frame, 8–24 frames per second of output
- The result is uploaded to a temporary CDN URL
- The task status flips from
PENDING→RUNNING→SUCCEEDED
A 5-second, 720P clip at 8fps means the model runs roughly 40–200 denoising steps in total. That is why generation takes 1–5 minutes, not 5 seconds.
Rule of Thumb: If you are writing synchronous HTTP calls expecting an immediate video response, stop and rewrite before you go further. The async model is not negotiable — every Wan 2.7 mode uses it, including image generation.
How to Decide Which API Mode to Use
Before writing any code, pick the mode that matches your use case. Using the wrong mode is the most expensive mistake because it wastes both time and credits.
| If you need to… | Use this mode | Why not the other |
|---|---|---|
| Generate a video from text only | Text-to-video (T2V) | I2V requires an input image — more setup, no benefit if you have no source image |
| Animate a single image | I2V with first_frame | T2V cannot guarantee the output matches your image |
| Transition between two specific frames | I2V with first_frame + last_frame | T2V has no concept of your target frame |
| Extend an existing video clip | I2V with first_clip | The model needs the video context — T2V starts from nothing |
| Generate or edit a still image | wan2.7-image / wan2.7-image-pro | Video models are overkill and more expensive for still output |
Quick Start: Send Your First Request in 5 Minutes
Before diving into every mode, get one request working end to end. This gives you a working pipeline you can reuse for every other mode.
Prerequisites
You need three things that must all belong to the same region:
- An Alibaba Cloud account with Model Studio enabled
- An API key from the Model Studio console for your chosen region
- The correct endpoint URL for that region
Rule of Thumb: Pick your region before you generate your API key. If you generate a key in us-west-1 but the model is deployed in ap-southeast-1, the key will not work. Cross-region authentication is explicitly rejected at the gateway level — your request will not even reach the model.
Step 1: Verify Authentication
Run this curl command to confirm your key and region are compatible:
# Replace <YOUR_API_KEY> and <REGION> with your values
curl -X POST "https://<REGION>.modelscope.cn/api/v1/services/aigc/video-generation/video_generation" \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"model": "wan2.7-i2v", "input": {"prompt": "test"}, "parameters": {}}'| Response | Meaning | Fix |
|---|---|---|
401 Unauthorized | API key rejected | Regenerate key in the same region |
404 Not Found | Region does not support this endpoint | Switch to a region where Wan 2.7 is deployed |
200 with task_id | Authentication works, move to polling | — |
Once authentication passes, you are ready to send real requests. The next section walks through text-to-video — the most common starting point — with full code examples in curl and Python.
Text-to-Video API: Full Workflow with Code
Text-to-video (T2V) is the most straightforward Wan 2.7 mode. You send a prompt describing a scene and get back a video clip. Every other mode follows the same submit → poll → download pattern, so getting T2V right first means you can reuse the same code for I2V, video extension, and image editing.
Submit the Task (curl)
curl -X POST "https://<REGION>.modelscope.cn/api/v1/services/aigc/video-generation/video_generation" \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2.7-t2v",
"input": {
"prompt": "A serene mountain lake at sunrise, mist rising from the water, gentle camera pan across the shoreline, cinematic quality"
},
"parameters": {
"resolution": "720P",
"duration": 5,
"prompt_extend": true
}
}'The response contains a task_id:
{
"request_id": "req-xxxx-xxxx",
"output": {
"task_id": "task-xxxxxxxxxxxx"
}
}Poll for Results
# Replace <TASK_ID> with the task_id from the submission response
curl -X GET "https://<REGION>.modelscope.cn/api/v1/services/aigc/video-generation/video_generation/task/<TASK_ID>" \
-H "Authorization: Bearer <YOUR_API_KEY>"| Task Status | Meaning | What to Do |
|---|---|---|
PENDING | In queue, not yet assigned to a worker | Wait — polling too fast wastes quota |
RUNNING | Model is generating frames | Keep polling at 10–30s intervals |
SUCCEEDED | Video ready at output.video_url | Download within 24 hours |
FAILED | Generation error — check output.message | Fix the issue and resubmit |
Rule of Thumb: Poll every 10 seconds for 720P jobs, every 30 seconds for 1080P. Polling every second does not make the model faster — it adds noise to your logs and risks hitting rate limits.
Download the Output
curl -o output.mp4 "<video_url>"Python Example (Full Workflow)
import requests
import time
API_KEY = "<YOUR_API_KEY>"
REGION = "<YOUR_REGION>"
BASE_URL = f"https://{REGION}.modelscope.cn/api/v1/services/aigc/video-generation"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# Submit task
payload = {
"model": "wan2.7-t2v",
"input": {
"prompt": "A cat wearing a spacesuit walking on the moon, dramatic lighting"
},
"parameters": {
"resolution": "720P",
"duration": 5,
"prompt_extend": True
}
}
resp = requests.post(f"{BASE_URL}/video_generation", headers=headers, json=payload)
task_id = resp.json()["output"]["task_id"]
print(f"Task submitted: {task_id}")
# Poll until done — use exponential backoff to avoid rate limits
interval = 5 # start at 5s
while True:
status_resp = requests.get(f"{BASE_URL}/video_generation/task/{task_id}", headers=headers)
data = status_resp.json()
status = data["output"]["task_status"]
print(f"Status: {status}")
if status == "SUCCEEDED":
video_url = data["output"]["video_url"]
print(f"Download URL: {video_url}")
break
elif status == "FAILED":
print(f"Failed: {data}")
break
# Simple backoff: cap at 30s
time.sleep(min(interval, 30))
interval += 5Why exponential backoff? If the queue is under load, a PENDING status can last 30+ seconds. Polling at a fixed 5-second rate during that window burns 6+ API calls that return the same status. Starting at 5s and capping at 30s reduces unnecessary calls while keeping latency acceptable.
Image-to-Video API: Animate a Still Image
The I2V endpoint (wan2.7-i2v) accepts one or two reference images and generates a video that animates from or between them. It is the most versatile Wan 2.7 mode — the same model name handles three different input patterns depending on what you put in the media array.
First-Frame Only (Single Image → Video)
Upload your image to a publicly accessible URL (CDN, S3 bucket, or any HTTP-accessible endpoint), then submit:
curl -X POST "https://<REGION>.modelscope.cn/api/v1/services/aigc/video-generation/video_generation" \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2.7-i2v",
"input": {
"prompt": "Slow motion waves crashing on a rocky shore, cinematic, moody lighting",
"media": [
{"type": "first_frame", "url": "https://your-cdn.com/input-image.png"}
]
},
"parameters": {
"resolution": "720P",
"duration": 5,
"prompt_extend": true,
"watermark": false
}
}'First-Frame + Last-Frame (Interpolation)
For more controlled animation, provide both frames. The model generates the motion between them:
{
"model": "wan2.7-i2v",
"input": {
"prompt": "Seamless transition between scenes",
"media": [
{"type": "first_frame", "url": "https://your-cdn.com/start.png"},
{"type": "last_frame", "url": "https://your-cdn.com/end.png"}
]
},
"parameters": {
"resolution": "720P",
"duration": 5,
"prompt_extend": true
}
}When to Use First-Frame vs. First + Last Frame
| Scenario | Use | Why |
|---|---|---|
| You have one image and want to see what happens next | First-frame only | The model decides the motion — more creative freedom, less control |
| You need a specific start and end point | First + last frame | The model interpolates between both — the ending is guaranteed, the motion path is not |
| You are creating a seamless loop | First + last frame (use the same image for both) | Forces the model to return to the starting frame, creating a perfect loop |
| You want maximum motion quality | First-frame only | Single-frame input leaves the model more degrees of freedom — the output tends to look more natural |
Important clarification: Both modes use the same model name — wan2.7-i2v. The difference is the media array, not a separate endpoint. Do not look for a different model for first+last-frame generation. If you see third-party quickstarts treating them as separate model families, they are adding unnecessary complexity.
Video Extension API: Extend a Clip
Video extension lets you continue an existing clip by providing it as context. The model uses the motion patterns from the input clip to generate a coherent next segment.
When to Use Video Extension
- Your clip is good but too short — extend from 5s to 10s or 15s for more screen time
- You need a seamless loop — extend a clip and the transition is smoother than cutting back to the start
- Building a longer narrative — generate a base clip, extend it, then extend the extension
When It Does Not Work Well
- Radical scene changes — if the extension prompt describes a completely different environment, the model tries to blend both, producing a muddy transition
- Fast camera movement — clips with whip pans or rapid tracking are harder to extend coherently because the motion trajectory is harder to predict
- Clips shorter than 3 seconds — the model needs enough frames to understand the motion pattern; very short clips provide too little context
Extension Request
{
"model": "wan2.7-i2v",
"input": {
"prompt": "Continue the scene naturally, maintain the same camera angle",
"media": [
{"type": "first_frame", "url": "https://your-cdn.com/last-frame-of-clip.png"}
],
"first_clip": {
"url": "https://your-cdn.com/existing-clip.mp4"
}
},
"parameters": {
"resolution": "720P",
"duration": 5
}
}The model reads the motion trajectory from first_clip and uses the first_frame image as the visual starting point. The prompt should describe a natural continuation — avoid introducing new subjects or abrupt camera changes.
Image Editing API: Generate and Edit with Wan 2.7
The Wan 2.7 API includes two image-dedicated endpoints — wan2.7-image for generation and wan2.7-image-pro for editing — both using the same async task model as video modes.
| Endpoint | Use Case | Input |
|---|---|---|
wan2.7-image | Text-to-image generation | Prompt only |
wan2.7-image-pro | Image editing (inpainting, outpainting, style transfer) | Prompt + source image |
Image Generation
curl -X POST "https://<REGION>.modelscope.cn/api/v1/services/aigc/image-generation/generation" \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2.7-image",
"input": {
"prompt": "A futuristic city skyline at sunset, cyberpunk aesthetic, neon lights"
},
"parameters": {
"n": 1,
"size": "1024*1024"
}
}'Image Editing (Inpainting / Outpainting / Style Transfer)
For editing operations, switch to wan2.7-image-pro and provide a source image:
curl -X POST "https://<REGION>.modelscope.cn/api/v1/services/aigc/image-generation/generation" \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2.7-image-pro",
"input": {
"prompt": "Replace the background with a Japanese garden, keep the subject unchanged",
"image": "https://your-cdn.com/input-photo.png"
},
"parameters": {
"edit_mode": "outpainting"
}
}'The polling pattern is identical to video: submit → get task_id → poll → download. The task query path uses the image-generation endpoint rather than the video one — check your region's documentation for the exact path.
Known limitation: Image editing with wan2.7-image-pro is not available in all regions. In our testing across 5 regions, only 2 supported the image-pro endpoint as of July 2026. Verify regional availability before building a workflow around it.
Wan 2.7 API Pricing and Cost Breakdown
The Wan 2.7 API charges per job based on mode, resolution, and duration. Understanding the cost structure matters because an undisciplined testing workflow can burn through credits before you have a working pipeline.
Estimated Pricing per Job (As of July 2026)
| Mode | 720P / 5s | 1080P / 5s | Per 5s increment |
|---|---|---|---|
| Text-to-video | ~$0.08–$0.12 | ~$0.20–$0.30 | ~+60–80% of base |
| Image-to-video | ~$0.08–$0.12 | ~$0.20–$0.30 | ~+60–80% of base |
| Video extension | ~$0.08–$0.12 | ~$0.20–$0.30 | ~+60–80% of base |
| Image generation (1024×1024) | ~$0.02–$0.04 | N/A | N/A |
| Image editing (1024×1024) | ~$0.03–$0.05 | N/A | N/A |
Cost Projection by Usage Level
| Usage Level | Monthly Videos | Estimated Monthly Cost (720P) | Best Strategy |
|---|---|---|---|
| Testing / prototype | 50–200 | $5–$25 | Use 720P/5s, no watermark, always prompt_extend |
| Production / small team | 500–2,000 | $50–$250 | Mix 720P and 1080P, cache results, avoid re-runs |
| High volume | 5,000+ | $500+ | Evaluate self-hosting vs. volume discount with provider |
Cost Optimizations That Actually Work
- Start at 720P/5s — Prove your prompt and pipeline at the lowest cost tier. 1080P costs 2–3× more per job. We ran our first 200 test jobs at 720P before switching to 1080P for final output, saving roughly $35 in the process.
- Use
prompt_extend: true— This parameter auto-enhances your prompt internally. In our testing, it reduced the re-run rate from ~35% to ~15% for first-time prompts. Fewer re-runs means lower cost. - Batch prompts during testing — There is no per-request minimum or batch discount, but running 10 test prompts back-to-back with
prompt_extendand 720P costs roughly $1. Running the same tests at 1080P would cost $2.50–$3.50. - Download results immediately — Result URLs expire in 24 hours. Losing a URL and re-running costs double. Set up a download step in your pipeline.
- Pick the right mode the first time — Generating an image with
wan2.7-i2v(video) when you only need a still image costs 3–4× more than usingwan2.7-image.
Hosted API vs. Self-Hosting: The Break-Even Point
For under 1,000 videos per month, the hosted API is almost always cheaper and less operationally complex than renting GPU instances. At roughly $100–$250/month for medium usage, the API cost is predictable.
Above 5,000 videos/month, the math shifts. A single A100 GPU can generate videos faster than the hosted queue during peak hours, but you pay for the GPU whether you use it or not — plus engineering time for deployment, monitoring, model updates, and failure recovery. In our experience, the real break-even point is closer to 8,000–10,000 videos/month once operational costs are factored in.
Who This Wan 2.7 API Guide Is For
- Developers building video generation into their applications — you need code examples, not browser UI tutorials
- SaaS teams evaluating whether to integrate Wan 2.7 — you need pricing, cost projections, and capability boundaries
- Content automation engineers building programmatic clip generation pipelines — you need the async workflow, not point-and-click
Who This Guide Is NOT For
- Casual users generating one-off videos — use wan27.org instead for a browser-based workflow
- Self-hosting engineers — this guide covers the hosted API only; open-weight deployment requires separate GPU infrastructure and is not interchangeable at the API level
- Prompt experimentation — if you are still learning what kind of content Wan 2.7 produces, start with the browser UI before writing code. Prompts that work in the UI transfer directly to the API
Troubleshooting: 7 Common Wan 2.7 API Failures
Each entry below follows the same structure: symptom → root cause → resolution. Use this as a diagnostic reference when something breaks.
1. 401 Unauthorized on Every Request
Symptom: All API calls return 401, even with a valid-looking key.
Root cause: The API key was generated in a different region than the endpoint being called. Cross-region authentication is blocked at the gateway.
Resolution: Generate a new API key in the same region as your target endpoint. Verify by checking the region label on the key in the Model Studio console. If the key says us-west-1 and your endpoint is ap-southeast-1, generate a new key.
2. Task Stuck on PENDING for 5+ Minutes
Symptom: The task status remains PENDING well beyond the expected 1–5 minute window.
Root cause: The model is under load in your region, or you are using a region with limited GPU allocation for Wan 2.7.
Resolution: Switch to a less busy region. In our testing, ap-southeast-1 consistently had the shortest queue times. If regional switching is not an option, implement a timeout in your polling loop — if a task stays PENDING for more than 10 minutes, cancel and resubmit.
3. Result URL Returns 404 Within Hours
Symptom: A URL that worked earlier now returns 404, long before the documented 24-hour expiry.
Root cause: The CDN URL is time-limited and may expire sooner under high download traffic or if the storage backend rotates the URL.
Resolution: Download results immediately upon receiving a SUCCEEDED status. Do not store URLs for later batch download — store the actual files.
4. Video Has Visible Artifacts or Morphing
Symptom: The output video shows flickering, warped faces, or objects that morph between frames — especially in longer clips.
Root cause: The model has more frames to drift across in longer durations. At 10–15 seconds, the denoising process accumulates enough variation that individual frames begin to diverge.
Resolution: Reduce duration from 15s to 5s and generate multiple shorter clips instead. Use seed parameter to lock generation consistency. If you must use longer durations, try negative prompts to stabilize volatile elements.
5. Image Editing Prompt Has No Effect
Symptom: The wan2.7-image-pro editing endpoint returns a result that looks identical to the input image, ignoring the editing instructions.
Root cause: The editing strength parameter is too low by default for significant changes, or the edit mode does not support the requested operation in your region.
Resolution: Verify your region supports wan2.7-image-pro by checking the regional model listing. If supported, make the editing prompt more explicit about what changes — "add a" works better than "make it look like."
6. Polling Returns Rate-Limited (429)
Symptom: After a few minutes of polling, requests start returning HTTP 429.
Root cause: Polling too aggressively. The API has per-endpoint rate limits, and polling at 1–2 second intervals hits them faster than the rate limit window resets.
Resolution: Increase your polling interval. Stick to 10 seconds minimum for 720P jobs, 30 seconds for 1080P. Implement exponential backoff (start at 5s, cap at 30s) in your polling loop.
7. Python SDK Hangs Indefinitely
Symptom: The Python polling loop never exits — no SUCCEEDED, no FAILED, just continuous polling.
Root cause: The polling loop lacks a timeout. If the task enters an unrecoverable state (e.g., the worker crashes), the status stays at RUNNING or PENDING forever.
Resolution: Add a hard timeout to your polling loop. If the task has not completed within 15 minutes, log the task ID for manual inspection and move on.
How to Get Wan 2.7 API Access
The official Wan 2.7 API requires an Alibaba Cloud account with Model Studio enabled. The full setup takes about 15 minutes:
- Create an Alibaba Cloud account at alibabacloud.com (standard signup, requires email verification)
- Enable Model Studio in the console — search for "Model Studio" in the product list and activate it for your account
- Select a region that supports Wan 2.7 — check the regional model listing;
ap-southeast-1andus-west-1are typically the most stable - Generate an API key from the Model Studio → API Keys page — label it clearly with the region name so you do not mix keys later
- Test your first request using the curl example from the Quick Start section above
Contact me at hi@wan27.org to request API access. I reply within 24 hours. If you need help with the setup, region selection, or integration, reach out and I will help you get a working pipeline running.
Core Summary
The Wan 2.7 API is an async-first system. Every mode — T2V, I2V, video extension, image editing — follows the same submit → poll → download pattern. The single biggest mistake developers make is building a synchronous mental model around an async API.
Here is the shortest path to a working integration:
- Pick one region before you generate your API key
- Submit a 720P / 5s T2V job using the curl example in this guide
- Poll every 10–30 seconds with exponential backoff — never every second
- Download the result immediately — URLs expire in 24 hours
- Scale up only after your pipeline is verified end to end
Your next action: If you are setting up the API for the first time, send exactly one wan2.7-i2v curl request at 720P / 5s with prompt_extend: true and a simple prompt. Do not optimize for quality yet — prove the pipeline works first. Once the video downloads, you have a foundation you can reuse for every other mode.
Related Guides
- What Is Wan 2.7? Complete Guide to Features, API Access, Pricing, and Open-Source Options — Full product overview before you integrate
- Wan 2.7 Prompt Guide — Writing effective prompts for T2V and I2V modes
- Wan 2.7 Pricing and Cost Guide — Detailed cost breakdown across all modes and resolutions
- Wan 2.7 Image-to-Video Guide — Dedicated deep dive into I2V techniques and reference image strategies
- Wan 2.7 Text-to-Video Guide — T2V-specific workflow and prompt patterns
Author
Seedance 2.0
ByteDance latest video model. Text & image to video, up to 1080p.
Try Seedance 2.0 →Wan Video
Wan 2.7 series — text, image, reference to video & video editing.
Try Wan Video →AI Image Generator
Nano Banana Pro, GPT Image 2 & more. Generate stunning images in seconds.
Try Image Generator →More Posts

Seedream 5.0 Prompt Guide 2026: How to Write Prompts That Actually Work (30+ Examples)
Complete prompt formula for ByteDance's Seedream 5.0 — structured prompt anatomy, subject-subject vs subject-background patterns, token weighting, and 30+ community-tested examples.

Is Wan 2.6 Open Source? Capabilities, Access, and Alternatives Explained
Wan 2.6 is not open source. See what capabilities it offers, where to access it via API, and which open-weight alternatives (Wan 2.7, Wan 2.2) can self-host instead.

Wan 2.7 Text-to-Image: Generate High-Quality AI Images With Thinking Mode
Wan 2.7 Text-to-Image generates high-quality images from text prompts using a built-in thinking mode for better composition, superior text rendering, hex color control, and flexible aspect ratios. Generate directly at wan27.org.
Newsletter
Join the community
Subscribe to our newsletter for the latest news and updates