Setup guide
Connect Claude Code CLI
Claude Code is Anthropic's coding agent for the terminal. It talks to CheapTokens in the native Claude Messages format, so you only change three settings.
Before you start
- A CheapTokens account with some balance. Create one if you haven't.
- Your API key from Dashboard → API key. It starts with
ct_live_. - A model that supports the Claude Messages format. Claude models all do, and the model list on this page shows the others.
The snippets below use claude-sonnet-5-5. Pick another model to update them.
Windows
-
Install Claude Code, then open a new terminal window.PowerShell
irm https://claude.ai/install.ps1 | iex
-
Create the file
%USERPROFILE%\.claude\settings.jsonwith this content. If the file already exists, add theenvblock to it. Note that the base URL has no/v1at the end.settings.json{ "env": { "ANTHROPIC_BASE_URL": "https://cheaptokens.pw", "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY", "ANTHROPIC_MODEL": "claude-sonnet-5-5", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5" } } -
Go to your project folder and start Claude Code. It skips the Anthropic login because the key is already set.PowerShell
claude
-
Type
/status. It should show https://cheaptokens.pw as the Anthropic base URL. Then send a message. -
Using the Claude Code extension for VS Code instead? Install it (
code --install-extension anthropic.claude-code), open the Command Palette, run Preferences: Open User Settings (JSON) and add this inside the outer braces:VS Code settings.json"claudeCode.environmentVariables": [ { "name": "ANTHROPIC_BASE_URL", "value": "https://cheaptokens.pw" }, { "name": "ANTHROPIC_AUTH_TOKEN", "value": "YOUR_API_KEY" }, { "name": "ANTHROPIC_MODEL", "value": "claude-sonnet-5-5" } ]
macOS
-
Install Claude Code, then open a new terminal window.Terminal
curl -fsSL https://claude.ai/install.sh | bash
-
Create the file
~/.claude/settings.jsonwith this content. If the file already exists, add theenvblock to it. Note that the base URL has no/v1at the end.settings.json{ "env": { "ANTHROPIC_BASE_URL": "https://cheaptokens.pw", "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY", "ANTHROPIC_MODEL": "claude-sonnet-5-5", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5" } } -
Go to your project folder and start Claude Code. It skips the Anthropic login because the key is already set.Terminal
claude
-
Type
/status. It should show https://cheaptokens.pw as the Anthropic base URL. Then send a message. -
Using the Claude Code extension for VS Code instead? Install it (
code --install-extension anthropic.claude-code), open the Command Palette, run Preferences: Open User Settings (JSON) and add this inside the outer braces:VS Code settings.json"claudeCode.environmentVariables": [ { "name": "ANTHROPIC_BASE_URL", "value": "https://cheaptokens.pw" }, { "name": "ANTHROPIC_AUTH_TOKEN", "value": "YOUR_API_KEY" }, { "name": "ANTHROPIC_MODEL", "value": "claude-sonnet-5-5" } ]
Linux
-
Install Claude Code, then open a new terminal window.Terminal
curl -fsSL https://claude.ai/install.sh | bash
-
Create the file
~/.claude/settings.jsonwith this content. If the file already exists, add theenvblock to it. Note that the base URL has no/v1at the end.settings.json{ "env": { "ANTHROPIC_BASE_URL": "https://cheaptokens.pw", "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY", "ANTHROPIC_MODEL": "claude-sonnet-5-5", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5" } } -
Go to your project folder and start Claude Code. It skips the Anthropic login because the key is already set.Terminal
claude
-
Type
/status. It should show https://cheaptokens.pw as the Anthropic base URL. Then send a message. -
Using the Claude Code extension for VS Code instead? Install it (
code --install-extension anthropic.claude-code), open the Command Palette, run Preferences: Open User Settings (JSON) and add this inside the outer braces:VS Code settings.json"claudeCode.environmentVariables": [ { "name": "ANTHROPIC_BASE_URL", "value": "https://cheaptokens.pw" }, { "name": "ANTHROPIC_AUTH_TOKEN", "value": "YOUR_API_KEY" }, { "name": "ANTHROPIC_MODEL", "value": "claude-sonnet-5-5" } ]
Check that it works
Send a short message in Claude Code CLI, then open Dashboard → Usage. The request appears there within a few seconds, with its model, tokens and cost.
Good to know
- Already signed in to Claude Code with an Anthropic account? Type
/logoutonce so the two logins don't clash. - Switch model at any time with
/model claude-sonnet-5-5, or start withclaude --model claude-sonnet-5-5. ANTHROPIC_DEFAULT_HAIKU_MODELis the small model Claude Code uses for background jobs such as naming sessions.- For one terminal session only, you can set
ANTHROPIC_BASE_URLandANTHROPIC_AUTH_TOKENas environment variables instead of editing the file. - Don't put your key in a project's own
.claude/settings.json. That file is usually committed to git.
If something goes wrong
| What you see | What to do |
|---|---|
401 or invalid_api_key | The key is wrong, disabled or has extra spaces. Create a new key and paste it again. |
402 or insufficient_quota | Your balance is empty. Top up under Billing. |
404 or model_not_found | The model ID has a typo. Copy it from the models page. |
| 404 on every request | The base URL is wrong. Check whether this tool needs the /v1 ending (see the steps above). |
| 429 | Too many requests per minute. Wait a few seconds and retry. |
Prefer a guided version? Open the setup wizard →