Local AI coding agent: Claude Code, Codex, OpenCode setup
Updated Fact-checked
A local AI coding agent runs the model on hardware you control, so your code never goes to a model provider and there is no per-token bill. Serve an open-weight model with Ollama on your own computer or vLLM on a GPU server, then point Claude Code, Codex CLI or OpenCode at it. The cost is quality and speed: a model that fits on one consumer GPU is usually weaker at long, multi-file work than the strongest hosted models.
Use a local model with your agent#
| Agent | Supported? | With Ollama | With vLLM | Note |
|---|---|---|---|---|
| Claude Code | Works, not supported by Anthropic | ollama launch claude |
ANTHROPIC_BASE_URL=http://gpu-host:8000 |
Ollama and vLLM document it; Anthropic doesn’t support Claude Code with non-Claude models |
| Codex CLI | Yes | ollama launch codex, or codex --oss |
A custom provider in ~/.codex/config.toml |
--oss covers Ollama and LM Studio |
| OpenCode | Yes | Select a discovered Ollama model in /models |
Select a discovered vLLM model or set the server address | OpenCode also discovers LM Studio locally. |
| Contenox Harness | Yes | Ollama / Ollama Cloud under Local | vLLM under Cloud | Also includes built-in Local AI on Windows x64 from 1.0.22. Mix local and cloud models per session. |
Ollama or vLLM?#
| Ollama | vLLM | |
|---|---|---|
| Best for | One person on one computer | A team sharing a GPU server |
| Setup | Install, ollama pull, done |
Python, a GPU, and the right flags for tool calls |
| Models | Ready-made, quantized downloads | Models from Hugging Face |
| Default address | http://127.0.0.1:11434 |
http://localhost:8000 |
Start with Ollama unless you already run GPU servers.
ollama pull qwen3
On a shared GPU server, with a Qwen3-Coder model:
vllm serve Qwen/Qwen3-Coder-30B-A3B-Instruct --served-model-name qwen3-coder --enable-auto-tool-choice --tool-call-parser qwen3_xml
The vLLM flags matter: without them, automatic tool calls are off and the agent can’t act. Full steps: vLLM.
Claude Code#
With Ollama, run ollama launch claude. Or set the variables 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
For vLLM, set ANTHROPIC_BASE_URL to the server and map ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL to your served model name; see vLLM.
Claude Code is built for Claude models, and Anthropic doesn’t support routing it to others. It works through these servers, but some features, such as built-in web search, don’t.
Codex CLI#
With Ollama, run ollama launch codex, or:
codex --oss -m qwen3
For vLLM, add a custom provider to ~/.codex/config.toml with base_url = "http://gpu-host:8000/v1"; see vLLM. Codex only speaks the Responses API, which both Ollama and vLLM serve.
OpenCode#
OpenCode v2 discovers models from running local Ollama, LM Studio and vLLM servers. Start the server, load or pull a chat model, then open /models in the OpenCode terminal. If your server uses a different address, set its provider’s settings.baseURL. With another OpenAI-compatible server, supply its address and model ID in a custom provider entry. OpenCode local models · Step-by-step local setup
Contenox Harness#
Windows x64 builds from Contenox Harness 1.0.22 include Local AI. The app downloads and runs models on your computer. For a fresh installation, follow the built-in Local AI walkthrough.
Modeld architecture explains the native workers, shared sessions and transport, with a desktop walkthrough.
- On first launch, choose Use local AI. In an app you have already set up, open Backends → Providers → Local AI → Manage models.
- Select Detect my hardware. From the model inventory, select Check hardware first to open the setup page.
- Choose the recommended chat model, or browse the available models, then select Download and use. For an installed model, select Use for chat.
- Wait for the download and chat check to finish. The model becomes your chat default and appears in the Model chip.

If a download needs repository access, the app shows Open model repository and asks for a Hugging Face read token. Use Manage models to download more models or remove their files. To free memory while keeping the download, open Backends → Local AI status, expand the model’s row and select Unload from memory.

