Claude Code
Route Claude Code through the LuluTokens Anthropic-compatible endpoint.
Claude Code speaks the Anthropic Messages API, which the gateway relays at
POST /v1/messages. It is configured entirely through environment variables — no
config file edit is required.
The base URL here is https://api.lulutokens.ai with no /v1 suffix. The
Anthropic client appends /v1/messages itself; adding /v1 yourself produces
requests to /v1/v1/messages, which the gateway answers with 404.
Configure
Set the environment variables
export ANTHROPIC_BASE_URL="https://api.lulutokens.ai"
export ANTHROPIC_AUTH_TOKEN="sk-..."ANTHROPIC_AUTH_TOKEN — not ANTHROPIC_API_KEY — is the variable for a
third-party gateway: it makes the client send Authorization: Bearer <token>,
which is what LuluTokens expects.
Choose the models
Claude Code uses two models: a main one for reasoning and a small, fast one for background work such as summarising and file classification. Point both at IDs that exist on the gateway:
export ANTHROPIC_MODEL="claude-sonnet-4-5"
export ANTHROPIC_SMALL_FAST_MODEL="claude-haiku-4-5"Run it
claudeCheck /status inside Claude Code — it shows the base URL and model in use, so
you can confirm the traffic is going to LuluTokens.
Keeping it project-local
Exporting the variables globally sends all your Claude Code usage through the gateway. To scope it to one project, put them in that project's settings instead:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.lulutokens.ai",
"ANTHROPIC_AUTH_TOKEN": "sk-...",
"ANTHROPIC_MODEL": "claude-sonnet-4-5"
}
}.claude/settings.json is committed by default. Put the key in
.claude/settings.local.json (git-ignored) instead, or keep the key in the
environment and only set the URL and model here.
Cost
Claude Code replays the full conversation on every turn, so a long session costs far more than the same number of questions asked separately. Two things help:
- Use
/clearbetween unrelated tasks rather than letting one session grow. - Keep
ANTHROPIC_SMALL_FAST_MODELpointed at a genuinely cheap model — it is called constantly in the background.
Per-request cost is visible in the console's usage logs.
Troubleshooting
| Symptom | Fix |
|---|---|
404 on every request | ANTHROPIC_BASE_URL includes /v1 — remove it |
401 | Using ANTHROPIC_API_KEY instead of ANTHROPIC_AUTH_TOKEN |
| Still hitting Anthropic directly | A settings.json env block is overriding your shell exports |
| Works, but the model is wrong | The model variable name differs in your version — see the note above |