← Back to TIL

Using Ollama with Claude Code


Ollama is now compatible with Claude Code. Use local LLMs directly in the CLI.

Prerequisites:

  • Claude Code installed
  • Ollama CLI or Desktop installed

Configuration via ENV variables:

ANTHROPIC_AUTH_TOKEN=ollama
ANTHROPIC_BASE_URL=http://localhost:11434
claude --model <modelname>

Pro tip - Aliases for quick switching:

alias claude-ollama='ANTHROPIC_AUTH_TOKEN=ollama ANTHROPIC_BASE_URL=http://localhost:11434 claude --model gwen3-coder:30b'
Claude Code Model Picker with Ollama
Claude Code Model Picker with Ollama

Source