• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer
Best Free Web Resources — local AI tools and hardware guides

Best Free Web Resources

Local AI Tools & Digital Engineering Resources

What can I run?
  • AI Tools
    • Start: Local LLMs
    • Ollama Models & VRAM
    • LM Studio Models
    • GPU Comparison
    • AI Hardware Matrix
    • Local LLM Directory
    • VRAM Calculator
    • Hardware Compare
    • Local Model Recommender
    • API Pricing & ROI
  • Local AI Guides
  • Web Resources
    • Inspiration
    • Photography
    • Games
    • SEO
    • Tutorial
      • Coding
      • WordPress
    • Resume/CV
    • Graphics
      • Logo
    • Freebies
Running Claude Code on a local model with ollama launch claude, 64k context and ask permissions

Claude Code With a Local Model: Running It on Ollama

November 12, 2026 by BFWR Editorial

Claude Code is Anthropic’s coding agent for the terminal, and it normally talks to Anthropic’s models. Since Ollama added an Anthropic-compatible API, it can also run against a model on your own machine: ollama launch claude sets it up in one command. It is one of the rising “ollama” searches this month, and there are limits you should know before relying on it.

This guide covers the two ways to set it up, the context-length and model settings that make or break it, what the compatibility layer does not support, and what still leaves your machine. BFWR has not benchmarked this setup; everything below comes from Ollama’s and Anthropic’s documentation.

Quick answer

  • Fastest setup: ollama launch claude, then pick a model.
  • Manual setup: point Claude Code at Ollama with ANTHROPIC_BASE_URL=http://localhost:11434, ANTHROPIC_AUTH_TOKEN=ollama and an empty ANTHROPIC_API_KEY, then run claude --model <model>.
  • Context: Ollama says to set a 64K or larger context window for local models. Its default on most graphics cards is 4K.
  • Models: use one with tool support, such as Qwen3.8, Qwen3-Coder, gpt-oss or Gemma 4.
  • Limits: prompt caching, token counting and forced tool choice from Anthropic’s API are not supported by Ollama.

Setup 1: ollama launch claude

Ollama’s integration page for Claude Code starts with a single command:

ollama launch claude

It starts Claude Code connected to Ollama and lets you pick a model. For scripts and CI, Ollama documents a non-interactive form: the --yes flag “skips selectors, pulls the model when needed”, and requires --model. Arguments after -- pass straight through to Claude Code:

ollama launch claude --model qwen3.8:27b --yes -- -p "how does this repository work?"

You need both Ollama and Claude Code installed. Claude Code’s installer is curl -fsSL https://claude.ai/install.sh | bash on macOS and Linux, and irm https://claude.ai/install.ps1 | iex in PowerShell on Windows.

Setup 2: environment variables

If you prefer to see what is going on, set the variables yourself. These are Ollama’s documented values:

export ANTHROPIC_AUTH_TOKEN=ollama
export ANTHROPIC_API_KEY=""
export ANTHROPIC_BASE_URL=http://localhost:11434
claude --model qwen3.8:27b

The token is a placeholder: Ollama’s compatibility page labels it “required but ignored”, and notes that “The local server does not validate API keys.” Claude Code’s own reference describes ANTHROPIC_BASE_URL as the way to “Override the API endpoint to route requests through a proxy or gateway”, and ANTHROPIC_AUTH_TOKEN as a “Custom value for the Authorization header”.

Ollama adds one warning that catches people out: “Claude settings can override shell variables.” If you have a base URL or key in ~/.claude/settings.json, change it there, then run /status inside Claude Code to confirm where it is connected.

Background tasks need a model too

Claude Code does not use only the model you pick. Its reference says the ANTHROPIC_DEFAULT_HAIKU_MODEL variable sets the “Model ID that the haiku alias resolves to, also used for background functionality”. There are matching variables for the sonnet and opus aliases, and CLAUDE_CODE_SUBAGENT_MODEL for subagents. When you set things up by hand, point these at a local model too; otherwise background work or a subagent may request a Claude model name that your Ollama server does not have:

export ANTHROPIC_DEFAULT_HAIKU_MODEL=qwen3.8:27b
export CLAUDE_CODE_SUBAGENT_MODEL=qwen3.8:27b

