Skip to main content
Watch: I Built an AI App Without Leaving Databricks

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

  1. Step 1.

    Quick start: launch Claude Code with Ollama.

    Terminal
    ollama launch claude
  2. Step 2.

    Manual setup step 1: install Claude Code (macOS / Linux).

    Terminal
    curl -fsSL https://claude.ai/install.sh | bash
  3. Step 3.

    Manual setup step 1 (Windows PowerShell).

    Terminal
    irm https://claude.ai/install.ps1 | iex
  4. Step 4.

    Manual setup step 2: set the environment variables.

    Terminal
    export ANTHROPIC_AUTH_TOKEN=ollama
    export ANTHROPIC_API_KEY=""
    export ANTHROPIC_BASE_URL=http://localhost:11434
  5. Step 5.

    Manual setup step 3: run Claude Code with a model.

    Terminal
    claude --model qwen3.5
  6. Step 6.

    Or run with environment variables inline (cloud model through local Ollama).

    Terminal
    ANTHROPIC_AUTH_TOKEN=ollama ANTHROPIC_BASE_URL=http://localhost:11434 ANTHROPIC_API_KEY="" claude --model kimi-k2.7-code:cloud
  7. Step 7.

    Non-interactive use (scripts, Docker, CI). --yes skips selectors, pulls the model when needed, and requires --model; arguments after -- go to Claude Code.

    Terminal
    ollama launch claude --model gemma4:cloud --yes -- -p "how does this repository work?"
  8. 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 /status inside Claude Code to check the connection.

    Terminal
    ANTHROPIC_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 serve or 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.

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.

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.