Use Claude Code with a custom Anthropic-compatible API
Last verified
Claude Code can use a custom Anthropic-compatible endpoint. With nexinfer, the required values are the API base URL and a key created in your dashboard.
1. Create an API key
Sign in to the nexinfer dashboard, create a key and keep it out of source control. Current model availability and account limits are shown in the dashboard.
2. Set the environment variables
export ANTHROPIC_BASE_URL=https://api.nexinfer.com
export ANTHROPIC_AUTH_TOKEN=sk-nexinfer-xxxx
Replace the example key with your own. Add the variables to your shell profile only if you want them to persist between terminal sessions.
3. Start Claude Code
claude
If authentication fails, confirm that the key is active and that ANTHROPIC_BASE_URL does not include /v1.
What this setup changes
- Claude Code sends compatible API requests to
api.nexinfer.com. - Your key, model access and usage records are managed in the nexinfer dashboard.
- Model availability can change with account permissions and provider capacity.
Diagnose errors by status code
Claude Code surfaces the API’s error responses directly. Each status code points to a different layer — fix the layer, not the symptom:
| Status | Error type | What it means | What to do |
|---|---|---|---|
| 401 | authentication_error | Key invalid, inactive, or sent the wrong way | Confirm the key is active in the dashboard; use ANTHROPIC_AUTH_TOKEN (not ANTHROPIC_API_KEY) with a base URL that has no /v1 suffix |
| 403 | permission_error | Key is valid but not allowed to use this model | Check the key’s group assignment and model access in the dashboard |
| 404 | not_found_error | Model ID not available on this endpoint | Compare the model name against the current model list in the dashboard |
| 400 | invalid_request_error | Malformed request — most often a conversation that exceeds the model’s context window | Run /compact in Claude Code, or start a fresh session; long files pasted into the conversation are the usual cause |
| 429 | rate_limit_error | Too many requests or tokens per minute, or quota exhausted | These are different problems: a per-minute limit clears on its own (Claude Code retries with backoff; the retry-after header says when), while an exhausted balance or quota does not — check usage and balance in the dashboard before retrying in a loop |
| 500 / 529 | api_error / overloaded_error | Transient model-provider failure or capacity pressure | Safe to retry; Claude Code retries automatically. If it persists for minutes, check the dashboard announcements rather than changing your configuration |
Two practical notes:
- 429 is the most misread error. Retrying harder makes the per-minute case worse and never fixes the quota case. Identify which one you have first — the response body says whether it is a rate limit or an account limit.
- Context-limit 400s grow with session length. Claude Code accumulates conversation history; a session that worked all morning can start failing after enough turns.
/compactreclaims space without losing the thread.
This guide does not promise a specific price, rate limit or model. Check the dashboard before relying on a model for production work.
Using Codex instead? Follow the Codex custom API guide.
Continue in the dashboard
Create an account, generate an API key and check the current model and account availability.
Create account →