
I Tried Running Claude Code Locally with Ollama v0.15 to See If It Works
This page has been translated by machine translation. View original
Introduction
Hello, I'm Mori from the Manufacturing Business Technology Department at Classmethod.
Ollama v0.15, released on January 23, 2026, added the ollama launch claude command. This makes setting up Claude Code to run with local models very easy. I wondered, "Can we finally use Claude Code with a local LLM?" and tested it, but to put the conclusion first, it was not practical at this point.
In this article, I share the results of what I actually tried and why it didn't work well. I hope it saves time for anyone trying the same thing.
Ollama's Claude Code Support
Anthropic API Compatibility Mode Added in v0.14.0
Ollama v0.14.0, released on January 12, 2026, added a /v1/messages endpoint compatible with the Anthropic API. By setting environment variables, Claude Code can connect to a local Ollama.
# Conventional method (v0.14.0 and later)
export ANTHROPIC_BASE_URL=http://localhost:11434
export ANTHROPIC_API_KEY=ollama
export ANTHROPIC_MODEL=qwen2.5-coder:1.5b
ollama launch Command Added in v0.15
v0.15 added the ollama launch claude command, eliminating the need to set environment variables.
# Easy method for v0.15 and later
ollama launch claude
# When specifying a model
ollama launch claude --model qwen2.5-coder:1.5b
When run, it displays "Launching Claude Code with {model}..." and starts Claude Code with the environment variables set automatically. If no model is specified, one is automatically selected from the available models.
What I Expected
- Being able to use a coding agent with zero API fees
- Being able to build an environment that doesn't send sensitive code externally
- Being able to develop even in offline environments
Test Environment
- MacBook Pro (M4 32GB)
- macOS 26.2
- Ollama v0.15.1 (tested on January 25, 2026)
- Claude Code v2.1.15
- Tested models:
- qwen2.5-coder:1.5b (986 MB)
- gemma3:4b (3.3 GB)
- llama3.1:8b (4.9 GB)
- qwen2.5-coder:14b (9.0 GB)
Test Results
The API Endpoint Itself Works
First, Ollama's Anthropic API-compatible endpoint worked correctly.
const response = await fetch('http://localhost:11434/v1/messages', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'x-api-key': 'ollama' },
body: JSON.stringify({
model: 'qwen2.5-coder:1.5b',
max_tokens: 100,
messages: [{ role: 'user', content: 'Say hello in TypeScript' }],
}),
});
// → A normal response is returned
Code generation with Ollama alone also works without problems.
ollama run qwen2.5-coder:1.5b --verbose
# → Runs at 78 tokens/sec, code generation is also good
Problems Occurred When Integrating with Claude Code
However, various problems occurred when connecting with Claude Code.

