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

The snippets below use claude-sonnet-5-5. Pick another model to update them.

Windows

  1. Install Claude Code, then open a new terminal window.
    PowerShell
    irm https://claude.ai/install.ps1 | iex
  2. Create the file %USERPROFILE%\.claude\settings.json with this content. If the file already exists, add the env block to it. Note that the base URL has no /v1 at 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"
      }
    }
  3. Go to your project folder and start Claude Code. It skips the Anthropic login because the key is already set.
    PowerShell
    claude
  4. Type /status. It should show https://cheaptokens.pw as the Anthropic base URL. Then send a message.
  5. 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

  1. Install Claude Code, then open a new terminal window.
    Terminal
    curl -fsSL https://claude.ai/install.sh | bash
  2. Create the file ~/.claude/settings.json with this content. If the file already exists, add the env block to it. Note that the base URL has no /v1 at 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"
      }
    }
  3. Go to your project folder and start Claude Code. It skips the Anthropic login because the key is already set.
    Terminal
    claude
  4. Type /status. It should show https://cheaptokens.pw as the Anthropic base URL. Then send a message.
  5. 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

  1. Install Claude Code, then open a new terminal window.
    Terminal
    curl -fsSL https://claude.ai/install.sh | bash
  2. Create the file ~/.claude/settings.json with this content. If the file already exists, add the env block to it. Note that the base URL has no /v1 at 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"
      }
    }
  3. Go to your project folder and start Claude Code. It skips the Anthropic login because the key is already set.
    Terminal
    claude
  4. Type /status. It should show https://cheaptokens.pw as the Anthropic base URL. Then send a message.
  5. 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

If something goes wrong

What you seeWhat to do
401 or invalid_api_keyThe key is wrong, disabled or has extra spaces. Create a new key and paste it again.
402 or insufficient_quotaYour balance is empty. Top up under Billing.
404 or model_not_foundThe model ID has a typo. Copy it from the models page.
404 on every requestThe base URL is wrong. Check whether this tool needs the /v1 ending (see the steps above).
429Too many requests per minute. Wait a few seconds and retry.

Prefer a guided version? Open the setup wizard →