---
title: "Claude Code with Ollama and Local Models | Reason Machines"
description: "Run Claude Code with Ollama and local models using Ollama's documented setup: ollama launch claude, or ANTHROPIC_BASE_URL. What Ollama supports, what Anthropic doesn't, and the 64k context advice."
url: "https://reasonmachines.com/guides/claude-code-ollama"
section: "Coding agent guides"
---

# Claude Code with Ollama and local models

Ollama documents running Claude Code against local and cloud models through its Anthropic-compatible API: run ollama launch claude, or point Claude Code at Ollama with ANTHROPIC_BASE_URL. Anthropic doesn't support routing Claude Code to non-Claude models, so this is Ollama's integration, not Anthropic's; Ollama recommends a context window of 64k tokens or more.

Updated Nov 2026

[Start with Reason](https://reasonmachines.com/) on the web, or [download Reason for macOS](https://reasonmachines.com/download).

## Run Claude Code with a local model

1. **Install Claude Code and Ollama**: Install Claude Code with Anthropic's installer, and install Ollama from ollama.com.
2. **Launch Claude Code through Ollama**: Ollama's quick start pulls a model if needed and starts Claude Code connected to it. Run ollama launch claude. Choose a model that supports tool calling and set a context window of 64k tokens or more.
3. **Or set the variables yourself**: Ollama's manual setup points Claude Code at your local Ollama server by setting ANTHROPIC_BASE_URL to http://localhost:11434, ANTHROPIC_AUTH_TOKEN to ollama and an empty ANTHROPIC_API_KEY. Claude settings can override these variables; run /status in Claude Code to check the connection.

## What's supported, and by whom

Ollama's documentation lists Claude Code as an integration and says it "connects Claude Code to local and cloud models through its Anthropic-compatible API". Anthropic's gateway documentation says Anthropic "doesn't support routing Claude Code to non-Claude models through any gateway". In practice: Ollama supports this setup; Anthropic does not, and Claude Code features may not all work with other models.

Anthropic also notes that requests sent with a gateway credential don't use your claude.ai subscription login, so its usage limits don't apply to them. Local models cost nothing per token, but quality and speed depend on the model and your hardware.

- [Ollama docs: Claude Code](https://docs.ollama.com/integrations/claude-code)
- [Claude Code docs: LLM gateways](https://code.claude.com/docs/en/llm-gateway)

## Other agents with local models

Codex supports open models with codex --oss, which uses Ollama, and opencode connects to Ollama at localhost:11434. When you'd rather not run models yourself, Reason's web and Mac apps run hosted models on the accounts you connect.

- [Ollama docs: Codex](https://docs.ollama.com/integrations/codex)
- [opencode docs: providers](https://opencode.ai/docs/providers)
- [Claude Code alternatives, free ones included](https://reasonmachines.com/guides/claude-code-alternatives.md)
- [opencode vs Claude Code](https://reasonmachines.com/guides/opencode-vs-claude-code.md)

## Questions

### Can Claude Code use local models?

Through Ollama, yes: Ollama documents ollama launch claude and an ANTHROPIC_BASE_URL setup for local and cloud models. Anthropic doesn't support routing Claude Code to non-Claude models.

### Does Claude Code with Ollama use my Claude plan?

No. Requests go to Ollama, so your Claude plan's usage limits don't apply to them.

### Which local model should I use?

Ollama advises choosing a model with enough context for your repository, a 64k-token context window or more for local models, and a model that supports tool calling.

## More guides

- [Claude Code alternatives, free ones included](https://reasonmachines.com/guides/claude-code-alternatives.md)
- [opencode vs Claude Code](https://reasonmachines.com/guides/opencode-vs-claude-code.md)
- [Codex vs Claude Code](https://reasonmachines.com/guides/codex-vs-claude-code.md)
- [Claude Code usage limit reached: what to do](https://reasonmachines.com/guides/claude-code-usage-limit.md)
- [How the Claude usage limit works](https://reasonmachines.com/guides/claude-usage-limit-explained.md)
- [When the Claude weekly limit resets](https://reasonmachines.com/guides/claude-weekly-limit-reset.md)
- [All coding agent guides](https://reasonmachines.com/guides.md)
- [Download Reason for macOS](https://reasonmachines.com/download)
