Skip to Content
GatewayAPI ReferenceError Reference

Error Reference

All gateway errors follow the OpenAI-compatible error format. This page documents every error type, code, and HTTP status code the gateway can return.

Error format

{ "error": { "message": "Human-readable error description", "type": "error_type_category", "param": null, "code": "machine_readable_code" } }
FieldTypeDescription
messagestringHuman-readable description of the error
typestringError category (see Error types below)
paramstring or nullThe request parameter that caused the error, if applicable
codestringMachine-readable error code for programmatic handling

Error types

TypeDescription
invalid_request_errorThe request was malformed or missing required fields
authentication_errorAPI key is missing, invalid, expired, or rotated
permission_errorThe request was blocked by a governance policy
rate_limit_errorThe organization has exceeded its rate limit
insufficient_quotaThe organization has exceeded its plan quota
not_found_errorThe requested resource does not exist
upstream_errorThe upstream LLM provider returned an error
gateway_errorInternal gateway error
timeout_errorThe upstream provider timed out
connection_errorFailed to connect to the upstream provider
service_unavailableThe provider is temporarily unavailable (circuit breaker open)

HTTP status codes

CodeTypeWhen
200SuccessRequest completed successfully
202AcceptedRequest requires HITL approval (includes approval_id)
400Client errorInvalid JSON, missing fields, provider mismatch
401AuthenticationMissing or invalid API key
403ForbiddenBlocked by governance (PII, model allowlist, cost, content safety)
404Not foundResource not found
410GoneModel has been retired
413Payload too largeRequest body exceeds 10 MB
429Rate limitedRPM limit exceeded or plan quota exhausted
500Server errorInternal gateway error
502Bad gatewayFailed to connect to upstream provider
503Service unavailableCircuit breaker open or gateway shutting down
504Gateway timeoutUpstream provider timed out

Complete error catalog

Authentication errors (401)

invalid_api_key

Missing or invalid Curate-Me API key.

{ "error": { "message": "Missing or invalid credentials. Provide a valid gateway key via X-CM-API-Key / Authorization: Bearer <gateway-key>, or a valid dashboard access token via Authorization: Bearer <jwt>.", "type": "authentication_error", "param": null, "code": "invalid_api_key" } }

key_rotated

The API key has been rotated and the grace period has expired.

{ "error": { "message": "API key has been rotated. Use the new key. Replacement key ID: key_xyz789", "type": "authentication_error", "param": null, "code": "key_rotated" } }

missing_provider_key

No provider API key was supplied and no stored secret exists.

{ "error": { "message": "Missing provider API key. Provide your provider's API key via X-Provider-Key header, Authorization: Bearer <provider-key>, or store it via POST /gateway/admin/secrets.", "type": "authentication_error", "param": null, "code": "missing_provider_key" } }

Invalid request errors (400)

invalid_json

The request body is not valid JSON.

{ "error": { "message": "Invalid JSON body", "type": "invalid_request_error", "param": null, "code": "invalid_json" } }

missing_model

The model field is missing from the request body.

{ "error": { "message": "Missing 'model' field in request body", "type": "invalid_request_error", "param": null, "code": "missing_model" } }

unknown_model

The specified model is not recognized by the gateway.

{ "error": { "message": "Unknown model 'foo-bar'. Supported prefixes: gpt-, o1-, o3-, claude-, gemini-, deepseek-", "type": "invalid_request_error", "param": null, "code": "unknown_model" } }

provider_mismatch

The model does not belong to the provider endpoint it was sent to.

{ "error": { "message": "Model 'gpt-4o' is a openai model but was sent to the google endpoint. Use the correct endpoint.", "type": "invalid_request_error", "param": null, "code": "provider_mismatch" } }

request_too_large

The request body exceeds the 10 MB size limit.

{ "error": { "message": "Request body too large. Maximum size is 10485760 bytes (10 MB).", "type": "invalid_request_error", "param": null, "code": "request_too_large" } }

model_retired

The requested model has been retired (past its shutdown date).

{ "error": { "message": "Model 'gpt-4' has been retired (shutdown: 2026-01-15). Use 'gpt-4o' instead.", "type": "invalid_request_error", "param": null, "code": "model_retired" } }

Rate limit errors (429)

rate_limit

The organization has exceeded its requests-per-minute (RPM) limit.

HTTP/1.1 429 Too Many Requests X-RateLimit-Limit: 60 X-RateLimit-Remaining: 0 X-RateLimit-Reset: 1709056860 Retry-After: 12
{ "error": { "message": "Rate limit exceeded. Retry after 12 seconds.", "type": "rate_limit_error", "param": null, "code": "rate_limit" } }

plan_limit_exceeded

The organization has exceeded its plan’s daily request quota or budget.

