Native multimodal API

Use the ApiGo native media_tasks protocol for models that advertise media actions. It has its own request envelope; OpenAI Images/Videos request bodies are not interchangeable with it. The operation list includes ApiGo Media alongside the other protocol families.

Availability depends on the target environment and the selected model. The environment must enable native media and SDK creation, and your inference API key must have access. A model visible in the catalog does not by itself guarantee creation access. These examples describe the contract, not a completed generation or a deployment guarantee.

Authentication and endpoints

Use an inference API key from Workspace → API Keys, with Authorization: Bearer <APIGO_API_KEY>. Workspace management OpenAPI keys are a separate credential type.

Method Path Purpose
GET /v1/media/models List authorized media models
GET /v1/media/models/{model_code} Read one model and its actions
POST /v1/media/tasks Create with sync, async, or stream
GET /v1/media/tasks/{task_id} Read task state and any available outputs
GET /v1/media/tasks/{task_id}/billing Read task billing without initiating generation or posting charges

All paths use https://api.apigo.ai. Task queries require a currently authorized inference key in the same Workspace.

Discover the exact action and mode

curl 'https://api.apigo.ai/v1/media/models?limit=20&offset=0' \
  -H "Authorization: Bearer $APIGO_API_KEY"

The response contains data, limit, offset, and has_more. limit defaults to 20 and accepts 1–100. offset defaults to 0. Increase offset by data.length while has_more is true. Deduplicate by model_code because the catalog can change between pages.

Each model exposes model_code and actions[]. Select an exact actions[].action, then confirm the requested mode appears in that action's supported_modes. Use model_code as the creation request's model.

media_specs describes model-level resolutions, aspect ratios, video duration in seconds, and audio generation. An empty object or omitted property means the catalog provides no information for it. An explicit false indicates the corresponding capability is unavailable. Use the model's input contract to determine which values apply to a specific operation and input.

For example, generate.image and edit.image express different operations. Providing a reference image does not change generate.image into edit.image. Use editing only when the model explicitly advertises edit.image, and follow that model's native reference-input contract. Do not infer capabilities from a model name.

Choose a mode advertised by the selected action. For async, query the returned platform mint_ task ID until terminal. An optional HTTPS callback is supported for async; public cancellation is not supported here.

Create and save the initial result

Create media-request.json with the following envelope. Replace <MODEL_CODE>, choose an advertised action/mode, and replace input with the selected model's documented JSON parameters. The prompt field below is illustrative; input fields are model-specific.

{
  "model": "<MODEL_CODE>",
  "action": "generate.image",
  "mode": "sync",
  "input": {
    "prompt": "A lighthouse at sunrise"
  }
}

model, action, mode, and object-valued input are required. Preserve native input fields; there is no shared image/video parameter schema. Omit callback_url or set it to null, or provide a public HTTPS URL for async only. Platform delivers the terminal notification up to four times, retrying after 5, 10, and 20 seconds.

For sync, send Accept: application/json:

curl 'https://api.apigo.ai/v1/media/tasks' \
  -H "Authorization: Bearer $APIGO_API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Idempotency-Key: <UNIQUE_GENERATION_INTENT_KEY>' \
  --data-binary @media-request.json

For stream, set mode to stream in the file and use a new intent key for this separate generation:

curl --no-buffer 'https://api.apigo.ai/v1/media/tasks' \
  -H "Authorization: Bearer $APIGO_API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Accept: text/event-stream' \
  -H 'Idempotency-Key: <ANOTHER_UNIQUE_GENERATION_INTENT_KEY>' \
  --data-binary @media-request.json

Inspect SSE JSON data.type for the public lifecycle events apigo.task.started, apigo.task.completed, and apigo.task.failed. Model-native content events may appear between them. Keep their native payloads. A model-specific “completed” event, EOF, or [DONE] alone does not establish the public task's terminal state. Inspect the terminal event's status; completion can be partial or failed.

