Claude Code
Run Claude Code through OpenLLM with openllm claude, map the Opus, Sonnet and Haiku slots to your models, or set ANTHROPIC_BASE_URL yourself.
| Command | openllm claude |
| Mode | Per session. Nothing is installed. |
| Talks to | Anthropic Messages API via ANTHROPIC_BASE_URL |
| Default model | ultra |
| Skip approvals | openllm -d claude (adds --dangerously-skip-permissions) |
| Remove | Nothing to remove. Run claude directly. |
Before you begin
- Install the OpenLLM CLI. See Install.
- Install Claude Code so that
claudeis on yourPATH. If it is missing,openllm claudeprints the official installer,https://claude.ai/install.sh. - Have at least one model available. See Providers.
If no API key is saved yet, the first run asks you to paste your sk-llm-… key and saves it to ~/.openllm/.env.
Set up with openllm claude
openllm claudeEvery argument after claude goes to Claude Code unchanged, so openllm claude --resume behaves like claude --resume. OpenLLM's own flags go before the client name: -d, --new, and --attach [id].
At launch, OpenLLM picks a gateway: your local daemon at http://127.0.0.1:8787 if it answers, otherwise https://www.openllm.sh. It then starts the real claude binary with this session-only setup:
- Temporary files in
~/.openllm/run/claude/<pid>/, passed with--settingsand--mcp-config. They are deleted when Claude Code exits. - Environment:
ANTHROPIC_BASE_URLpoints at the gateway.ANTHROPIC_DEFAULT_OPUS_MODEL=ultra,ANTHROPIC_DEFAULT_SONNET_MODEL=plus, andANTHROPIC_DEFAULT_HAIKU_MODEL=lite. Your key reaches Claude Code through anapiKeyHelperscript that reads it from the environment, so the key is never written to disk. - Removed for the session:
ANTHROPIC_API_KEY,ANTHROPIC_AUTH_TOKEN, andCLAUDE_CODE_OAUTH_TOKEN, so only one credential is active. - Settings layered on yours: default model
ultra, a status line with the directory and context use, and memory hooks that recall before each prompt and save after each turn. Your claude.ai connectors are turned off in these sessions. - MCP: the
openllmserver (openllm mcp). See MCP server.
Your ~/.claude directory, login, history, and projects are untouched.
Interactive sessions run in a background session host. When you run openllm claude without arguments and a Claude Code session is already running on this machine, OpenLLM offers to attach to it. To always start fresh, run openllm --new claude. To list sessions, run openllm sessions list.
Set up without the CLI
openllm claude is the recommended path. To run Claude Code against OpenLLM without the OpenLLM CLI, set these variables in the shell that starts claude:
export ANTHROPIC_BASE_URL="https://www.openllm.sh"
export ANTHROPIC_AUTH_TOKEN="sk-llm-YOUR_KEY"
export ANTHROPIC_DEFAULT_OPUS_MODEL="ultra"
export ANTHROPIC_DEFAULT_SONNET_MODEL="plus"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="lite"
claude --model ultra- Leave
/v1offANTHROPIC_BASE_URL. Claude Code adds/v1/messagesitself. ANTHROPIC_AUTH_TOKENsends your key asAuthorization: Bearer, andANTHROPIC_API_KEYsends it asx-api-key. OpenLLM accepts either. Set only one of them.- If you are also signed in to claude.ai, Claude Code can warn that two credentials are set.
openllm claudeavoids this by removing the other credentials for the session. - To use the daemon on the same machine, set
ANTHROPIC_BASE_URL="http://127.0.0.1:8787". See Use the local daemon.
A manual setup doesn't get the memory hooks, the status line, or the openllm MCP server. To add the MCP server yourself, see MCP server.
Choose models
Claude Code's three model slots map to OpenLLM aliases:
| Claude Code slot | OpenLLM model |
|---|---|
| Opus | ultra |
| Sonnet | plus |
| Haiku | lite |
To pin a specific model, pass its id: openllm claude --model <provider/model>, or use /model inside a session. Get ids from GET /v1/models. To change what ultra, plus, and lite resolve to, edit the chains in Configuration. See Routing and fallback.
To turn off automatic memory, set MEMORY_AUTO_RECALL=0 or MEMORY_AUTO_SAVE=0. See Memory.
Who pays for a request
The model that serves the request decides. A Claude subscription hop runs on your own Claude login through the daemon on one of your devices. An API-key hop bills your provider account. Included openllm/ models count against your plan's allowance. See Providers and Plans and limits.
Check that it works
openllm claude -p "Reply with OK"The reply prints to your terminal. Open Overview in the app: the request appears with the model that served it.
Common problems
| Symptom | Cause | Fix |
|---|---|---|
Claude Code is not installed | claude is not on your PATH | Install Claude Code, then run openllm claude again |
No models are available for your OpenLLM account. | Nothing in your model list | Connect a provider on Providers |
OpenLLM could not authorize the model-list check. | Key is invalid or revoked | Save a new key with openllm login |
-d turns on Claude Code's debug mode | -d was placed after claude | Put it first: openllm -d claude |
403 subscription_requires_daemon | The chain has only subscription models and no device can serve them | Run openllm start, or add an API-key model to the chain. See Errors |
| claude.ai connectors are missing | They are off in OpenLLM sessions | Run claude directly when you need them |
For anything else, see Troubleshooting.
Remove it
There is nothing to uninstall. Exit Claude Code and run claude directly to use it without OpenLLM. Temporary files are deleted on exit; files left by a crashed launch are cleaned up on the next launch.
Last updated on
Clients
Connect Claude Code, Codex, OpenCode, Grok Build, Hermes, Raycast, ChatGPT for Mac or DeepSeek Harness to OpenLLM, or any OpenAI or Anthropic client.
Codex
Run the Codex CLI through OpenLLM with openllm codex, pick a model with -m, or add OpenLLM as a custom model provider in ~/.codex/config.toml.