{ "error": { "message": "Plan limit exceeded: free tier allows 100 requests per day", "type": "insufficient_quota", "param": null, "code": "plan_limit_exceeded" } }

Permission errors (403)

cost_limit

The estimated request cost exceeds the per-request cost cap.

{ "error": { "message": "Estimated cost $3.50 exceeds per-request limit $2.00", "type": "permission_error", "param": null, "code": "cost_limit" } }

daily_budget

The organization’s daily budget has been exhausted.

{ "error": { "message": "Daily budget exhausted: $24.50 spent + $0.52 estimated > $25.00 limit", "type": "permission_error", "param": null, "code": "daily_budget" } }

monthly_budget

The organization’s monthly budget has been exhausted.

{ "error": { "message": "Monthly budget exhausted: $248.00 spent + $2.10 estimated > $250.00 limit", "type": "permission_error", "param": null, "code": "monthly_budget" } }

pii_detected

PII or secrets were detected in the request content.

{ "error": { "message": "PII detected in request: credit card number found in message content", "type": "permission_error", "param": null, "code": "pii_detected" } }

model_not_allowed

The requested model is not in the organization’s allowed model list.

{ "error": { "message": "Model 'gpt-4o' is not in the allowed model list for this organization", "type": "permission_error", "param": null, "code": "model_not_allowed" } }

needs_approval

The request requires human approval before execution.

{ "error": { "message": "Request requires human approval: Estimated cost $12.50 exceeds HITL threshold $10.00", "type": "permission_error", "param": null, "code": "needs_approval" } }

Note: The OpenAI/Anthropic proxy endpoints return HTTP 202 with approval details instead of a 403 for HITL-triggered requests. The Google and DeepSeek proxies currently return 403.


HITL approval response (202)

When the HITL gate triggers, the OpenAI/Anthropic proxy returns a 202 with approval metadata:

HTTP/1.1 202 Accepted X-CM-Approval-ID: apr_abc123def456 Retry-After: 30
{ "status": "pending_approval", "approval_id": "apr_abc123def456", "retry_after_seconds": 30, "message": "Request requires human approval: Estimated cost $12.50 exceeds HITL threshold $10.00", "estimated_cost": 12.50, "model": "gpt-4o" }

This is not an error per se — the request has been accepted and is awaiting approval. Poll GET /v1/approvals/{approval_id}/status to check the outcome.


Upstream errors (502, 504)

upstream_{status_code}

The upstream provider returned an error.

{ "error": { "message": "Google Gemini API error: Invalid API key provided", "type": "upstream_error", "param": null, "code": "upstream_401" } }

timeout

The upstream provider timed out.

{ "error": { "message": "Google Gemini API timed out", "type": "timeout_error", "param": null, "code": "timeout" } }

connection_error

Failed to establish a connection to the upstream provider.

{ "error": { "message": "Failed to connect to Google Gemini API", "type": "connection_error", "param": null, "code": "connection_error" } }

circuit_breaker_open

The provider’s circuit breaker is open due to repeated failures.

{ "error": { "message": "Google Gemini is temporarily unavailable (circuit breaker open)", "type": "service_unavailable", "param": null, "code": "circuit_breaker_open" } }

Internal errors (500)

internal_error

An unexpected error occurred within the gateway.

{ "error": { "message": "Internal gateway error", "type": "gateway_error", "param": null, "code": "internal_error" } }

Retry guidance

Error codeRetryableStrategy
rate_limitYesWait for Retry-After seconds, then retry
plan_limit_exceededNoUpgrade plan or wait for the next billing period
daily_budgetNoWait until the next UTC day or increase the daily budget
monthly_budgetNoWait until the next month or increase the monthly budget
cost_limitNoReduce max_tokens or use a cheaper model
pii_detectedNoRemove PII from the request content
model_not_allowedNoUse an allowed model or update the allowlist
needs_approvalYesPoll GET /v1/approvals/{id}/status and re-submit after approval
circuit_breaker_openYesWait for retry_after_seconds and retry
timeoutYesRetry with exponential backoff
connection_errorYesRetry with exponential backoff
upstream_429YesWait for Retry-After from the provider
upstream_500YesRetry with exponential backoff
upstream_502YesRetry with exponential backoff
upstream_503YesRetry with exponential backoff
invalid_jsonNoFix the request body
missing_modelNoInclude the model field
unknown_modelNoUse a supported model name
provider_mismatchNoSend the request to the correct provider endpoint
invalid_api_keyNoUse a valid API key
missing_provider_keyNoInclude a provider API key
internal_errorYesRetry with exponential backoff

Retry headers

When the gateway retries an upstream request due to transient failures, it includes retry metadata in the response:

HeaderDescription
X-Gateway-Retry-AttemptsNumber of retry attempts made
X-Gateway-Retry-Delay-MsTotal retry delay in milliseconds

These headers are present on both successful and failed responses when retries occurred.