Set up an Ollama coding agent on Windows, Mac or Linux
Updated Fact-checked
An Ollama coding agent in Contenox uses two apps. Ollama downloads and runs the model. Contenox sends it your messages and displays its replies. For this walkthrough, install both on the same computer. You need an internet connection for the initial downloads. Local chat with the downloaded model works without an Ollama account or API key.
Contenox#
1. Install and open Ollama#
Install Contenox for your computer if you haven’t already. Then set up Ollama for your system.
| Where you’re running Ollama | What to do |
|---|---|
| Windows 10 22H2 or newer | Download and run OllamaSetup.exe. Open Ollama from Start, then open a new PowerShell window. The desktop app keeps the local server running. Ollama for Windows |
| macOS 14 Sonoma or newer | Download the .dmg, open it, drag Ollama into Applications, and launch it. Accept the prompt to install the command-line tool, then open Terminal. Ollama for Mac |
| Linux | Run the installer below in a terminal. Then run ollama list. If it cannot connect, run ollama serve, leave that terminal open and continue in a second terminal. Ollama for Linux |
Run this in your Linux terminal.
curl -fsSL https://ollama.com/install.sh | sh
2. Download a chat model and check the server#
Run these commands in PowerShell or Terminal. The first downloads a small model that supports tools. The second should list qwen2.5:3b. Model details and download size
ollama pull qwen2.5:3b
ollama list
On the computer running Contenox, open http://127.0.0.1:11434/api/tags in your browser. You should see JSON containing "name":"qwen2.5:3b". If the page won’t open, launch Ollama. If the page shows an empty models list, finish the download above. Once this check passes, leave Ollama running.
3. Fill in the Ollama provider in Contenox#
On first launch, select Use another provider. If you already see the workspace, open Backends → Providers. Under Local, select Ollama / Ollama Cloud.

