ModelGo Unified Video API Integration Guide & Examples
| Method | Path | Use |
|---|---|---|
POST | /v1/modelgo/videos | Create a video task (202 + task object) |
GET | /v1/modelgo/videos?idempotency_key={key} | Find the task a create with that Idempotency-Key produced |
GET | /v1/videos/{task_id} | Query a task |
GET | /v1/videos/{task_id}/content | Download an output (?index=N for the N-th) |
The Unified Video API uses a shared set of parameter names. ModelGo translates them for each channel. The task object gives you the generation status, billing status, and result expiry.
Choose a model that lists modelgo_videos in the Model Catalog for the site you are calling. Replace <model> in the example with that model. A model that does not offer the protocol returns 400 model_protocol_not_offered. If the catalog lists no eligible models, use OpenAI Video or a vendor entrypoint. Check that the site has published a signing key before setting callback_url.
1. Create a task
curl https://api.modelgo.ai/v1/modelgo/videos \
-H "Authorization: Bearer $MODELGO_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-42-video" \
-d '{
"model": "<model>",
"prompt": "A small red ball rolling slowly across a wooden table, soft daylight",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9",
"callback_url": "https://hooks.example.com/modelgo/video"
}'The create answers 202 with the task object:
{
"id": "gw_b82e2f02-730b-4c62-a31d-f3955e84d0ad",
"object": "video",
"model": "<model>",
"status": "queued",
"created_at": 1794909756,
"polling_url": "/v1/videos/gw_b82e2f02-730b-4c62-a31d-f3955e84d0ad",
"parameters": { "aspect_ratio": "16:9", "duration": 5, "generate_audio": false, "resolution": "720p" },
"outputs": [],
"billing": { "status": "reserved" }
}- The task ID is always generated by the gateway (
gw_+ UUID). AnX-Request-IDyou send is kept for correlation but does not become the task ID. 202means the task exists — including when the supplier's acceptance could not be confirmed in time: such a task staysqueuedwhile the platform confirms it with the supplier, and fails withupstream_submission_unconfirmed(not charged) if it cannot. It is never created twice.- An error response means no task was created and nothing is held; fix the request or retry.
Request fields
| Field | Type | Description |
|---|---|---|
model | string | Required. Logical model name |
prompt | string | Text prompt. Required unless the model accepts media-only input and media is sent |
negative_prompt | string | What the video should avoid |
duration | integer | Length in seconds; -1 lets the model choose, where the model allows it |
resolution | string | For example 720p, 1080p |
aspect_ratio | string | For example 16:9, 9:16, 1:1, adaptive |
size | string | Output size, for models that take a size instead of resolution and aspect ratio |
frame_images | array | First and last frame images, see Media |
input_references | array | Reference images, videos and audio, see Media |
generate_audio | bool | Generate an audio track |
seed | integer | Random seed |
watermark | bool | Add a watermark |
extensions | object | Parameters specific to the model, which it declares, for example {"camera_fixed": true} |
callback_url | string | HTTPS address to notify once the task finishes, see Webhooks |
user | string | Accepted and ignored |
stream, provider and previous_job_id are refused as unsupported_parameter; any other top-level field is refused as unknown_parameter. A JSON null counts as not sent.
Each model accepts its own subset. A model declares which of these parameters it takes, their allowed values and defaults, and the combinations it allows (for example, a last frame only together with a first frame). The request is checked against the model before anything is held or sent to a supplier, and every problem comes back in one response; a value outside an enum comes back with the allowed values (see Errors). Omitted parameters take the model's defaults, and the values actually used are returned in the task's parameters.
Media
{
"frame_images": [
{ "type": "image_url", "image_url": { "url": "https://example.com/first.png" }, "frame_type": "first_frame" },
{ "type": "image_url", "image_url": { "url": "https://example.com/last.png" }, "frame_type": "last_frame" }
],
"input_references": [
{ "type": "image_url", "image_url": { "url": "https://example.com/style.png" } },
{ "type": "video_url", "video_url": { "url": "https://example.com/motion.mp4" } },
{ "type": "audio_url", "audio_url": { "url": "https://example.com/voice.mp3" } }
]
}frame_images: images with aframe_typeoffirst_frameorlast_frame, each at most once.input_references:image_url,video_urloraudio_urlitems. How many of each a model takes, and whether frames and references can be combined, is part of the model's contract.url: a publichttp(s)URL the supplier can download without credentials, redirects, cookies or Referer. The protocol also accepts adata:URI, but not every model takes one.
2. Query a task
curl https://api.modelgo.ai/v1/videos/gw_b82e2f02-730b-4c62-a31d-f3955e84d0ad \
-H "Authorization: Bearer $MODELGO_API_KEY"{
"id": "gw_b82e2f02-730b-4c62-a31d-f3955e84d0ad",
"object": "video",
"model": "<model>",
"status": "completed",
"progress": 100,
"created_at": 1794909756,
"completed_at": 1794909871,
"expires_at": 1795169071,
"metadata": {
"duration": 5,
"url": "https://api.modelgo.ai/v1/videos/gw_b82e2f02-730b-4c62-a31d-f3955e84d0ad/content"
},
"polling_url": "/v1/videos/gw_b82e2f02-730b-4c62-a31d-f3955e84d0ad",
"parameters": { "aspect_ratio": "16:9", "duration": 5, "generate_audio": false, "resolution": "720p" },
"outputs": [
{
"index": 0,
"url": "https://api.modelgo.ai/v1/videos/gw_b82e2f02-730b-4c62-a31d-f3955e84d0ad/content",
"content_type": "video/mp4",
"expires_at": 1795169071
}
],
"billing": { "status": "settled", "amount": "<amount>", "currency": "<currency>" }
}| Field | Description |
|---|---|
status | queued → in_progress → completed or failed; it never moves backwards |
progress | 0–100 |
parameters | The parameters used, defaults included (prompt and media are not repeated); the task is billed on these |
outputs[] | Delivered files: index, url, content_type and expires_at. The links are always ModelGo's, never a supplier's |
metadata.url | The same as outputs[0].url, for OpenAI Video clients |
expires_at | When the first output stops being downloadable (Unix seconds) |
billing.status | reserved (held, not charged yet) · settling (finished, the charge is being finalized) · settled (with amount and currency) · not_charged |
error | On failed: code and message |
- The task object is a superset of the OpenAI Video object, so OpenAI Video clients can read it unchanged.
- Any API key of the same workspace can query the task; other workspaces get
404. Rotating a key does not lose its tasks. statusandbilling.statusare reported separately: a finished generation readscompleted+settlingwhile the charge is finalized, and its outputs can already be downloaded.- Poll every 5–10 seconds with backoff, or set a
callback_urlinstead of polling. - Failure codes include
task_expired(no result before the task's deadline),upstream_submission_unconfirmed(the supplier never confirmed the create) andresult_unavailable(the output could not be copied to ModelGo storage), alongside the supplier's own codes. Failed tasks are not charged. DELETE /v1/videos/{task_id}is not available for unified tasks (400 unsupported_operation).
3. Download
curl https://api.modelgo.ai/v1/videos/gw_b82e2f02-730b-4c62-a31d-f3955e84d0ad/content -o video.mp4- No credential is required: the link itself is the credential. Treat it as a secret: do not share it publicly, log it or store it long-term.
?index=Nselects the N-th output;Rangerequests are supported.- Download before the output's
expires_at; afterwards the link returns404 content_not_available. 409while the generation is still running.
4. Idempotent retries
Send an Idempotency-Key (1–128 characters of A-Z a-z 0-9 _ . : -) with any create you may retry. A key is scoped to your workspace and API key for 24 hours; requests are compared after normalizing the JSON, so key order and whitespace do not matter.
| Situation | Response |
|---|---|
| Same key, same request | 202 with the original task and the header Idempotent-Replayed: true; nothing new is created or charged |
| Same key, different request | 409 idempotency_conflict |
| The first request is still being submitted | 409 idempotency_request_in_progress with Retry-After; retry after it |
| The first request was refused (parameters, balance, rate limit, …) | The key was not used; retry with the same key |
If a create timed out before you received a task ID, find the task by its key:
curl "https://api.modelgo.ai/v1/modelgo/videos?idempotency_key=order-42-video" \
-H "Authorization: Bearer $MODELGO_API_KEY"200 returns the task object; 404 task_not_found means no task was created under the key (create again with the same key); 409 idempotency_request_in_progress means the first request is still being submitted. The lookup covers your own workspace and API key over the last 24 hours.
5. Webhooks
Set callback_url to be notified once when the task completes or fails instead of polling. The event's data is the task object GET /v1/videos/{task_id} returns at that moment, and every delivery is signed. See Webhooks for the request format and how to verify it.
6. Errors
Problems with the request come back together, before anything is held or sent to a supplier:
{
"error": {
"code": 400,
"message": "Parameter 'duration': value is outside the guaranteed numeric range",
"metadata": {
"admission_code": "unsupported_value",
"admission_problems": [
{ "param": "duration", "code": "unsupported_value", "reason": "value is outside the guaranteed numeric range" },
{ "param": "resolution", "code": "unsupported_value", "reason": "value is outside the guaranteed enum", "allowed": ["720p", "1080p"] },
{ "param": "seed", "code": "unsupported_parameter", "reason": "model does not support this parameter" }
],
"error_class": "client_unsupported_parameter",
"request_id": "gw_f002d1ac-e181-4c83-af7d-499a2231f03b"
}
},
"trace_id": "ed6ee67eccdd7cc10c4b641626aaeaf8"
}code | Meaning |
|---|---|
unknown_parameter | The field is not part of the unified protocol |
unsupported_parameter | The platform or this model does not take the parameter |
unsupported_value | The value is outside the model's enum or range; enum problems include allowed |
invalid_parameter_combination | The model does not allow this combination, for example a last frame without a first frame |
unsupported_extension | extensions names a parameter the model does not declare |
invalid_request_structure | Wrong type or shape: a media item, frame_type, the Idempotency-Key format, … |
invalid_callback_url | callback_url is not an acceptable address, see Webhooks |
Other responses:
| HTTP | Meaning |
|---|---|
400 model_protocol_not_offered | The model is not offered on the unified API |
400 unsupported_operation | DELETE /v1/videos/{task_id} on a unified task |
401 / 402 / 403 / 429 | Authentication, balance or budget, policy, rate limit — see Errors & Rate Limits |
409 | Idempotency, see above |
503 | No channel can take the request right now, or result delivery is unavailable; retry later |
7. Billing
- The create holds the estimated cost (
billing.status: reserved). A completed task is charged once, on what was actually generated, and settles withamountandcurrency. - Refused creates, failed tasks and expired tasks are not charged (
not_charged). - Queries, idempotent replays and webhook deliveries never charge again.