Michael Limberger
Need me? Email mike@limberger.ca
AI
Configuration
Point the CLI at your box
This is where we tell Claude Code to talk to Ollama instead of Anthropic's cloud. Claude Code runs on the workstation. Your configured model runs on the Ollama server.
Ollama controls, via the Modelfile: context window size (num_ctx), model parameters like temperature, and which base model.
Claude Code controls, via env vars or settings.json: where to send requests, which model name, timeouts and permissions, and Claude Code behavior.
You cannot set the context window in Claude Code config.
That value is baked into the Ollama model.
If you skipped the Modelfile in the last part, go back.
Set up both for reliability.
Environment variables in ~/.zshrc take priority.
~/.claude/settings.json is the backup.
If both exist, env vars win.
The same six lines, two homes
Show me.
In ~/.zshrc, then source ~/.zshrc:
export ANTHROPIC_BASE_URL="http://10.0.0.79:11434"
export ANTHROPIC_AUTH_TOKEN="ollama"
export ANTHROPIC_MODEL="qwen3-coder-32k"
export ANTHROPIC_SMALL_FAST_MODEL="qwen3-coder-32k"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1"
export API_TIMEOUT_MS="600000"
Settings file:
mkdir -p ~/.claude
nano ~/.claude/settings.json
{
"env": {
"ANTHROPIC_BASE_URL": "http://10.0.0.79:11434",
"ANTHROPIC_AUTH_TOKEN": "ollama",
"ANTHROPIC_MODEL": "qwen3-coder-32k",
"ANTHROPIC_SMALL_FAST_MODEL": "qwen3-coder-32k",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
"API_TIMEOUT_MS": "600000"
}
}
Replace 10.0.0.79 with your Ollama IP, or use localhost.
Replace qwen3-coder-32k with the name ollama list shows.
Common mistake: using the base model (qwen3-coder-next:latest) instead of the configured one.
If you do that, you get 4K context and wonder why everything feels broken.
What each line is for
ANTHROPIC_BASE_URL is where to send API requests.
Normally that is Anthropic's cloud.
We point it at Ollama's Anthropic-compatible endpoint.
Format: http://HOST:PORT.
Default Ollama port is 11434.
Same machine: localhost.
Remote: the IP, or a hostname if DNS works.
ANTHROPIC_AUTH_TOKEN is normally your Anthropic API key.
Ollama does not need authentication, but Claude Code will not start without something here.
ollama is a dummy value.
Any non-empty string works.
This does not affect security.
Ollama ignores it.
ANTHROPIC_MODEL must exactly match a model name in Ollama.
Wrong: qwen3-coder-next:latest (the base model, 4K context).
Right: qwen3-coder-32k.
You can switch later: 8k for light and fast, 32k for normal coding, 64k for large codebases.
ANTHROPIC_SMALL_FAST_MODEL is what Claude Code uses for quick tasks like summarization.
With local models, use the same model name.
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC set to "1" (as a string) stops Claude Code contacting Anthropic for telemetry and updates.
Without this, it may hang.
API_TIMEOUT_MS is how long to wait, in milliseconds.
The default is too short for local models (30 to 120 seconds per response is common).
600000 is 10 minutes.
900000 is 15.
If you see timeout errors, increase it.
Yolo mode, if you want it
By default Claude Code asks permission before editing files or running commands. You can pre-approve:
{
"env": {
"ANTHROPIC_BASE_URL": "http://10.0.0.79:11434",
"ANTHROPIC_AUTH_TOKEN": "ollama",
"ANTHROPIC_MODEL": "qwen3-coder-32k",
"ANTHROPIC_SMALL_FAST_MODEL": "qwen3-coder-32k",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
"API_TIMEOUT_MS": "600000"
},
"permissions": {
"allow": [
"Bash", "Read", "Write", "Edit", "MultiEdit", "NotebookEdit"
],
"deny": []
}
}
Bash means any shell command. Read means any file. Write creates or overwrites. Edit modifies. MultiEdit touches several files. NotebookEdit is for Jupyter. This is yolo mode. Great for productivity. Risky if you are not paying attention.
More selective allow list: Bash(npm run *), Bash(git *), Bash(prove *), plus Read, Write, Edit.
Deny examples: Bash(rm -rf *) and Bash(sudo *).
First launch: cd ~/some-project-directory then claude.
You will see a login prompt with options for a Claude account with subscription, an Anthropic Console account, or a 3rd-party platform.
Select option 3.
That uses your configured base URL instead of authenticating with Anthropic.
Type "Hello, can you see me?" Wait 30 to 60 seconds. The first query is slow. If you get a response, it is working.
Cannot connect: check ANTHROPIC_BASE_URL, run curl http://YOUR_IP:11434/api/version, and confirm Ollama is running.
Model not found: the name must match ollama list exactly, and you want the 32k configured model.
Timeout: increase API_TIMEOUT_MS; the first request is the slowest.
Stuck on login: pick option 3, and make sure settings.json is valid JSON.
Forgetful mid-chat: you are probably on the 4K base model.
Check ollama ps and look at CONTEXT.
Test the pipeline before blaming Claude Code.
Hit the version endpoint.
Run the 32k model and confirm CONTEXT is 32768.
Curl /v1/messages and ask it to say hello in Perl.
If that works and Claude Code does not, the problem is settings.
Env vars override settings.json, so check env | grep ANTHROPIC for conflicts.
Context size is set in Ollama, not here.
Next: context windows in depth.