Tools & integrationsGuide
How to connect Claude Code to CheapTokens
Run Claude Code on open-weight models through the CheapTokens Anthropic-compatible API with four environment variables — and what Anthropic does not support.

Claude Code reads its API address from ANTHROPIC_ — the setting Anthropic documents for gateways. Point it at CheapTokens and name one of our models, and Claude Code sends its requests to our Anthropic-compatible API instead of Anthropic's. The variables follow the Claude Code documentation as of October 2026; the setup has not been run on a live installation yet.
Before you start#
- Claude Code is installed.
- You have a CheapTokens API key and a positive balance — see Your first API request.
Step 1. Set the variables#
export ANTHROPIC_BASE_URL="https://api.cheaptokens.dev"
export ANTHROPIC_API_KEY="your-cheaptokens-key"
export ANTHROPIC_MODEL="deepseek-ai/DeepSeek-V4-Flash-0731"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-ai/DeepSeek-V4-Flash-0731"ANTHROPIC_— the address withoutBASE_ URL /v1: Claude Code adds the path itself.ANTHROPIC_— your CheapTokens key.API_ KEY ANTHROPIC_MODEL— the model for the session.ANTHROPIC_— the model for small background tasks. Without it Claude Code would request a Claude model, which our API does not have.DEFAULT_ HAIKU_ MODEL
Other model IDs: zai- and MiniMaxAI/; see GLM vs DeepSeek vs MiniMax.
Step 2. Check that it works#
Start Claude Code in the same terminal and ask a short question about the project. An answer means the requests go through CheapTokens. If you get an error, look at its status code in Connection errors and fixes.
How to switch back#
Unset the variables (or open a new terminal without them) and start Claude Code again — it returns to its own login and endpoint.
unset ANTHROPIC_BASE_URL ANTHROPIC_API_KEY ANTHROPIC_MODEL ANTHROPIC_DEFAULT_HAIKU_MODELAgents resend the whole conversation on every step, so input tokens make up most of the bill — see What an AI agent costs.