To connect an existing server on Windows, macOS or Linux, open Backends → Providers and choose Ollama / Ollama Cloud under Local, or vLLM under Cloud. Keep the default address for Ollama, or enter the vLLM server’s host and port only, without /v1, then select Connect. Connected models appear in the same Model chip, so you can switch per session. Download Contenox Harness.
What hardware do I need?#
Token speed comes from memory bandwidth, not core count. Generating a token reads the model’s weights out of memory once, so the ceiling is blunt: bandwidth divided by the bytes read per token. A model that fits in VRAM runs far faster than one on the CPU because a GPU’s memory carries ten to twenty times the bandwidth of system RAM, not because its cores work harder. For agentic coding the bar is higher than for chat: aim for 45 tokens a second or more, since 30 drags across an agent’s many turns, and give a mid-difficulty task at least 68k tokens of context to hold the instructions, tool definitions, files and command output it resends each turn.
Two numbers decide a setup:
- Capacity (GB) sets what loads at all. The weights plus the KV cache for your context must fit, or the model won’t start, or it spills to slower memory.
- Bandwidth (GB/s) sets how fast it runs once it fits.
| Hardware | Memory | Bandwidth | For local coding |
|---|---|---|---|
| RTX 5090 | 32 GB GDDR7 | ~1,792 GB/s | Fastest consumer card. MSRP $1,999; street prices ran higher in 2026. |
| RTX 4090 | 24 GB | ~1,008 GB/s | Strong for models under 24 GB. |
| Apple M3 Ultra | up to 512 GB unified | ~819 GB/s | Unified memory fits very large models; bandwidth sits below a 5090. |
| Apple M4 Max | up to 128 GB unified | ~546 GB/s | The same trade, smaller. |
| Intel Arc Pro B60 | 24 GB | ~456 GB/s | Cheap VRAM per gigabyte; wants IPEX-LLM and Linux to run well. |
| Intel Arc B580 | 12 GB | ~456 GB/s | About $249. Fits 8–12B models. |
| No GPU (dual-channel DDR5) | system RAM | ~90 GB/s | 5–12 tokens a second on an 8B model. Fine to try, too slow for agent work. |
Prices move; bandwidth and capacity don’t. Check current retail before buying.
A mixture-of-experts (MoE) model reads only the few experts its router picks per token, so it runs at the speed of its active size while taking memory for its full size. Qwen3-30B-A3B holds 30.5B parameters but activates 3.3B a token: it generates about as fast as a dense 3B model and needs memory for the 30B. That unlocks a trick — keep the shared layers on the GPU and push the expert weights into system RAM, with llama.cpp’s --n-cpu-moe, and a model too big for your VRAM runs anyway, slower. Because only some experts fire per token, they can even sit on different GPUs or hosts; a dense model resists that, since every token needs every weight.
After the weights load, the memory left over is your cache budget: it sets how much context stays in fast memory. Run past it and older tokens move to slower memory and get read back — a penalty of bytes divided by bandwidth, which shrinks as bandwidth grows. So a long context punishes a CPU and barely touches a 5090, and the exact cache budget matters most on slow hardware. Ollama adds a catch of its own: it can halve the KV cache by quantizing it, but only with flash attention on, which older cards don’t support, so the context costs the most memory exactly where there is the least. Ollama recommends at least 64000 tokens for coding tools; see the context fix.
Tests of Contenox Runtime’s local inference daemon measured that gap: a stable prompt of about 9,000 tokens prefilled in 7.61 s on a CPU, against 1.77 s on a 6 GB laptop GPU and 0.03 s once the prefix was already cached. Keeping the start of the prompt unchanged is what makes the warm number possible (see prompt caching).
With Ollama, run ollama ps while a model is loaded. PROCESSOR shows whether it runs fully on the GPU, and CONTEXT shows the context length it got. A CPU share means the model plus its context didn’t fit and is running at system-RAM speed — use a smaller model or a shorter context.
For agentic coding, the Contenox team’s research on local inference advises against a laptop unless it is really a workstation: a desktop with a full-size GPU, a dedicated GPU node on your network, or a cloud GPU rented by the hour keeps up where a laptop’s memory and bandwidth can’t. Reach for one when a hosted model is off the table for privacy, compliance, offline work or volume, and skip local otherwise. The reasoning is in How to run local LLMs for coding.
Which local models work for a coding agent?#
The model must support tool calls; without them, the agent can’t read files or run commands.
- Ollama: filter the library to models with tool support.
- vLLM: the tool calling guide lists the model families it can parse tool calls for, and the parser flag each needs.
New open-weight models appear every few weeks. Try a candidate on a small, real task, such as fixing one failing test, before giving it larger work. See How to choose a model for coding.
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 a local modelBest 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: runtimes, model sizes and setup in 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.
Ollama: connect a model on your computerSet up an Ollama coding agent on Windows, Mac or LinuxSet up an Ollama coding agent in Contenox on Windows, macOS or Linux. Install Ollama, download a chat model, check the connection and send your first message.
vLLM: connect a team GPU serverSet 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.