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
VariableValueNotes
ANTHROPIC_BASE_URLhttps://api.claudech.comNo /v1. Claude Code appends /v1/messages itself
ANTHROPIC_AUTH_TOKENyour sk-... keySent as Authorization: Bearer. ANTHROPIC_API_KEY (sent as x-api-key) also works; set one, not both
ANTHROPIC_MODELa Claudech model idThe main model for new sessions
ANTHROPIC_SMALL_FAST_MODELa Claudech model idUsed for background and quick tasks; a fast model keeps sessions responsive
Use the Anthropic address

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:

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#

SymptomCauseFix
404 or "not found" on every requestANTHROPIC_BASE_URL includes /v1 or /v1/chat/completionsSet it to exactly https://api.claudech.com
401 invalid_api_keyKey copied with whitespace, or a revoked keyRe-copy the key; check its status under API keys
messages.1.role: Invalid optionClaude Code 2.1.154+ puts hook output in a system messageClaudech handles this automatically; make sure the base URL is the Anthropic address above
thinking.type: Invalid optionClaude Code 2.1.221+ sends adaptive thinking settingsHandled automatically on Claudech
402 insufficient_balanceYour balance is emptyTop up under Billing
Variables ignoredThey were set in a different terminal, or both ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY are setSet 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.