ANTHROPIC_BASE_URL at Tokios and set your Tokios API key, and Claude Code runs against a local model on Ollama, LM Studio, llama.cpp, or vLLM — from any machine, not just the one running the model. Every request goes down your private tunnel to your own hardware.
Prerequisites
- A running Tokios Connector paired with your local model — see Connector Install
- A registered model deployment name — see Register a Model
- A Tokios API key — see API Keys
- Claude Code installed
Set up the environment
- Windows CMD
- macOS & Linux
claude-code-windows.cmd
Persist the configuration
To avoid exporting the variables in every new terminal session, add them to Claude Code’s own settings file, your shell profile, or a.env file.
~/.claude/settings.json
The most portable option, because it travels with your Claude Code config rather than your shell. Use .claude/settings.json inside a project to scope it to that project instead:
~/.claude/settings.json
Claude Code reads this file at startup, so a session that is already open won’t pick up an edit until you restart it. If your key is rejected here, swap
ANTHROPIC_API_KEY for ANTHROPIC_AUTH_TOKEN, which sets the raw Authorization: Bearer value — the form gateways that issue their own keys expect..env files (for example, via direnv or a shell plugin), create a .env in your project root:
.env
Verify the connection
Run a quick one-shot prompt to confirm that Claude Code is reaching your local model through Tokios:Claude Code sends the request in Anthropic messages format. Tokios translates it to whatever your local backend expects and streams the response back.