Use any model in Claude Code with Redline
Claude Code talks to an Anthropic-style Messages endpoint. Redline exposes one, so you can point the CLI at it and drive a non-Claude model through the same agent, with a per-key spend cap and no prompt retention.
The base URL, the token and the model
Claude Code reads its endpoint from ANTHROPIC_BASE_URL. It appends /v1/messages itself, so the base URL is https://redline-gateway.pages.dev with no path. The key goes in ANTHROPIC_AUTH_TOKEN, sent as an Authorization: Bearer header. This setup was verified end to end with Claude Code 2.1.268.
# Put these in your shell profile, then run: claude
export ANTHROPIC_BASE_URL=https://redline-gateway.pages.dev
export ANTHROPIC_AUTH_TOKEN=rl-...
export ANTHROPIC_MODEL=qwen/qwen3-coder-30b-a3b-instruct
export ANTHROPIC_DEFAULT_HAIKU_MODEL=qwen/qwen3-30b-a3b-instruct-2507
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=262144
Or set the same values under env in your Claude Code settings file:
// ~/.claude/settings.json
{
"env": {
"ANTHROPIC_BASE_URL": "https://redline-gateway.pages.dev",
"ANTHROPIC_AUTH_TOKEN": "rl-...",
"ANTHROPIC_MODEL": "qwen/qwen3-coder-30b-a3b-instruct",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen/qwen3-30b-a3b-instruct-2507",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "262144"
}
}
Use ANTHROPIC_AUTH_TOKEN and leave ANTHROPIC_API_KEY unset. Both are accepted (auth token as a bearer header, api key as x-api-key), but do not set both. ANTHROPIC_SMALL_FAST_MODEL is deprecated; the Haiku model is what runs background calls like session titles.
Swap qwen/qwen3-coder-30b-a3b-instruct for any model on the Claude Code model list. ANTHROPIC_DEFAULT_HAIKU_MODEL is the small model Claude Code uses for background work such as session titles; qwen/qwen3-30b-a3b-instruct-2507 above was the tested Haiku slot.
Set the context length yourself
Claude Code does not recognise a non-Claude model id, so it assumes a 200K context. If your model is larger or smaller, set CLAUDE_CODE_MAX_CONTEXT_TOKENS to its real value (it is 262,144 for the model above). Every model page lists the number to use.
The model must support tool calling
Claude Code reads, edits and runs commands only through tool calls, so the model you set here must support tool calling. A model without it can chat but cannot touch your files. Redline marks tool support on every model page. A model without it returns a 400 that names the model and costs nothing, so a wrong pick fails fast rather than billing you.
What it costs
Claude Code sends roughly 25,000 tokens of system prompt and tool definitions on every call, before your own message. On a cheap model like the pair above, a single simple prompt cost about $0.004 in testing. That is small, but it is per call and an agent makes many, so put a spend cap on the key.
What does not work
- WebSearch does not work. Claude Code's built-in WebSearch is an Anthropic server-side tool; the gateway cannot translate it, so it fails. Your own file and Bash tools work.
- Reasoning does not carry between turns. A reasoning model's thinking is not preserved across turns through the gateway. DeepSeek V4 Flash, for example, shows its reasoning as thinking blocks within a turn.
- A model may write a tool call as text. Some models occasionally emit a tool call as plain text instead of calling the tool. The gateway cannot fix that; it is the model.
- Token counts are estimates. The count_tokens path is an estimate, not an exact count.
- Refuses less, not never. An uncensored finetune is loosely aligned and can still refuse; there are zero abliterated models live today. Nothing here guarantees a model will answer anything.
FAQ
Does the /model picker list Redline models?
No. Claude Code only surfaces ids it recognises as Claude. Set the model with the ANTHROPIC_MODEL environment variable instead.
Why set CLAUDE_CODE_MAX_CONTEXT_TOKENS?
Claude Code does not know a non-Claude model, so it assumes a 200K context. Setting this variable to the model's real context length stops it from truncating too early or overrunning the model.
Will the spend cap stop a runaway agent?
Yes. Redline reserves the worst-case cost before each call and clamps the response length to what the cap covers, so an agent stuck in a loop cannot bill past the cap you set on the key.
Does WebSearch work?
No. Claude Code's WebSearch is an Anthropic server-side tool that the gateway cannot translate. File editing and Bash work; web search does not.
Are my prompts stored?
No. Redline stores the model id, token counts and cost, not the prompt or completion, and returns a signed receipt of the prompt hash. See the privacy page.
Pick a model
Every model below is in the live catalogue and supports tool calling. Prices include the margin; each links to its own page with the exact environment block and context length.