Skip to content

How-ToGPU

How to Use Claude Code With Local AI Models in Ollama

Run `ollama launch claude` to connect Anthropic's Claude Code to a local model, or install Claude Code and set ANTHROPIC_BASE_URL to http://localhost:11434 with the token 'ollama'. Raise Ollama's context length to at least 64k tokens, since it defaults to 4k on GPUs under 24GiB, and note hosted web search and some tool controls aren't fully supported. Forge PC has not tested this setup.

By , Editorial team

4 min read

How to Use Claude Code With Local AI Models in Ollama

Claude Code is Anthropic's command-line coding agent: it reads your project, edits files and runs commands with your permission. Normally it talks to Anthropic's cloud models, but Ollama now offers an Anthropic-compatible API, so you can point Claude Code at a model running on your own graphics card instead. That keeps your code on your PC and avoids per-token costs, at the price of using a much smaller model.

Forge PC has not tested this setup or measured its speed. The steps are based on Ollama's Claude Code, Anthropic compatibility and context length documentation and on Anthropic's Claude Code setup guide, checked on 16 November 2026.

What you need

  • Windows 10 version 1809 or later (Anthropic also supports macOS and several Linux distributions), at least 4GB of RAM and an internet connection, according to Anthropic's system requirements.

  • Ollama installed and running. If you haven't used it before, start with our Ollama and LM Studio beginner's guide.

  • A graphics card with enough video memory for a capable model and a long context window. Coding agents read a lot of code, so context matters as much as model size. Our how much VRAM and best GPU for local LLMs guides explain what to aim for.

  • Git for Windows (recommended). Anthropic says Claude Code uses it for its Bash tool on Windows; without it, Claude Code falls back to PowerShell.

A note on accounts: Anthropic's documentation says Claude Code requires a paid Claude plan or a Console account, or a supported third-party provider such as Amazon Bedrock, and that the free Claude plan doesn't include it. Ollama's documented setup instead points Claude Code at your local server using environment variables. Anthropic doesn't list Ollama as a provider, so check Anthropic's terms if you're unsure.

Method 1: One command with ollama launch

Ollama's documentation says the simplest way to start is:

ollama launch claude

This lets you choose a model and launches Claude Code connected to Ollama. To pick a specific local model, add --model. For example, Ollama's library page for Xiaomi's MiMo-V2.6 coding model lists:

ollama launch claude --model mimo-v2.6

Method 2: Manual setup on Windows

1. Install Claude Code. In PowerShell, Anthropic's and Ollama's documentation give:

irm https://claude.ai/install.ps1 | iex

Open a new terminal and run claude --version to check it installed. Anthropic also offers winget install Anthropic.ClaudeCode, though it notes WinGet installs don't update automatically.

2. Point Claude Code at Ollama. Ollama's docs use these environment variables (shown here in PowerShell syntax for the current session):

$env:ANTHROPIC_AUTH_TOKEN = "ollama"
$env:ANTHROPIC_API_KEY = ""
$env:ANTHROPIC_BASE_URL = "http://localhost:11434"

Ollama says the auth token is required but ignored by the local server.

3. Run Claude Code with a local model from your project folder:

claude --model mimo-v2.6

Replace mimo-v2.6 with any model you've downloaded with ollama pull. If you've previously set different URLs or keys in Claude's settings, Ollama warns that those can override environment variables; run /status in Claude Code to check the connection.

Step 3: Set a big enough context window

This is the step most people miss. Ollama's documentation says its default context length depends on your video memory: 4k tokens below 24GiB of VRAM, 32k between 24 and 48GiB, and 256k at 48GiB or more. That's too short for a coding agent, and Ollama recommends at least 64,000 tokens for agents and coding tools.

You can raise it with the slider in the Ollama app's settings, or by starting the server with the OLLAMA_CONTEXT_LENGTH environment variable set to 64000. A larger context uses more memory, so check the result with:

ollama ps

Ollama says that for best performance the PROCESSOR column should show the model running fully on the GPU, rather than partly offloaded to the CPU. If it isn't, try a smaller model or quantisation; our guide to speeding up Ollama covers the options.

