Errors
The gateway returns OpenAI-compatible error envelopes with a DeepToken-specific category header so clients can branch retry behaviour without parsing strings.
The envelope
{
"error": {
"message": "human-readable description",
"type": "category_name",
"code": "specific_code"
}
}
Every response also carries an X-Gateway-Error-Category header. The category is one of:
| Category | Meaning | Retry? |
|---|---|---|
platform_error | DeepToken-side fault | Yes, with backoff |
upstream_error | Upstream provider failure | Retry only when the subtype and request semantics allow it |
quota_error | Wallet, budget, or rate-limit signal | Top up, adjust the budget, or wait for the window |
user_error | Bad request, authentication, or permission failure | Fix the request |
Common codes
401 invalid_api_keyβ key revoked or never existed403 model_not_allowedβ your key's allowlist forbids the model403 ip_not_allowedβ request IP is not in the key's allowlist402 org_wallet_emptyβ strict-mode org wallet has zero balance403 budget_limit_exceededβ project or API-key budget ceiling breached429 rate_limit_exceededβ request rate exceeded the configured window503 no_available_channelβ no operational channel serves this model
The gateway may route retryable upstream failures to another eligible channel. When an error reaches the client, inspect the HTTP status, error.code, category, and subtype before deciding to retry.
When you should retry
Retry 5xx platform_error responses with exponential backoff and jitter. Wait for the configured window after rate_limit_exceeded; adjust the budget or wait for its period after budget_limit_exceeded. Authentication, permission, model, and validation errors must be fixed before retrying.