Notice: MAI Image 2.7 launch limited-time 20% off, covering the full text-to-image and image editing lineup, try it now
Notice: Black Friday 2026 × Cyber Monday: Get up to 30% extra on top-ups, DeepSeek free to use · View the promotion
Open navigation

Create Task

Endpoint: POST /v1/tasks

Submit a generation task. You get a taskId back right away while the model keeps working in the background — then poll Get Task Detail or wait for the callback to fetch the result.

Headers

HeaderValueRequiredNotes
AuthorizationBearer YOUR_API_KEYyesAccount API key. Required on every request.
Content-Typeapplication/jsonnoOptional. The body is always parsed as JSON; if sent, only application/json is accepted (charset is fine) — anything else returns 415.
Idempotency-Keyorder-42-submitnoOptional. Idempotency key, up to 255 bytes. Retries with the same key under the same account create the task only once; replays return the original taskId.

The full rules for these headers (authentication scope, content type, idempotency scenarios) are documented in the Unified Async API Introduction.

Request body

Request example — POST https://api.hiapi.ai/v1/tasks

{
  "model": "happyhorse-1.0",
  "callback": {
    "url": "https://example.com/hiapi/callback",
    "when": "final"
  },
  "input": {
    "prompt": "a cyan glass data center entrance",
    "duration": 5,
    "resolution": "720p"
  }
}
ParameterTypeRequiredDefaultDescription
modelstringyes—The model you want to run. Exact model IDs are listed in the model catalog at /models, which is also what the model pages are generated from. e.g. happyhorse-1.0
routestringno—Model route (e.g. beta, ext) for models that expose multiple routes with different pricing or capacity. See the model routes section below. e.g. ext
inputobjectyes—The model’s business parameters; fields are defined per model.
callbackobjectno—Terminal-notification config; omit to skip callbacks and poll yourself. See the callback section below.
↳ urlstringyes—Required when callback is present; HiAPI POSTs here when terminal. Must be a valid http(s) URL.
↳ whenstringnofinalCurrently only final — both success and fail fire a callback.
storagestringnotempOutput storage tier: temp (default, kept ~7 days) or persistent (kept long-term, billed by size). Insufficient balance or exceeding your storage cap silently downgrades to temp; the actual tier is reflected on the task detail response. e.g. persistent

Do not put callback fields in input

Do not put any callback / webhook / notify field inside input, or the request is rejected. Callbacks are configured only via the top-level callback — see the callback section below.

input fields depend on the model

The prompt / duration / resolution above are illustrative. Each model accepts different input fields — refer to the relevant model page.

Keep outputs longer

Outputs are temporary by default and expire after about 7 days. Set "storage": "persistent" to keep them long-term, or promote them later — see Output Storage.

Model routes (route)

Some models expose multiple routes (e.g. beta, ext) with different pricing or capacity. Select one with the optional top-level route parameter — the preferred spelling over the legacy @ suffix:

{ "model": "gpt-image-2/text-to-image", "route": "ext", "input": { ... } }

Routes published in the model catalog:

ModelAvailable routes
gpt-image-2/text-to-imagedefault, beta, ext
gpt-image-2/image-to-imagedefault, ext
seedance-2.0default, ext
gpt-image-2.5-flare/text-to-imagedefault
gpt-image-2.5-flare/image-to-imagedefault
gpt-image-2.5-sunburst/text-to-imagedefault
gpt-image-2.5-sunburst/image-to-imagedefault
  • The 2.5 series registers capability-specific models on the default route, plus a pro route under the family name: send model gpt-image-2.5-flare with route: "pro". The bare family name without a capability suffix and without route is not a registered model and fails with 400
  • Passing model gpt-image-2/text-to-image with route: "ext" selects the ext route
  • Omitting route, or sending "" / null / "default", all mean the model’s default route
  • An unknown route fails fast with 400 INVALID_REQUEST whose message lists the available routes
  • On the task detail, a task submitted with route echoes the field back and model holds the resolved full name; the route value participates in the idempotency hash, so the same Idempotency-Key with a different route returns 422

The authoritative list of exact model IDs and their routes is models.json, the same catalog the model pages are generated from.

Success response (HTTP 200)

{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "tk-hiapi-01HZTQ8BX2N3GM3YFK4Z9D7VQR"
  }
}
  • taskId looks like tk-hiapi- + 26 chars, 35 chars total.
  • Returned as soon as the task is created — generation continues in the background.

Failure response

{
  "code": 400,
  "message": "invalid request",
  "data": null,
  "error_code": "INVALID_REQUEST"
}

code is the HTTP status; error_code is the business error code (enum under status information). Common synchronous failures: invalid body (400), insufficient balance (402), non-JSON Content-Type (415). When the platform is temporarily unavailable it may return HTTP 503 — retry later with backoff.

Callbacks (Webhook)

Provide callback.url when creating a task and HiAPI notifies you with a POST on terminal state — no polling needed. Request format, signature verification, delivery retries and idempotency: see Callbacks in the introduction.