Skip to content

Async tasks (video / MJ / async image)

Longer-running generation (video, Midjourney, async image) uses the task API: submit and get a task_id immediately, then poll status until success or failure.

Availability

The task API is ready, but whether a given task type (video / Midjourney, etc.) is available depends on whether the platform has enabled that capability. Confirm the target task_type is enabled before submitting, or check the console "Tasks" page.

Create a task

POST https://gateway.mindproxy.ai/v1/tasks
bash
curl https://gateway.mindproxy.ai/v1/tasks \
  -H "Authorization: Bearer $TT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "task_type": "async_image",
    "public_model": "flux-1-dev",
    "prompt": "a futuristic city at sunset",
    "idempotency_key": "my-task-001"
  }'
FieldDescription
task_typeRequired: video / midjourney / async_image
public_modelPublic model ID (recommended)
promptTask description
idempotency_keyIdempotency key (optional, strongly recommended)
input_assets_jsonInput assets (optional, JSON object, e.g. a reference image)
metadata_jsonCustom metadata (optional)

Response (HTTP 202 Accepted):

json
{
  "task_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "status": 1,
  "request_id": "req_...",
  "hold_id": "hold_..."
}

With task_id you can start polling.

Get task status

GET https://gateway.mindproxy.ai/v1/tasks/{task_id}
json
{
  "task_id": "f47ac10b-...",
  "task_type": 3,
  "status": 4,
  "public_model": "flux-1-dev",
  "result_assets_json": "{\"image_url\":\"https://.../image.png\",\"seed\":12345}",
  "created_at": "2026-06-22T10:00:00Z",
  "completed_at": "2026-06-22T10:02:00Z"
}

On success, results are in result_assets_json (a stringified JSON), commonly: image_url / video_url / thumbnail_url / seed, depending on the task type.

Status values

status is a numeric enum:

ValueStatusMeaning
1CREATEDCreated, pending
2SUBMITTEDQueued
3PROCESSINGProcessing
4SUCCEEDEDSuccess, result in result_assets_json
5FAILEDFailed, see error_code / error_message
6CANCELLEDCancelled
7EXPIREDExpired (timeout / TTL)
8REFUNDEDRefunded (hold released, not charged)

task_type is also an enum: 1 = midjourney, 2 = video, 3 = async_image.

Polling tips

  • Poll every 2–5 seconds until the status reaches a terminal state (4/5/6/7/8).
  • You can also follow progress via the events endpoint (below).

Task events

GET https://gateway.mindproxy.ai/v1/tasks/{task_id}/events?limit=50&offset=0
json
{
  "task_events": [
    {
      "task_event_id": "event-...",
      "event_type": "created",
      "status": 1,
      "message": "task created",
      "created_at": "2026-06-22T10:00:00Z"
    }
  ]
}

Cancel a task

POST https://gateway.mindproxy.ai/v1/tasks/{task_id}/cancel
json
{ "reason": "user cancelled" }

Cancel, failure and expiry all release the hold and don't charge.

Billing

A task holds funds on creation and settles on success by real usage. Failed / cancelled / expired tasks are not charged, the hold is auto-released, and no stuck balance is left behind.

End-to-end flow

  1. POST /v1/tasks to submit, get task_id (status 1).
  2. Poll GET /v1/tasks/{task_id} until status reaches 4 (success) or 5/6/7 (failed / cancelled / expired).
  3. On success, read the asset URL from result_assets_json.

Gateway: gateway.mindproxy.ai · Built with VitePress