Save media URLs, Base64 data, and other outputs when first delivered, and retrieve expiring URLs in time. Task queries and idempotent retries do not guarantee replay of the original media or SSE stream. A missing output must not trigger an automatic paid generation.

Task identity and read-only recovery

Public JSON and SSE envelopes use task_id: mint_<uuid>, the current call's request_id, and identity_version: 2. X-Request-ID correlates the HTTP attempt; X-Task-ID is returned once a public intent is known. Keep the exact returned task ID across retries and queries. It is different from Console history IDs and provider task IDs.

curl "https://api.apigo.ai/v1/media/tasks/$TASK_ID" \
  -H "Authorization: Bearer $APIGO_API_KEY"

curl "https://api.apigo.ai/v1/media/tasks/$TASK_ID/billing" \
  -H "Authorization: Bearer $APIGO_API_KEY"

Read queries do not initiate a new generation. An accepted intent without an upstream association can return local pending or unknown metadata with an empty result. Once associated, queries use that task's original source. A query is not a durable media download or replay endpoint.

Execution status and billing_status are independent. Execution may be pending, queued, running, succeeded, partially_succeeded, failed, cancelled, expired, or unknown; billing may be pending, finalized, or not_required. HTTP 200 does not prove execution success. Source billing state does not prove a Workspace wallet transaction; use Workspace billing records for settlement. Preserve model-native usage and quantity/decimal values without coercing them to token counts.

Idempotency and errors

Use one Idempotency-Key per generation intent: 1–128 bytes, without control characters. For explicit recovery, reuse the same inference API key, intent key, and identical request values. The recovery window is 24 hours from first dispatch and does not extend on retries. An active intent returns 409; an eligible explicit retry reuses the original intent and source and may receive an upstream conflict response. This is not a cached-media replay promise. Without an idempotency key, each POST is a new generation intent.

Keep a task ID returned in an error and query it first. If acceptance is unknown, do not automatically change the key or repeat POST as a new intent. An error before a confirmed intent may have no task ID; keep its request_id for investigation. A different payload under the same key conflicts, and an expired key is not an automatic recovery mechanism. Use a new key only for an intentional new generation.

HTTP status Meaning and next step
400 Check model/action/mode, object-valued input, task ID, pagination, and callback restrictions
401 / 403 Check inference credentials, model/action access, region, eligible funding mode, and environment SDK enablement
402 Check eligible account funding
404 The model/task is unavailable or outside the current Workspace's visibility
406 / 415 Match Accept to mode and send Content-Type: application/json
409 Inspect error.code and any returned task_id; resolve the original intent before starting another
429 Respect rate/concurrency limits and any Retry-After header
502 / 503 Delivery, acceptance, configuration, or service state may be unavailable; preserve identity and check the original task

After creation is confirmed, public media errors can include task_id, request_id, and identity_version: 2. Codes such as media_acceptance_unknown, media_response_incomplete, and media_response_invalid require recovery checks; they do not establish zero charges. A failed task can also be represented in HTTP 200 or an SSE task event, so handle both transport errors and task state.

Async video and image results

For Seedance request fields and examples by model, see the Seedance native API guide. Its direct BytePlus calls use separate credentials and task IDs; keep the ApiGo request envelope when calling /v1/media/tasks.

Read Seedream images from result.data[] and inspect each item for error. Sync and stream image media are delivered only in the creation response; save them promptly. For Seedance use an advertised generate.video or edit.video action with mode: "async", then query the returned mint_ task ID. On success read result.content.video_url and optional last_frame_url. A Draft continuation uses the platform Draft task ID, never a provider ID. Asset management uses authorized Website endpoints and does not imply a public asset-management API.

{
  "model": "<MODEL_CODE>",
  "action": "generate.video",
  "mode": "async",
  "input": { "content": [{ "type": "text", "text": "A lighthouse at sunrise" }], "resolution": "720p" }
}

Submit with a new intent key, then query the returned mint_ ID and /billing. This example does not initiate a generation.