Claude Code with Ollama and local models

  1. 1
    Open ReasonSign in on the web, or in the Mac app.
  2. 2
    Settings › ModelsConnect the plans you already pay for.
  3. 3
    In the composerGive Reason the branch and what's next.

Use Reason on the web, or in the Mac app.

Claude Code, your own 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.

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.

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.

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