Docs · Guide
Use Ollama or LM Studio models in Claude Code and Codex
Claude Code speaks Anthropic Messages and Codex speaks OpenAI Responses. A local model server speaks OpenAI Chat Completions, and some speak Anthropic Messages too. magpie sits between them on your computer, so Claude Code and Codex can run on the models you pulled in Ollama or loaded in LM Studio.
The gateway runs at 127.0.0.1:3425. magpie points the agent at it and sends each request on to your server. When the server speaks the agent’s API itself, the request is passed on as it is. When it doesn’t, magpie translates the request and the reply, streaming and tool calls included.
Ollama, LM Studio
Presets with their default ports and no key. magpie asks the server which models it has.
oMLX, MLX-Serve
MLX servers for Apple silicon, also presets.
Anything else
vLLM, llama.cpp’s server or any OpenAI-compatible URL, on this computer or another.
Supported servers
These are under On this machine when you add a provider:
| Server | Default address | APIs magpie uses |
|---|---|---|
| Ollama | http://localhost:11434 | Chat Completions, Anthropic Messages |
| LM Studio | http://localhost:1234 | Chat Completions |
| oMLX | http://localhost:8000 | Chat Completions, Responses, Anthropic Messages |
| MLX-Serve | http://localhost:11234 | Chat Completions, Responses, Anthropic Messages |
So Claude Code on Ollama, oMLX or MLX-Serve sends its requests to the server as they are, and on LM Studio magpie translates them. Codex on oMLX or MLX-Serve goes as it is, and on Ollama or LM Studio magpie turns its Responses requests into Chat Completions.
Set it up
- Start the serverPull or load a model in Ollama or LM Studio and leave the server running.
- Add it in magpieIn the Providers tab, press + Add provider and pick Ollama or LM Studio under On this machine. No key is needed. magpie asks the server which models it has, and they show as
ollama/…orlmstudio/…. - Pick the model for the agentIn the Agents tab, click the model on the Claude Code or Codex row and choose the local one. magpie writes Claude Code’s
settings.jsonor Codex’sconfig.toml. Start a new session to use it.
The same from a terminal:
ollama pull qwen3 magpie provider add ollama magpie models # every model, as provider/model magpie claude ollama/qwen3 # Claude Code magpie codex ollama/qwen3 # Codex
Inside the agent, Claude Code’s and Codex’s /model list magpie’s models too, so you can move between a local model and a cloud one there. What changes in each agent’s config is in Models in Claude Code and Models in Codex.
Another port or another computer
If the server listens on another port, or runs on another computer such as a GPU box or a NAS, change Server address in the provider’s editor. Each of its URLs moves there and keeps its path.
magpie provider add lmstudio address=http://192.168.1.5:1234 magpie provider set ollama address=192.168.1.20:11434 magpie provider set ollama address= # back to the default
A server behind HTTPS with a self-signed certificate can be reached with Don't check its certificate in the editor; it applies to that provider’s own hosts only.
vLLM, llama.cpp and other servers
A server with no preset is added as Custom: paste its URL, such as http://localhost:8080/v1, and press Detect APIs. magpie sends the smallest request to Chat Completions, Responses, Anthropic Messages and Gemini at that URL and keeps the ones that answer. The key can be left empty for a server that needs none.
Context window
Agents plan around how long a request the model takes. Claude Code takes a model it doesn’t know for 200K, and Codex compacts a conversation at 90% of the window it is told. A local model is often loaded with a much smaller window, so tell magpie the real one: Context window under Advanced in the provider’s editor, for every model or one of them. magpie passes it on to the agents.
magpie provider set ollama context=32k magpie provider set ollama context.qwen3=128k
Masking
magpie’s privacy masking replaces keys, tokens and other secrets with placeholders before a request leaves the gateway, a request to a local server too. When the model runs on your own computer or network, you can turn on Send requests unmasked in its editor, or run magpie provider set ollama unmasked=yes. It is your call: Ollama’s cloud models, or a relay you run locally, pass a request on to a vendor whatever the address.
FAQ
Can Claude Code use Ollama?
Yes. Add Ollama in magpie and pick one of its models for Claude Code. magpie writes the gateway’s address into Claude Code’s settings.json, and Ollama’s Anthropic-compatible API takes Claude Code’s requests as they are.
Can Codex use Ollama or LM Studio?
Yes. Codex speaks only the Responses API, so magpie turns its requests into Chat Completions for Ollama and LM Studio, and the replies back, tool calls included. oMLX and MLX-Serve take Responses themselves.
Do I need an API key?
No. The local presets take none. A server you secured with a key can have it in the provider’s editor.
Can the model run on another computer?
Yes. Set the provider’s Server address to that computer, such as http://192.168.1.20:11434.
Why does Claude Code fail on long conversations with a local model?
It assumes a model it doesn’t know takes 200K. Set the real Context window on the provider in magpie, and Claude Code and Codex compact before they reach it.
How do I go back?
Pick one of the agent’s own models in magpie, or run magpie claude default or magpie codex default. What magpie wrote comes out, and what it replaced comes back.
Looking for cloud models? See Models in Claude Code and Models in Codex. Stuck? Ask on Discord.