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 | DeepToken-side fault | Yes, with backoff |
upstream | Upstream provider 5xx / timeout | Already retried; do not retry |
quota | Your wallet / per-key budget is empty | No β top up |
user | Bad request / unknown model / disallowed model | No β fix 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 wallet_emptyβ strict-mode org wallet has zero balance429 budget_exceededβ rolling per-key USD ceiling breached503 no_available_channelβ no operational channel serves this model504 upstream_timeoutβ upstream didn't respond within the gateway window
The gateway already retries 503 no_available_channel and 504 upstream_timeout up to three times internally. By the time your client sees them, the fallback chain is exhausted.
When you should retry
Only retry 5xx platform errors and the 429 budget_exceeded after the indicated window passes. Everything else is deterministic from the request β retrying without fixing the cause just wastes credits.