Skip to content

Docs

Errors

Markdown version

Every error from the REST API and the MCP server says what went wrong, what to do, and links here:

{ "error": { "code": "unauthorized", "message": "…", "fix": "…", "docs": "https://www.restolayer.com/docs/errors#unauthorized" } }

Over MCP, a JSON-RPC error carries the same fix and docs in error.data, and a tool's error result in its content. Rate limits are in X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset on every response.

bad_request

HTTP 400: The request didn't validate. Fix what the message (and details.issues, when present) names, then send it again.

unauthorized

HTTP 401: No credential, or a bad one. Send Authorization: Bearer <key>. Get a key in Settings → API keys, or create a sandbox with its own key: POST /v1/sandbox (or lg sandbox create).

forbidden

HTTP 403: Not allowed with this credential. Use a key with the scope the message names (Settings → API keys), or do this in the web app if it's web-only.

not_found

HTTP 404: No such thing. Check the id or the path. List the resource to find the id, or see /v1/openapi.json for the routes.

conflict

HTTP 409: It changed, or it can't happen in this state. Read it again and retry with its current version or state.

moved

HTTP 301: Merged into another record. Read the record at the Location header (details.merged_into) instead.

gone

HTTP 410: No longer available. It was removed or expired; don't retry.

rate_limited

HTTP 429: Too many requests. Wait the number of seconds in Retry-After, then retry. X-RateLimit-Remaining shows what's left.

policy_blocked

HTTP 422: The organization's policy refused it. Don't retry: tell a person which rule the message names (kill switch, consent, do-not-contact, budgets).

unavailable

HTTP 503: Temporarily unavailable. Retry after a short wait (the Retry-After header, when present).

internal

HTTP 500: Something failed on our side. Retry once. If it fails again, report the request id (the x-request-id header).

Inference API errors

The inference API (/v1/chat/completions, /v1/messages, /v1/responses, /v1/embeddings and the other surfaces) answers in each client's own error shape, so OpenAI and Anthropic SDKs raise their usual error classes.

policy_refused

Your organization's guardrails or data policy refused the request before it reached any provider. Nothing was charged. The request isn't retried: change the request or the policy (Guardrails in the console, lg guardrails, MCP lg_guardrails_*). The HTTP status is unchanged (403 for a model, provider or region rule; 400 for content and data policy), and so is the message; match on the code and the reason, never the message.

OpenAI-style (/v1/chat/completions, /v1/responses, the surfaces):

{ "error": { "type": "permission_error", "code": "policy_refused", "reason": "model_denied", "param": "model", "message": "…" } }

Anthropic-style (/v1/messages):

{ "type": "error", "error": { "type": "policy_refused", "reason": "model_denied", "message": "…" }, "request_id": "…" }
reasonStatusWhat refused it
model_denied403The model is on a deny list, or not on an allow list
provider_denied403Every provider for the model is denied, or none is on the allow list
eu_only_no_endpoint403EU-only is on and the model has no endpoint in the EU
data_policy_no_endpoint400The organization's data policy (no training, no prompt retention) excludes every endpoint
zdr_no_endpoint400Zero data retention is required and no endpoint offers it
sensitive_info400Sensitive information (secrets, card numbers, personal data) with the guardrail set to refuse
prompt_injection400A prompt injection with the guardrail set to refuse

A refusal caused only by the request's own provider preferences (only, ignore, its own data_collection) is not a policy refusal: it keeps its usual code. Refused requests are in the request log (blocked ones with the kinds found, never the text).

No key yet? Create a sandbox with its own limited key: quickstart or lg sandbox create.

Send feedback

Tell us what's broken, confusing or missing on this page, or an idea. It goes to the team that builds the product.
Please don't include passwords or card numbers.
Only to reply about this. Never added to any mailing list.