API error 500 (and 529 overloaded)
A 500 is an upstream failure; 529 is Anthropic's explicit "model at capacity" code. Neither is caused by your prompt. Claude Code retries a few times on its own; if it gives up, wait a minute and resume with claude -c. Switching tier with /model often works immediately because capacity is per model. On this gateway a saturated upstream account is failed over automatically, which is why 529s are rarer here than against a single account.
API error 400 — bad request / context too long
In Claude Code a 400 almost always means the conversation plus the files it has read no longer fit the model's window. /compact summarises history; /clear starts fresh; or switch to a (1M) variant of the model. Other 400s: an unsupported parameter after an upgrade (run claude update), or an image or file the model cannot accept.
API error 429 — rate limit / rate exceeded
Three limits apply: requests per minute, tokens per minute and concurrent requests. Agentic sessions hit concurrency first — every subagent is a parallel streaming request holding a slot until it finishes. Reduce parallelism, let the retry-after elapse, and for sustained work ask for a higher concurrency on your gateway account.
401 / authentication errors
invalid x-api-key or authentication_error means the key does not belong to the endpoint. If ANTHROPIC_BASE_URL points at the gateway, the key must be a gateway key; an Anthropic console key will be refused, and the reverse is also true. /status shows which endpoint and key are active. If you use /login and an API key at the same time, the key wins.
"No healthy upstream"
Not an API error: it is the load balancer in front of a service reporting that no backend is available. On the official endpoint it means an outage; from a gateway it means the whole upstream pool is down or throttled. Wait and retry; do not change your configuration.
Claude Code not working at all
- Starts then exits silently → run
claude /doctor; usually a Node version or PATH problem. - Hangs at startup → network or proxy; try
ANTHROPIC_BASE_URLon a reachable endpoint. command not found→ see the install guide.- Tools fail with permission errors →
/permissions, or--allowedToolsin scripts.
Frequently asked questions
Why does Claude Code keep returning API error 500?
The model backend is failing or overloaded (529 is the explicit form). Retry after a pause, switch tier with /model, or resume with claude -c. It is not your configuration.
How do I fix Claude Code error 400 context length?
Run /compact to summarise the session, /clear to reset, or switch to a 1M-context model variant.
Why does Claude Code say invalid API key?
The key does not match the endpoint in ANTHROPIC_BASE_URL. Gateway URL needs a gateway key; Anthropic URL needs a console key.
Run Claude Code on the gateway
Same models, two environment variables, credits at 7.69× face value — or a flat-rate unlimited plan.
Get an API key See unlimited plansAI Prime Tech is an independent API gateway and is not affiliated with, endorsed by, or sponsored by Anthropic. “Claude” and “Claude Code” are trademarks of Anthropic. Claude Code features described here follow Anthropic’s public documentation at the time of writing and change frequently; prices and model lists on this page are read from this gateway’s live settings.