For tools that insist on Anthropic model names, Ollama’s documentation offers a second route: copy a local model under a Claude name with ollama cp, for example ollama cp qwen3-coder claude-3-5-sonnet.

The context length setting

Ollama’s integration page says it plainly: for local models, “Choose a model and set a 64k+ context window.” Its context-length documentation repeats the point for agents in general: “Tasks which require large context like web search, agents, and coding tools should be set to at least 64000 tokens.”

Ollama’s own default is much smaller: 4K of context on graphics cards with less than 24GB of memory, 32K from 24 to 48GB, and 256K above that. An agent’s instructions and tool definitions take up a large share of a 4K window before any of your code is added, so raise it before you start:

OLLAMA_CONTEXT_LENGTH=65536 ollama serve

A 64K context costs memory. Our OpenCode local setup guide has a table of eight coding-capable models at 32K and 64K, computed with our VRAM calculator: Gemma 4 12B needs about 10.3GB at 64K and Qwen3.8 27B about 22.5GB, both at 4-bit. The same numbers apply here, because the limit is the model and its context, not the agent in front of it. They apply to personal agents too; see our OpenClaw guide.

Which model to use

Claude Code reads files, edits them and runs commands through tool calls, so the model must support tools. On Ollama’s library pages, look for the tools label; Qwen3.8, Qwen3-Coder, gpt-oss and Gemma 4 all carry it. Ollama’s own manual-setup example uses qwen3.5.

Be realistic about quality. Claude Code was designed around Anthropic’s models, and a 27B local model is much smaller, so results depend heavily on which model you choose. Our list of the best local LLMs for coding compares the candidates on licence, memory and published benchmark scores.

What the compatibility layer does not support

Ollama supports “a subset of the Anthropic Messages API”. Messages, streaming, system prompts, images, tool calls and thinking all work. Its documentation lists these as not currently supported:

  • the token-counting endpoint, /v1/messages/count_tokens
  • tool_choice, for forcing or disabling specific tools
  • prompt caching with cache_control blocks
  • the Batches API, citations and PDF document blocks

Two more are partial: images only as base64, not URLs, and extended thinking with “budget_tokens accepted but not enforced”. Token counts are approximations from the model’s own tokenizer. For Ollama’s cloud models, the integration page adds that “Hosted WebSearch and advanced tool controls are not fully supported.”

Claude Code’s side has one consequence of its own. Its reference notes that when ANTHROPIC_BASE_URL points at a non-Anthropic host, “MCP tool search is disabled by default”, and that Remote Control is disabled.

What still leaves your machine

With a local model, your prompts and code go to Ollama on localhost, not to Anthropic. Claude Code itself still has its own network activity, which you can reduce:

  • DISABLE_TELEMETRY=1 opts out of telemetry. Anthropic’s reference says “Telemetry events don’t include user data like code, file paths, or Bash commands”, and that the setting also disables feature-flag fetching.
  • DISABLE_ERROR_REPORTING=1 opts out of error reporting.
  • Ollama’s cloud models (names ending in :cloud) run on Ollama’s servers, not yours. Check the model name if staying local is the point.

Also note the licence. Claude Code is not open source: its repository states “© Anthropic PBC. All rights reserved. Use is subject to Anthropic’s Commercial Terms of Service.” If you want an open-source agent for local models, OpenCode is MIT-licensed.

Permissions

Ollama’s page notes that “Claude Code prompts for permission on most actions.” That is a safer default than OpenCode’s, which lets the agent edit files and run commands without asking unless you configure it otherwise. Keep it that way with a local model, and avoid --dangerously-skip-permissions outside an isolated environment. A smaller model misreads instructions more often, and the prompt is your chance to catch it.

If Ollama runs on another machine on your network, change ANTHROPIC_BASE_URL to that machine’s address, and read our guide to running Ollama as a server first. Ollama’s documentation describes no built-in authentication for its API, so it should not be reachable from the open internet.

FAQ

Is Claude Code free with Ollama?

The Claude Code tool costs nothing to install. Running it against a local model through Ollama has no per-token cost; you pay in hardware and electricity. Ollama’s cloud models need an Ollama account and key.

Do I need an Anthropic account?

Ollama’s documented setup sets the token to a placeholder and the API key to empty, and sends requests to your local server. Its instructions do not include signing in to Anthropic.

