Claude Code custom API: Opus, Sonnet and Haiku 5.5 on Lazu

Guide Claude Code custom API claude-sonnet-5-5claude-opus-5-5 Lazu

Short answer: set ANTHROPIC_BASE_URL to https://api.lazu.ai and ANTHROPIC_AUTH_TOKEN to your Lazu key, and Claude Code bills by API usage instead of a Claude subscription. Use Sonnet 5.5 day to day, switch to Opus 5.5 for hard problems, and leave background work to Haiku 5.5.

You need Claude Code 2.1.293 or later (Opus 5.5 needs 2.1.280, Sonnet 5.5 2.1.284, Haiku 5.5 2.1.293). Check with claude --version.

The quick way: one script #

In Console › API Keys, pick a key, choose Connect, choose Claude Code and copy the one-line script:

curl -fsSL https://api.lazu.ai/setup/claude-code | sh -s -- --model claude-sonnet-5-5 --opus claude-opus-5-5 --light claude-haiku-5-5

The script asks for the key in the terminal, so it stays out of your shell history. It writes ~/.claude/settings.json, and the next Claude Code session uses it. On Windows, use the PowerShell version from the same dialog.

Manual setup #

Edit ~/.claude/settings.json in your home directory. Don't put credentials in a project's .claude/settings.json that gets committed.

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.lazu.ai",
    "ANTHROPIC_AUTH_TOKEN": "sk-lazu-...",
    "ANTHROPIC_DEFAULT_MODEL": "claude-sonnet-5-5",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5",
    "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1",
    "CLAUDE_CODE_ATTRIBUTION_HEADER": "0"
  }
}
Variable What it does
ANTHROPIC_BASE_URL Sends requests to Lazu. No /v1; Claude Code adds the path.
ANTHROPIC_AUTH_TOKEN Your Lazu key, sent as Authorization: Bearer. It takes precedence over ANTHROPIC_API_KEY.
ANTHROPIC_DEFAULT_MODEL The model new sessions start on
ANTHROPIC_DEFAULT_OPUS / SONNET / HAIKU_MODEL What /model opus, /model sonnet and /model haiku mean. The HAIKU one also runs background tasks.
Last two lines Compatibility settings; keep them. The first stops Claude Code from sending experimental beta headers, which some upstreams reject.

If you set ANTHROPIC_MODEL before: it overrides the default you save in /model, so every launch switches back. To switch freely with /model, use ANTHROPIC_DEFAULT_MODEL as above.

Then run /status inside Claude Code. It shows the API base URL and the credential in use, so you can confirm it points at Lazu.

Splitting work across the three models #

Model Price (input / output, USD per million tokens) Good for
Opus 5.5 $4 / $20 Hard problems, architecture, long planning
Sonnet 5.5 $2 / $10 Everyday coding, bug fixes, most agent work
Haiku 5.5 $0.10 / $0.50 (prompts up to 100K tokens) Subagents, background tasks, simple bulk edits

Useful setups:

  • /model opusplan plans with Opus and executes with Sonnet.
  • Give subagents their own model with model: haiku in the subagent definition, or with CLAUDE_CODE_SUBAGENT_MODEL. The built-in Explore subagent runs on your main model, not Haiku, unless you define your own.
  • In Claude Code, thinking can't be turned off on any of the three; the default effort is medium, and thinking is billed as output.

The Haiku 5.5 100K trap #

When a Haiku 5.5 prompt (including cache reads and writes) is over 100,000 tokens, every price for that whole request is 5x: $0.50 input and $2.50 output. Claude Code gives Haiku 5.5 a 1M context window, so long sessions cross 100K easily.

Use Haiku 5.5 in the HAIKU slot for background tasks and subagents; avoid it as the main model for long sessions. The full arithmetic is in Claude Haiku 5.5 costs 5x past 100K tokens.

Prices and lanes #

Claude models on Lazu have two lanes:

  • Stable: Anthropic's official API at the official price. Use it for anything.
  • Discount: a reverse-engineered channel. A third-party supplier connects through the official client; it is not the official API. Much cheaper, but recommended only inside Claude Code. Availability varies, a failure does not fall back to the stable lane, and the upstream may add its own system prompt.

Switching needs no config change: edit the key in the console and set that model to Discount. Keep your own programs on the stable lane. Current prices, read live from the catalog:

claude-sonnet-5-5Anthropic · 1M · Stable $2.00 / $10.00 · Discount $0.86 / $4.30Model page →

USD per million tokens

LaneInputOutputCache readCache write
Anthropic official price$2.00$10.00$0.10$2.50 (5m)
Lazu Stable · Same as official$2.00$10.00$0.10$2.50 (5m)
Lazu Agent · −57%$0.86$4.30$0.043$1.07 (5m)

A dash means no price is recorded, not free usage. The request receipt is the final billing record.

claude-opus-5-5Anthropic · 1M · Stable $4.00 / $20.00 · Discount $1.72 / $8.60Model page →

USD per million tokens

LaneInputOutputCache readCache write
Anthropic official price$4.00$20.00$0.20$5.00 (5m)
Lazu Stable · Same as official$4.00$20.00$0.20$5.00 (5m)
Lazu Agent · −57%$1.72$8.60$0.086$2.15 (5m)

A dash means no price is recorded, not free usage. The request receipt is the final billing record.

Check that it works #

claude -p "Introduce yourself in one sentence"

An answer means you are connected. The console's usage log shows each request's model, lane, tokens and charge. To see what a whole task cost, reconcile its session.

Troubleshooting #

Can I use DeepSeek or GPT in Claude Code? Yes. Claude Code speaks only Anthropic's Messages protocol, and Lazu translates its requests for other models: start it with claude --model deepseek-flash or claude --model gpt-6-luna, and tool calls such as reading files and editing code work as usual. We don't recommend Gemini in Claude Code yet; it isn't reliable there. For how the translation works, see Claude Code on GPT and DeepSeek: how Lazu translates APIs. You can also code with GPT, DeepSeek, Kimi or GLM in Codex; see Codex with third-party models. The same Lazu key works in both.

You signed in with a Claude subscription before: run /logout in Claude Code first. With only the base URL set and no key, Claude Code keeps using the subscription.

401: the key is wrong, or settings.json isn't valid JSON (a trailing comma, for example). You can also try ANTHROPIC_API_KEY in place of ANTHROPIC_AUTH_TOKEN.

400 about an unsupported beta: check that CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS is "1".

Model not found: the ID is wrong, the key is limited to other models, or your Claude Code is too old to know the 5.5 models.

Next #

Related
2026-11-18Claude Code gateway contract: 10 traps that stall agents 2026-09-30LLM API pricing comparison: Claude, GPT, Gemini, DeepSeek 2026-11-18OpenCode custom provider: Claude, GPT and DeepSeek on Lazu

Try it with a key

Start free