Setup guide - Documented by Ollama
Use Ollama in Claude Code
Ollama exposes an Anthropic-compatible API, so Claude Code can point at a local Ollama server (or ollama.com cloud) with ANTHROPIC_BASE_URL. Ollama also ships a one-command launcher, ollama launch claude.
Last verified 8 steps3 official sources
Steps
- Step 1.
Quick start: launch Claude Code with Ollama.
Terminalollama launch claude - Step 2.
Manual setup step 1: install Claude Code (macOS / Linux).
Terminalcurl -fsSL https://claude.ai/install.sh | bash - Step 3.
Manual setup step 1 (Windows PowerShell).
Terminalirm https://claude.ai/install.ps1 | iex - Step 4.
Manual setup step 2: set the environment variables.
Terminalexport ANTHROPIC_AUTH_TOKEN=ollama export ANTHROPIC_API_KEY="" export ANTHROPIC_BASE_URL=http://localhost:11434 - Step 5.
Manual setup step 3: run Claude Code with a model.
Terminalclaude --model qwen3.5 - Step 6.
Or run with environment variables inline (cloud model through local Ollama).
TerminalANTHROPIC_AUTH_TOKEN=ollama ANTHROPIC_BASE_URL=http://localhost:11434 ANTHROPIC_API_KEY="" claude --model kimi-k2.7-code:cloud - Step 7.
Non-interactive use (scripts, Docker, CI).
--yesskips selectors, pulls the model when needed, and requires--model; arguments after--go to Claude Code.Terminalollama launch claude --model gemma4:cloud --yes -- -p "how does this repository work?" - Step 8.
Connect directly to Ollama's cloud with no local Ollama install: set your API key in OLLAMA_API_KEY, then in Bash or Zsh run the following. Run
/statusinside Claude Code to check the connection.TerminalANTHROPIC_BASE_URL=https://ollama.com \ ANTHROPIC_AUTH_TOKEN="$OLLAMA_API_KEY" \ ANTHROPIC_API_KEY="" \ claude --model glm-5.3-flash
Caveats
- Steps come from Ollama's own Claude Code integration page; Claude Code's docs were not used for the endpoint.
- Ollama recommends setting context length to 64k or higher for larger repositories; Ollama's default context depends on VRAM (4k under 24 GiB, 32k at 24-48 GiB, 256k at 48 GiB or more). Raise it with
OLLAMA_CONTEXT_LENGTH=64000 ollama serveor the app slider. - Claude settings files can override shell variables; update any base URL or credentials there.
- Per Ollama: hosted WebSearch and advanced tool controls are not fully supported over the Anthropic-compatible API; choose a model that supports tools.
- Model ids ending in :cloud run on Ollama's cloud and need
ollama signin.
More setup guides
Same tool, other providers
Related reading
- What Is OpenClaw? Setup, Skills, MCP Server, Claude Code, and Ollama (2026 Guide)What is OpenClaw? A self-hosted personal AI agent you reach through chat apps. Install, skills and ClawHub, its MCP server, Claude Code use, and Ollama models.
- Ollama Decision Models: Run Nimble Locally with --askOllama 0.40.4 runs decision models locally: ollama run nimble --ask answers yes/no, label and score questions with probabilities. Commands and limits.
- Ollama 0.40 on Mac: MLX by Default, Disk Space DoubledOllama 0.40 runs supported models on MLX on Apple Silicon and keeps a backup copy of each model you load. What it costs in disk, what is fixed, and the cleanup.
- GitHub Copilot CLI With Ollama: Local Models and the New SandboxCopilot CLI 1.0.94 finds local Ollama models from /model and ships an OS-level sandbox. Setup, the 4k context trap, and why local is not offline.
- Hermes Agent Guide (2026): What It Is, Local Setup With Ollama, Skills, and Hermes vs OpenClawHermes Agent is Nous Research's open-source, self-improving AI agent. Run it locally with Ollama, see how its skills system works, and compare it with OpenClaw.
- GitHub Copilot for JetBrains Gains Persistent Memory and Ollama BYOKGitHub Copilot for JetBrains adds memory across chat sessions, Ollama as a BYOK provider, and enterprise settings for MCP access. What each feature does.
FAQ
How do I use Ollama in Claude Code?
Ollama exposes an Anthropic-compatible API, so Claude Code can point at a local Ollama server (or ollama.com cloud) with ANTHROPIC_BASE_URL. Ollama also ships a one-command launcher, ollama launch claude.
Which Ollama model ids work in Claude Code?
The official docs read for this guide list qwen3.5, kimi-k2.7-code:cloud, gemma4:cloud and glm-5.3-flash. Requests go to http://localhost:11434.
Is this an official Ollama and Claude Code setup?
Ollama documents this setup in its own docs. It was last checked against 3 official pages on October 17, 2026.
Sources
Last verified against 3 official pages.
- docs.ollama.comhttps://docs.ollama.com/integrations/claude-code
- raw.githubusercontent.comhttps://raw.githubusercontent.com/ollama/ollama/main/docs/integrations/claude-code.mdx
- raw.githubusercontent.comhttps://raw.githubusercontent.com/ollama/ollama/main/docs/context-length.mdx
Newsletter
New models, set up the day they ship
One email per week. New model releases, the coding tools that support them and how to wire them up.