Claude Code reads your codebase, edits files, and runs commands, and Ollama connects it to local and cloud models through its Anthropic-compatible API. The quickest way to put the two together is ollama launch: one command starts the agent already configured to talk to Ollama’s local endpoint, so no manual environment variables are required. The Ollama commands cheat sheet lists the command as ollama launch [APP], pointing Claude Code, Codex, OpenCode and 15 other tools at Ollama, with flags --model, --config, --restore and -y.
Launch one of the three agents
| Agent | Command | What it starts |
|---|---|---|
| Claude Code | ollama launch claude |
Anthropic’s terminal coding agent, connected to Ollama |
| Codex | ollama launch codex |
OpenAI’s Codex CLI, connected to Ollama |
| OpenCode | ollama launch opencode |
The open-source OpenCode agent, connected to Ollama |
The first launch walks through model selection and starts the agent with the correct settings. To pin the model yourself, add --model: ollama launch claude --model qwen3.5. Ollama’s Claude Code guide adds a headless form for scripts, Docker, or continuous integration: ollama launch claude --yes --model qwen3.5, where --yes skips the selectors, pulls the model when needed, and requires --model, and arguments after -- are passed directly to Claude Code. If you would rather configure the connection yourself, the manual path sets three environment variables and starts Claude Code normally: ANTHROPIC_BASE_URL=http://localhost:11434, ANTHROPIC_AUTH_TOKEN=<redacted>, and ANTHROPIC_API_KEY="", then claude --model qwen3.5. The token value is ignored by the local Ollama server, which does not validate API keys; Claude Code simply needs one set.
What the agent needs from the model
A coding agent is not a chat: it edits files and runs commands in a loop, driven by the model, so the model must support tool calling and have enough context for your repository. Ollama’s Claude Code guide says to choose a model with enough context for your repository, and a third-party guide to the setup puts the figure at a context window of 64,000 tokens or more. The NVIDIA tutorial that ships ollama launch inside its Ollama sandbox names Qwen 3.5, Nemotron-3-Super, GLM-5, and Kimi-K2.5 as the models with reliable tool-calling support for agentic workflows, and uses qwen3.5 in its launch examples. Pick the model first; a model without tool support will chat but cannot drive the agent.
Try it: launch Claude Code on a practice folder
Open a terminal in a practice folder, then launch the agent with a model you have already pulled:
ollama launch claude --model qwen3.5
| Check | What you should see | What it means |
|---|---|---|
| Agent starts | Claude Code opens without asking for an API key or a base URL | ollama launch wired the connection for you |
| Model named | The session uses the local model you passed with --model |
Your prompts go to Ollama, not to a cloud service |
| Agent works | It can read files in the folder and ask before editing them | The model can call the agent’s tools |
Expected result. We checked Ollama’s Claude Code guide, which describes ollama launch and the –yes form, and the Ollama commands cheat sheet, which lists ollama launch and its flags. We did not run ollama launch on this machine, so we have no agent session of our own; the launch above is the expected result.
Limits
A local model is not Claude: Anthropic’s documentation says sending Claude Code to non-Claude models through a gateway of any kind is unsupported, so the combination works technically but outside Anthropic’s support, and a compatibility layer may not follow every new Claude Code feature. Model names ending in :cloud run on ollama.com, not on your hardware, so your prompts leave your computer. The 64,000-token figure and the tool-calling model list in this guide come from third-party guides, not from Ollama’s own documentation, and the launch examples come from a third-party NVIDIA tutorial. This guide starts a ready-made coding agent; sending your own requests to Ollama’s Anthropic-compatible endpoint from your own code is a different task. We did not test any of this ourselves.
Sources
- Ollama documentation, Claude Code — ollama launch starts Claude Code with Ollama; –yes skips selectors, pulls the model when needed, and requires –model; choose a model with enough context for your repository
- Ollama commands cheat sheet — ollama launch [APP] points Claude Code, Codex, OpenCode and 15 other tools at Ollama (third-party guide, checked against Ollama 0.40.14)
- NVIDIA OpenShell tutorial — ollama launch claude, codex and opencode; –yes –model qwen3.5 for headless use; Qwen 3.5, Nemotron-3-Super, GLM-5 and Kimi-K2.5 for reliable tool calling (third-party tutorial)
- Claude Code with Ollama guide — a context window of 64K tokens or more; Anthropic does not support routing Claude Code to non-Claude models (third-party guide)
