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

  1. Pull a modelPull a model in Ollama, such as qwen3, and leave the server running.
  2. 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/….
  3. Pick it for an agentIn the Agents tab, click the model on the agent’s row and choose an Ollama model.
Terminal
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.

Terminal
magpie provider set ollama address=192.168.1.20:11434
magpie provider set ollama address=     # back to the default

Ollama Cloud

  1. Get a keyMake one at ollama.com/settings/keys.
  2. 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.
  3. Pick it for an agentChoose an Ollama Cloud model, such as deepseek-v4-pro, on the agent’s row.
Terminal
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

ProviderChat CompletionsAnthropic Messages
Ollamahttp://localhost:11434/v1http://localhost:11434
Ollama Cloudhttps://ollama.com/v1https://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:

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

Terminal
magpie claude ollama/qwen3
magpie codex ollama/qwen3
magpie gemini model ollama/qwen3
magpie opencode ollama/qwen3

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.

Terminal
magpie provider set ollama context=32k
magpie provider set ollama context.qwen3=128k

Reasoning

Terminal
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.

Usage and cost

Terminal
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.

Troubleshooting

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.