Errors
Every error uses the same shape, so you can handle them uniformly:
{
"error": {
"message": "This API key has expired.",
"request_id": "req_2ae80f15bd6e",
"type": "key_expired"
}
}
Branch on type, not on message. The message wording may improve over time; the
type is stable. Always log request_id: it is the fastest way for support to find
your exact request.
Your key or your account
| Type | HTTP | What happened | What to do |
|---|---|---|---|
invalid_api_key |
401 | The key does not exist, or the Authorization header is malformed. |
Check the header reads Authorization: Bearer perisai_router_sk_.... Keys are shown once at creation; create a new one if it is lost. |
key_disabled |
401 | The key was switched off in the console. | Re-enable it under API keys, or use another key. |
key_rotated |
401 | The key was rotated and its grace window has ended. | Use the replacement key; the old key's page in the console links to it. |
key_expired |
401 | The key passed its expiry date. | Create a new key, or clear the expiry on this one. |
org_suspended |
403 | The organization is suspended, so every key and the Playground stop working. The answer never says why. | An Owner or Superadmin signs in to the console: the notice at the top of every page gives the reason, what to do, the deadline and where to appeal. |
Credit and limits
All four mean a budget was reached. They are separate types so you can tell which budget without parsing prose.
| Type | HTTP | What happened | What to do |
|---|---|---|---|
insufficient_credits |
402 | The organization balance is zero or below. | Top up. Balance is visible under Credits. |
workspace_budget_reached |
402 | The workspace hit its credit limit for the period. | Raise the workspace limit, or wait for the period to reset. |
key_budget_reached |
402 | This key hit its own credit limit. | Raise the key limit, or use a different key. |
rate_limited |
429 | Too many requests too quickly: over your key's per-minute limit, over your account's (x-ratelimit-scope: org), or 30 unknown keys from your IP in 10 minutes. |
Back off and retry after Retry-After seconds. If it happens at normal load, ask your admin to raise the key's guardrail rate limit. |
Note that credit checks run before the request is sent, so a key with a budget smaller than the cost of one request is refused immediately rather than part way through.
The model you asked for
| Type | HTTP | What happened | What to do |
|---|---|---|---|
model_not_found |
404 | No such model or alias, or it is disabled platform-wide. | Call GET /v1/models for the current list. |
guardrail_unavailable |
503 | The external guardrail that checks this key's requests did not answer, so the request was not sent. Nothing is billed. | Retry with backoff. If it persists, ask your workspace admin. |
guardrail_blocked |
400 | A content check on the key's guardrails refused the prompt: personal data, a secret, a blocked term or a prompt injection attempt. The message names which, never the data. Also returned for a realtime or live session on a key with content checks or an external prompt check, which cannot be inspected. Nothing is billed. | Remove it from the prompt, or ask a workspace admin to set that check to Redact or Monitor. |
model_not_allowed |
403 | The model exists, but this key's guardrails do not permit it. | Pick a model from the key's allowed list, or change the guardrail. |
provider_blocked |
403 | The model exists and is allowed, but the key's guardrails block every provider that could serve it. | Unblock a provider in the guardrail, or choose a model served elsewhere. |
no_eligible_provider |
400 | Nothing can serve this model right now: every provider in its chain is down or switched off. | This is an outage, not a configuration problem. Retry shortly. |
no_capable_model |
400 | You asked for perisairouter/auto, but no model your key may use can serve this request: it carries an image and no vision model is allowed, uses tools and no tool-capable model is allowed, or is larger than every allowed context window. |
Allow a model that can do it in the key's guardrails, or send a smaller request. |
model_wrong_endpoint |
400 | The model is not served on this endpoint, such as an embedding model sent to /v1/chat/completions. The error carries an endpoints list naming the ones that serve it. |
Send the request to an endpoint in endpoints. GET /v1/models lists every model's endpoints. |
provider_blocked and no_eligible_provider are deliberately different. The first
is your policy refusing the request; the second is a real outage. If you see the
first, look at your guardrails, not at our status page.
Your request
| Type | HTTP | What happened | What to do |
|---|---|---|---|
invalid_request |
400 | The body is not valid JSON, has no model, or (on an audio or image upload) is not multipart/form-data with the upload as a file part. Or a field of the perisai_router object is not accepted: cost_tier other than low, medium or high, sticky other than true or false, or a models list that is empty, too long, holds an alias or a bare *, or is sent with a model other than perisairouter/auto, or a cost_tier that differs from the tier in the model id (perisairouter/auto:code:low). |
Check for truncation or a trailing comma, the model field, the upload's file part, and the perisai_router fields. |
request_too_large |
413 | The body exceeds 4 MB, or 26 MB for an audio upload to /v1/audio/transcriptions. |
Send less context, split the work across requests, or split the audio into shorter files. |
unsupported_parameter |
400 | The body carries a parameter this model cannot handle. | Almost always tools sent to a model without tool support. Switch to a tool-capable model such as deepseek/deepseek-v4-flash, or the perisairouter/smart alias. |
method_not_allowed |
405 | Wrong HTTP method for this path. | Chat completions, embeddings, responses and moderations are POST; the model list is GET. |
unknown_endpoint |
404 | No such path under /v1. |
Check the URL. The base URL must end in /v1. |
not_implemented |
501 | A reserved endpoint that is planned but not built, such as /v1/agents. |
Nothing to do; it will start working when the feature ships. |
forbidden_origin |
403 | MCP only: the request came from a web page on another site. | Call the MCP server from a program, not from a browser page. |
unsupported_protocol_version |
400 | MCP only: the MCP-Protocol-Version header names a version Peris.ai Router does not speak. |
Use 2025-06-18 or 2025-03-26. See MCP server. |
The provider or Peris.ai Router itself
| Type | HTTP | What happened | What to do |
|---|---|---|---|
upstream_rejected |
400 | The provider refused the request, usually a malformed or unsupported field. | Check your parameters against the provider's limits. |
upstream_error |
502 | The provider returned an error. | Retry. If it persists, the provider is having trouble. |
upstream_timeout |
504 | The provider did not answer in time, 180 s. | Retry, and consider a smaller request. |
all_providers_failed |
502 | Every provider in the chain was tried and all failed. | Retry with backoff. This is an outage on the provider side. |
gateway_unavailable |
503 | Peris.ai Router cannot reach its own gateway. | Retry with backoff. Check /healthz. |
Retrying safely
Retry these, with exponential backoff: rate_limited, upstream_error,
upstream_timeout, all_providers_failed, gateway_unavailable, guardrail_unavailable,
no_eligible_provider.
Do not retry these; they will fail identically until something changes:
invalid_api_key, key_disabled, key_expired, org_suspended,
insufficient_credits, workspace_budget_reached, key_budget_reached,
model_not_found, model_not_allowed, guardrail_blocked, provider_blocked, no_capable_model, model_wrong_endpoint, invalid_request,
request_too_large, unsupported_parameter, method_not_allowed,
unknown_endpoint, not_implemented, forbidden_origin, unsupported_protocol_version.
Checking whether it is us
GET /healthz needs no key and reports whether the gateway has providers loaded:
{ "status": "ok", "gateway_providers": 2 }
A status of degraded with gateway_providers: 0 means Peris.ai Router is up but cannot
route anything, and every chat request will fail until it recovers.