Why does Claude Code fail to call tools or forget the task?

Usually the context window. Raise Ollama’s context to 64K or more, and use a model with tool support.

Claude Code or OpenCode for local models?

Both work through Ollama. Claude Code asks permission by default and is proprietary. OpenCode is open source and provider-neutral, with permissive defaults you should tighten. DeepSeek Harness also accepts a local OpenAI-compatible server. Our Ollama vs Claude comparison covers the wider local-versus-API trade-off.

Related guides and tools

  • LiteLLM and its alternatives, if you want one endpoint in front of several backends
  • LLM context windows and what they cost in VRAM
  • VRAM calculator and Ollama models and VRAM
  • LM Studio Bionic
  • Cline with a local model
  • Pi coding agent with a local model

Sources

  • Ollama docs: Claude Code integration
  • Ollama docs: Anthropic compatibility and context length
  • Claude Code docs: environment variables and model configuration
  • anthropics/claude-code on GitHub (licence notice; v2.1.302, 16 October 2026)

Updated 18 October 2026. Ollama and Claude Code documentation were read on that date; both change often.

⚡ Free Interactive Tools

Work out what your hardware can actually run

Free calculators and directories, sized from real model weights — before you download gigabytes or order a card:

📦 Ollama Models & VRAM Memory cost + pull command 🚀 Start: Local LLMs Hardware, runner and first model 📊 What Can I Run? Models by VRAM tier, 8GB–128GB 💻 Hardware Matrix 75 laptops & GPUs profiled

Filed Under: Coding, Technology

About BFWR Editorial

BFWR Editorial is the byline for guides researched and written by Best Free Web Resources. These guides are built from primary sources — model cards, configuration files, official documentation and vendor pricing pages — and every figure is dated and linked so you can check it yourself. Size and memory numbers are arithmetic computed from published model data or from our own calculators, never measurements: BFWR does not operate a hardware test lab and publishes no benchmarks of its own. Where a figure comes from a vendor, we say so.

Primary Sidebar

⚡ FREE INTERACTIVE TOOLS

Local AI Hardware & VRAM Matrix

Benchmark your PC or Mac for local AI, calculate VRAM requirements, and compare cloud API costs vs local hardware ROI.

🚀 New here? Start with Local LLMs → 💻 Hardware Matrix (79 Devices) → 📚 Local LLM Directory (30 Models) → 🎮 AI GPU Comparison → ⚡ VRAM & KV Cache Calculator → 💰 API Pricing & Break-Even → 🍎 Mac VRAM Unlocker (90% Boost) →
📦 Ollama 🖥️ LM Studio ⚙️ llama.cpp 🚦 vLLM 💬 Open WebUI 🎨 ComfyUI 🔒 Self-Hosted 📊 VRAM Tiers 🎯 Recommender ⚖️ Comparisons

Search

  • Facebook
  • Instagram
  • RSS
  • Twitter
  • YouTube

Footer

Latest Guides

  • Best Free Android Emulator for PC in 2026: Which Are Still Maintained
  • Pi Coding Agent With a Local Model: Ollama, llama.cpp and Context Setup
  • Kimi K3.1 Pro Locally: 2.8 Trillion Parameters and the Memory It Takes
  • MiniMax H3 in ComfyUI: Files, VRAM and the Licence That Excludes the US
  • ComfyUI Install in 2026: Desktop vs Portable vs Manual, and Which to Pick
  • Mistral Large 4 Locally: 1 Trillion Parameters, the Memory It Takes and the Licence

AI Tools & Calculators

  • What can I run?
  • VRAM Calculator
  • GGUF Size Calculator
  • Fine-tuning VRAM
  • LoRA Training VRAM
  • Image Generation VRAM
  • Mac VRAM Optimizer

Browse & Compare

  • Models Directory (30 models)
  • Hardware Matrix (79 devices)
  • Image Models
  • Model Licences
  • Comparisons
  • Model Recommender
  • API Pricing & ROI

Guides & Resources

  • Technology
  • Coding
  • Tutorials
  • Freebies
  • Graphics

Copyright © 2026 · Best Free Web Resources · All Rights Reserved.  |  About · Privacy Policy · Contact · AI Tools Hub