Claude Code
Run Claude Code on the bInference Router in four steps, with Claude, GPT or uncensored models.
The bInference Router speaks the same Messages API as Anthropic, so Claude Code talks to it directly. There is nothing extra to install and nothing running on your computer besides Claude Code itself. Every call is paid from your bInference credit.
You need Claude Code installed (claude --version prints a version) and a bInference account or agent with credit.
Make a key
On binference.io, press Create key. An account key spends your own credit; an agent key spends that agent's AI budget. Turn on Limit spending and set a daily limit: Claude Code works in loops and can make hundreds of calls in an afternoon.
Copy the key. It is shown once.
Point Claude Code at the Router
Open ~/.claude/settings.json (on Windows, %USERPROFILE%\.claude\settings.json) and add these lines. If the file already has settings, add the model line and the five variables to them.
{
"model": "sonnet",
"env": {
"ANTHROPIC_BASE_URL": "https://binference.io/api",
"ANTHROPIC_AUTH_TOKEN": "binf_...",
"ANTHROPIC_API_KEY": "",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5",
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "32000"
}
}| Line | What it does |
|---|---|
model | Starts every session on Claude Sonnet 5.5. Without it, Claude Code starts on Opus 5.5, which costs more. |
ANTHROPIC_BASE_URL | Sends every model call to the Router. Leave out /v1: Claude Code adds it. |
ANTHROPIC_AUTH_TOKEN | Your binf_ key. |
ANTHROPIC_API_KEY | Left empty, so an Anthropic key set elsewhere on your computer is never sent along. |
ANTHROPIC_DEFAULT_HAIKU_MODEL | Runs Claude Code's small side jobs, like naming a session, on Haiku 4.5 instead of your main model. |
CLAUDE_CODE_MAX_OUTPUT_TOKENS | Caps each answer at 32,000 tokens, so each turn holds less credit. See What a turn holds. |
The key is in this file
Keep ~/.claude/settings.json to yourself, and never put the key in a project's
.claude/settings.json: that file is committed and shared with everyone who clones
the project.
To try it in one terminal first, set the same values there instead. They last until you close the terminal:
export ANTHROPIC_BASE_URL="https://binference.io/api"
export ANTHROPIC_AUTH_TOKEN="binf_..."
export ANTHROPIC_API_KEY=""
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5"
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=32000
claude --model sonnetStart Claude Code and check
Run claude in your project, then type /status. Three lines confirm the setup: Auth token names ANTHROPIC_AUTH_TOKEN, Anthropic base URL shows https://binference.io/api, and Model shows Sonnet.
❯ /status
- cwd:
- ~/my-project
- Auth token:
- ANTHROPIC_AUTH_TOKEN
- Anthropic base URL:
- https://binference.io/api
- Model:
- sonnet (claude-sonnet-5-5)
Send any message. Its call shows on your Calls page within a minute, with what it cost.
If you also sign in to Claude Code with a Claude plan, the key takes over while it is set. Your sign-in stays saved: see Go back to your Claude plan.
Pick a model
Type /model to switch at any time, or start with claude --model <name>. The next section lists good picks.
Models to start with
- Claude Sonnet 5.5DefaultEveryday coding
- Claude Opus 5.5Large codebases
- Claude Fable 5.1The hardest tasks
- Claude Haiku 4.5Quick, small edits
- GPT-6.1 SolAgentic coding
- GPT-6 AstraOpenAI's flagship
- Abliterated Large v2UncensoredWhat others refuse
Every model was run through Claude Code on the Router before this page was written, each reading files and running commands with Claude Code's tools. Any other model on Models that handles tools well works the same way: use its id with /model.
Claude Code is built for Claude models. GPT and Abliteration models work through the Router, but Anthropic doesn't support them in Claude Code, so a feature may behave differently. On them, Claude Code prints that it doesn't know the model and keeps the session within 200,000 tokens before it compacts. That is expected.
More Claude models in the menu: add "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1" to env, and /model also lists every Claude model the Router serves, older versions included, by name.
What a turn holds
Before each call starts, the Router holds enough credit for the longest answer the call allows, plus the conversation so far. You pay only what the model writes, and the rest comes back when the call ends. See How a call is paid.
Claude Code asks for long answers: room for 128,000 tokens on Opus 5.5. At the start of a session, that holds about $2.40 per turn, and Claude Code's helpers running at the same time each hold their own. With the 32,000 cap from step 2, the same Opus turn holds about $0.67, and a Sonnet 5.5 turn about $0.33. Holds grow as the conversation grows, and pricier models like GPT-6 Astra hold several times more.
- Haiku 4.5$0.18
- Abliterated Large v2$0.18
- Sonnet 5.5$0.33
- GPT-6.1 Sol$0.33
- Opus 5.5$0.67
- Fable 5.1402$1.53
- Opus 5.5No cap402$2.36
- GPT-6 Astra402$9.09
5 of 8 fit in $13 models get 402
One Sonnet 5.5 turn: held and paid
When your credit can't cover a hold, Claude Code shows API Error: 402 and that the balance is below the request's reserve. Lower CLAUDE_CODE_MAX_OUTPUT_TOKENS, for example to 16000, pick a cheaper model, or add credit.
What you pay is a different story: Claude Code resends the whole conversation each turn, and the Router passes its cache marks through. In our test on Sonnet 5.5, the second call read 26,463 tokens from the cache and cost about a twelfth of the first.
Good to know
- Long sessions: a request over 4 MB is refused with
413, usually because of pasted screenshots. Run/compactor/clear. To compact sooner, add"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "400000"toenv. /costshows Anthropic's prices, not what you paid. Your real charges are on the Calls page./contextcounts are estimates: the Router doesn't count tokens ahead of a call, so Claude Code estimates them.- Auto mode may say the session "isn't eligible" for free safety checks. Press Enter: the checks run as ordinary calls on your key. To skip the notice, add
"CLAUDE_CODE_AUTO_MODE_SERVER": "0"toenv. - Remote Control and voice dictation need a Claude sign-in, so they're off while the key is set.
- Claude desktop app: its Code tab keeps its own setting for the address and ignores this file. This page covers Claude Code in a terminal and in VS Code.
- VS Code extension: put the same variables in VS Code's own settings, under
claudeCode.environmentVariables, as{ "name": "ANTHROPIC_BASE_URL", "value": "https://binference.io/api" }entries. The extension checks for a key there before it starts. - Let Claude Code watch its credit: connect the MCP server with the same key, and Claude Code can check its own balance, usage and limits.
Go back to your Claude plan
Delete the lines you added in step 2, or the whole env block, and start Claude Code again. Your Claude sign-in was kept: /status shows it as the login method again.
If something goes wrong
| You see | Fix |
|---|---|
| Claude Code asks you to sign in | It didn't read the key. Check the path and the JSON of ~/.claude/settings.json, or set the values in the same terminal |
/status has no Anthropic base URL line | Same as above: the settings didn't reach Claude Code |
401 and invalid_api_key | The key is wrong or revoked. Make a new one on API keys |
402 and "below this request's reserve" | The credit can't cover the hold. See What a turn holds |
402 and key_limit | The key reached its spending limit. It resets at 00:00 UTC, or raise it |
413 | The conversation passed 4 MB. Run /compact |
Every error code is on Errors, with what to do.