I asked Claude Code for a tiny Python file: one function, a few asserts. Nine minutes later, the "agent" answered with a JSON blob pretending to be a tool call, no file on disk, and Claude Code reported the run as a success.
That was test number two. The setup is the one YouTube calls free Claude Code: point Claude Code at Ollama, run an open model on your own hardware, pay no API fees. I watched several videos on it, so I decided to test it myself and put real numbers on it. The idea is real: Ollama speaks the same API format as Anthropic, so Claude Code doesn't know the difference.
A month ago I ran AI offline for 7 days on a €200 mini PC and wrote that coding agents built for cloud models were "not realistic" on that box. That was a prediction from the numbers, not a test. So I tested it, on the same mini PC and then on my Mac, with the same tiny task every time.
This post covers:
- What "free Claude Code" actually runs, and what it doesn't.
- The setup, in four commands.
- Five tests, four failures, and the one that worked.
- Why the wait is minutes, not seconds: the 13,000 tokens you never see.
- What the popular tutorials do, and a safety alert about "free Opus" promises.
- When this setup is worth it.
What "free Claude Code" actually is
Claude Code is two things that usually ship together: the harness (the terminal app, the agent loop, the tools that read and write files and run commands) and the model that decides what to do (Claude, through Anthropic's API).
The free setup keeps the harness and swaps the model:
You (terminal on the Mac) | "create palindrome.py and run it" v Claude Code (Mac) -- builds the request: system prompt + tool definitions + your message | HTTP, Anthropic Messages format v Ollama (mini PC or Mac) -- the open model reads everything and answers: | "call the Write tool with this content" v Claude Code runs the tool on YOUR disk, appends the result to the history, sends the whole history again, and asks: what next? No Anthropic model runs anywhere in this setup. Claude's weights are not public, so there is no "old Claude" to download. Every decision comes from the open model you picked (Gemma, Qwen, Llama). Claude Code is the hands; the open model is the brain.
That's not a criticism. It's the most useful thing to understand before you try it, because every result below is the open model's result, on your hardware.
The setup in four commands
Ollama added compatibility with the Anthropic Messages API in v0.14.0 (January 2026), including tool calls and tool results (docs). On the machine running Ollama, raise the context window first (more on why in the next section):
# systemd install (Linux): sudo systemctl edit ollama.service, then add # [Service] # Environment=OLLAMA_CONTEXT_LENGTH=32768 # Environment=OLLAMA_HOST=0.0.0.0:11434 # only if Claude Code runs on another machine sudo systemctl daemon-reload && sudo systemctl restart ollama # or, running it by hand (macOS too) OLLAMA_CONTEXT_LENGTH=32768 ollama serve Ollama listens only on 127.0.0.1 by default (FAQ), which is all you need when Claude Code runs on the same machine. My Ollama runs on the mini PC and Claude Code on the Mac, so I set OLLAMA_HOST to expose it on my network.
Then, on the machine where you run Claude Code:
export ANTHROPIC_BASE_URL=http://192.168.1.214:11434 # your Ollama host export ANTHROPIC_AUTH_TOKEN=ollama # required, ignored by Ollama claude --model gemma4:e4b ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN are documented Claude Code environment variables; the token is a placeholder Ollama ignores. Ollama also ships a one-liner, ollama launch claude, that picks a model and sets this up for you (docs). Two optional variables I used in the tests: CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 turns off telemetry, error reporting and auto-updates, and API_TIMEOUT_MS gives a slow server more time to start answering.
Ollama's API has no authentication. If you expose it like that, keep it on a network you trust.
The test: one tiny task, five runs
Every run got the same prompt, in headless mode (claude -p), allowed to use only Write, Read and python3:
Create a file palindrome.py with a function is_palindrome(text) that ignores case and spaces, plus a few asserts at the bottom. Then run it with python3. It needs three steps: write the file, run it, report. For reference, I ran the same prompt on Claude itself (Opus 5.5, on my Pro plan): three steps, 10.6 seconds, and plain asserts that fail when they should. That's a practical reference, not a controlled comparison: a different model on different hardware, which is exactly the choice you face.
| Claude Code | 2.1.311, headless (-p), my usual global config loaded |
| Ollama | 0.35.0 |
| Models | qwen2.5-coder:7b and gemma4:e4b, default 4-bit tags |
| Mini PC | AMD Ryzen 3 3300U (4 cores, 15 W), Proxmox container with 4 cores and 10 GB of the 16 GB RAM, integrated Radeon Vega via Vulkan |
| Mac | Apple M3, 16 GB unified memory, Ollama running natively |
| When | 3 November 2026, one run per configuration (a real-use test, not a lab benchmark) |
Here's what happened:
| # | Machine | Model and context | Result | Time |
|---|---|---|---|---|
| 1 | Mini PC, iGPU | Qwen2.5-Coder 7B, default 4k | No file. Fake tool call as text | 1 min |
| 2 | Mini PC, iGPU | Qwen2.5-Coder 7B, 32k | No file. Correct code, wrong format | 9 min |
| 3 | Mini PC, iGPU | Gemma 4 E4B, 32k | File created, then the GPU crashed | 27 min |
| 4 | Mini PC, CPU only | Gemma 4 E4B, 32k | File created, stopped by my 45 min limit | 45 min+ |
| 5 | Mac M3 | Gemma 4 E4B, 32k | Done: file written, run, reported | 3 min 33 s |
Each failure taught something different, so let's go through them.
Test 1: the default context keeps a sixth of the prompt
Ollama's default context window depends on your GPU memory: 4k tokens below 24 GiB of VRAM (docs). That covers my mini PC and also a 16 GB Mac.
Claude Code's request was about 12,900 tokens. Ollama's log shows it kept about 2,000 of them in a 4,096-token slot. The model saw fragments: it named a real Claude Code tool, Skill, and one of my skills. But it answered with this, as plain text instead of a structured call:
{"name": "Skill", "arguments": {"skill": "code-review"}} Claude Code saw a normal text answer and exited with no error.
A failure that reports success is worse than a crash. If you script this, check the files, not the exit code.
The fix is the OLLAMA_CONTEXT_LENGTH line above. Ollama's docs recommend at least 64,000 tokens for coding tools; I used 32,768 because the container has 10 GB of RAM, and the largest prompt in these tests was about 19,000 tokens, so it fit.
Test 2: right code, wrong format
With the full prompt in context, Qwen2.5-Coder understood the task and wrote a correct function. But it wrote the tool call as text again, with a made-up path and Markdown fences inside the file content:
{"name": "Write", "arguments": {"file_path": "/Users/.../palindrome.py", "content": "<Markdown code fence>python\ndef is_palindrome(text): ..."}} Claude Code only runs tools that arrive as structured tool_use blocks. This one arrived as prose, so nothing was written.
The surprising part: Ollama lists tools among Qwen2.5-Coder's capabilities (ollama show qwen2.5-coder:7b). A declared capability is not proof that the model emits calls in the format the agent needs. Gemma 4 E4B declares it too, so the next tests tried it.
Test 3: the first real tool call, and a GPU crash
Gemma 4 E4B called Write properly. After about nine minutes, palindrome.py existed on my Mac's disk, created by a model running on a mini PC.
Then step two. Claude Code sent the whole history again, now about 19,300 tokens, and the mini PC had to read it from the start. During that reading, the integrated GPU's Vulkan driver failed (vk::Queue::submit: ErrorDeviceLost) and Ollama's runner crashed. After 27 minutes Claude Code gave up with an API error.
Test 4: stable on CPU, but too slow to finish
To rule out the driver, I made a CPU-only copy of the model (PARAMETER num_gpu 0 in a Modelfile). No crash this time, but prompt reading dropped to 11 to 14 tokens per second. The file appeared after about 19 minutes; step two took until about 44 minutes; my 45-minute limit stopped it in step three.
Test 5: the Mac finishes in three and a half minutes
Same model, same context, same prompt, on an M3. Claude Code wrote the file, ran it, read the output and reported that all tests passed. The whole run took 3 minutes 33 seconds.
The quality matched the model, not the harness. In both Gemma files I inspected, it wrapped the asserts in try/except and printed a message instead of failing. From the Mac run, trimmed:
try: assert is_palindrome("racecar") == True, "Test Case 2 Failed: 'racecar'" assert is_palindrome("hello") == False, "Test Case 3 Failed: 'hello'" # ... print("\nAll tests passed successfully!") except AssertionError as e: print(f"\n--- TEST FAILED ---\n{e}") The script exits with status 0 even when a test fails. A reviewer would catch it; an agent that trusts the exit code would not.
Why it takes minutes: the 13,000 tokens you never see
The model's writing speed was not the main problem. Gemma wrote about 7 tokens per second on the mini PC's GPU and about 20 on the Mac, fine for a short file. The problem was reading. These ranges come from Ollama's logs across the runs above:
| Machine | Prompt reading (tokens/s) | Generation (tokens/s) | Reading a 13k prompt |
|---|---|---|---|
| Mini PC, CPU only | 11 to 14 | about 3 | 15 to 20 min |
| Mini PC, iGPU | 19 to 37 | 3.7 to 7.5 | 6 to 11 min |
| Mac M3 | 190 to 230 | 13 to 21 | about 1 min |
Every agent step sends the system prompt, the tool definitions and the whole conversation so far. In my runs that was about 12,900 tokens on step one and about 19,000 on step two. That number includes my own global setup (a CLAUDE.md with engineering rules and a list of skills), so a clean install sends less, but the shape is the same: the agent pays for its instructions on every step, before the first word of the answer.
Two more costs showed up in the logs:
- The cache didn't save the second step. Ollama can reuse the start of a previous prompt, but on the Mac it re-read all 19,000 tokens on step two, so its cache didn't match the earlier request. I don't know what changed between steps. Anthropic's prompt caching is built to avoid paying for the same prefix twice; locally, I paid full price.
- Claude Code hangs up on a silent server. While Ollama reads a long prompt, it sends nothing. On the mini PC, Claude Code dropped the connection about every six minutes and retried, which is consistent with the five-minute idle timeout its docs describe for streaming responses. Each retry reused part of Ollama's cache, so it crept forward, slowly.
API_TIMEOUT_MSdidn't change this, because it only covers the wait for response headers. The same page listsAPI_FORCE_IDLE_TIMEOUTandCLAUDE_STREAM_IDLE_TIMEOUT_MSfor this watchdog. I didn't test them, so the retries may be avoidable; the reading time isn't.
On a 4-core mini PC the agent loop is the bottleneck, not the model. The same model, without Claude Code's 13,000-token prompt, wrote 200 tokens in about 27 seconds in my raw benchmark.
What the popular tutorials actually do
I looked at six videos that promise free Claude Code. They use three different routes:
| Route | What runs the model | What you give up |
|---|---|---|
| Ollama, local model | Your machine | Speed and quality, set by your hardware |
| A proxy or router to free cloud tiers | Someone else's servers, often several providers | Your code leaves your machine; free tiers have limits |
| "Free Opus for 6 months" | Unknown | You can't verify who provides it: a security risk |
The local route is the one I tested, and the better tutorials are honest about it: it's private, it has no API fees, and it's slower.
The proxy route connects Claude Code to free tiers of other providers' models (GLM, Gemini and others), and one of them rotates accounts to avoid hitting limits. It's fast because the model runs in a data centre, but your code goes to whoever runs those servers, and rotating accounts to dodge limits can break the providers' terms of service.
The third route promises real Claude models (Opus, the newest ones) for free, unlimited, for months. I didn't open those links, so I can't say what's behind them, and this is not an accusation against anyone. It's a safety alert, because these videos use patterns that security researchers warn about in tutorial videos in general (TechRadar, Cybereason):
- a "guide" locked behind subscribe, like and comment;
- the real link in a pinned comment instead of the description;
- "activate it on your PC first, then on your phone", which asks you to run something on your computer;
- three-minute videos with keyword-stuffed descriptions.
Claude's models run in Anthropic's cloud, and every request has a cost. If a third party promises unlimited access to paid Claude models for free, treat it as a red flag: check who provides it, don't click links to unlock a subscription, and never enter your credentials or run software you don't understand. One legitimate offer I verified is Anthropic's six months of Claude Max for eligible open-source maintainers, and you apply for it on Anthropic's own site.
Trade-offs: when this setup makes sense
| Local model through Claude Code | Claude through Anthropic's API | |
|---|---|---|
| Cost per use | No API fees (hardware and electricity) | Subscription or per token |
| Privacy | Model requests stay on your network | Code goes to Anthropic |
| This 3-step task | 3.5 min on an M3; didn't finish on a mini PC | 10.6 s (Opus 5.5) |
| Quality | The open model's (4B to 8B here) | Claude's |
| Works offline | Yes | No |
| Failure mode | Failed silently twice in five runs | No silent failure in my one run |
I'd use it for three things: learning how an agent loop works (watching the logs is the best tutorial I know), small private tasks on a machine with Apple Silicon or a real GPU, and offline work where cloud isn't an option.
I wouldn't use it on a low-power mini PC, for anything with more than a handful of steps, or as a cheaper replacement for Claude on real work. The harness was designed around Claude: its instructions and tool descriptions were written for a model that follows them well. A 4B model gets the same manual, and these tests show where it slips.
FAQ
Is this really Claude Code?
The app is. The model isn't: every decision comes from the open model you run.
Would a bigger model fix the failures?
Probably some of them, at a higher cost. Ollama's own blog suggests larger coding models such as qwen3-coder and gpt-oss:20b, which need more memory than my mini PC's container has. I haven't tested them here.
Why not just use the 64k context Ollama recommends?
On a machine with 16 GB or more to spare, do. A bigger window costs memory, and my container has 10 GB. These tests never went past about 19,000 tokens.
Does ollama launch claude change the results?
It saves the configuration step. The model, the hardware and the prompt size are the same, so the speed is too.
Is my code private with this setup?
With a local model, the model requests go only to your Ollama server. Claude Code itself still sends telemetry and error reports unless you set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1. With the proxy route, your code goes to the provider. For sensitive code, check the app's network traffic and telemetry settings yourself instead of relying on one variable.
Takeaway
- "Free Claude Code" is Claude Code without Claude. The open model does all the thinking.
- Raise Ollama's context first. The 4k default kept a sixth of the prompt, and the model improvised.
- Test tool calling, don't trust the label. Both models declared it; only one delivered. Good code in the wrong format writes nothing.
- Prompt reading decides if it works. About 13,000 tokens per step took 15 to 20 minutes on a mini PC CPU and about a minute on an M3. Claude did the whole task in 10.6 seconds.
- Check the result, not the exit code. Two runs looked fine and weren't.
- One run per setup is a field test, not a failure rate. Your hardware and model will move these numbers; the failure modes are what to look for.
- Be careful with "free Opus" promises. Don't unlock guides, follow pinned links or run unknown software to get a subscription. One legitimate offer I verified is Anthropic's open-source program, applied for on anthropic.com.
What's the slowest hardware you've run a coding agent on, and did it finish? Tell me in the comments.
I'm Diogo Soares, a Staff AI Engineer working on AI agents and legacy modernization. If this was useful, follow me here on DEV.to and on Instagram at @diogosoares.dev, where the five tests become a carousel you can save before you try this yourself. This article also has a video walkthrough on my YouTube channel, Diogo Soares Dev, so subscribe there for the next experiments. Let's also connect on LinkedIn, or check out diogosoares.dev.




