13. Asynchronous Tasks (Video / Midjourney)#
Long-running jobs such as video generation and Midjourney image generation follow an asynchronous pattern: submit the task, receive a task id immediately, then poll for the result.
13.1 Submitting a video task#
POST /v1/video/create (alias POST /v1/videos)
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Video model name (e.g. the sora / veo / wan / doubao families) |
prompt | string | No | Text description (mutually exclusive with content; sending both is an error) |
content | array | No | Multimodal content array. Text element: {"type":"text","text":"…"}; reference element: {"type":"image_url","image_url":{"url":"…"}} (video_url, audio_url follow the same pattern — the field name matches type); references may carry a role (reference_image, reference_video, reference_audio — e.g. pass a reference audio for audio-driven generation). URLs accept http(s), asset:, data: |
input | object | No | Sora-style nested input |
parameters | object | No | Wan-style parameter block (top-level fields of the same name take precedence over values inside parameters) |
images | array | No | List of reference image URLs (image-to-video; must be http/https URLs) |
aspect_ratio / ratio | string | No | Aspect ratio, e.g. 16:9 (the two are equivalent; ratio wins) |
resolution | string | No | Resolution, e.g. 720p / 1080p |
duration | integer | No | Video duration in seconds, 1–15; the Seedance family requires 4–15 |
generate_audio | boolean | No | Generate video with audio. Only effective on models that support audio output (e.g. Veo 3, audio-enabled Seedance); unsupported models fail upstream. Omitted = channel default |
watermark | boolean | No | Whether to add a watermark |
seed | integer | No | Random seed (0–4294967295) for reproducible results |
return_last_frame | boolean | No | Whether to return the video's last frame in the result |
enhance_prompt | boolean | No | Whether to let the upstream enhance the prompt |
enable_upsample | boolean | No | Whether to enable upsampling |
execution_expires_after | integer | No | Task retention in seconds, 1–172800; the task expires afterwards |
# Basic text-to-video
curl http://183.240.79.21:52099/v1/video/create \
-H "Authorization: Bearer sk-你的YiTuoToken-Key" \
-H "Content-Type: application/json" \
-d '{
"model": "sora-2",
"prompt": "一只在草地上奔跑的柯基犬,阳光明媚",
"aspect_ratio": "16:9"
}'
# Generate video with audio (pass generate_audio: true on models that support it)
curl http://183.240.79.21:52099/v1/video/create \
-H "Authorization: Bearer sk-你的YiTuoToken-Key" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3",
"prompt": "海浪拍打礁石,伴随海鸥鸣叫",
"resolution": "1080p",
"generate_audio": true
}'
A successful submission returns a task
id; use it to poll the task status (see 13.3).generate_audiois passed through to the upstream: if the target model does not support audio the task fails upstream, and the reason is visible in theerrorfield of the 13.3 query result.
13.2 Submitting a Midjourney task#
| Endpoint | Description |
|---|---|
POST /v1/mj/submit/imagine | Text to image |
POST /v1/mj/submit/blend | Multi-image blending |
POST /v1/mj/submit/action | Upscale / variation and other operations on an existing task |
curl http://183.240.79.21:52099/v1/mj/submit/imagine \
-H "Authorization: Bearer sk-你的YiTuoToken-Key" \
-H "Content-Type: application/json" \
-d '{
"model": "midjourney",
"prompt": "a cute corgi astronaut, digital art --ar 16:9"
}'
13.3 Querying task status#
GET /v1/tasks/{id} — query with the id returned at submission. Task ownership is enforced: querying someone else's task returns 404 (to prevent enumeration). Adding ?fresh=true triggers a live upstream poll.
curl http://183.240.79.21:52099/v1/tasks/0000019f-... \
-H "Authorization: Bearer sk-你的YiTuoToken-Key"
13.4 Task list#
GET /v1/tasks — lists your own tasks (newest first).
| Query parameter | Description |
|---|---|
task_type | Filter by type (e.g. video, mj) |
status | Filter by status |
offset | Offset, defaults to 0 |
limit | Page size, defaults to 50, max 200 |
curl "http://183.240.79.21:52099/v1/tasks?task_type=video&limit=20" \
-H "Authorization: Bearer sk-你的YiTuoToken-Key"
13.5 Canceling a task#
POST /v1/tasks/{id}/cancel — cancels a running task and unfreezes the pre-frozen quota. Returns 404 if the task does not exist or is already in a terminal state.
curl -X POST http://183.240.79.21:52099/v1/tasks/0000019f-.../cancel \
-H "Authorization: Bearer sk-你的YiTuoToken-Key"