ModelGo Unified Video API Integration Guide & Examples

MethodPathUse
POST/v1/modelgo/videosCreate 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}/contentDownload 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

bash
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:

json
{
  "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). An X-Request-ID you send is kept for correlation but does not become the task ID.
  • 202 means the task exists — including when the supplier's acceptance could not be confirmed in time: such a task stays queued while the platform confirms it with the supplier, and fails with upstream_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

FieldTypeDescription
modelstringRequired. Logical model name
promptstringText prompt. Required unless the model accepts media-only input and media is sent
negative_promptstringWhat the video should avoid
durationintegerLength in seconds; -1 lets the model choose, where the model allows it
resolutionstringFor example 720p, 1080p
aspect_ratiostringFor example 16:9, 9:16, 1:1, adaptive
sizestringOutput size, for models that take a size instead of resolution and aspect ratio
frame_imagesarrayFirst and last frame images, see Media
input_referencesarrayReference images, videos and audio, see Media
generate_audioboolGenerate an audio track
seedintegerRandom seed
watermarkboolAdd a watermark
extensionsobjectParameters specific to the model, which it declares, for example {"camera_fixed": true}
callback_urlstringHTTPS address to notify once the task finishes, see Webhooks
userstringAccepted 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

json
{
  "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 a frame_type of first_frame or last_frame, each at most once.
  • input_references: image_url, video_url or audio_url items. How many of each a model takes, and whether frames and references can be combined, is part of the model's contract.
  • url: a public http(s) URL the supplier can download without credentials, redirects, cookies or Referer. The protocol also accepts a data: URI, but not every model takes one.

2. Query a task

bash
curl https://api.modelgo.ai/v1/videos/gw_b82e2f02-730b-4c62-a31d-f3955e84d0ad \
  -H "Authorization: Bearer $MODELGO_API_KEY"
json
{
  "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>" }
}
FieldDescription
statusqueued → in_progress → completed or failed; it never moves backwards
progress0–100
parametersThe 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.urlThe same as outputs[0].url, for OpenAI Video clients
expires_atWhen the first output stops being downloadable (Unix seconds)
billing.statusreserved (held, not charged yet) · settling (finished, the charge is being finalized) · settled (with amount and currency) · not_charged
errorOn 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.
  • status and billing.status are reported separately: a finished generation reads completed + settling while the charge is finalized, and its outputs can already be downloaded.
  • Poll every 5–10 seconds with backoff, or set a callback_url instead of polling.
  • Failure codes include task_expired (no result before the task's deadline), upstream_submission_unconfirmed (the supplier never confirmed the create) and result_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

bash
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=N selects the N-th output; Range requests are supported.
  • Download before the output's expires_at; afterwards the link returns 404 content_not_available.
  • 409 while 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.

SituationResponse
Same key, same request202 with the original task and the header Idempotent-Replayed: true; nothing new is created or charged
Same key, different request409 idempotency_conflict
The first request is still being submitted409 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:

bash
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:

json
{
  "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"
}
codeMeaning
unknown_parameterThe field is not part of the unified protocol
unsupported_parameterThe platform or this model does not take the parameter
unsupported_valueThe value is outside the model's enum or range; enum problems include allowed
invalid_parameter_combinationThe model does not allow this combination, for example a last frame without a first frame
unsupported_extensionextensions names a parameter the model does not declare
invalid_request_structureWrong type or shape: a media item, frame_type, the Idempotency-Key format, …
invalid_callback_urlcallback_url is not an acceptable address, see Webhooks

Other responses:

HTTPMeaning
400 model_protocol_not_offeredThe model is not offered on the unified API
400 unsupported_operationDELETE /v1/videos/{task_id} on a unified task
401 / 402 / 403 / 429Authentication, balance or budget, policy, rate limit — see Errors & Rate Limits
409Idempotency, see above
503No 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 with amount and currency.
  • Refused creates, failed tasks and expired tasks are not charged (not_charged).
  • Queries, idempotent replays and webhook deliveries never charge again.