ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN. Do not add /v1 to the Claude Code Base URL.
Prerequisites
- Claude Code installed (see Claude Code docs)
- BetterToken API Key (register here (
https://www.bettertoken.ai/register))
Setup
- Automatic setup
- Configure via CC Switch
- Manual setup
You can run the BetterToken automatic setup script directly. It only writes the BetterToken provider configuration and does not replace the installation prerequisites above. The script requires
Node.js. If you do not pass an API Key or model explicitly, the script prompts for them when the tool supports interactive input.Follow the step for your operating system. You only need one of them.Use the VS Code extension
If you use the Claude Code VS Code extension:Set environment variables
If you use a
Claude_* key, click Edit in settings.json and update claudeCode.environmentVariables:Add model mappings for Codex_* keys
If your API Key belongs to the
Codex_* group, use:gpt-5.4 is only an example Codex group model ID. Copy the current model ID from the BetterToken model plaza (https://www.bettertoken.ai/pricing). When the extension uses the Opus tier by default, it will resolve through ANTHROPIC_DEFAULT_OPUS_MODEL.Verify the setup
Start Claude Code and send a message. A normal reply means the connection is working. If authentication fails, check:ANTHROPIC_AUTH_TOKENcontains the correct BetterToken API KeyANTHROPIC_BASE_URLishttps://www.bettertoken.aiClaude_*keys are not setting model variables, orCodex_*keys include theANTHROPIC_DEFAULT_*_MODELmappings- No old environment variables are overriding your config
FAQ
What should I do if I see API Error: Unable to connect to API (ConnectionRefused)?
What should I do if I see API Error: Unable to connect to API (ConnectionRefused)?
This usually means Claude Code cannot reach the BetterToken API. It is normally a network, proxy, or firewall issue, not an API Key or model mapping problem.Check that your local network is working, then confirm your system proxy, company network, router, or security software is not blocking
https://www.bettertoken.ai. If you use a firewall, allow Claude Code to access that address.