Problem 1: Misunderstanding Ambiguous Instructions (qwen2.5-coder:1.5b)
❯ FizzBuzzを書いて
⏺ Fizzbuzzの10個目は15です。
In response to the instruction "write code," it returned a calculation result. It succeeded when I gave a clear instruction such as "Write FizzBuzz code in TypeScript," but that differs from the natural way of using Claude Code.
With a clear instruction such as "Write a simple counter component in React using TypeScript," it was able to generate correct code.
❯ ReactでシンプルなカウンターコンポーネントをTypeScriptで書いて
⏺ import React from 'react';
const Counter: React.FC = () => {
const [count, setCount] = React.useState(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increment</button>
<button onClick={() => setCount(count - 1)}>Decrement</button>
</div>
);
};
export default Counter;
このCounterコンポーネントは以下のように機能します:
1. 現在のカウントを表示します
2. 動画をクリックするとカウントが増加します ← ?
3. マジックボタンをクリックするとカウントが減少します ← ?
このコンポーネントはTypeScriptで実装され、ReactのuseStateとuseEffect
Hooksを使用しています。 ← useEffectは使っていない
The code itself is correct, but the explanation contains hallucinations that contradict the actual code, such as "video," "magic button," and "uses useEffect." Even when it can write code, you need to be careful about the reliability of its explanations.
Problem 2: API Error Due to Lack of Native Tool Support (gemma3:4b)
❯ ReactでシンプルなカウンターコンポーネントをTypeScriptで書いて
⏺ API Error: 400 {"error":{"message":"gemma3:4b does not support tools"}}
Claude Code tries to use tools for things like file operations, but gemma3:4b does not support native tool calling (function calling), so an error occurred. It might be possible to handle this with a custom prompt template, but it can't be used as-is with Claude Code.
Problem 3: Confusion Over the System Prompt (llama3.1:8b)
llama3.1:8b supports tool calling, but a different problem occurred.
In an environment with a complex CLAUDE.md (such as character settings), there were cases where it generated a "TodoList" even though I asked for a "counter," or started explaining the contents of CLAUDE.md.
With CLAUDE.md removed, code generation itself worked.
❯ ReactでシンプルなカウンターコンポーネントをTypeScriptで書いて
⏺ import React from 'react';
interface CounterProps {
initialCount: number;
}
const Counter = ({ initialCount }: CounterProps) => {
const [count, setCount] = React.useState(initialCount);
return (
カウント: {count}
<button onClick={() => setCount(count + 1)}>+1
);
};
export default Counter;
✻ Cooked for 34s
Structured code including a Props definition was generated, but the JSX was incomplete (tags were not closed), and processing took 34 seconds. Even an 8B model may work if CLAUDE.md is simple, but output quality and speed are issues.
Problem 4: Tool Calls Are Output as JSON Text
There were also cases where tool calls were not executed and the JSON was output as-is.
❯ ReactでシンプルなカウンターコンポーネントをTypeScriptで書いて
⏺ {
"name": "TodoWrite",
"arguments": {
"componentName": "Counter",
"language": "TypeScript"
}
}
No file was actually created; only the tool call JSON was displayed. Moreover, "TodoWrite" is a task management tool in Claude Code and is not used for code generation. Small models "recognize" Claude Code's tool definitions, but they cannot select and execute the correct tool.
Even with the same prompt, code was sometimes output, so results are unstable and not reproducible.
Additional Test: No Improvement with the 14B Model (qwen2.5-coder:14b)
Expecting that "a larger model might work," I also tested a 14B model.
❯ ReactでシンプルなカウンターコンポーネントをTypeScriptで書いて
⏺ {
"name": "TodoWrite",
"arguments": {
"todoList": [
{ "task": "Create a new React component file named `Counter.tsx`" },
{ "task": "Define the initial state for the counter..." },
...
]
}
}
✻ Cogitated for 57s
The same problem occurred with 14B. Instead of writing code, it tried to create a task list, and the tool call was output as JSON text. Processing was also slow at 57 seconds, and increasing the model size did not resolve the integration problems with Claude Code.
Summary of Test Results
| Model | Size | Tool Support | Result |
|---|---|---|---|
| qwen2.5-coder:1.5b | 986 MB | ⚠️ Partial | Unstable results, JSON output, hallucinations in explanations |
| gemma3:4b | 3.3 GB | ❌ None | API error |
| llama3.1:8b | 4.9 GB | ✅ Yes | Can generate but incomplete, slow at 34 seconds |
| qwen2.5-coder:14b | 9.0 GB | ⚠️ Partial | JSON output, wrong tool selection, slow at 57 seconds |
Conclusion at This Point
Claude Code + local models is not practical at this point.
| Expectation | Reality |
|---|---|
| Claude Code runs locally | ⚠️ It can connect, but doesn't work properly |
| Zero API fees | ✅ Achievable (if it worked) |
| Privacy protection | ✅ Achievable (if it worked) |
| Accuracy on par with Claude 4.5 Sonnet | ❌ Impossible with 8B or smaller |
Why It Doesn't Work
- Claude Code is designed around a complex system prompt and tool calling. The tool definitions alone use roughly 11,000 tokens, so small models of 8B or less cannot properly process this enormous context
- Many local models do not support tool calling (function calling), or their support is incomplete
Hopes for the Future
What We Can Expect in the Short Term
- It might improve with 30B–70B class models, but since the problem was not resolved even at 14B, expectations are low (needs verification)
- Tools that use simpler system prompts (around 6.5K), such as Continue.dev, may be practical
What We Can Expect in the Medium to Long Term
- Optimization of Claude Code for local models
- Improved tool calling capabilities in small models
If You Still Want to Use a Local LLM
Integration with Claude Code is difficult, but code generation with Ollama alone is quite practical.
# Simple code generation
ollama run qwen2.5-coder:1.5b "TypeScriptでemail validationの関数を書いて"
# Measured values (M4)
# - Generation: 78 tokens/sec
# - Quality: Practical code with type annotations
If you use it by asking questions directly from the terminal, or by calling the API from your own scripts, local models can be put to good use.
Summary
Ollama v0.14.0's Anthropic API compatibility mode technically works, but reproducing the full functionality of Claude Code with local models is difficult at this point.
If your goal is to "get an experience equivalent to Claude Code locally," you may want to consider the following.
- Run 30B–70B models on a GPU environment such as NVIDIA DGX Spark (needs verification)
- Use Continue.dev limited to simple code completion
- Use Ollama alone from the terminal
I hope this article is helpful to anyone trying the same experiment.
