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:

StatusError typeWhat it meansWhat to do
401authentication_errorKey invalid, inactive, or sent the wrong wayConfirm the key is active in the dashboard; use ANTHROPIC_AUTH_TOKEN (not ANTHROPIC_API_KEY) with a base URL that has no /v1 suffix
403permission_errorKey is valid but not allowed to use this modelCheck the key’s group assignment and model access in the dashboard
404not_found_errorModel ID not available on this endpointCompare the model name against the current model list in the dashboard
400invalid_request_errorMalformed request — most often a conversation that exceeds the model’s context windowRun /compact in Claude Code, or start a fresh session; long files pasted into the conversation are the usual cause
429rate_limit_errorToo many requests or tokens per minute, or quota exhaustedThese 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 / 529api_error / overloaded_errorTransient model-provider failure or capacity pressureSafe 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. /compact reclaims 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 →