| Field | What to enter |
|---|---|
| Base URL | Keep http://127.0.0.1:11434 for Ollama on this computer. For another machine, enter its reachable server address and port. The /api/tags path was only for the browser check. For direct access to Ollama Cloud, enter https://ollama.com/api. |
| Advanced → API Key (optional) | Leave blank for a standard local Ollama server. For Ollama Cloud, choose Create key and paste the key here, or use the environment-variable field below. Ollama Cloud keys |
| Advanced → Environment variable name | Leave blank for local Ollama or when you pasted a key above. Use this field when Contenox should read a key from its environment. Enter just the variable name, such as OLLAMA_API_KEY. Set the variable in the environment that launches Contenox and fully restart the app after changing it. |
On a local installation you can leave Advanced collapsed. When editing an existing cloud connection, a stored key is kept until you choose to replace it.
Select Connect. During first-run setup, Contenox checks the connection and selects a default chat model. If it presents Default model, choose qwen2.5:3b and select Save and continue. From an existing workspace, choose the model in the Model menu below the message box.
4. Get your first reply#
In Contenox Scratchpad, ask Suggest three checks before launching a website on mobile. You should see the answer in your chat. If it stays busy, run ollama run qwen2.5:3b "Suggest three checks before launching a website on mobile." in your terminal. A reply there confirms Ollama can load the model. Check the selected provider and model in Contenox next. Continue with your first project
If the terminal replies but Contenox shows Execution failed, run ollama ps in a second terminal while sending another message in Contenox. Look at CONTEXT and PROCESSOR. The agent sends its instructions and tool definitions along with your question. A long context split across the CPU and GPU can spend most of the first turn processing that input. Try a smaller tool-capable model that fits with the context you need. Diagnose slow local replies
Use Ollama with your agent#
| Agent | Supported? | How | Note |
|---|---|---|---|
| Claude Code | Works, not supported by Anthropic | ollama launch claude, or ANTHROPIC_BASE_URL=http://localhost:11434 |
Ollama documents this. Anthropic doesn’t support routing Claude Code to non-Claude models, so expect rough edges |
| Codex CLI | Yes | ollama launch codex, or codex --oss |
Ollama recommends at least 64k context for Codex |
| OpenCode | Yes | Start Ollama and select a discovered model in /models |
Ollama supplies the model’s capabilities. |
| Contenox | Yes | Backends → Providers → Ollama / Ollama Cloud | Pulled models appear in the Model chip |
The other-client examples below use qwen3. Download it first with ollama pull qwen3 if you want to follow those examples. For longer coding sessions, see context settings.
Claude Code#
ollama launch claude
Or set it up yourself. In PowerShell on Windows:
$env:ANTHROPIC_AUTH_TOKEN = "ollama"
$env:ANTHROPIC_API_KEY = ""
$env:ANTHROPIC_BASE_URL = "http://localhost:11434"
claude --model qwen3
On macOS or Linux:
export ANTHROPIC_AUTH_TOKEN=ollama
export ANTHROPIC_API_KEY=""
export ANTHROPIC_BASE_URL=http://localhost:11434
claude --model qwen3
Claude Code is built and supported for Claude models. Anthropic says it doesn’t support routing it to other models through any gateway, so a feature that works with Claude may fail here.
Codex CLI#
ollama launch codex
Or start Codex in local mode with a model:
codex --oss -m qwen3
--oss uses Ollama or LM Studio. To always pick Ollama, set oss_provider = "ollama" in ~/.codex/config.toml; otherwise Codex asks.
OpenCode#
Start Ollama and pull the model you want to use. OpenCode v2 discovers models on the local Ollama server and reads their reported capabilities. Open /models in the OpenCode terminal and choose your Ollama model. For a server at another address, set providers.ollama.settings.baseURL to its OpenAI-compatible endpoint, including /v1. OpenCode’s Ollama setup
Which Ollama models work for a coding agent?#
Pick a model tagged for tools — without it the agent can’t read files or run commands (Ollama’s library, filtered to tools). These picks were checked against Ollama’s library in November 2026:
| Your GPU / unified memory | Pick | Notes |
|---|---|---|
| 8 GB | qwen3.5:9b, short tasks only |
For real agent work at this size, use Ollama Cloud (below). |
| 12 GB | qwen3.5:9b |
Runs a full 64k context on the GPU. |
| 16 GB | qwen3.5:9b-q8_0 |
Or qwen3-coder:30b partly on the CPU. |
| 24 GB | qwen3.8:27b |
The sweet spot for local agent work. |
| 48 GB+ | qwen3.8:27b-q8_0, or qwen3-coder-next at 64 GB+ |
8-bit weights and a longer context. |
| Too big to fit | an Ollama Cloud model | glm-5.3:cloud, kimi-k2.7-code:cloud. |
On an Apple Silicon Mac, read “memory” as the unified memory left after the system and your apps. Best Ollama models for coding works out the pick, the context memory and the benchmarks for each size.
A few rules behind the table:
- Favor a mixture-of-experts model where one fits. A 30B-A3B model activates about 3B of its 30B parameters per token, so it runs near a 3B’s speed while needing memory for the full 30B.
- Keep the whole model on the GPU. If
ollama psshows a CPU share, the model plus its context didn’t fit and is running at system-RAM speed, ten to twenty times slower than VRAM. Use a smaller model or a shorter context. - Size the context for agent work, not chat. An agent resends its tools, files and command output every turn; aim for at least 64k tokens (see the context fix below).
- Try it on a real task first, such as explaining one module or fixing one failing test.
Too big to fit? Ollama now runs the largest open models on its own servers — see Ollama Cloud below. What the hardware does to token speed and context is in Run models locally.
Why does the agent ignore my request or forget the tools?#
Usually the context is too short. An agent sends instructions, tool definitions, file contents and command output every turn. If that doesn’t fit, part of the prompt is cut, and that can be your request or the tool list.
Ollama’s default depends on your GPU memory. Its docs recommend at least 64000 tokens for agents and coding tools. Use the context slider in the Ollama app’s settings, or set OLLAMA_CONTEXT_LENGTH before Ollama starts.
On Windows, quit Ollama from the system tray, then in PowerShell:
setx OLLAMA_CONTEXT_LENGTH 64000
Start Ollama again from the Start menu. On macOS or Linux, for a single run:
OLLAMA_CONTEXT_LENGTH=64000 ollama serve
Check CONTEXT in ollama ps. A longer context needs more memory, so watch PROCESSOR too. In Contenox, the Token Limit chip sets how much history a session keeps; keep it no higher than your machine can hold.
Common errors#
- Connection refused or Unreachable: Ollama isn’t running, or the address is wrong. Start it and check the address. In Contenox, then select Check again.
- No models found: Ollama is running but has no models. Run
ollama pullwith a model name. - The model answers in text instead of using tools: it doesn’t support tool calls, or its context is too short. Switch to a model tagged for tools and raise the context.
- Ollama runs on another machine and can’t be reached: Ollama listens only on
127.0.0.1by default. On that machine, setOLLAMA_HOSTto0.0.0.0:11434and restart Ollama; the Ollama FAQ has the steps per OS. Anyone on your network can then use it, so keep it on a trusted network.
Can I use Ollama Cloud instead?#
Yes, if your computer can’t run the models you want. Ollama Cloud runs them on Ollama’s servers, so your code leaves your machine. Create a key at ollama.com/settings/keys.
- Claude Code: set
ANTHROPIC_BASE_URLtohttps://ollama.com, your key inANTHROPIC_AUTH_TOKEN,ANTHROPIC_API_KEYempty, and startclaude --modelwith a cloud model. - Codex CLI: use a cloud tag, for example
codex --oss -m gpt-oss:120b-cloud. - OpenCode:
/connect, choose Ollama Cloud and paste the key. OpenCode’s docs say to runollama pull gpt-oss:20b-cloudlocally first, then pick the model with/models. - Contenox: in the same Ollama / Ollama Cloud provider, set Base URL to
https://ollama.com/api, open Advanced and paste the key into API Key (optional), or enterOLLAMA_API_KEYas the Environment variable name, then Connect. Use Add another connection to keep your local server too.
Ollama Cloud has its own plans and usage limits; see Ollama’s pricing page.
Where this provider comes from: Contenox began as an Ollama client. The first version was about 70 lines of Go: read
OLLAMA_URL, fall back tohttp://localhost:11434, POST{"model": "llama3.2", "prompt": "Why is the sky blue?", "stream": false}to/api/generate, print the reply. Everything else grew from that one visible problem, and the provider above still talks to the same endpoint family. The story is in From a Simple Ollama Client to 26k LOC.
Related#
Best Ollama models for coding: which models hold up in agent workBest Ollama models for coding, by VRAMThe best Ollama model for coding at 8, 12, 16, 24 and 48+ GB VRAM and on Ollama Cloud: exact tags, tool support, context memory and the benchmarks behind them.
Best Ollama harness: which agent to pair with OllamaBest Ollama harness for coding: Claude Code, OpenCode, CodexOllama defaults to 4K context even on a 16 GB GPU. Compare 9 coding harnesses and see which local models Contenox picks for 8 GB and 16 GB cards.
How to run local LLMs for coding: hardware, model sizes and setup in more depthHow to run local LLMs for coding: hardware, setup, contextHow to run local LLMs for coding: which model fits your GPU, the Ollama setup, the context setting that breaks agents, and connecting Claude Code, Codex or OpenCode.
Run models locally: Ollama or vLLM, and what local models can’t do yetLocal AI coding agent: Claude Code, Codex, OpenCode setupRun a local AI coding agent on your own hardware: Ollama or vLLM, setup for Claude Code, Codex CLI and OpenCode, memory needs, and models that call tools.
vLLM: serve models for a teamSet up a vLLM coding agent on Windows, Mac or LinuxSet up a vLLM coding agent in Contenox. Start a server on Linux, Windows with WSL, or Apple Silicon, check its model and connect from the desktop.
How to choose a model for codingHow to compare AI coding models on your own codebaseCompare AI coding models on five tasks from your repository. Score each run on passing tests, unnecessary edits, elapsed time and cost per finished task.
ChatGPT subscriptionUse your ChatGPT subscription for a coding agent | ContenoxUse your ChatGPT subscription for a coding agent. Set up device sign-in in Contenox or use Codex on desktop, in an editor or in the terminal. Check plan limits.
GitHub Copilot subscriptionUse your GitHub Copilot subscription in other coding agentsUse your GitHub Copilot subscription outside VS Code: sign-in steps for OpenCode, Codex and Contenox Harness, which plans you need, and how AI Credits are billed.
Anthropic (Claude)Claude coding agent on Windows: API key setup | ContenoxRun a Claude coding agent on Windows: Claude Code with a subscription or API key, OpenCode with a key, why Codex can't, plus models, billing and key errors.
GeminiGemini coding agent: API key, free tier and setup | ContenoxSet up a Gemini coding agent: AI Studio key in OpenCode, Antigravity CLI or Contenox Harness, why Claude Code and Codex can't, free-tier data use, models and 429 fixes.