What works and what doesn't

Ollama lists chat, running commands through Claude Code's permission system, tool calling, file edits, subagents, vision and thinking controls as supported with compatible models. However, its Anthropic compatibility documentation says tool-choice controls, deferred tools and hosted web search are not fully supported. Ollama offers its own web search API as an alternative.

The bigger limitation is the model. A 9B-parameter model running on a gaming graphics card is far less capable than Anthropic's cloud models, so expect it to need more guidance and to make more mistakes on large tasks. Keep Claude Code's permission prompts on, use Git so you can undo changes, and review edits before accepting them.

Alternatives

If you'd rather work inside your editor, see how to use Continue with Ollama, or Aider with Ollama for another terminal-based option. Other tools can use Ollama's OpenAI-compatible API.

Our verdict

Claude Code with Ollama is easy to set up, especially with ollama launch claude, and it's a genuinely useful way to run a coding agent privately on your own PC. The catch is that local models are much less capable than Anthropic's own, and you must raise Ollama's context length to at least 64k tokens or the agent will struggle. Start with a small coding model, keep permissions on and use Git. Forge PC has not tested this setup.

The bottom line

Claude Code with Ollama is easy to set up, especially with `ollama launch claude`, and it's a genuinely useful way to run a coding agent privately on your own PC. The catch is that local models are much less capable than Anthropic's own, and you must raise Ollama's context length to at least 64k tokens or the agent will struggle. Start with a small coding model, keep permissions on and use Git. Forge PC has not tested this setup.

Sources

  1. 01Ollama, Claude Code integration
  2. 02Ollama, Anthropic compatibility
  3. 03Ollama, Context length
  4. 04Anthropic, Claude Code advanced setup
  5. 05Ollama, mimo-v2.6 model library page

About the author

Forge PC Staff

Editorial team

The shared byline for articles researched, written and edited by the Forge PC editorial team. How we source, check and correct our work is set out in our editorial policy.

More from Forge PC Staff

Read next

How to Enable AMD Fluid Motion Frames (AFMF 2.1) on a Radeon Graphics Card

How-To

How to Enable AMD Fluid Motion Frames (AFMF 2.1) on a Radeon Graphics Card

To enable AMD Fluid Motion Frames, install Adrenalin 25.3.1 or newer, then select the HYPR-RX profile (RX 7000 and newer) or turn on AMD Fluid Motion Frames under Gaming > Graphics, globally or per game. AFMF 2.1 works on RX 6000 cards and newer in DirectX 11, DirectX 12, Vulkan and OpenGL games, with VSync off; RX 6000 cards need exclusive full screen.

Forge PC Staff2 min

How to Use System Restore in Windows 11: Turn It On, Create a Restore Point and Roll Back

How-To

How to Use System Restore in Windows 11: Turn It On, Create a Restore Point and Roll Back

Microsoft says System Protection isn't on by default. Search for Create a restore point, select your C: drive, choose Configure and turn it on, then create a restore point before installing drivers or tools. To roll back, run rstrui.exe, or use Troubleshoot > Advanced options > System Restore in Windows RE. Personal files aren't affected, but it isn't a backup.

Forge PC Staff3 min

How to Use Live Captions and Translation in Windows 11

How-To

How to Use Live Captions and Translation in Windows 11

Press Windows + Ctrl + L to turn on live captions in Windows 11 22H2 or later, download the language files, then dock or float the captions and pick a style. Captions are generated on the device and work offline. On a Copilot+ PC with 24H2 or later, live captions can translate from over 40 languages into English and 27 into Chinese (Simplified).

Forge PC Staff3 min

How to Manage Ollama Models: List, Remove and Move Them to Another Drive

How-To

How to Manage Ollama Models: List, Remove and Move Them to Another Drive

Run ollama ls to list your models, ollama ps to see what's loaded, ollama stop to unload one and ollama rm to delete it. On Windows, models are stored in C:\Users\%username%\.ollama\models; to move them, quit Ollama, set an OLLAMA_MODELS user environment variable to a folder on a bigger drive and restart Ollama.

Forge PC Staff3 min