Video Generation
Level: Intermediate · Category: API reference
Tags: Text-to-video · Image-to-video · Jobs
wan-2-2 (Wan2.2 TI2V-5B) makes short video clips from a text prompt, or from a prompt and a first
frame. A clip takes minutes, so the API is a job: you create it, poll it, then download the MP4. It
follows the OpenAI Videos API shape. Keys and setup are on LLM API Access.
| Method and path | What it does |
|---|---|
POST /v1/videos | Create a job. Returns its id and status: "queued". |
GET /v1/videos/{id} | The job's status (queued, in_progress, completed, failed) and progress (0 to 100) |
GET /v1/videos/{id}/content | The finished MP4. Returns 409 while the clip is still rendering. |
DELETE /v1/videos/{id} | Delete the job and its file |
GET /v1/videos | Your jobs, newest first |
Jobs are private to the API key that created them: another key, even your own, gets 404 for the
same id. Finished jobs are kept for 24 hours, so download the MP4 soon after it completes.
Make a clip
import os
import time
import requests
API = "https://openai.rc.asu.edu/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['OPENAI_API_KEY']}"}
job = requests.post(f"{API}/videos", headers=HEADERS, json={
"model": "wan-2-2",
"prompt": "a saguaro cactus at sunrise, slow camera pan",
"size": "1280x704",
"seconds": 2,
"steps": 10,
}).json()
while job["status"] not in ("completed", "failed"):
time.sleep(15)
job = requests.get(f"{API}/videos/{job['id']}", headers=HEADERS).json()
print(job["status"], job.get("progress"))
if job["status"] == "completed":
video = requests.get(f"{API}/videos/{job['id']}/content", headers=HEADERS)
with open("clip.mp4", "wb") as f:
f.write(video.content)
In testing, this 2-second clip at 10 steps finished in about 45 seconds.
Options
| Field | Meaning |
|---|---|
prompt | What happens in the clip |
size | WIDTHxHEIGHT; both multiples of 32. The model's native size is 1280x704. |
seconds | Clip length. Clips are 24 frames per second, and the frame count is rounded to the nearest one the model accepts, so a clip can be a few hundredths of a second off (the job reports the real length as a string, for example "2.04"). The model was trained on 5-second clips. |
steps | Denoising steps: fewer is faster, more is sharper. A 5-second clip at 20 steps takes about 3 minutes once the model is warm. |
input_reference | A first frame (image to video). Send the request as multipart/form-data with the image as a file. |
Image to video with curl:
curl -s https://openai.rc.asu.edu/v1/videos \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F model=wan-2-2 \
-F prompt="the camera pushes slowly forward" \
-F input_reference=@first_frame.png \
-F seconds=5
Each server renders one clip at a time, and when every server is busy, new jobs wait in the queue.
Related guides
- Image generation: make the first frame.
- Limits and Errors: queuing and error codes.