Docs · Provider
Ollama in Claude Code, Codex, Gemini CLI and OpenCode
Ollama serves the models you pull on two APIs, OpenAI Chat Completions and Anthropic Messages, at http://localhost:11434. Ollama Cloud serves its models the same way at ollama.com, with an API key. Add either to magpie once, and Claude Code, Codex, Gemini CLI, OpenCode and every other agent you connect can use them through magpie’s local gateway at 127.0.0.1:3425, each agent with a model of its own.
Add Ollama
- Pull a modelPull a model in Ollama, such as
qwen3, and leave the server running. - Add the providerIn magpie’s Providers tab, press + Add provider and pick Ollama under On this machine. No key is needed. magpie asks the server which models it has, and they show as
ollama/…. - Pick it for an agentIn the Agents tab, click the model on the agent’s row and choose an Ollama model.
ollama pull qwen3 magpie provider add ollama magpie provider test ollama
Model ids in magpie are provider/model, so a model you pulled as qwen3 reads ollama/qwen3. A tag stays in the id, as in ollama/qwen3:8b. In the terminal UI, magpie asks for the server’s address when you add it. LM Studio, oMLX, vLLM and llama.cpp’s server are in Local models.
Another port or another computer
If Ollama 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. Only the scheme, host and port change; each API keeps its path. The scheme can be left out, and http is taken; a path pasted with the address, such as /v1, is dropped.
magpie provider set ollama address=192.168.1.20:11434 magpie provider set ollama address= # back to the default
- Proxies. A server on your own network is reached directly, whatever proxy Settings or the system name. A proxy you set on the provider itself is still used.
- HTTPS. An Ollama 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.
Ollama Cloud
- Get a keyMake one at ollama.com/settings/keys.
- Add the providerIn the Providers tab, press + Add provider, pick Ollama Cloud, paste the key and save. magpie asks Ollama Cloud which models the key can use.
- Pick it for an agentChoose an Ollama Cloud model, such as
deepseek-v4-pro, on the agent’s row.
magpie provider add ollama-cloud <key> magpie claude ollama-cloud/deepseek-v4-pro
Names, reasoning levels and prices come from models.dev’s ollama-cloud catalog. The key is kept in magpie’s settings.
Endpoints
| Provider | Chat Completions | Anthropic Messages |
|---|---|---|
| Ollama | http://localhost:11434/v1 | http://localhost:11434 |
| Ollama Cloud | https://ollama.com/v1 | https://ollama.com |
An agent whose API Ollama serves is passed on to that API. magpie uses no Responses endpoint for either, so when it has to translate, it uses Chat Completions: it keeps Responses first only for OpenAI’s own models, and Messages first only for Claude models.
Model list
magpie asks the server for its list at the Chat Completions base: http://localhost:11434/v1/models, or https://ollama.com/v1/models for Ollama Cloud. A model shows in magpie once Ollama has it. After you pull another, press Fetch models in the provider’s editor, or run magpie provider refresh ollama. Pick the models agents see in the provider’s model list, or from the terminal:
magpie provider refresh ollama magpie provider models ollama +qwen3
Ollama 0.35.0 and later (0.40.5 for its cloud models) also serves decision models, such as Nimble, Clef and Tev. magpie reads Ollama’s /api/tags as well, and a model marked there as a decision model becomes one of the provider’s decision models for intent routing, never an agent’s model. An older Ollama lists none.
In each agent
magpie claude ollama/qwen3 magpie codex ollama/qwen3 magpie gemini model ollama/qwen3 magpie opencode ollama/qwen3
- Claude Code speaks Anthropic Messages, and so does Ollama at
http://localhost:11434, so its requests go there as they are. Models in Claude Code. - Codex speaks OpenAI Responses, which magpie doesn’t send to Ollama. magpie turns each request into Chat Completions and the reply back, streaming and tool calls included. Models in Codex.
- Gemini CLI speaks Google’s Gemini API. magpie translates each request to Chat Completions and the reply back. Models in Gemini CLI.
- OpenCode speaks Chat Completions, so its requests go to Ollama’s
/v1as they are. Models in OpenCode.
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. To go back to the agent’s own models, run magpie claude default or magpie codex default.
Context window and num_ctx
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. magpie doesn’t read an Ollama chat model’s window, so tell it 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
num_ctx. Some clients send Ollama’s per-request options, such as{"num_ctx": …}, beside the Chat Completions fields. magpie leaves them out of every request it sends on: no Chat Completions API reads them, Ollama’s own/v1included. The window the model runs with is Ollama’s to set; give magpie the same number.- Too long. When a conversation outgrows the window, Ollama answers “exceeded max context length”. magpie tells the agent so the way it understands,
context_length_exceededor Anthropic’s “prompt is too long”, so the agent compacts and tries again.
Reasoning
- Effort. The effort an agent asks for is fitted to the nearest level the model has, as the catalog lists them. A model whose levels magpie doesn’t know is asked as the agent asked.
- Reasoning off. When an agent whose requests magpie translates, such as Codex or Gemini CLI, turns reasoning off and the model lists
noneamong its levels, magpie asks for none. - Your own levels.
magpie model effortsoffers only the levels you name, or sends a model no reasoning field at all.
magpie model efforts ollama/qwen3 low,medium,high magpie model efforts ollama/qwen3 off
Tool calls
Claude Code’s and OpenCode’s tool calls reach Ollama as the agent wrote them. For Codex and Gemini CLI, magpie translates the tools, the model’s calls and their results to Chat Completions and back, in streamed replies too.
Privacy masking
magpie’s privacy masking replaces keys, tokens and other secrets with placeholders before a request leaves the gateway, a request to a local Ollama 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.
- Cloud models. Ollama’s cloud models pass a request on to a vendor whatever the address, so it is your call. The editor warns you while it is on for a provider that isn’t local, such as Ollama Cloud.
- Tool arguments. In a request in Ollama’s own format, a tool call’s arguments are masked as tool arguments, as in every other API.
- Anonymous stats. magpie’s daily stats name an Ollama model only when models.dev knows it; any other counts as “other”. See Privacy.
Usage and cost
- Usage. The Usage tab counts the tokens of every Ollama call. A model is priced at the price magpie finds for its id, which for a local model can be its maker’s list price. To count a local model at nothing, give it your own price.
- Free first.
free=yescounts every model of the provider as free, so a Free first routing spends it before paid ones. Prices and Usage’s costs stay as listed. - Ollama Cloud’s allowance. magpie reads the account’s balance from Ollama Cloud. The included allowance shows as a plan, in dollars used, with when it resets; an older plan shows its session and weekly limits instead. Credits you bought show as a balance. Past the allowance Ollama Cloud draws on those credits, so a spent allowance with credits left doesn’t stop the key.
- Peak hours. On Ollama Cloud,
deepseek-v4.1-flashanddeepseek-v4-pro(with their tags) cost double from 12:00 to 18:00 UTC, Monday to Friday. models.dev lists the off-peak price; the Usage tab doubles it in those hours, and a Cheapest first routing counts it. - Out of allowance. When Ollama Cloud says a key is out without saying when it comes back, as its weekly limit does, magpie rests the key for 15 minutes.
quota-restsets how long, up to 8 days. With several keys (Add another key) the next one takes over; when every key is out, the gateway answers at once with Retry-After.
magpie model price ollama/qwen3 0,0,0,0 magpie provider set ollama free=yes magpie provider quota-rest ollama-cloud 7d magpie provider fallback ollama-cloud ollama/qwen3
magpie as an Ollama server
Some apps take a custom model only as an Ollama server: VS Code’s Copilot Ollama provider, Visual Studio’s Copilot BYOK, Zed’s Ollama provider and the ollama CLI. Point them at magpie’s gateway, http://127.0.0.1:3425, and they see magpie’s models, from every provider, not only Ollama.
- Routes. magpie answers
/api/version,/api/tags,/api/show,/api/chatand/api/generate. - The same path. A chat there is served as
/v1/chat/completionsis, so key limits, routing, fallbacks and usage are the same. A gateway key held to some models lists only those. - What it tells.
/api/tagsand/api/showmark tools, vision when the model reads images, and thinking when it reasons./api/showalso gives the model’s window, or 32768 for one magpie doesn’t know. TheollamaCLI’sname:latestfinds a model calledname.
Troubleshooting
- A model you pulled isn’t listed. The list comes from the server. Press Fetch models, or run
magpie provider refresh ollama, and pick it in the provider’s model list. Use the name Ollama lists, tag included. - Ollama isn’t running.
magpie provider test ollamasends a tiny request through each endpoint, or to each model you name; add--as codexor--as claude-codeto send it the way that agent would. Start Ollama, or check Server address.fallbacknames where requests go while it is down. - “exceeded max context length”. The conversation is longer than the model was loaded for. Set the real Context window on the provider, and the agents compact before they reach it.
- Another computer can’t be reached. Check the address and port in Server address; for HTTPS with a self-signed certificate, turn on Don't check its certificate.
FAQ
How do I use Ollama in Claude Code?
Add Ollama in magpie (Providers, Add provider, Ollama under On this machine), then pick one of its models on Claude Code’s row, or run magpie claude ollama/qwen3. Claude Code’s requests go through magpie’s gateway to Ollama’s Anthropic Messages API at http://localhost:11434 as they are.
Can Codex use Ollama?
Yes. Codex speaks only the Responses API, so magpie turns its requests into Chat Completions for Ollama, and the replies back, tool calls included. Run magpie codex ollama/qwen3.
Can Gemini CLI and OpenCode use Ollama?
Yes. Gemini CLI speaks Google’s API, so magpie translates its requests to Ollama’s Chat Completions and the replies back. OpenCode speaks Chat Completions, so its requests go to Ollama as they are. Run magpie gemini model ollama/qwen3 or magpie opencode ollama/qwen3.
How do I run qwen3-coder from Ollama in Claude Code?
Pull it in Ollama, press Fetch models in the provider’s editor in magpie (or run magpie provider refresh ollama), and pick it on Claude Code’s row. Its id in magpie is ollama/ and the name Ollama lists it under, tag included. Set its Context window too: Claude Code takes a model it doesn’t know for 200K.
Can magpie use Ollama on another computer?
Yes. Set the provider’s Server address to that computer, such as magpie provider set ollama address=192.168.1.20:11434. A server on your own network is reached directly, not through a proxy set in Settings or the system.
Does magpie work with Ollama Cloud?
Yes. Add Ollama Cloud with a key from ollama.com/settings/keys. magpie lists the models the key can use, prices them from models.dev, and shows the account’s included allowance and the credits you bought.
Do I need an API key for a local Ollama?
No. The Ollama preset takes none. Ollama Cloud needs one.
Other local servers, such as LM Studio, oMLX, vLLM and llama.cpp’s server, are in Local models. To let a local model classify each request for routing, see Intent routing.
By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · Mistral · OpenRouter · GitHub Copilot
Every agent: Models in Claude Code, Models in Codex, Models in Gemini CLI, Models in OpenCode. Ask on Discord if you get stuck.