Skip to main content
Claude Code reads two environment variables to decide where to send requests. Point 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

Set up the environment

claude-code-windows.cmd
Always pass --model with your registered model name. Claude Code’s model picker only lists claude* ids, so it won’t show your Tokios models — naming it explicitly routes the request to your deployment.

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.
~/.bashrc or ~/.zshrc Open your shell profile and append:
Then reload it:
.env file If your workflow supports .env files (for example, via direnv or a shell plugin), create a .env in your project root:
.env
Load it before starting Claude Code:

Verify the connection

Run a quick one-shot prompt to confirm that Claude Code is reaching your local model through Tokios:
Expected output:
If you see a response, your requests are flowing through the Tokios gateway to your local model successfully.
Claude Code sends the request in Anthropic messages format. Tokios translates it to whatever your local backend expects and streams the response back.