Chapter 13 of 212 min

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)

ParameterTypeRequiredDescription
modelstringYesVideo model name (e.g. the sora / veo / wan / doubao families)
promptstringNoText description (mutually exclusive with content; sending both is an error)
contentarrayNoMultimodal 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:
inputobjectNoSora-style nested input
parametersobjectNoWan-style parameter block (top-level fields of the same name take precedence over values inside parameters)
imagesarrayNoList of reference image URLs (image-to-video; must be http/https URLs)
aspect_ratio / ratiostringNoAspect ratio, e.g. 16:9 (the two are equivalent; ratio wins)
resolutionstringNoResolution, e.g. 720p / 1080p
durationintegerNoVideo duration in seconds, 1–15; the Seedance family requires 4–15
generate_audiobooleanNoGenerate 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
watermarkbooleanNoWhether to add a watermark
seedintegerNoRandom seed (0–4294967295) for reproducible results
return_last_framebooleanNoWhether to return the video's last frame in the result
enhance_promptbooleanNoWhether to let the upstream enhance the prompt
enable_upsamplebooleanNoWhether to enable upsampling
execution_expires_afterintegerNoTask retention in seconds, 1–172800; the task expires afterwards
Shell
# 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_audio is passed through to the upstream: if the target model does not support audio the task fails upstream, and the reason is visible in the error field of the 13.3 query result.

13.2 Submitting a Midjourney task#

EndpointDescription
POST /v1/mj/submit/imagineText to image
POST /v1/mj/submit/blendMulti-image blending
POST /v1/mj/submit/actionUpscale / variation and other operations on an existing task
cURL
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
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 parameterDescription
task_typeFilter by type (e.g. video, mj)
statusFilter by status
offsetOffset, defaults to 0
limitPage size, defaults to 50, max 200
cURL
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
curl -X POST http://183.240.79.21:52099/v1/tasks/0000019f-.../cancel \
  -H "Authorization: Bearer sk-你的YiTuoToken-Key"