Video Generation API Guide
Call Veo, Seedance, MiniMax, Omni, and Wan video models with one API key, all through the OpenAI video format.
📋 Overview
Xiaomai API video generation is an asynchronous task: submit a task to get a task ID, poll its status, then download the video when it is done. Every video model uses the same endpoints; only the request body values differ.
⚠️ Supported Environment
Anything that can send HTTP requests works: Windows (PowerShell), macOS / Linux (curl), Python, Node.js, and so on.
🚨 Common Pitfall: Use an image-video Group Key
Video models are only available in the image-video group. A key from another group (such as Claude-Code-api or General) gets a "no access" or "model not found" error. Create a dedicated key in the image-video group first.
🔗 Related Links
| Resource | URL |
|---|---|
| API base URL | https://xiaomai.win |
| Console / model marketplace | xiaomai.win |
| Create a key | Create an API Key |
| Top up | Top Up Balance |
✨ Features
- One endpoint: all video models share
POST /v1/videos; switch models by changingmodeland its parameters - Several modes: text-to-video, reference images, first and last frames, reference video / audio, and video editing (depending on the model)
- Media hosting: upload local images, videos, and audio to
/v1/uploadsand get HTTPS URLs back - Automatic refunds: the cost is pre-charged at submit and refunded automatically if the task fails
- Up-front validation: unsupported durations, resolutions, aspect ratios, or media counts return 400 right away, with no charge
🛠️ Endpoints
| Purpose | Method and path |
|---|---|
| Submit a video task | POST /v1/videos |
| Query task status | GET /v1/videos/{task_id} |
| Download the video | GET /v1/videos/{task_id}/content (supports HEAD and Range) |
| Upload media | POST /v1/uploads |
| Delete media | DELETE /v1/uploads/{id} |
Every endpoint uses the same key:
Authorization: Bearer sk-xxxx
Content-Type: application/json⚙️ Flow: Submit → Poll → Download
Step 1: Submit a Task
curl https://xiaomai.win/v1/videos \
-H "Authorization: Bearer sk-xxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance-2.0",
"prompt": "The girl in the reference image walks toward the camera along the beach, slow push-in",
"resolution": "720p",
"seconds": 5,
"ratio": "9:16",
"images": ["https://media.xiaomai.win/uploads/xxxxx.jpg"]
}'$headers = @{ Authorization = "Bearer sk-xxxx" }
$body = @{
model = "seedance-2.0"
prompt = "The girl in the reference image walks toward the camera along the beach, slow push-in"
resolution = "720p"
seconds = 5
ratio = "9:16"
images = @("https://media.xiaomai.win/uploads/xxxxx.jpg")
} | ConvertTo-Json
Invoke-RestMethod -Uri "https://xiaomai.win/v1/videos" -Method Post `
-Headers $headers -ContentType "application/json; charset=utf-8" `
-Body ([System.Text.Encoding]::UTF8.GetBytes($body))The response only means the task was accepted, not that the video is ready:
{
"id": "task_xxxxx",
"object": "video",
"model": "seedance-2.0",
"status": "queued",
"progress": 0,
"created_at": 1795000000
}Step 2: Poll the Status
curl https://xiaomai.win/v1/videos/task_xxxxx \
-H "Authorization: Bearer sk-xxxx"Invoke-RestMethod -Uri "https://xiaomai.win/v1/videos/task_xxxxx" `
-Headers @{ Authorization = "Bearer sk-xxxx" }Status flow: queued → in_progress → completed or failed. progress is 0–100.
A failed task carries the reason:
{
"id": "task_xxxxx",
"object": "video",
"status": "failed",
"progress": 0,
"error": {
"code": "video_generation_failed",
"message": "failure reason"
}
}💡 Polling Tips
- Poll every 10–20 seconds; polling faster does not make the task finish sooner
- Most tasks finish within minutes, but some models can take tens of minutes at peak times. Wait up to 60 minutes before treating a task as timed out
- After a timeout, do not resubmit right away. Contact support with the task ID first to avoid paying twice
Step 3: Download the Video
curl https://xiaomai.win/v1/videos/task_xxxxx/content \
-H "Authorization: Bearer sk-xxxx" \
-o result.mp4Invoke-WebRequest -Uri "https://xiaomai.win/v1/videos/task_xxxxx/content" `
-Headers @{ Authorization = "Bearer sk-xxxx" } -OutFile result.mp4A task is only truly done when status is completed and the /content download succeeds. Always download through /content, save the file yourself, and avoid downloading the whole file repeatedly.
Full Python Example
import time
import requests
BASE = "https://xiaomai.win"
KEY = "sk-xxxx" # a key in the image-video group
H = {"Authorization": "Bearer " + KEY}
body = {
"model": "seedance-2.0",
"prompt": "The girl in the reference image walks toward the camera along the beach, slow push-in",
"resolution": "720p",
"seconds": 5,
"ratio": "9:16",
"images": ["https://media.xiaomai.win/uploads/xxxxx.jpg"],
}
r = requests.post(BASE + "/v1/videos", headers=H, json=body, timeout=120)
if r.status_code == 400: # rejected parameters, not charged
raise SystemExit(r.json()["error"]["message"])
r.raise_for_status()
task_id = r.json()["id"]
print("task:", task_id)
deadline = time.time() + 60 * 60 # wait up to 60 minutes
while time.time() < deadline:
time.sleep(15)
s = requests.get(f"{BASE}/v1/videos/{task_id}", headers=H, timeout=60).json()
print(s["status"], s.get("progress"))
if s["status"] == "completed":
with requests.get(f"{BASE}/v1/videos/{task_id}/content", headers=H, stream=True, timeout=600) as v:
v.raise_for_status()
with open("result.mp4", "wb") as f:
for chunk in v.iter_content(1 << 20):
f.write(chunk)
print("saved result.mp4")
break
if s["status"] == "failed": # refunded automatically
raise SystemExit(s.get("error", {}).get("message"))
else:
raise SystemExit("Not finished after 60 minutes; contact support with the task ID")📤 Media Upload /v1/uploads
Images, videos, and audio in video requests must be public HTTPS URLs. Local paths and base64 are not accepted. Upload local files first:
# Option 1: send the file (field name: file / image / video / audio)
curl https://xiaomai.win/v1/uploads \
-H "Authorization: Bearer sk-xxxx" \
-F "[email protected]"
# Option 2: send a data URL
curl https://xiaomai.win/v1/uploads \
-H "Authorization: Bearer sk-xxxx" \
-H "Content-Type: application/json" \
-d '{"data_url": "data:image/jpeg;base64,/9j/4AAQ..."}'# PowerShell 7+
Invoke-RestMethod -Uri "https://xiaomai.win/v1/uploads" -Method Post `
-Headers @{ Authorization = "Bearer sk-xxxx" } `
-Form @{ file = Get-Item ".\reference.jpg" }Example response:
{
"id": "xxxxx",
"url": "https://media.xiaomai.win/uploads/xxxxx.jpg",
"mime": "image/jpeg",
"size": 245760,
"expires_at": 1795259200
}| Item | Rule |
|---|---|
| Size | Up to 100 MB per file; larger files return 413 |
| Types | Images png / jpg / gif / webp / bmp; videos mp4 / mov / webm / m4v; audio mp3 / wav / aac / m4a / ogg / flac. Detected from file content; other types are rejected |
| Retention | Deleted automatically after 72 hours; submit your task before then |
| Cost | Uploads are free |
| Delete | DELETE /v1/uploads/{id}; you can only delete your own files |
⚠️ Use the Returned url As Is
The url ends with the real file extension (.jpg, .mp4, and so on). Copy it exactly into the video request. Do not build it yourself or drop the extension; some models fail to download URLs without one.
💡 Shrink Reference Images First
Resize reference images to at most 1280 px on the long side and 2 MB each. Video models output 720p–4k at most, so full-size camera photos bring no benefit and make tasks more likely to fail.
📝 Request Parameters
Common Fields
| Field | Required | Description |
|---|---|---|
model | Yes | Model ID, exactly as in the console model marketplace (including Chinese characters and brackets) |
prompt | Yes | Prompt text, must not be empty |
seconds | No | Duration in whole seconds; duration also works. Send only one |
resolution | No | Resolution such as 720p, 1080p, 4k; the model default is used when omitted |
ratio | No | Aspect ratio such as 16:9, 9:16; aspect_ratio also works |
images | No | Reference image URLs, such as ["https://..."] |
first_frame / last_frame | No | First / last frame image URL. Cannot be combined with images references |
videos | No | Reference video (or video to edit) URLs |
audios | No | Reference audio URLs |
⚠️ Parameter Notes
- Only use values the model supports for duration, resolution, and aspect ratio. Unsupported values return 400 with the allowed values, and nothing is charged
- Keep the prompt consistent with the parameters. If the prompt says "30-second vertical video", send
seconds: 30andratio: "9:16"; contradictions often make generation fail - Do not send fields not listed here (such as
group). They have no effect, and some models may reject the request - Reference images are strongly recommended. Text-only results are hard to control and often need redoing
🎬 Choosing a Model
The available video models change over time, so this page lists no models or prices; check the console model marketplace for the current model IDs, billing methods, and live prices. The actual charge of each task is in the usage logs. All video models are in the image-video group.
- Each model supports different resolutions, durations, aspect ratios, and media counts; unsupported values return 400 with the allowed values in the error, and nothing is charged
- Billing is per video or per second; some models have tiers by resolution / duration
- For Seedance models, always send
seconds; when omitted, the upstream picks its default duration
⚠️ Copy Model IDs Exactly
Some model IDs contain Chinese characters or full-width Chinese brackets. Copy them from the marketplace without changes.
Below are notes and request examples for some models; the live list in the marketplace is authoritative.
omni_flash-1.2 Notes
- Video editing: put one video URL to edit in
videosand the task switches to edit mode; edit mode ignoressecondsandratio - First and last frames: at most 2; with 2 frames the duration cannot exceed 10 seconds
Examples by Model
{
"model": "veo_3_1",
"prompt": "Smooth transition from the first frame to the last frame",
"resolution": "1080p",
"ratio": "16:9",
"first_frame": "https://media.xiaomai.win/uploads/first.jpg",
"last_frame": "https://media.xiaomai.win/uploads/last.jpg"
}{
"model": "minimax-h3",
"prompt": "The person in the reference images turns and smiles in a café, slow orbit shot",
"seconds": 10,
"ratio": "9:16",
"images": [
"https://media.xiaomai.win/uploads/a.jpg",
"https://media.xiaomai.win/uploads/b.jpg"
]
}{
"model": "omni_flash-1.2",
"prompt": "Turn the daytime scene into night with the street lights on",
"resolution": "1080p",
"videos": ["https://media.xiaomai.win/uploads/source.mp4"]
}{
"model": "seedance-2.5",
"prompt": "Requirements: 15-second vertical ad. Content: the sofa in the reference image shown in a living room. 0–5 s: push in; 5–10 s: orbit; 10–15 s: pull back and hold",
"seconds": 15,
"ratio": "9:16",
"images": ["https://media.xiaomai.win/uploads/sofa.jpg"]
}{
"model": "seedance-2.0-4k",
"prompt": "The sports car in the reference image speeds through a rainy city at night, tracking shot",
"seconds": 5,
"ratio": "16:9",
"images": ["https://media.xiaomai.win/uploads/car.jpg"],
"generate_audio": true,
"watermark": false
}{
"model": "wan3.0-video",
"prompt": "The kitten in the reference image chases a butterfly on the grass",
"resolution": "720P",
"seconds": 5,
"ratio": "16:9",
"images": ["https://media.xiaomai.win/uploads/cat.jpg"]
}Wan 3.0 Notes
- Defaults to 1080P, the most expensive tier. To save money, send
"resolution": "480P"or"720P"explicitly - In
images, the 1st image is the first frame and the 2nd is the last frame - To use reference images / video / audio (instead of frames), send them in
metadata.input.media. They cannot be combined with frames:
{
"model": "wan3.0-video",
"prompt": "The person in the reference image runs along the beach",
"resolution": "720P",
"seconds": 8,
"metadata": {
"input": {
"media": [
{ "type": "reference_image", "url": "https://media.xiaomai.win/uploads/person.jpg" },
{ "type": "reference_audio", "url": "https://media.xiaomai.win/uploads/bgm.mp3" }
]
}
}
}- Up to 10 reference images and up to 5 reference videos and 5 reference audio files
seconds: -1means smart duration. It is pre-charged as 30 seconds and settled on the actual duration when done- With a reference video, billed seconds = input video duration + output video duration
- Prompt rewriting is on by default; send
"prompt_extend": falseto turn it off
💰 Billing and Refunds
| Case | Charged? |
|---|---|
| Submit returns 400 (unsupported parameters) | Not charged; error.message gives the reason |
| Submit returns 401 / 403 / 429, etc. | Not charged |
| Submit succeeds | Pre-charged from the request parameters |
Task ends failed | Refunded in full automatically |
Task completed but you dislike the result | Charged normally; this is not a failure |
- Per video: one price per video; some models have tiers by resolution / duration (the duration must still be allowed)
- Per second:
duration × price per second; some models have tiers by resolution - Unit prices change over time; check the console marketplace
- The actual charge and matched price tier of each task are shown in the console usage logs
FAQ
"No access to group" or "model not found"?
The key is not in the image-video group. Create a new key in that group, or change the existing key's group to image-video. See Update Token Settings.
400 "must be a public HTTP(S) URL"?
An image, video, or audio field holds a local path or base64. Upload it with /v1/uploads first, then use the returned url.
400 "supports seconds ... ; got ..."?
The duration, resolution, or aspect ratio is outside the model's range. The error lists the allowed values.
The task stays queued / in_progress?
Most videos are ready in minutes, but peak times take longer. Keep polling every 10–20 seconds for up to 60 minutes. Do not resubmit: each submission is charged separately.
The task completed but /content fails?
Retry the download with the same task ID first. If it keeps failing, contact support with the task ID instead of submitting a new paid task.