$Cheapa API Docs

Claude Code CLI

Configure Anthropic's Claude Code CLI to route through Cheapa API for unified billing and model access.

What This Does

Claude Code is Anthropic's official CLI for AI-assisted development. By configuring it to use Cheapa API's endpoint, you can use any supported model — not just Claude — while consolidating all your AI spend under a single Cheapa API account. Your token usage draws from your Cheapa API balance automatically.


Setup

Step 1: Locate Your Settings File

Claude Code stores its configuration in a settings.json file. Find it based on your OS:

OSPath
macOS / Linux~/.claude/settings.json
Windows%USERPROFILE%\.claude\settings.json

If the file doesn't exist, create it.

Step 2: Configure Environment Variables

Open settings.json and add the following configuration:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.cheapaapi.com/",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_Cheapa API_API_KEY",
    "ANTHROPIC_MODEL": "gpt-5.4",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "kimi-k2.7-code",
    "ANTHROPIC_SMALL_FAST_MODEL": "glm-5-turbo"
  }
}

Replace YOUR_Cheapa API_API_KEY with your actual key from cheapaapi.com/keys.

Step 3: Alternative — Environment Variables in Shell

If you prefer not to modify the settings file, set environment variables in your shell:

export ANTHROPIC_BASE_URL="https://api.cheapaapi.com/"
export ANTHROPIC_AUTH_TOKEN="YOUR_Cheapa API_API_KEY"

Add these to your ~/.zshrc or ~/.bashrc to persist across sessions.

Step 4: Verify the Connection

Run Claude Code and start a conversation:

claude

Try a simple prompt to confirm the connection works.


Use CaseModelWhy
Complex reasoning & planninggpt-5.4Highest capability
Code generation & refactoringkimi-k2.7-codeOptimized for code
Large codebase analysisgemini-3.1-pro1M+ token context
Quick operationsglm-5-turboFast, low latency
Budget workloadsglm-5Cost-effective

Troubleshooting

Connection refused or timeout

  • Verify the base URL is exactly https://api.cheapaapi.com/ (with trailing slash for Claude Code)
  • Check that your API key is valid at cheapaapi.com/keys

Authentication errors

  • Ensure ANTHROPIC_AUTH_TOKEN is set, not ANTHROPIC_API_KEY — Claude Code expects the token variant
  • Remove any quotes around the key if you're setting it via shell export

Model not found errors

  • Use model slugs exactly as shown in the Models reference
  • Claude Code may require you to specify a model explicitly if the default isn't recognized

Notes

  • Claude Code was designed for Claude models but works with any OpenAI-compatible endpoint
  • The ANTHROPIC_SMALL_FAST_MODEL is used for background tasks — set it to a low-cost model
  • All token consumption appears in your Cheapa API dashboard in real-time

On this page