Claude Code now runs on local models via Ollama and vLLM - zero API cost agentic coding
Ollama added support for Anthropic's Messages API, letting Claude Code run against locally hosted models instead of Anthropic's cloud. The setup enables agentic coding workflows with zero API costs using models like Qwen3-Coder or Codestral 2.
Ollama announced support for Anthropic's Messages API, which means Claude Code can now run against locally hosted models instead of calling Anthropic's cloud API. The practical result is agentic coding with zero API costs.
The setup works because Claude Code communicates with its model backend via the Messages API. Ollama now speaks that same API format, so Claude Code does not know or care whether it is talking to Anthropic's servers or a local model on your machine. The agent's planning, code navigation, file editing, and git workflow features all work the same way regardless of the backend.
To get started, you need Ollama installed and a capable model downloaded. Qwen3-Coder-32B and Codestral 2 are the recommended options for coding tasks. Both need at least 64K context window for reliable agentic use, which these models support natively. Smaller models or models with shorter context windows will struggle with multi-file editing and long coding sessions.
The configuration involves setting two environment variables to redirect Claude Code's API calls to your local Ollama instance. The official Ollama documentation provides step-by-step instructions for the setup. The process takes about five minutes if Ollama is already installed and a model is already downloaded.
There are tradeoffs to be aware of. Local models are not as capable as Claude Opus or Sonnet for complex multi-step reasoning. An agentic coding session burns 10 to 50 times more tokens than a plain chat interaction, and every tool call, file read, and test iteration adds to the count. Long sessions on local hardware can be slow depending on your GPU.
The sweet spot is a hybrid approach: use local models for routine edits, file organization, simple code generation, and boilerplate tasks. Switch to Anthropic's API for complex refactoring, architecture decisions, and tasks that need stronger reasoning. This hybrid strategy can reduce your monthly API costs significantly while keeping quality high where it matters most.
vLLM is the alternative for people who want maximum throughput or are serving multiple users. It supports the same model backends as Ollama but is optimized for GPU utilization and parallel request handling. The setup is slightly more involved but delivers better performance on NVIDIA hardware with 24GB+ VRAM.
For anyone running Claude Code regularly, this update turns API costs from a fixed monthly expense into an optional upgrade for hard problems.