Tool integration · Anthropic Messages
Use TokenRa in Claude Code
Claude Code is Anthropic's coding agent for the terminal. It calls models through the Anthropic Messages API, so connecting it to TokenRa takes three settings: the base URL, your TokenRa API key and a model ID. Every model in the table below completed a file task in Claude Code on October 29, 2026.
- Base URL
https://tokenra.io- API format
- Anthropic Messages
- Config file
~/.claude/settings.json- Tested with
- Claude Code 2.1.312
Before you start
Before you start
- A TokenRa API key: create an account, then add a key on the API Keys page of the console. Keys start with
sk-. - No Anthropic account: Claude Code does not need a Claude login when it runs on TokenRa.
Install
Install Claude Code
Use Anthropic's installer, Homebrew or WinGet. Installing with npm still works, but Anthropic marks it as deprecated.
# macOS / Linux
curl -fsSL https://claude.ai/install.sh | bash
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex
# Homebrew (macOS / Linux) or WinGet (Windows)
brew install --cask claude-code
winget install Anthropic.ClaudeCode
# Check the installation
claude --versionConfigure
Connect Claude Code to TokenRa
Claude Code reads environment variables from the env block of its user settings file, ~/.claude/settings.json (on Windows %USERPROFILE%\.claude\settings.json). Create the file if it does not exist, put in the block below and replace sk-... with your key:
{
"env": {
"ANTHROPIC_BASE_URL": "https://tokenra.io",
"ANTHROPIC_AUTH_TOKEN": "sk-...",
"ANTHROPIC_MODEL": "deepseek-v4.1-flash",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4.1-flash",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4.1-flash",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4.1-flash",
"CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-v4.1-flash",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
}
}| Setting | What to put in |
|---|---|
ANTHROPIC_BASE_URL | https://tokenra.io, without /v1. Claude Code adds /v1/messages itself. |
ANTHROPIC_AUTH_TOKEN | Your TokenRa API key, sent as Authorization: Bearer. |
ANTHROPIC_MODEL | The model Claude Code works with: any model ID from the table below. |
ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL | The models behind Claude Code's opus, sonnet and haiku aliases. Claude Code also uses the haiku model for background tasks, so set all three to TokenRa model IDs. They can be different models. |
CLAUDE_CODE_SUBAGENT_MODEL | The default model for subagents. |
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC | Optional. 1 turns off auto-updates, telemetry and error reports to Anthropic. Remove the line to keep auto-updates. |
Save the file and start Claude Code again. The file must be strict JSON: no comments, no trailing commas and straight quotes only.
Or use environment variables
The same variables work when you set them in your shell instead of the settings file:
# macOS / Linux: add these lines to ~/.zshrc or ~/.bashrc, then open a new terminal
export ANTHROPIC_BASE_URL="https://tokenra.io"
export ANTHROPIC_AUTH_TOKEN="sk-..."
export ANTHROPIC_MODEL="deepseek-v4.1-flash"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4.1-flash"
# Windows PowerShell: saved for your user, used by new terminals
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://tokenra.io", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "sk-...", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "deepseek-v4.1-flash", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_DEFAULT_HAIKU_MODEL", "deepseek-v4.1-flash", "User")ANTHROPIC_API_KEY is sent as x-api-key, and in interactive mode Claude Code asks you once to approve it. ANTHROPIC_AUTH_TOKEN skips that prompt.Verify
Check the connection
Run a one-off prompt in any folder:
claude -p "Reply with OK if you can read this."An answer means the base URL, key and model are right. Without -p, claude starts an interactive session: on the first start it asks for a color theme and whether you trust the folder, but with the settings above it does not ask you to log in. Inside a session, /status shows which settings files were loaded.
Models
Tested models
On 2026-10-29 every model below finished the same task in Claude Code 2.1.312: read a file with the Read tool, then create a new file with the Write tool. Times are for the whole task in one run and will vary.
| Model | Model ID | Task time (one run) |
|---|---|---|
| DeepSeek V4.1 Flash 1017 | deepseek-v4.1-flash-1017 | 4 s |
| DeepSeek V4.1 Flash | deepseek-v4.1-flash | 5 s |
| MiniMax M3 | minimax-m3 | 6 s |
| GLM-5.3 | glm-5.3 | 7 s |
| GLM-5.3 Flash | glm-5.3-flash | 9 s |
| Qwen3.8 Max | qwen3.8-max | 14 s |
| Kimi K3 | kimi-k3 | 15 s |
| MiniMax M3.1 Flash | minimax-m3.1-flash | 26 s |
| Kimi K3.1 Pro | kimi-k3.1-pro | 32 s |
gemini-3.8-flash cannot be used here: its upstream rejects every request that carries tool definitions (HTTP 400), and coding agents send tools with every request.Switch
Switch models
- During a session:
/model kimi-k3.1-proswitches to another TokenRa model right away./modelon its own opens the picker, where theopus,sonnetandhaikuentries point to the models you set inANTHROPIC_DEFAULT_*_MODEL. - For one launch:
claude --model kimi-k3.1-pro. - For new sessions: change
ANTHROPIC_MODEL. While it is set, Claude Code starts every session on that model, whatever you picked with/modelbefore.
FAQ
FAQ
Claude Code asks me to log in
Claude Code did not pick up the TokenRa settings. Check that the file is ~/.claude/settings.json (on Windows %USERPROFILE%\.claude\settings.json), that it is valid JSON and that the variables sit inside "env". If you used environment variables, open a new terminal so they are loaded.
HTTP 401: Invalid token
The key is missing, mistyped or deleted. Copy it again from API Keys, and check that ANTHROPIC_BASE_URL is https://tokenra.io rather than Anthropic's address.
HTTP 503: model_not_found
The model ID is wrong, or Claude Code asked for a Claude model that TokenRa does not serve. Set ANTHROPIC_MODEL and the three ANTHROPIC_DEFAULT_*_MODEL variables to IDs from the model list.
HTTP 403: insufficient_user_quota
The account balance is used up. Top up under Wallet in the console and try again.
Responses are slow
Reasoning models can think for a while before each step: Kimi K3.1 Pro needed about 30 seconds for the test task, DeepSeek V4.1 Flash about 5. For quick edits pick a faster model from the table. Claude Code waits up to 10 minutes for each request by default (API_TIMEOUT_MS).
Does my code go to TokenRa?
Yes. Claude Code sends your prompts and the file contents it reads to the API you configure, here TokenRa, which forwards them to the model provider. Zero data retention describes how TokenRa handles request content.
Where can I see usage and cost?
Every request is listed under Usage Logs in the console, with its model, tokens and cost. Live rates are on the Model Square.