Errors
HTTP status codes, error envelopes, and task-level failures.
Two kinds of failure — don't conflate them
- Request-level failures (the submit/query call itself errors): a non-2xx HTTP status plus an OpenAI-style error envelope.
- Task-level failures (no image was produced):
GET /v1/tasks/{task_id}still returns HTTP 200, but withdata.status = failedand details indata.error(see Query tasks).
Request-level error envelope:
HTTP status codes
| HTTP | Meaning | What to do |
|---|---|---|
400 | Invalid parameters (count, aspect ratio, too many reference images, a malformed or expired task_id, etc.), or a misspelled model / a model your key is not enabled for (code = model_not_available) | Check the request body; fix the model name as the error message suggests, or list your models with GET /v1/models |
401 | No API key sent (code = missing_api_key), or an invalid key (including a deleted key) | Check Authorization; if a key was deleted or leaked, create a new one in the console |
402 | Insufficient credits, the key's spending cap is used up, or the key has expired | Top up, raise the cap, or create a new key |
403 | The key is disabled | Re-enable the key in the console |
404 | Task query: the task_id cannot be found (code = task_not_found) — not found more than 15 minutes after creation, a timestamp in the future, or a task that does not belong to your key's account (identical to a non-existent task) | Stop polling; check the task_id and the API key you are using |
413 | The request body exceeds the gateway limit (code = request_body_too_large) | Shrink the request body; pass reference images as URLs |
429 | Rate limited; or, for task queries, too many lookups of task_ids that cannot be found in a short time (afterwards, not-found ids return 429 for that account; your own tasks are unaffected) | Back off per the Retry-After header and retry |
5xx | Gateway / upstream error | Retry later; contact support if it persists |
type and code of gateway-level errors
Gateway-level errors (model not available, missing / invalid key, oversized request body) carry type: "jiufeng_error"; task-level errors use meaningful types such as invalid_request_error or payment_required. Branch on the HTTP status and error.code, not on the message text.
code | HTTP | When |
|---|---|---|
model_not_available | 400 | The model is misspelled, differs in case, or your key is not enabled for it. No task is created and no credits are charged; the message lists the models your key can use, and when the name is very close or differs only in case it also suggests the correct spelling |
request_body_too_large | 413 | The request body exceeds the gateway limit |
missing_api_key | 401 | The request has no Authorization header (or an empty one). Send Authorization: Bearer sk-… |
GET /v1/models/{model}: for Jiufeng models (e.g. gpt-image-2, MiniMax-H3) it returns 200 with the model object when your key can use the model, and 404 otherwise. To check what your key can use, rely on the GET /v1/models list.
An invalid key returns 401 with a message starting with invalid API key; code is either invalid_api_key (the key is malformed, e.g. characters missing from the copy) or empty (well-formed but the key does not exist or was deleted), so branch on the HTTP status.
Known behaviour
- A
task_idthat cannot be found returns200withpendingfor 15 minutes after its creation time (a window for just-submitted tasks not yet written), then404 task_not_found. Sopendingalone does not prove the task exists; cap your polling loop and stop on404.
FAQ
- A deleted key still works for a few seconds: deleting invalidates the cache and is effective immediately in almost all cases; under extreme concurrency there can be a very brief cache window. To be certain, confirm the key returns
401after deletion. - Are failed tasks refunded?: for cases like timeouts the platform issues a refund; refunded tasks do not trigger a webhook callback — confirm them by polling.
- Result image won't open: result files are kept for 30 days, then deleted automatically (the exact deadline is
expires_at) — re-host them to your own storage before then.