Claude Code setup
Claude Code reads its API address, key and models from environment variables. Set them to Claudech and every request it makes is billed per token from your Claudech balance. This guide covers macOS, Linux and Windows.
Before you start#
- Claude Code installed. Follow Anthropic's installation instructions; this guide only changes where it sends requests.
- A Claudech API key. Create one under API keys. API access unlocks after your first purchase; any token package is enough.
1. Check the key works#
Claude Code uses the Anthropic Messages format, so test that endpoint directly:
curl https://api.claudech.com/v1/messages \
-H "x-api-key: sk-..." \
-H "anthropic-version: 2026-10-04" \
-H "Content-Type: application/json" \
-d '{"model": "claude-fable-5-1", "max_tokens": 256, "messages": [{"role": "user", "content": "Say hello"}]}'2. Set the environment variables#
export ANTHROPIC_BASE_URL="https://api.claudech.com"
export ANTHROPIC_AUTH_TOKEN="sk-..." # sent as Authorization: Bearer
export ANTHROPIC_MODEL="claude-fable-5-1" # main model
export ANTHROPIC_SMALL_FAST_MODEL="claude-sonnet-5" # background and quick tasks
claude| Variable | Value | Notes |
|---|---|---|
ANTHROPIC_BASE_URL | https://api.claudech.com | No /v1. Claude Code appends /v1/messages itself |
ANTHROPIC_AUTH_TOKEN | your sk-... key | Sent as Authorization: Bearer. ANTHROPIC_API_KEY (sent as x-api-key) also works; set one, not both |
ANTHROPIC_MODEL | a Claudech model id | The main model for new sessions |
ANTHROPIC_SMALL_FAST_MODEL | a Claudech model id | Used for background and quick tasks; a fast model keeps sessions responsive |
Do not point ANTHROPIC_BASE_URL at https://api.claudech.com/v1 or /v1/chat/completions. Those are the OpenAI-format endpoints, and Claude Code requests to them fail.
3. Make it permanent#
Variables set in a terminal only last for that session. To apply them every time, add the export lines to your shell profile (~/.zshrc or ~/.bashrc), or put them in ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.claudech.com",
"ANTHROPIC_AUTH_TOKEN": "sk-...",
"ANTHROPIC_MODEL": "claude-fable-5-1",
"ANTHROPIC_SMALL_FAST_MODEL": "claude-sonnet-5"
}
}On Windows, settings.json is in %USERPROFILE%\.claude\.
4. Switch models#
Inside a session, run /model and enter any Claudech model id, for example claude-opus-5 for hard debugging or claude-sonnet-5 for quick edits. The full list with prices is on Models.
Costs#
Agent sessions send long prompts: the conversation, file contents and tool output are resent on every turn. Most of that repeats, so it is served from the prompt cache and billed at the much lower cached-input rate automatically. Each request appears on the Usage page with its tokens and cost. To estimate a month of use, try the AI API cost calculator.
Troubleshooting#
| Symptom | Cause | Fix |
|---|---|---|
404 or "not found" on every request | ANTHROPIC_BASE_URL includes /v1 or /v1/chat/completions | Set it to exactly https://api.claudech.com |
401 invalid_api_key | Key copied with whitespace, or a revoked key | Re-copy the key; check its status under API keys |
messages.1.role: Invalid option | Claude Code 2.1.154+ puts hook output in a system message | Claudech handles this automatically; make sure the base URL is the Anthropic address above |
thinking.type: Invalid option | Claude Code 2.1.221+ sends adaptive thinking settings | Handled automatically on Claudech |
402 insufficient_balance | Your balance is empty | Top up under Billing |
| Variables ignored | They were set in a different terminal, or both ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY are set | Set them in the terminal that runs claude, or use settings.json; keep only one key variable |
For Cursor, see Cursor setup. Other editors and chat apps are on Other tools.
Claude Code is a product of Anthropic. Claudech is an independent service and is not affiliated with, endorsed by or sponsored by Anthropic.