Claude Code integration

Point Claude Code at Modellane through the Anthropic Messages API with a few environment variables, and choose a model for each slot.

Claude Code sends requests in the Anthropic Messages format. Set the base URL, your key and the model variables, and its requests go to Modellane models.

Claude Code is Anthropic's coding agent for the terminal. It sends requests in the Anthropic Messages format to the address in ANTHROPIC_BASE_URL, so it can reach Modellane models through POST /v1/messages.

Set the environment variables#

Set these before you start Claude Code:

Shell

export ANTHROPIC_BASE_URL="https://usemodellane.com"
export ANTHROPIC_AUTH_TOKEN="your-api-key"
export ANTHROPIC_MODEL="lane-1"
export ANTHROPIC_DEFAULT_OPUS_MODEL="lane-1"
export ANTHROPIC_DEFAULT_SONNET_MODEL="lane-1"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="lane-1"
export CLAUDE_CODE_SUBAGENT_MODEL="lane-1"
claude
ParamValue
ANTHROPIC_BASE_URLhttps://usemodellane.com, without /v1: Claude Code adds /v1/messages itself
ANTHROPIC_AUTH_TOKENA key from API keys, sent as a bearer token. ANTHROPIC_API_KEY also works; it is sent as x-api-key
ANTHROPIC_MODELThe main model
ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODELThe models behind Claude Code's three model slots
CLAUDE_CODE_SUBAGENT_MODELThe model for subagents

Use any id from Models & pricing for each variable. A common choice is a strong model for the main and Opus slots and a cheaper, faster one for the Haiku slot, which Claude Code uses for small background tasks.

To keep the settings for every session, put the same values in the env block of ~/.claude/settings.json:

JSON

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://usemodellane.com",
    "ANTHROPIC_AUTH_TOKEN": "your-api-key",
    "ANTHROPIC_MODEL": "lane-1",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "lane-1",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "lane-1",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "lane-1",
    "CLAUDE_CODE_SUBAGENT_MODEL": "lane-1"
  }
}

Keep this file out of shared repositories, since it holds your key.

Verify#

Send one test prompt in print mode:

Shell

claude -p "Reply with the word ready."

A reply means the base URL, key and model are right. authentication_error points at the key, not_found_error at a model variable.

What to expect#

  • Tool use works through the Messages API, including Claude Code's file and shell tools. Pick a model that lists Tool calls in Models & pricing.
  • Server tools are skipped: tools that run on Anthropic's servers, such as web search, are removed from the request without an error.
  • Thinking: the model's reasoning comes back as thinking blocks when Claude Code asks for them, but the thinking budget is not applied. Models that reason do so on their own, and reasoning is billed as output tokens.
  • Token counts: when Claude Code asks /v1/messages/count_tokens for the size of a prompt, it gets an estimate from the prompt size. The billed prompt tokens in your usage can differ.
  • Model discovery: Claude Code keeps only Claude model names when it discovers models from a gateway, so Modellane models do not show up there. Choose them with the variables above.
  • Prompt caching is automatic; cache_control markers are accepted and have no extra effect.
  • No PDFs or documents: document blocks are not supported. When Claude Code reads a PDF, the request fails with a 400 error, and the PDF stays in the conversation, so every later request fails too. Run /clear to continue, and convert the file to text first.
  • Up to 128 tools per request: Claude Code's own tools plus every tool from your MCP servers count toward this limit. With many MCP servers connected, requests can fail with a 400 error; disable the servers you do not need.

The Anthropic Messages API guide lists every supported field and limit.

Images#