Skip to content
Docs Menu & Search

Documentation

Errors

Error response format and every status code the API can return.

Error Format

Errors return a non-2xx HTTP status and a JSON body with an error object containing a machine-readable code and a human-readable message. Some errors include extra fields (for example, recharge_url or retry_after_seconds). The one exception is EMPTY_RESPONSE, which arrives with HTTP 200 (see the table).

{
  "error": {
    "code": "INSUFFICIENT_BALANCE",
    "message": "Credit balance is too low for this request. Please add credits.",
    "recharge_url": "https://app.nabh.cloud/billing"
  }
}

Status Codes

HTTPCodeMeaning
400INVALID_REQUESTMalformed JSON, or a required field such as model or input is missing.
401AUTHENTICATION_ERRORAPI key is missing, invalid, or expired.
402INSUFFICIENT_BALANCEYour credits (or the institution pool) are exhausted. Includes a recharge_url when the credits are your own.
402SPEND_LIMIT_REACHEDThis API key has reached the monthly spend limit you set on it. Raise or remove the limit on the API Keys page, or wait for the 1st (IST).
402PROJECT_BUDGET_REACHEDThe key’s project has reached its monthly budget. Raise the budget on the Projects page, or wait for the 1st (IST).
403PERMISSION_DENIEDThe requested model isn’t available on your plan, or the key isn’t scoped correctly for an institution course.
403IP_NOT_ALLOWEDRequest IP is not in the key’s IP allowlist.
403ACCOUNT_SUSPENDEDThe account has been suspended.
404INVALID_REQUESTUnknown model ID, or the model was called on the wrong endpoint — check that model’s docs page for its exact base URL.
404MODEL_UNAVAILABLEThe model is temporarily unavailable. Retry shortly, or choose another model.
404NOT_FOUNDThe URL isn’t an API endpoint (for example /v1/responses or /v1/completions — use /v1/chat/completions).
405METHOD_NOT_ALLOWEDThe endpoint exists but not for this HTTP method; the Allow header lists the right one.
411MISSING_CONTENT_LENGTHAudio upload is missing a Content-Length header.
413REQUEST_TOO_LARGEThe JSON request body is larger than 10 MB.
413INPUT_TOO_LARGEText-to-speech input exceeds the 8,000-character limit.
413FILE_TOO_LARGEAudio upload exceeds the 25 MB limit.
400 / 413CONTEXT_LENGTH_EXCEEDEDThe request is too large for the model’s context window or output limit. Shorten the input or lower max_tokens.
429RATE_LIMIT_EXCEEDEDToo many requests for your plan’s per-minute or per-day limit. Includes a Retry-After header and retry_after_seconds in the body.
429MODEL_BUSYThe model itself is busy, not your account. No Retry-After is sent: retry with backoff.
503SERVICE_UNAVAILABLEA dependency (auth, rate limiter, model catalog, course policy) is temporarily down. Safe to retry.
504GATEWAY_TIMEOUTThe model sent nothing for 100 seconds (300 seconds for the models nabh.cloud runs on its own servers, such as medha). Without streaming nothing is sent until the answer is complete, so for long outputs set stream: true or lower max_tokens. Safe to retry.
5xxAPI_ERRORThe model provider returned an unexpected error or the upstream connection failed. Safe to retry.
200EMPTY_RESPONSEThe model finished without producing anything; the request was not charged. The success status was already sent when this was found, so the error comes as HTTP 200 with an error body (or as an error event in a stream); the Request Log shows it as 502. Almost always the request is longer than the model’s context window (input plus max_tokens): shorten the conversation or lower max_tokens.

Handling Errors

  • Check the HTTP status first, then branch on error.code for specific handling.
  • On 402 INSUFFICIENT_BALANCE, prompt the user to recharge using the provided recharge_url.
  • On 429 RATE_LIMIT_EXCEEDED, wait for Retry-After then retry with backoff — see Rate Limits.
  • On 429 MODEL_BUSY, retry with exponential backoff; there is no Retry-After.
  • On HTTP 200, still check for an error object before reading choices — that is how EMPTY_RESPONSE arrives.
  • On 503 SERVICE_UNAVAILABLE, retry with backoff — it means a dependency is temporarily down, not that your request was invalid.
  • On 504 GATEWAY_TIMEOUT or API_ERROR, retry with backoff — these mean the model provider timed out or errored, not that your request was invalid.
Download on the App StoreGet it on Google Play