How to Use Claude Code with a Custom API Endpoint (OriginCoder Setup Guide)
Published 2026-11-11
Claude Code reads its API address and credentials from environment variables, so it can talk to any gateway that speaks the Anthropic Messages format. This guide shows how to point it at OriginCoder, the AI API gateway, in about five minutes. It covers the three ways to configure it: CC-Switch one-click import, environment variables, and settings.json.
If you searched for "Claude Code API" or "Claude Code proxy": a gateway like this sits between Claude Code and the model provider. You keep using the same claude command, only the address and key change.
What you need
- Claude Code installed (for example with
npm install -g @anthropic-ai/claude-code; follow Anthropic's own install instructions if they differ on your system). - An OriginCoder account with a balance or an active subscription. Create an account and see the model pricing page for what each model costs.
- An API key in a group that serves Claude models (Anthropic platform).
Step 1: create an API key
- Sign in and open API Keys in the console.
- Click Create API Key, give it a name, and choose a group that serves Claude models.
- Copy the key. Treat it like a password.
The group decides which models the key can call and at what rate, so pick it deliberately. The console shows the exact models and prices per group.
Step 2, option A: one-click import with CC-Switch
CC Switch is a desktop tool that manages provider settings for Claude Code, Codex and Gemini CLI. OriginCoder can hand it a ready-made provider:
- Install CC Switch and start it once.
- In the OriginCoder console, find your key in the API Keys list and click Import to CCS.
- Your browser asks to open CC Switch. Confirm.
- A provider named after the site appears in CC Switch. Select it, then restart Claude Code.
If nothing opens, CC Switch is probably not installed or not registered as the handler for its link type; the console then shows a "not installed" message. Some deployments hide the import button. In that case use option B or C.
Step 2, option B: environment variables
Open the Use Key dialog for your key in the console. It prints the exact values for your account. The shape is:
export ANTHROPIC_BASE_URL="https://origincoder.com"
export ANTHROPIC_AUTH_TOKEN="your-api-key"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
Use the Base URL shown in the console for your account. Do not add /v1 to ANTHROPIC_BASE_URL: Claude Code appends the request path itself, and a doubled /v1/v1 returns 404.
Put these lines in ~/.zshrc or ~/.bashrc to keep them across sessions. On Windows, the console shows the Command Prompt and PowerShell equivalents.
Step 2, option C: settings.json
To avoid touching your shell profile, put the same values in Claude Code's user settings file, ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://origincoder.com",
"ANTHROPIC_AUTH_TOKEN": "your-api-key",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}
Do not commit this file to a repository, because it contains your key.
Step 3: verify
Start Claude Code in any project and ask it something short. Then open Usage in the OriginCoder console: the request should appear with its token counts and cost. If you prefer to test the endpoint without Claude Code, any OpenAI-compatible client works against https://origincoder.com/v1:
curl https://origincoder.com/v1/chat/completions \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{"model": "a-model-from-your-group", "messages": [{"role": "user", "content": "ping"}]}'
Replace the model name with one listed for your group on the pricing page.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| 401 or "invalid API key" | Wrong or disabled key, or an extra space when pasting | Copy the key again from the console |
| 404 on every request | /v1 added to ANTHROPIC_BASE_URL |
Remove /v1 for Claude Code |
| "model not found" or 403 | The key's group does not serve that model | Pick another model, or move the key to a group that does |
| Still talking to the old provider | Another config source overrides it | Check for an existing ANTHROPIC_* variable or provider in CC Switch |
| Balance errors | No balance or an expired subscription | Top up or renew in the console |
Cost and safety notes
- Usage is billed per request from your balance (or consumed from a subscription quota), and every call is recorded with token counts and cost, so you can reconcile against your own logs.
- A gateway is a third party in the request path: your prompts and code context pass through it. Read the terms and decide what you are comfortable sending, as you would with any provider.
- OriginCoder is an independent platform and is not affiliated with Anthropic.
Next: compare the options in Claude Code alternative: official subscription vs. API gateway, or see how gateways differ in the LLM gateway comparison.