IranRouter
Docs contents

Docs

Errors

The error envelope and what every code we emit actually means.

The error envelope

The same shape OpenAI returns, so your existing error handling works. The code field is the precise one — branch on it, never on the message text.

json
{
  "error": {
    "message": "insufficient balance",
    "type": "insufficient_quota",
    "code": "insufficient_balance"
  }
}

Codes

۴۰۰ — Bad request

codeMeaning and what to do
invalid_requestThe body is malformed — the message names the field.
request_exceeds_token_limitprompt + max_tokens exceeds your whole tokens-per-minute allowance. Retrying never fixes this: shorten the prompt or lower max_tokens.
streaming_disabledStreaming is temporarily off. Re-send with stream=false.

۴۰۱ — Authentication

codeMeaning
invalid_api_keyWrong, revoked or expired key. The most common real cause is a stray space or newline from copying.

۴۰۲ — Balance or quota

codeMeaning and what to do
insufficient_balanceNot enough balance to cover this request's hold. Top up — or lower max_tokens so the hold shrinks.
monthly_cap_reachedThis key's monthly spend cap is exhausted.
plan_quota_reachedThe plan's token allowance is spent and the plan allows no overage.
overage_disabledAllowance spent and overage is not enabled for this account. Enable it, or switch the key to credit.
overage_limit_reachedThe overage ceiling is exhausted.

۴۰۳ — Permission

codeMeaning and what to do
model_not_allowedThis key is deliberately restricted to a specific model list.
model_not_in_planThe model is outside your plan. Switch the key to credit to reach every model from your wallet — details.
byok_disabledBring-your-own-key is switched off platform-wide.

۴۰۴ / ۴۲۹ / ۵۰۳

codeHTTPMeaning
model_not_found404Unknown model ID — either it does not exist or it is unpublished.
rate_limit_rpm / rph / rpd / tpm429That window's rate limit is full. Honour retry-after.
key_daily_token_budget_reached429The key's daily token budget. Resets at Tehran midnight.
key_daily_budget_reached429The key's daily Rial budget.
free_daily_limit429The free plan's daily ceiling.
global_throttle429A temporary platform-wide throttle during a spike.
no_capacity503No healthy route for this model right now. Retry shortly.
gateway_paused503The service is in maintenance mode.
pricing_unavailable503No active rate to price with; we would rather not charge blind.

Retry pattern

Which are worth retrying and which are not:

  • Retryable: 429 (after retry-after), 503 no_capacity, 5xx upstream — with exponential backoff.
  • Pointless: 400, 401, 403, 404the answer will not change until the request does.
  • Needs a human: 402a top-up or a settings change is required.

When you contact support

Send the x-request-id header value. With it we find the exact request — without it we are guessing.