Skip to content
会nokai.studio

Errors

Every error response uses the same envelope:

{
  "code": 401,
  "msg": "Missing or invalid API key",
  "data": null,
  "request_id": "req_01abc..."
}

Match on code -- it is the stable contract. msg is human-readable and may change. Include request_id in support requests -- it is the trace key.

HTTP status codes

StatusMeaning
400Validation error -- body or query params failed validation.
401Missing or invalid API key.
402Insufficient credits.
403API key is valid but not permitted for this resource.
404Resource not found, or belongs to another account.
408Generation service timed out -- retry the request.
422Invalid model name or input parameters.
429Rate limited. Honor the Retry-After header.
500Internal server error. We are alerted. Use request_id to report it.
503Service temporarily unavailable -- retry with backoff.

Job failure codes

When a job reaches fail state, failCode identifies the reason:

failCodeMeaning
CONTENT_POLICYPrompt or input refused by the generation service.
TIMEOUTGeneration took too long. Retry.
PROVIDER_ERRORUpstream generation error. Retry.
INVALID_MODELModel name does not exist.
INSUFFICIENT_CREDITSBalance too low when the job was claimed. Top up and retry.

Best practices

  • Log request_id on every error. Support uses it to find the exact request in traces.
  • Match on code integer, never on msg string. Messages are human-readable and shift over releases.
  • On 429, read Retry-After and wait exactly that many seconds. Do not guess backoff.
  • On 402, top up credits at the dashboard before retrying. The job was not queued.
  • On 408 and 503, retry with exponential backoff starting at 2s.