site: Mistral and Ollama pages in en, zh and ja

/docs/mistral and /docs/ollama (with zh/ and ja/) answer "how do I use
Mistral / Ollama in Claude Code, Codex, Gemini CLI and OpenCode".

Facts come from the source: the mistral, ollama and ollama-cloud
presets in internal/provider/presets.go, chattidy.go (thinking parts,
#483, #494), mistral_plan.go, ollama_usage.go, local_address.go,
gateway/ollama.go, and the usage text of internal/cli/providers_cli.go
and model_cli.go for every CLI example (provider add, fallback, models
+id, model price, model efforts).

Every docs page with a "By provider" line now lists both, in one order;
sitemap.xml, llms.txt and llms-full.txt (rebuilt) carry them.

Run on mote: node --test worker.test.mjs install.test.mjs (fail 0);
JSON-LD of the six pages parsed. Deployed (e33573b9) and every new URL
answers 200.
Not tried: the CLI examples against a live magpie (read from the
source's usage text instead).
This commit is contained in:
yetone
2026-11-10 04:54:13 +08:00
parent 53b2773d77
commit b681b036d2
33 changed files with 2481 additions and 32 deletions
+1 -1
View File
@@ -251,7 +251,7 @@ magpie claude codex/gpt-5.5</pre></div>
</ul>
<p>The routing modes are in <a href="/docs/start#routing">Get started</a>.</p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a></p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/mistral">Mistral</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a> · <a href="/docs/ollama">Ollama</a></p>
<h2 id="faq"><a class="anchor" href="#faq">FAQ</a></h2>
<h3>Do I set <code>ANTHROPIC_BASE_URL</code> myself?</h3>
+1 -1
View File
@@ -251,7 +251,7 @@ magpie codex claude/…</pre></div>
</ul>
<p>The routing modes are in <a href="/docs/start#routing">Get started</a>.</p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a></p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/mistral">Mistral</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a> · <a href="/docs/ollama">Ollama</a></p>
<h2 id="faq"><a class="anchor" href="#faq">FAQ</a></h2>
<h3>Do I write <code>[model_providers]</code> myself?</h3>
+1 -1
View File
@@ -297,7 +297,7 @@ magpie opencode copilot/claude-opus-5.5</pre></div>
<h3>Why is a Copilot model missing from my list?</h3>
<p>magpie lists what Copilot’s <code>/models</code> gives the account: chat models only, without the ones no model picker offers or the account can’t turn on. A model Copilot answered with “The requested model is not supported.” is left out for 6 hours, then tried again in case your plan changed.</p>
<p style="margin-top:48px"><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/openrouter">OpenRouter</a></p>
<p style="margin-top:48px"><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/mistral">Mistral</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/ollama">Ollama</a></p>
<p>Every agent: <a href="/docs/claude-code-models">Models in Claude Code</a>, <a href="/docs/codex-models">Models in Codex</a>, <a href="/docs/gemini-cli-models">Models in Gemini CLI</a>, <a href="/docs/opencode-models">Models in OpenCode</a>. Ask on <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> if you get stuck.</p>
</article>
</main>
+1 -1
View File
@@ -235,7 +235,7 @@ magpie gemini model codex/gpt-5.5</pre></div>
</ul>
<p>The routing modes and rules are in <a href="/docs/start#routing">Get started</a>.</p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a></p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/mistral">Mistral</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a> · <a href="/docs/ollama">Ollama</a></p>
<h2 id="faq"><a class="anchor" href="#faq">FAQ</a></h2>
<h3>Can Gemini CLI use models that aren’t Gemini?</h3>
+1 -1
View File
@@ -310,7 +310,7 @@ magpie claude google-vertex/gemini-3.1-pro-preview</pre></div>
<h3>Can I use my Gemini Code Assist or Antigravity sign-in instead?</h3>
<p>Yes. Both are subscriptions: <code>magpie accounts add gemini</code> or <code>magpie accounts add antigravity</code>, then pick a <code>gemini/…</code> or <code>antigravity/…</code> model. Code Assist needs a Standard or Enterprise account with a Google Cloud project of its own.</p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a></p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/mistral">Mistral</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a> · <a href="/docs/ollama">Ollama</a></p>
<p style="margin-top:48px">Every agent: <a href="/docs/claude-code-models">Models in Claude Code</a>, <a href="/docs/codex-models">Models in Codex</a>, <a href="/docs/gemini-cli-models">Models in Gemini CLI</a>, <a href="/docs/opencode-models">Models in OpenCode</a>. Ask on <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> if you get stuck.</p>
</article>
</main>
+1 -1
View File
@@ -283,7 +283,7 @@ magpie provider fallback xai deepseek/deepseek-v4-pro</pre></div>
<h3>Does magpie show my xAI balance?</h3>
<p>No. The Usage tab counts tokens, cache and cost for every Grok call, priced from models.dev, but magpie reads no balance from xAI. You can type the balance in with <code>magpie provider key-balance</code>, and the Usage page shows it less what magpie has priced since.</p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a></p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/mistral">Mistral</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a> · <a href="/docs/ollama">Ollama</a></p>
<p style="margin-top:48px">Every agent: <a href="/docs/claude-code-models">Models in Claude Code</a>, <a href="/docs/codex-models">Models in Codex</a>, <a href="/docs/gemini-cli-models">Models in Gemini CLI</a>, <a href="/docs/opencode-models">Models in OpenCode</a>. Ask on <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> if you get stuck.</p>
</article>
</main>
+1 -1
View File
@@ -251,7 +251,7 @@ magpie claude codex/gpt-5.5</pre></div>
</ul>
<p>ルーティングモードは<a href="/docs/ja/start#routing">はじめに</a>で説明しています。</p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a></p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/mistral">Mistral</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a> · <a href="/docs/ja/ollama">Ollama</a></p>
<h2 id="faq"><a class="anchor" href="#faq">よくある質問</a></h2>
<h3><code>ANTHROPIC_BASE_URL</code> は自分で設定しますか?</h3>
+1 -1
View File
@@ -251,7 +251,7 @@ magpie codex claude/…</pre></div>
</ul>
<p>ルーティングモードは<a href="/docs/ja/start#routing">はじめに</a>で説明しています。</p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a></p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/mistral">Mistral</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a> · <a href="/docs/ja/ollama">Ollama</a></p>
<h2 id="faq"><a class="anchor" href="#faq">よくある質問</a></h2>
<h3><code>[model_providers]</code> は自分で書きますか?</h3>
+1 -1
View File
@@ -297,7 +297,7 @@ magpie opencode copilot/claude-opus-5.5</pre></div>
<h3>Copilot のモデルが一覧にないのはなぜですか?</h3>
<p>magpie が並べるのは、Copilot の <code>/models</code> がそのアカウントに返すモデルです。チャットモデルだけで、どのモデルピッカーにも出ないものと、そのアカウントで有効にできないものは除きます。Copilot が「The requested model is not supported.」で断ったモデルは 6 時間外し、プランが変わった場合に備えてその後もう一度試します。</p>
<p style="margin-top:48px"><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/openrouter">OpenRouter</a></p>
<p style="margin-top:48px"><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/mistral">Mistral</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/ollama">Ollama</a></p>
<p>ツールごとのガイド:<a href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>、<a href="/docs/ja/codex-models">Codex で他のモデル</a>、<a href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>、<a href="/docs/ja/opencode-models">OpenCode で他のモデル</a>。困ったときは <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> で質問してください。</p>
</article>
</main>
+1 -1
View File
@@ -235,7 +235,7 @@ magpie gemini model codex/gpt-5.5</pre></div>
</ul>
<p>ルーティングモードとルールは<a href="/docs/ja/start#routing">はじめに</a>で説明しています。</p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a></p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/mistral">Mistral</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a> · <a href="/docs/ja/ollama">Ollama</a></p>
<h2 id="faq"><a class="anchor" href="#faq">よくある質問</a></h2>
<h3>Gemini CLI で Gemini 以外のモデルを使えますか?</h3>
+1 -1
View File
@@ -310,7 +310,7 @@ magpie claude google-vertex/gemini-3.1-pro-preview</pre></div>
<h3>Gemini Code Assist や Antigravity のサインインは使えますか?</h3>
<p>使えます。どちらもサブスクです。<code>magpie accounts add gemini</code> か <code>magpie accounts add antigravity</code> を実行し、<code>gemini/…</code> か <code>antigravity/…</code> のモデルを選びます。Code Assist には、専用の Google Cloud プロジェクトを持つ Standard または Enterprise のアカウントが必要です。</p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a></p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/mistral">Mistral</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a> · <a href="/docs/ja/ollama">Ollama</a></p>
<p style="margin-top:48px">ツールごとのガイド:<a href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>、<a href="/docs/ja/codex-models">Codex で他のモデル</a>、<a href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>、<a href="/docs/ja/opencode-models">OpenCode で他のモデル</a>。困ったときは <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> で質問してください。</p>
</article>
</main>
+1 -1
View File
@@ -283,7 +283,7 @@ magpie provider fallback xai deepseek/deepseek-v4-pro</pre></div>
<h3>magpie で xAI の残高は見られますか?</h3>
<p>見られません。使用量タブは Grok の呼び出しごとにトークン・キャッシュ・費用を models.dev の価格で数えますが、magpie は xAI から残高を読みません。<code>magpie provider key-balance</code> で残高を入力すると、使用量ページはそこから magpie がそれ以降に計算した費用を引いて表示します。</p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a></p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/mistral">Mistral</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a> · <a href="/docs/ja/ollama">Ollama</a></p>
<p style="margin-top:48px">ツールごとのガイド:<a href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>、<a href="/docs/ja/codex-models">Codex で他のモデル</a>、<a href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>、<a href="/docs/ja/opencode-models">OpenCode で他のモデル</a>。困ったときは <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> で質問してください。</p>
</article>
</main>
+331
View File
@@ -0,0 +1,331 @@
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mistral を Claude Code・Codex・Gemini CLI・OpenCode で使う · magpie</title>
<meta name="description" content="magpie で Mistral のモデル(Devstral や Codestral も)を Claude Code・Codex・Gemini CLI・OpenCode から使う方法:Mistral の API キーは一度追加するだけ。ツールごとにモデルを選べて、各ツールのリクエストを Mistral の API に合わせる変換、思考内容の引き継ぎ、Le Chat プランの Vibe 月間予算の表示、費用の集計、複数キーへの振り分けは magpie が受け持ちます。">
<meta name="color-scheme" content="light dark">
<meta name="theme-color" content="#fafafa">
<script>
(() => {
let mode = "system";
try { mode = localStorage.getItem("theme") || "system"; } catch {}
const q = matchMedia("(prefers-color-scheme: dark)");
const apply = () => {
const t = mode === "system" ? (q.matches ? "dark" : "light") : mode;
document.documentElement.dataset.theme = t;
document.querySelector('meta[name="theme-color"]').content = t === "dark" ? "#0b0b0c" : "#fafafa";
document.querySelectorAll("button.theme").forEach((b) => { b.dataset.mode = mode; b.title = "Theme: " + mode; });
};
q.addEventListener("change", () => mode === "system" && apply());
window.setTheme = (m) => { mode = m; try { m === "system" ? localStorage.removeItem("theme") : localStorage.setItem("theme", m); } catch {} apply(); };
window.themeMode = () => mode;
apply();
})();
</script>
<script>try{if(/Linux/.test(navigator.userAgent)&&!/Android/.test(navigator.userAgent)||localStorage.getItem("omarchy")||/[?&]omarchy=/.test(location.search))document.write('<script src="/omarchy.js"><\/script>')}catch(e){}</script>
<link rel="icon" href="/favicon.png" type="image/png">
<link rel="apple-touch-icon" href="/img/icon-256.png">
<link rel="alternate" hreflang="en" href="https://usemagpie.ai/docs/mistral">
<link rel="alternate" hreflang="zh" href="https://usemagpie.ai/docs/zh/mistral">
<link rel="alternate" hreflang="ja" href="https://usemagpie.ai/docs/ja/mistral">
<link rel="alternate" hreflang="x-default" href="https://usemagpie.ai/docs/mistral">
<link rel="canonical" href="https://usemagpie.ai/docs/ja/mistral">
<link rel="stylesheet" href="/docs.css">
<meta property="og:site_name" content="magpie">
<meta property="og:title" content="Mistral を Claude Code・Codex・Gemini CLI・OpenCode で使う">
<meta property="og:description" content="magpie で Mistral のモデル(Devstral や Codestral も)を Claude Code・Codex・Gemini CLI・OpenCode から使う方法:Mistral の API キーは一度追加するだけ。ツールごとにモデルを選べて、各ツールのリクエストを Mistral の API に合わせる変換、思考内容の引き継ぎ、Le Chat プランの Vibe 月間予算の表示、費用の集計、複数キーへの振り分けは magpie が受け持ちます。">
<meta property="og:image" content="https://usemagpie.ai/img/og.png">
<meta property="og:url" content="https://usemagpie.ai/docs/ja/mistral">
<meta name="twitter:card" content="summary_large_image">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "TechArticle",
"headline": "Mistral を Claude Code・Codex・Gemini CLI・OpenCode で使う",
"description": "magpie で Mistral のモデル(Devstral や Codestral も)を Claude Code・Codex・Gemini CLI・OpenCode から使う方法:Mistral の API キーは一度追加するだけ。ツールごとにモデルを選べて、各ツールのリクエストを Mistral の API に合わせる変換、思考内容の引き継ぎ、Le Chat プランの Vibe 月間予算の表示、費用の集計、複数キーへの振り分けは magpie が受け持ちます。",
"inLanguage": "ja",
"url": "https://usemagpie.ai/docs/ja/mistral",
"about": {
"@type": "SoftwareApplication",
"name": "magpie",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "macOS, Windows, Linux"
},
"publisher": {
"@type": "Organization",
"name": "magpie",
"url": "https://usemagpie.ai/"
}
},
{
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "Claude Code で Mistral を使うには?",
"acceptedAnswer": {
"@type": "Answer",
"text": "magpie に Mistral の API キーを追加し(プロバイダ、プロバイダを追加、Mistral)、Claude Code の行で mistral-large-4 などの Mistral モデルを選ぶか、magpie claude mistral/mistral-large-4 を実行します。Mistral は Chat Completions しか提供していないので、magpie が Claude Code の Anthropic Messages リクエストを変換して https://api.mistral.ai/v1 に送り、返答を戻します。思考内容も含みます。"
}
},
{
"@type": "Question",
"name": "Codex で Devstral などの Mistral モデルを使えますか?",
"acceptedAnswer": {
"@type": "Answer",
"text": "使えます。Devstral を含め、Mistral のキーで使えるモデルならどれでも Codex から使えます。Codex が話す OpenAI Responses を Mistral は提供していないので、magpie が各リクエストを Chat Completions に変換し、apply_patch などの Codex のカスタムツールを関数としてモデルに渡し、呼び出しを Codex が実行できる形で返します。"
}
},
{
"@type": "Question",
"name": "OpenCode で Codestral などの Mistral モデルを使うには?",
"acceptedAnswer": {
"@type": "Answer",
"text": "magpie でモデルを選ぶか、magpie opencode mistral/mistral-large-4 を実行します。キーで Codestral や Devstral が使えるなら、使い方は同じです。OpenCode は Chat Completions を話すので、リクエストはそのまま Mistral に送ります。途中で直すのは Mistral が拒否するものだけで、OpenCode の store フィールドと、reasoning_content で送り返される前のターンの思考です。"
}
},
{
"@type": "Question",
"name": "Gemini CLI で Mistral を使えますか?",
"acceptedAnswer": {
"@type": "Answer",
"text": "使えます。Gemini CLI は Google の Gemini API を話すので、magpie がリクエストを Mistral の Chat Completions に変換し、返答を戻します。ストリーミングとツール呼び出しも含みます。magpie gemini model mistral/mistral-large-4 を実行してください。"
}
},
{
"@type": "Question",
"name": "Mistral が 422 extra_forbidden を返すのはなぜ?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Mistral は知らないフィールドをすべて拒否します。magpie は前のターンの思考を Mistral が受け付ける思考パートにして送り、一部のツールが付ける Ollama のオプションを外します。store(OpenCode)のように Mistral が名指しした省略可能なフィールドは外して問い合わせ直し、それ以降は送りません。"
}
},
{
"@type": "Question",
"name": "Le Chat プランの Vibe 予算を magpie で見られますか?",
"acceptedAnswer": {
"@type": "Answer",
"text": "見られます。Le Chat プラン(Pro・Student・Team)の Vibe キーには、その月の Vibe 予算の使用量、Mistral が請求する通貨、リセット日、プラン名が表示されます。コンソールで作った Studio キーには、代わりに組織の API 予算が “API · Month” として表示されます。"
}
}
]
}
]
}
</script>
</head>
<body>
<nav><div class="wrap">
<a class="brand" href="/ja/"><img class="bird" src="/img/magpie-small.svg" alt="">magpie <small>ドキュメント</small></a>
<div class="links">
<a href="/ja/">ホーム</a>
<a href="/docs/ja/start">はじめに</a>
<a href="/docs/ja/intent">インテントルーティング</a>
<a href="/docs/ja/plugins">プラグイン</a>
<a class="toc-only" href="/docs/ja/remote">リモート magpie</a>
<a class="toc-only" href="/docs/ja/docker">Docker</a>
<a class="toc-only" href="/docs/ja/privacy">プライバシー</a>
<a class="toc-only" href="/docs/ja/masking">プライバシーマスキング</a>
<a class="toc-only" href="/docs/ja/mcp-router">MCP ルーター</a>
<a class="toc-only" href="/docs/ja/library">ライブラリ</a>
<a class="toc-only" href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>
<a class="toc-only" href="/docs/ja/codex-models">Codex で他のモデル</a>
<a class="toc-only" href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>
<a class="toc-only" href="/docs/ja/subscriptions">サブスクを任意のエージェントで</a>
<a class="toc-only" href="/docs/ja/local-models">ローカルモデル</a>
<a class="toc-only" href="/docs/ja/opencode-models">OpenCode で他のモデル</a>
<a class="toc-only" href="/docs/ja/alternatives">CC Switch・CCR との比較</a>
<a href="/docs/ja/import">magpie に追加</a>
<a href="/docs/integrate">アプリ連携</a>
<a href="https://github.com/yetone/magpie-releases/releases">リリース</a>
</div>
<div class="langs">
<button class="icon-btn lang" type="button" aria-label="言語" title="言語" aria-haspopup="true" aria-expanded="false" aria-controls="langs"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="8" cy="8" r="6.25"/><path d="M1.75 8h12.5M8 1.75c1.7 1.75 2.55 3.83 2.55 6.25S9.7 12.5 8 14.25M8 1.75C6.3 3.5 5.45 5.58 5.45 8S6.3 12.5 8 14.25"/></svg></button>
<div class="lang-menu" id="langs" hidden>
<a href="/docs/mistral" hreflang="en" lang="en">English</a>
<a href="/docs/zh/mistral" hreflang="zh" lang="zh">中文</a>
<a href="/docs/ja/mistral" hreflang="ja" lang="ja">日本語</a>
</div>
</div>
<a class="icon-btn" href="https://discord.gg/vGSnD3ZKQF" aria-label="Discord の magpie" title="Discord に参加"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"/></svg></a>
<a class="icon-btn" href="https://github.com/yetone/magpie" aria-label="GitHub の magpie" title="GitHub のソースコード"><svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"/></svg></a>
<button class="icon-btn theme" type="button" aria-label="Theme" title="Theme: system"><svg class="i-system" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1.75" y="2.75" width="12.5" height="8.5" rx="1.5"/><path d="M5.5 14h5M8 11.25V14"/></svg><svg class="i-light" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="8" cy="8" r="3"/><path d="M8 1v1.5M8 13.5V15M1 8h1.5M13.5 8H15M3 3l1 1M12 12l1 1M3 13l1-1M12 4l1-1"/></svg><svg class="i-dark" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"><path d="M13.5 9.5A5.5 5.5 0 0 1 6.5 2.5a5.5 5.5 0 1 0 7 7Z"/></svg></button>
<a class="btn small" href="/#get">ダウンロード</a>
</div></nav>
<main class="wrap doc">
<aside class="toc">
<p>このページ</p>
<a href="#add">追加する</a>
<a href="#endpoints">エンドポイント</a>
<a href="#models">モデル一覧</a>
<a href="#agents">ツールごとの使い方</a>
<a href="#shaping">magpie が直すもの</a>
<a href="#reasoning">推論</a>
<a href="#search">Web 検索</a>
<a href="#cost">Vibe・費用・使用量</a>
<a href="#keys">複数のキー</a>
<a href="#trouble">うまくいかないとき</a>
<a href="#faq">よくある質問</a>
</aside>
<article>
<p class="eyebrow" id="overview">ドキュメント · プロバイダ</p>
<h1>Mistral を Claude Code・Codex・Gemini CLI・OpenCode で使う</h1>
<p class="lede">Mistral はモデルを一つの API、<code>api.mistral.ai</code> の OpenAI 形式の Chat Completions で提供しています。Mistral の API キーを magpie に一度追加すれば、Claude Code・Codex・Gemini CLI・OpenCode などつないだすべてのツールが、magpie のゲートウェイ <code>127.0.0.1:3425</code> 経由で Mistral を使えます。ツールごとに別のモデルを選べます。別の API を話すツールのリクエストは、途中で magpie が変換します。</p>
<h2 id="add"><a class="anchor" href="#add">Mistral を追加する</a></h2>
<ol class="steps">
<li><b>キーを取得</b><a href="https://console.mistral.ai/api-keys">console.mistral.ai</a> で作ります。Le Chat プランの Vibe キーも同じプロバイダに入れます。</li>
<li><b>プロバイダを追加</b>magpie の <span class="ui">プロバイダ</span> で <span class="ui">+ プロバイダを追加</span> を押し、<span class="ui">Mistral</span> を選んでキーを貼り付け、保存します。magpie がそのキーで使えるモデルを Mistral に問い合わせます。</li>
<li><b>ツールで選ぶ</b><span class="ui">エージェント</span> タブで、ツールの行のモデルを押し、<code>mistral-large-4</code> などの Mistral モデルを選びます。</li>
</ol>
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-add">コピー</button><pre id="ex-add">magpie provider add mistral &lt;key&gt;
magpie provider test mistral</pre></div>
<p>magpie のモデル ID は <code>プロバイダ/モデル</code> の形なので、Mistral のモデルは <code>mistral/mistral-large-4</code> のようになります。前がプロバイダ、後ろが Mistral 自身の ID です。キーは magpie の設定に保存され、magpie がシェルから読むことはありません。</p>
<p>OpenCode や Alma で Mistral をもう設定してあるなら、magpie がそれらのアプリから取り込むときに Mistral プロバイダとして入ります。キーごとに一つずつ項目を持つアプリ(“Mistral #0001”、“Mistral #0002”…)からは、その数だけキーを持つ一つの Mistral プロバイダになり、どのツールのモデル選択にも一度だけ並びます。</p>
<h2 id="endpoints"><a class="anchor" href="#endpoints">エンドポイント</a></h2>
<div class="table-wrap"><table>
<tr><th>API</th><th>アドレス</th><th>用途</th></tr>
<tr><td>Chat Completions</td><td><code>https://api.mistral.ai/v1</code></td><td>モデル一覧と、すべてのツールのリクエスト(OpenCode はそのまま、Claude Code・Codex・Gemini CLI は変換して)</td></tr>
<tr><td>課金</td><td><code>https://api.mistral.ai/v1/billing/budget</code>、<code>/v1/billing/subscription</code></td><td>キーのその月の Vibe 予算または API 予算と、加入しているプラン</td></tr>
</table></div>
<p>magpie の Mistral プロバイダには Anthropic Messages や Responses のアドレスがないので、どちらかを話すツールのリクエストは Chat Completions に変換し、返答を戻します。ストリーミングとツール呼び出しも含みます。</p>
<h2 id="models"><a class="anchor" href="#models">モデル一覧</a></h2>
<p>magpie は一覧を Mistral の <code>https://api.mistral.ai/v1/models</code> から取得するので、ツールにはそのキーで使えるモデルが並びます。名前・推論レベル・価格は models.dev の <code>mistral</code> カタログから取り、Devstral・Codestral・Magistral のモデルにはどの選択肢でも Mistral のロゴが付きます。Mistral はほかのラボのモデルも提供しています。GLM や DeepSeek の <code>deepseek-v4.1-flash-1017</code> などで、同じキーで使え、下に挙げる修正もそのまま効きます。ツールに見せるモデルは、プロバイダのモデル一覧かターミナルで選べます。</p>
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-models">コピー</button><pre id="ex-models">magpie provider models mistral +mistral-large-4 +mistral-medium-3.5
magpie provider refresh-every mistral 1d</pre></div>
<h2 id="agents"><a class="anchor" href="#agents">ツールごとの使い方</a></h2>
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-agents">コピー</button><pre id="ex-agents">magpie claude mistral/mistral-large-4
magpie codex mistral/mistral-large-4
magpie gemini model mistral/mistral-large-4
magpie opencode mistral/mistral-large-4</pre></div>
<ul>
<li><b>Claude Code</b> は Anthropic Messages を話しますが、Mistral はこれを提供していません。magpie が各リクエストを Chat Completions に変換し、返答を戻します。推論モデルの思考は、Claude Code には思考として、続いて本文として届きます。<a href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>。</li>
<li><b>Codex</b> は OpenAI Responses を話し、Mistral はこれも提供していないので、リクエストは変換して送ります。<code>apply_patch</code> などの Codex のカスタムツールは関数としてモデルに渡し、その呼び出しは Codex が実行できるカスタムツール呼び出しとして返します。<a href="/docs/ja/codex-models">Codex で他のモデル</a>。</li>
<li><b>Gemini CLI</b> は Google の Gemini API を話します。magpie が各リクエストを Chat Completions に変換し、返答を戻します。<a href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>。</li>
<li><b>OpenCode</b> は Chat Completions を話すので、リクエストはそのまま Mistral に送ります。手を入れるのは下に挙げた点だけです。<a href="/docs/ja/opencode-models">OpenCode で他のモデル</a>。</li>
</ul>
<h2 id="shaping"><a class="anchor" href="#shaping">magpie が Mistral 向けに直すもの</a></h2>
<p>Mistral の API は受け付けるものに厳しく、推論モデルの思考も独自の形で返します。magpie はそのまま渡すリクエストでも変換するリクエストでも、途中でその両方を整えます。</p>
<ul>
<li><b>パートに分かれた思考。</b>Mistral は推論モデルの思考を、型付きのパートとして <code>content</code> に入れて送ります。思考と本文が一つのチャンクに入ることもあります。Chat の仕様ではここは文字列です。OpenCode は最初のそうしたチャンクで止まっていました(“Invalid … stream event”)。magpie は思考を <code>reasoning_content</code> に、本文を普通の文字列に移します。ストリーミングでもそうでなくても同じです。</li>
<li><b>送り返される思考。</b>OpenCode は前のターンの思考を <code>reasoning_content</code> に入れて送り返しますが、Mistral はこれを 422 <code>extra_forbidden</code> で拒否します。magpie はそれを Mistral 自身が返すときの思考パートにして、そのターンの本文の前に置くので、思考はコンテキストに残ります。変換するリクエストも同じ扱いなので、Mistral が提供する DeepSeek のモデルでも Codex のツール呼び出しのループが止まりません。</li>
<li><b>Mistral が知らないフィールド。</b>OpenCode の <code>store</code> や Kimi Code の思考スイッチは 422 <code>extra_forbidden</code> になっていました。magpie は Mistral が名指しした省略可能なフィールドを外して問い合わせ直し、それで通れば以後 Mistral には送りません。</li>
<li><b>Ollama のオプション。</b>Hermes Agent のように、ゲートウェイを Ollama サーバーだと思ったツールは、Chat のフィールドの横に Ollama の <code>options</code>(その <code>num_ctx</code>)を付けて送ります。magpie はそれを外すので、Mistral には届きません。</li>
</ul>
<h2 id="reasoning"><a class="anchor" href="#reasoning">推論</a></h2>
<ul>
<li><b>推論の強さ。</b>ツールが求める推論の強さは、カタログにあるそのモデルのレベルのうち最も近いものに合わせます。レベルがわからないモデルには、ツールが求めたとおりに送ります。</li>
<li><b>推論オフ。</b>Gemini CLI のように magpie が変換するツールが推論をオフにし、モデルのレベルに <code>none</code> があるとき、magpie は none を求めます。</li>
<li><b>ターンをまたぐ思考。</b>推論モデルの思考は、ツールごとにそのツールの形で届きます。OpenCode には <code>reasoning_content</code>、Claude Code には思考ブロック、Codex には推論として。次のターンで送り返されると、Mistral には思考パートとして届きます。<a href="#shaping">magpie が直すもの</a> を見てください。</li>
</ul>
<h2 id="search"><a class="anchor" href="#search">Web 検索</a></h2>
<p>Mistral の Chat Completions API は magpie のために Web を検索しないので、どのツールでも magpie がモデルに自前の検索ツールを渡します。答えるのは設定で選んだ検索サービスで、選んでいなければ magpie が選びます。</p>
<h2 id="cost"><a class="anchor" href="#cost">Vibe・費用・使用量</a></h2>
<ul>
<li><b>Vibe の月間予算。</b>Le Chat プラン(Pro・Student・Team)には Mistral Vibe の 1 か月分が付いています。その Vibe キーの行には、その月の予算の使用量(Mistral が請求する通貨で)、リセット日、プラン名が表示されます。</li>
<li><b>API の月間予算。</b>コンソールで作った Studio キーには、組織の API 予算が “API · Month” として、Vibe の月とは別に表示されます。予算は組織のものなので、同じ組織のキーはどれも同じ数字になります。予算のないキーにはカードが出ません。</li>
<li><b>従量課金。</b>従量課金をオンにしていると、予算を超えた分は止まらずに請求されるので、その月の予算を使い切ってもキーのモデルは止まりません。</li>
<li><b>キャッシュのトークン。</b>返答がキャッシュ済みのプロンプトトークンを報告すると、<span class="ui">使用量</span> タブはそれをプロンプトの残りと分けて数えます。</li>
<li><b>キャッシュを生かす。</b>キーが複数あるとき、会話のキャッシュに残す価値があり(1,024 トークン以上)、まだ温かい(5 分以内に読まれた)あいだは、その会話は同じキーを使い続けます。</li>
<li><b>費用。</b>使用量タブは、models.dev にある Mistral の価格で呼び出しごとに費用を計算します。magpie は Mistral から残高を読みません。<code>key-balance</code> で自分で入力すると、使用量ページはそこから magpie がそれ以降のキーの呼び出しに付けた費用を引いて表示します。</li>
</ul>
<h2 id="keys"><a class="anchor" href="#keys">複数のキーとフェイルオーバー</a></h2>
<p>一つの Mistral プロバイダに複数のキーを入れられます。その下の <span class="ui">別のキーを追加</span> を押すか、まとめて貼り付けます。リクエストはオンになっている最初のキーに行き、そのキーが尽きるかレート制限にかかると次のキーが引き継ぎます。</p>
<ul>
<li><b>支出上限。</b><code>spend-cap</code> で、キーごとに 1 日・1 か月・累計のドル上限を決められます。金額は使用量タブの計算で数え、上限に達するとルーティングはほかのキーとフォールバックに移ります。</li>
<li><b>フォールバック。</b><code>fallback</code> で、Mistral の枠が尽きたときや落ちたときの行き先を決めます。別のプロバイダのモデルか、ルーティンググループです。</li>
</ul>
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-keys">コピー</button><pre id="ex-keys">magpie provider spend-cap mistral &lt;key&gt; 20 month
magpie provider key-balance mistral &lt;key&gt; 25
magpie provider fallback mistral deepseek/deepseek-v4-pro</pre></div>
<h2 id="trouble"><a class="anchor" href="#trouble">うまくいかないとき</a></h2>
<ul>
<li><b>422 <code>extra_forbidden</code>、“Extra inputs are not permitted”。</b>Mistral が知らないフィールドを拒否しました。ツールがよく送るものは magpie が直してあり、Mistral が名指しした省略可能なフィールドは外して問い合わせ直します。<a href="#shaping">magpie が直すもの</a> を見てください。</li>
<li><b>OpenCode で “Invalid … stream event”。</b>Mistral がパートに分けて返した思考が原因です。magpie は思考を <code>reasoning_content</code> に、本文を文字列にして OpenCode に渡します。</li>
<li><b>Vibe のカードが出ない。</b>magpie がその月の予算を表示するのは、Mistral が Vibe キーか Studio キーだと答え、予算がゼロより大きいキーだけです。</li>
<li><b>キーの確認。</b><code>magpie provider test mistral</code> は各エンドポイントに、または指定した各モデルに小さなリクエストを送ります。<code>--as codex</code> や <code>--as claude-code</code> を付けると、そのツールと同じ形で送ります。</li>
</ul>
<h2 id="faq"><a class="anchor" href="#faq">よくある質問</a></h2>
<h3>Claude Code で Mistral を使うには?</h3>
<p>magpie に Mistral の API キーを追加し(プロバイダ、プロバイダを追加、Mistral)、Claude Code の行で <code>mistral-large-4</code> などの Mistral モデルを選ぶか、<code>magpie claude mistral/mistral-large-4</code> を実行します。Mistral は Chat Completions しか提供していないので、magpie が Claude Code の Anthropic Messages リクエストを変換して <code>https://api.mistral.ai/v1</code> に送り、返答を戻します。思考内容も含みます。</p>
<h3>Codex で Devstral などの Mistral モデルを使えますか?</h3>
<p>使えます。Devstral を含め、Mistral のキーで使えるモデルならどれでも Codex から使えます。Codex が話す OpenAI Responses を Mistral は提供していないので、magpie が各リクエストを Chat Completions に変換し、apply_patch などの Codex のカスタムツールを関数としてモデルに渡し、呼び出しを Codex が実行できる形で返します。</p>
<h3>OpenCode で Codestral などの Mistral モデルを使うには?</h3>
<p>magpie でモデルを選ぶか、<code>magpie opencode mistral/mistral-large-4</code> を実行します。キーで Codestral や Devstral が使えるなら、使い方は同じです。OpenCode は Chat Completions を話すので、リクエストはそのまま Mistral に送ります。途中で直すのは Mistral が拒否するものだけで、OpenCode の <code>store</code> フィールドと、<code>reasoning_content</code> で送り返される前のターンの思考です。</p>
<h3>Gemini CLI で Mistral を使えますか?</h3>
<p>使えます。Gemini CLI は Google の Gemini API を話すので、magpie がリクエストを Mistral の Chat Completions に変換し、返答を戻します。ストリーミングとツール呼び出しも含みます。<code>magpie gemini model mistral/mistral-large-4</code> を実行してください。</p>
<h3>Mistral が 422 extra_forbidden を返すのはなぜ?</h3>
<p>Mistral は知らないフィールドをすべて拒否します。magpie は前のターンの思考を Mistral が受け付ける思考パートにして送り、一部のツールが付ける Ollama のオプションを外します。<code>store</code>(OpenCode)のように Mistral が名指しした省略可能なフィールドは外して問い合わせ直し、それ以降は送りません。</p>
<h3>Le Chat プランの Vibe 予算を magpie で見られますか?</h3>
<p>見られます。Le Chat プラン(Pro・Student・Team)の Vibe キーには、その月の Vibe 予算の使用量、Mistral が請求する通貨、リセット日、プラン名が表示されます。コンソールで作った Studio キーには、代わりに組織の API 予算が “API · Month” として表示されます。</p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a> · <a href="/docs/ja/ollama">Ollama</a></p>
<p style="margin-top:48px">ツールごとのガイド:<a href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>、<a href="/docs/ja/codex-models">Codex で他のモデル</a>、<a href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>、<a href="/docs/ja/opencode-models">OpenCode で他のモデル</a>。困ったときは <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> で質問してください。</p>
</article>
</main>
<footer><div class="wrap">
<span>© 2026 magpie · MIT</span>
<div class="links">
<a href="/ja/">ホーム</a>
<a href="/docs/ja/intent">インテントルーティング</a>
<a href="/docs/ja/plugins">プラグイン</a>
<a href="/docs/ja/remote">リモート magpie</a>
<a href="/docs/ja/docker">Docker</a>
<a href="/docs/ja/privacy">プライバシー</a>
<a href="/docs/ja/masking">プライバシーマスキング</a>
<a href="/docs/ja/mcp-router">MCP ルーター</a>
<a href="/docs/ja/library">ライブラリ</a>
<a href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>
<a href="/docs/ja/codex-models">Codex で他のモデル</a>
<a href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>
<a href="/docs/ja/subscriptions">サブスクを任意のエージェントで</a>
<a href="/docs/ja/local-models">ローカルモデル</a>
<a href="/docs/ja/opencode-models">OpenCode で他のモデル</a>
<a href="/docs/ja/alternatives">CC Switch・CCR との比較</a>
<a href="/docs/ja/import">magpie に追加</a>
<a href="/docs/integrate">アプリ連携</a>
<a href="https://github.com/yetone/magpie">GitHub</a>
<a href="https://discord.gg/vGSnD3ZKQF">Discord</a>
<a href="/docs/ja/contributors">コントリビューター</a>
<a href="https://github.com/yetone/magpie-releases/releases">リリース</a>
</div>
</div></footer>
<script>
(() => {
const next = { system: "light", light: "dark", dark: "system" };
document.querySelectorAll("button.theme").forEach((b) => {
b.dataset.mode = themeMode();
b.title = "Theme: " + themeMode();
b.addEventListener("click", () => setTheme(next[themeMode()]));
});
document.querySelectorAll(".copy").forEach((b) => b.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(document.getElementById(b.dataset.copy).textContent);
b.textContent = "コピーしました"; setTimeout(() => (b.textContent = "コピー"), 1400);
} catch {}
}));
})();
</script>
<script src="/docs.js"></script>
</body>
</html>
+377
View File
@@ -0,0 +1,377 @@
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ollama を Claude Code・Codex・Gemini CLI・OpenCode で使う · magpie</title>
<meta name="description" content="magpie で Ollama(このマシンでも別のマシンでも)と Ollama Cloud を Claude Code・Codex・Gemini CLI・OpenCode から使う方法:一度追加するだけで、ツールごとに qwen3 などのモデルを選べます。各ツールの API の変換、コンテキストウィンドウの伝達、使用量と Ollama Cloud の枠の集計は magpie が受け持ちます。">
<meta name="color-scheme" content="light dark">
<meta name="theme-color" content="#fafafa">
<script>
(() => {
let mode = "system";
try { mode = localStorage.getItem("theme") || "system"; } catch {}
const q = matchMedia("(prefers-color-scheme: dark)");
const apply = () => {
const t = mode === "system" ? (q.matches ? "dark" : "light") : mode;
document.documentElement.dataset.theme = t;
document.querySelector('meta[name="theme-color"]').content = t === "dark" ? "#0b0b0c" : "#fafafa";
document.querySelectorAll("button.theme").forEach((b) => { b.dataset.mode = mode; b.title = "Theme: " + mode; });
};
q.addEventListener("change", () => mode === "system" && apply());
window.setTheme = (m) => { mode = m; try { m === "system" ? localStorage.removeItem("theme") : localStorage.setItem("theme", m); } catch {} apply(); };
window.themeMode = () => mode;
apply();
})();
</script>
<script>try{if(/Linux/.test(navigator.userAgent)&&!/Android/.test(navigator.userAgent)||localStorage.getItem("omarchy")||/[?&]omarchy=/.test(location.search))document.write('<script src="/omarchy.js"><\/script>')}catch(e){}</script>
<link rel="icon" href="/favicon.png" type="image/png">
<link rel="apple-touch-icon" href="/img/icon-256.png">
<link rel="alternate" hreflang="en" href="https://usemagpie.ai/docs/ollama">
<link rel="alternate" hreflang="zh" href="https://usemagpie.ai/docs/zh/ollama">
<link rel="alternate" hreflang="ja" href="https://usemagpie.ai/docs/ja/ollama">
<link rel="alternate" hreflang="x-default" href="https://usemagpie.ai/docs/ollama">
<link rel="canonical" href="https://usemagpie.ai/docs/ja/ollama">
<link rel="stylesheet" href="/docs.css">
<meta property="og:site_name" content="magpie">
<meta property="og:title" content="Ollama を Claude Code・Codex・Gemini CLI・OpenCode で使う">
<meta property="og:description" content="magpie で Ollama(このマシンでも別のマシンでも)と Ollama Cloud を Claude Code・Codex・Gemini CLI・OpenCode から使う方法:一度追加するだけで、ツールごとに qwen3 などのモデルを選べます。各ツールの API の変換、コンテキストウィンドウの伝達、使用量と Ollama Cloud の枠の集計は magpie が受け持ちます。">
<meta property="og:image" content="https://usemagpie.ai/img/og.png">
<meta property="og:url" content="https://usemagpie.ai/docs/ja/ollama">
<meta name="twitter:card" content="summary_large_image">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "TechArticle",
"headline": "Ollama を Claude Code・Codex・Gemini CLI・OpenCode で使う",
"description": "magpie で Ollama(このマシンでも別のマシンでも)と Ollama Cloud を Claude Code・Codex・Gemini CLI・OpenCode から使う方法:一度追加するだけで、ツールごとに qwen3 などのモデルを選べます。各ツールの API の変換、コンテキストウィンドウの伝達、使用量と Ollama Cloud の枠の集計は magpie が受け持ちます。",
"inLanguage": "ja",
"url": "https://usemagpie.ai/docs/ja/ollama",
"about": {
"@type": "SoftwareApplication",
"name": "magpie",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "macOS, Windows, Linux"
},
"publisher": {
"@type": "Organization",
"name": "magpie",
"url": "https://usemagpie.ai/"
}
},
{
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "Claude Code で Ollama のローカルモデルを使うには?",
"acceptedAnswer": {
"@type": "Answer",
"text": "magpie に Ollama を追加し(プロバイダ → プロバイダを追加 → このマシン上の Ollama)、Claude Code の行でそのモデルを選ぶか、magpie claude ollama/qwen3 を実行します。Claude Code のリクエストは magpie のゲートウェイを通り、http://localhost:11434 にある Ollama の Anthropic Messages API へそのまま届きます。"
}
},
{
"@type": "Question",
"name": "Codex で Ollama は使えますか?",
"acceptedAnswer": {
"@type": "Answer",
"text": "使えます。Codex は Responses API しか話さないので、magpie がリクエストを Chat Completions に変換して Ollama に送り、返答を元に戻します。ツール呼び出しも含みます。magpie codex ollama/qwen3 を実行してください。"
}
},
{
"@type": "Question",
"name": "Gemini CLI や OpenCode でも Ollama は使えますか?",
"acceptedAnswer": {
"@type": "Answer",
"text": "使えます。Gemini CLI は Google の API を話すので、magpie がリクエストを Ollama の Chat Completions に変換し、返答を元に戻します。OpenCode は Chat Completions を話すので、リクエストはそのまま Ollama に届きます。magpie gemini model ollama/qwen3 か magpie opencode ollama/qwen3 を実行してください。"
}
},
{
"@type": "Question",
"name": "Ollama の qwen3-coder を Claude Code で使うには?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Ollama で pull してから、magpie のプロバイダ編集画面で「モデルを取得」を押し(または magpie provider refresh ollama を実行し)、Claude Code の行で選びます。magpie での ID は ollama/ に Ollama が表示する名前(タグ込み)を続けたものです。コンテキストウィンドウも設定してください。Claude Code は知らないモデルを 200K とみなします。"
}
},
{
"@type": "Question",
"name": "別のマシンの Ollama を使えますか?",
"acceptedAnswer": {
"@type": "Answer",
"text": "使えます。プロバイダのサーバーアドレスをそのマシンに変えます。たとえば magpie provider set ollama address=192.168.1.20:11434 です。自分のネットワーク内のサーバーには、設定やシステムのプロキシを通さず直接つなぎます。"
}
},
{
"@type": "Question",
"name": "Ollama Cloud にも対応していますか?",
"acceptedAnswer": {
"@type": "Answer",
"text": "対応しています。ollama.com/settings/keys で作ったキーで Ollama Cloud を追加すると、magpie はそのキーで使えるモデルを一覧にし、models.dev の価格で計算し、アカウントのプランに含まれる枠と購入したクレジットを表示します。"
}
},
{
"@type": "Question",
"name": "ローカルの Ollama に API キーは要りますか?",
"acceptedAnswer": {
"@type": "Answer",
"text": "要りません。Ollama のプリセットはキーなしで使えます。Ollama Cloud にはキーが要ります。"
}
}
]
}
]
}
</script>
</head>
<body>
<nav><div class="wrap">
<a class="brand" href="/ja/"><img class="bird" src="/img/magpie-small.svg" alt="">magpie <small>ドキュメント</small></a>
<div class="links">
<a href="/ja/">ホーム</a>
<a href="/docs/ja/start">はじめに</a>
<a href="/docs/ja/intent">インテントルーティング</a>
<a href="/docs/ja/plugins">プラグイン</a>
<a class="toc-only" href="/docs/ja/remote">リモート magpie</a>
<a class="toc-only" href="/docs/ja/docker">Docker</a>
<a class="toc-only" href="/docs/ja/privacy">プライバシー</a>
<a class="toc-only" href="/docs/ja/masking">プライバシーマスキング</a>
<a class="toc-only" href="/docs/ja/mcp-router">MCP ルーター</a>
<a class="toc-only" href="/docs/ja/library">ライブラリ</a>
<a class="toc-only" href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>
<a class="toc-only" href="/docs/ja/codex-models">Codex で他のモデル</a>
<a class="toc-only" href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>
<a class="toc-only" href="/docs/ja/subscriptions">サブスクを任意のエージェントで</a>
<a class="toc-only" href="/docs/ja/local-models">ローカルモデル</a>
<a class="toc-only" href="/docs/ja/opencode-models">OpenCode で他のモデル</a>
<a class="toc-only" href="/docs/ja/alternatives">CC Switch・CCR との比較</a>
<a href="/docs/ja/import">magpie に追加</a>
<a href="/docs/integrate">アプリ連携</a>
<a href="https://github.com/yetone/magpie-releases/releases">リリース</a>
</div>
<div class="langs">
<button class="icon-btn lang" type="button" aria-label="言語" title="言語" aria-haspopup="true" aria-expanded="false" aria-controls="langs"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="8" cy="8" r="6.25"/><path d="M1.75 8h12.5M8 1.75c1.7 1.75 2.55 3.83 2.55 6.25S9.7 12.5 8 14.25M8 1.75C6.3 3.5 5.45 5.58 5.45 8S6.3 12.5 8 14.25"/></svg></button>
<div class="lang-menu" id="langs" hidden>
<a href="/docs/ollama" hreflang="en" lang="en">English</a>
<a href="/docs/zh/ollama" hreflang="zh" lang="zh">中文</a>
<a href="/docs/ja/ollama" hreflang="ja" lang="ja">日本語</a>
</div>
</div>
<a class="icon-btn" href="https://discord.gg/vGSnD3ZKQF" aria-label="Discord の magpie" title="Discord に参加"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"/></svg></a>
<a class="icon-btn" href="https://github.com/yetone/magpie" aria-label="GitHub の magpie" title="GitHub のソースコード"><svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"/></svg></a>
<button class="icon-btn theme" type="button" aria-label="Theme" title="Theme: system"><svg class="i-system" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1.75" y="2.75" width="12.5" height="8.5" rx="1.5"/><path d="M5.5 14h5M8 11.25V14"/></svg><svg class="i-light" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="8" cy="8" r="3"/><path d="M8 1v1.5M8 13.5V15M1 8h1.5M13.5 8H15M3 3l1 1M12 12l1 1M3 13l1-1M12 4l1-1"/></svg><svg class="i-dark" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"><path d="M13.5 9.5A5.5 5.5 0 0 1 6.5 2.5a5.5 5.5 0 1 0 7 7Z"/></svg></button>
<a class="btn small" href="/#get">ダウンロード</a>
</div></nav>
<main class="wrap doc">
<aside class="toc">
<p>このページ</p>
<a href="#add">Ollama を追加する</a>
<a href="#remote">別のマシン</a>
<a href="#cloud">Ollama Cloud</a>
<a href="#endpoints">エンドポイント</a>
<a href="#models">モデル一覧</a>
<a href="#agents">ツールごとの使い方</a>
<a href="#window">コンテキストウィンドウ</a>
<a href="#reasoning">推論</a>
<a href="#tools">ツール呼び出し</a>
<a href="#masking">プライバシーマスク</a>
<a href="#cost">使用量と費用</a>
<a href="#server">Ollama サーバーとして</a>
<a href="#trouble">うまくいかないとき</a>
<a href="#faq">よくある質問</a>
</aside>
<article>
<p class="eyebrow" id="overview">ドキュメント · プロバイダ</p>
<h1>Ollama を Claude Code・Codex・Gemini CLI・OpenCode で使う</h1>
<p class="lede">Ollama は pull したモデルを <code>http://localhost:11434</code> で OpenAI Chat Completions と Anthropic Messages の二つの API で提供します。Ollama Cloud はクラウドのモデルを <code>ollama.com</code> で同じように提供し、API キーで使います。どちらかを magpie に一度追加すれば、Claude Code・Codex・Gemini CLI・OpenCode などつないだすべてのツールが、magpie のゲートウェイ <code>127.0.0.1:3425</code> 経由で使えます。ツールごとに別のモデルを選べます。</p>
<h2 id="add"><a class="anchor" href="#add">Ollama を追加する</a></h2>
<ol class="steps">
<li><b>モデルを pull する</b>Ollama で <code>qwen3</code> などのモデルを pull し、サーバーを動かしたままにします。</li>
<li><b>プロバイダを追加する</b>magpie の <span class="ui">プロバイダ</span> タブで <span class="ui">+ プロバイダを追加</span> を押し、<span class="ui">このマシン上</span> から Ollama を選びます。キーは要りません。magpie がサーバーにモデルを問い合わせ、<code>ollama/…</code> として表示されます。</li>
<li><b>ツールに割り当てる</b><span class="ui">エージェント</span> タブでツールの行のモデルをクリックし、Ollama のモデルを選びます。</li>
</ol>
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-add">コピー</button><pre id="ex-add">ollama pull qwen3
magpie provider add ollama
magpie provider test ollama</pre></div>
<p>magpie のモデル ID は <code>プロバイダ/モデル</code> の形なので、<code>qwen3</code> として pull したモデルは <code>ollama/qwen3</code> になります。タグも ID に残り、<code>ollama/qwen3:8b</code> のようになります。ターミナル UI で追加すると、サーバーのアドレスを聞かれます。LM Studio・oMLX・vLLM・llama.cpp のサーバーは <a href="/docs/ja/local-models">ローカルモデル</a> を見てください。</p>
<h2 id="remote"><a class="anchor" href="#remote">別のポート・別のマシン</a></h2>
<p>Ollama が別のポートで待ち受けている場合や、GPU マシンや NAS など別のマシンで動いている場合は、プロバイダの編集画面で <span class="ui">サーバーアドレス</span> を変えます。変わるのはスキーム・ホスト・ポートだけで、各 API のパスはそのままです。スキームは省略でき、その場合は <code>http</code> になります。アドレスと一緒に貼ったパス(<code>/v1</code> など)は取り除かれます。</p>
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-remote">コピー</button><pre id="ex-remote">magpie provider set ollama address=192.168.1.20:11434
magpie provider set ollama address= # 既定に戻す</pre></div>
<ul>
<li><b>プロキシ。</b>自分のネットワーク内のサーバーには、設定やシステムがどのプロキシを指定していても直接つなぎます。プロバイダ自体に設定したプロキシは使われます。</li>
<li><b>HTTPS。</b>自己署名証明書の HTTPS の後ろにある Ollama には、編集画面の <span class="ui">証明書を検証しない</span> でつなげます。そのプロバイダ自身のホストにだけ効きます。</li>
</ul>
<h2 id="cloud"><a class="anchor" href="#cloud">Ollama Cloud</a></h2>
<ol class="steps">
<li><b>キーを作る</b><a href="https://ollama.com/settings/keys">ollama.com/settings/keys</a> で作成します。</li>
<li><b>プロバイダを追加する</b><span class="ui">プロバイダ</span> タブで <span class="ui">+ プロバイダを追加</span> を押し、<span class="ui">Ollama Cloud</span> を選んでキーを貼り付け、保存します。magpie がそのキーで使えるモデルを Ollama Cloud に問い合わせます。</li>
<li><b>ツールに割り当てる</b>ツールの行で <code>deepseek-v4-pro</code> などの Ollama Cloud のモデルを選びます。</li>
</ol>
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-cloud">コピー</button><pre id="ex-cloud">magpie provider add ollama-cloud &lt;key&gt;
magpie claude ollama-cloud/deepseek-v4-pro</pre></div>
<p>モデル名・推論レベル・価格は models.dev の <code>ollama-cloud</code> カタログから取ります。キーは magpie の設定に保存されます。</p>
<h2 id="endpoints"><a class="anchor" href="#endpoints">エンドポイント</a></h2>
<div class="table-wrap"><table>
<tr><th>プロバイダ</th><th>Chat Completions</th><th>Anthropic Messages</th></tr>
<tr><td>Ollama</td><td><code>http://localhost:11434/v1</code></td><td><code>http://localhost:11434</code></td></tr>
<tr><td>Ollama Cloud</td><td><code>https://ollama.com/v1</code></td><td><code>https://ollama.com</code></td></tr>
</table></div>
<p>ツールが話す API を Ollama が提供していれば、リクエストはその API にそのまま渡ります。magpie はどちらにも Responses のエンドポイントを使わないので、変換が要るときは Chat Completions を使います。Responses を優先するのは OpenAI 自身のモデルだけ、Messages を優先するのは Claude のモデルだけです。</p>
<h2 id="models"><a class="anchor" href="#models">モデル一覧</a></h2>
<p>magpie は Chat Completions のベース URL から一覧を取ります。<code>http://localhost:11434/v1/models</code>、Ollama Cloud なら <code>https://ollama.com/v1/models</code> です。Ollama にあるモデルが magpie に表示されます。新しく pull したら、プロバイダの編集画面で <span class="ui">モデルを取得</span> を押すか、<code>magpie provider refresh ollama</code> を実行します。ツールに見せるモデルは、プロバイダのモデル一覧かターミナルで選べます。</p>
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-models">コピー</button><pre id="ex-models">magpie provider refresh ollama
magpie provider models ollama +qwen3</pre></div>
<p>Ollama 0.35.0 以降(クラウドモデルは 0.40.5 以降)は、Nimble・Clef・Tev などの判定モデルも提供します。magpie は Ollama の <code>/api/tags</code> も読み、判定モデルと示されたものをそのプロバイダの <a href="/docs/ja/intent">インテントルーティング</a> 用の判定モデルにします。ツールのモデルにはなりません。古い Ollama では一覧に出ません。</p>
<h2 id="agents"><a class="anchor" href="#agents">ツールごとの使い方</a></h2>
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-agents">コピー</button><pre id="ex-agents">magpie claude ollama/qwen3
magpie codex ollama/qwen3
magpie gemini model ollama/qwen3
magpie opencode ollama/qwen3</pre></div>
<ul>
<li><b>Claude Code</b> は Anthropic Messages を話し、Ollama も <code>http://localhost:11434</code> で提供しているので、リクエストはそのまま届きます。<a href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>。</li>
<li><b>Codex</b> は OpenAI Responses を話しますが、magpie はそれを Ollama には送りません。リクエストを Chat Completions に変換し、返答を元に戻します。ストリーミングとツール呼び出しも含みます。<a href="/docs/ja/codex-models">Codex で他のモデル</a>。</li>
<li><b>Gemini CLI</b> は Google の Gemini API を話します。magpie がリクエストを Chat Completions に変換し、返答を元に戻します。<a href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>。</li>
<li><b>OpenCode</b> は Chat Completions を話すので、リクエストは Ollama の <code>/v1</code> にそのまま届きます。<a href="/docs/ja/opencode-models">OpenCode で他のモデル</a>。</li>
</ul>
<p>ツールの中でも、Claude Code と Codex の <code>/model</code> に magpie のモデルが並ぶので、ローカルモデルとクラウドのモデルをそこで切り替えられます。ツール本来のモデルに戻すには <code>magpie claude default</code> か <code>magpie codex default</code> を実行します。</p>
<h2 id="window"><a class="anchor" href="#window">コンテキストウィンドウと num_ctx</a></h2>
<p>エージェントは、モデルが受け付けるリクエストの長さを前提に会話を組み立てます。Claude Code は知らないモデルを 200K とみなし、Codex は伝えられたウィンドウの 90% で会話を圧縮します。magpie は Ollama のチャットモデルのウィンドウを読まないので、実際の値を伝えてください。プロバイダの編集画面の <span class="ui">詳細設定</span> にある <span class="ui">コンテキストウィンドウ</span> で、全モデルにも個別のモデルにも設定できます。magpie がそれをエージェントに伝えます。</p>
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-window">コピー</button><pre id="ex-window">magpie provider set ollama context=32k
magpie provider set ollama context.qwen3=128k</pre></div>
<ul>
<li><b><code>num_ctx</code>。</b>クライアントによっては、Chat Completions のフィールドと並べて <code>{"num_ctx": …}</code> のような Ollama のリクエストごとのオプションを送ります。magpie は転送するすべてのリクエストからそれを外します。Ollama 自身の <code>/v1</code> も含め、Chat Completions API はこれを読まないためです。モデルが実際に使うウィンドウは Ollama 側で決まるので、magpie にも同じ数を設定してください。</li>
<li><b>長すぎる場合。</b>会話がウィンドウを超えると、Ollama は “exceeded max context length” を返します。magpie はそれをツールが理解できる形、つまり <code>context_length_exceeded</code> か Anthropic の “prompt is too long” で伝えるので、ツールは圧縮してやり直します。</li>
</ul>
<h2 id="reasoning"><a class="anchor" href="#reasoning">推論</a></h2>
<ul>
<li><b>推論の強さ。</b>ツールが求める強さは、カタログにあるそのモデルのレベルのうち最も近いものに合わせます。レベルがわからないモデルには、ツールの指定どおりに送ります。</li>
<li><b>推論オフ。</b>magpie が変換するツール(Codex や Gemini CLI)が推論をオフにし、モデルのレベルに <code>none</code> があれば、magpie は none を指定します。</li>
<li><b>レベルを自分で決める。</b><code>magpie model efforts</code> で、指定したレベルだけを出すことも、推論のフィールドをまったく送らないこともできます。</li>
</ul>
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-efforts">コピー</button><pre id="ex-efforts">magpie model efforts ollama/qwen3 low,medium,high
magpie model efforts ollama/qwen3 off</pre></div>
<h2 id="tools"><a class="anchor" href="#tools">ツール呼び出し</a></h2>
<p>Claude Code と OpenCode のツール呼び出しは、ツールが書いたとおりに Ollama へ届きます。Codex と Gemini CLI では、ツールの定義、モデルからの呼び出し、その結果を magpie が Chat Completions に変換して戻します。ストリーミングの返答でも同じです。</p>
<h2 id="masking"><a class="anchor" href="#masking">プライバシーマスク</a></h2>
<p>magpie の <a href="/docs/ja/masking">プライバシーマスク</a> は、リクエストがゲートウェイを出る前にキーやトークンなどの秘密をプレースホルダーに置き換えます。ローカルの Ollama へのリクエストも同じです。モデルが自分のマシンやネットワーク内で動いているなら、編集画面で <span class="ui">リクエストをマスクしない</span> をオンにするか、<code>magpie provider set ollama unmasked=yes</code> を実行します。</p>
<ul>
<li><b>クラウドモデル。</b>Ollama のクラウドモデルは、アドレスに関係なくリクエストをベンダーへ送ります。判断はあなた次第です。ローカルでないプロバイダ(Ollama Cloud など)でオンにしている間は、編集画面に注意が出ます。</li>
<li><b>ツールの引数。</b>Ollama 自身の形式のリクエストでも、ツール呼び出しの引数は他の API と同じくツールの引数としてマスクします。</li>
<li><b>匿名の統計。</b>magpie の日次統計は、models.dev が知っている Ollama のモデルだけを名前で記録し、それ以外は “other” とします。<a href="/docs/ja/privacy">プライバシー</a> を見てください。</li>
</ul>
<h2 id="cost"><a class="anchor" href="#cost">使用量と費用</a></h2>
<ul>
<li><b>使用量。</b><span class="ui">使用量</span> タブは Ollama の呼び出しごとにトークンを数えます。価格は magpie がそのモデルの ID で見つけたもので、ローカルモデルではモデルの開発元の定価になることがあります。ローカルモデルを無料として数えるには、自分で価格を設定してください。</li>
<li><b>無料優先。</b><code>free=yes</code> にすると、そのプロバイダのモデルはすべて無料として扱われ、<span class="ui">無料優先</span> のルーティングは有料のものより先に使います。価格と使用量の費用は定価のまま表示されます。</li>
<li><b>Ollama Cloud の枠。</b>magpie は Ollama Cloud からアカウントの残高を読みます。プランに含まれる枠はプランとして、使った金額(ドル)とリセットの時期つきで表示されます。古いプランではセッションの上限と週の上限が表示されます。購入したクレジットは残高として表示されます。枠を超えると Ollama Cloud はクレジットから引くので、枠を使い切ってもクレジットが残っていればキーは止まりません。</li>
<li><b>ピーク時間帯。</b>Ollama Cloud の <code>deepseek-v4.1-flash</code> と <code>deepseek-v4-pro</code>(タグ付きのものも)は、月曜から金曜の UTC 12:00〜18:00 に 2 倍の料金になります。models.dev にあるのはオフピークの価格で、使用量タブはこの時間帯に 2 倍で計算し、<span class="ui">最安優先</span> のルーティングもそれを考慮します。</li>
<li><b>枠を使い切ったとき。</b>Ollama Cloud がキーの枠切れを伝えても回復の時期を言わない場合(週の上限など)、magpie はそのキーを 15 分休ませます。<code>quota-rest</code> で最長 8 日まで変えられます。キーが複数あれば(<span class="ui">別のキーを追加</span>)次のキーが引き継ぎ、すべて使い切ったときはゲートウェイがすぐに Retry-After つきで返します。</li>
</ul>
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-cost">コピー</button><pre id="ex-cost">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</pre></div>
<h2 id="server"><a class="anchor" href="#server">magpie を Ollama サーバーとして使う</a></h2>
<p>カスタムモデルを Ollama サーバーとしてしか受け付けないアプリがあります。VS Code の Copilot の Ollama プロバイダ、Visual Studio の Copilot BYOK、Zed の Ollama プロバイダ、そして <code>ollama</code> CLI です。これらを magpie のゲートウェイ <code>http://127.0.0.1:3425</code> に向ければ、Ollama のものだけでなく、すべてのプロバイダの magpie のモデルが見えます。</p>
<ul>
<li><b>ルート。</b>magpie は <code>/api/version</code>・<code>/api/tags</code>・<code>/api/show</code>・<code>/api/chat</code>・<code>/api/generate</code> に応答します。</li>
<li><b>同じ経路。</b>ここでのチャットは <code>/v1/chat/completions</code> と同じ処理を通るので、キーの制限・ルーティング・フォールバック・使用量の集計も同じです。一部のモデルに限ったゲートウェイキーには、そのモデルだけが表示されます。</li>
<li><b>伝える情報。</b><code>/api/tags</code> と <code>/api/show</code> は、ツール、画像を読めるモデルなら vision、推論するモデルなら thinking を示します。<code>/api/show</code> はモデルのウィンドウも伝え、magpie が知らないモデルは 32768 とします。<code>ollama</code> CLI の <code>name:latest</code> は <code>name</code> という名前のモデルに当たります。</li>
</ul>
<h2 id="trouble"><a class="anchor" href="#trouble">うまくいかないとき</a></h2>
<ul>
<li><b>pull したモデルが一覧にない。</b>一覧はサーバーから取ります。<span class="ui">モデルを取得</span> を押すか <code>magpie provider refresh ollama</code> を実行し、プロバイダのモデル一覧で選んでください。名前は Ollama が表示するとおり、タグ込みで指定します。</li>
<li><b>Ollama が動いていない。</b><code>magpie provider test ollama</code> は各エンドポイント、または指定したモデルに小さなリクエストを送ります。<code>--as codex</code> や <code>--as claude-code</code> をつけると、そのツールと同じ形で送ります。Ollama を起動するか、<span class="ui">サーバーアドレス</span> を確かめてください。止まっている間のリクエストの行き先は <code>fallback</code> で決められます。</li>
<li><b>“exceeded max context length”。</b>会話がモデルを読み込んだときの長さを超えています。プロバイダに実際の <span class="ui">コンテキストウィンドウ</span> を設定すれば、ツールはそこに届く前に圧縮します。</li>
<li><b>別のマシンにつながらない。</b><span class="ui">サーバーアドレス</span> のアドレスとポートを確かめてください。自己署名証明書の HTTPS なら <span class="ui">証明書を検証しない</span> をオンにします。</li>
</ul>
<h2 id="faq"><a class="anchor" href="#faq">よくある質問</a></h2>
<h3>Claude Code で Ollama のローカルモデルを使うには?</h3>
<p>magpie に Ollama を追加し(プロバイダ → プロバイダを追加 → このマシン上の Ollama)、Claude Code の行でそのモデルを選ぶか、<code>magpie claude ollama/qwen3</code> を実行します。Claude Code のリクエストは magpie のゲートウェイを通り、<code>http://localhost:11434</code> にある Ollama の Anthropic Messages API へそのまま届きます。</p>
<h3>Codex で Ollama は使えますか?</h3>
<p>使えます。Codex は Responses API しか話さないので、magpie がリクエストを Chat Completions に変換して Ollama に送り、返答を元に戻します。ツール呼び出しも含みます。<code>magpie codex ollama/qwen3</code> を実行してください。</p>
<h3>Gemini CLI や OpenCode でも Ollama は使えますか?</h3>
<p>使えます。Gemini CLI は Google の API を話すので、magpie がリクエストを Ollama の Chat Completions に変換し、返答を元に戻します。OpenCode は Chat Completions を話すので、リクエストはそのまま Ollama に届きます。<code>magpie gemini model ollama/qwen3</code> か <code>magpie opencode ollama/qwen3</code> を実行してください。</p>
<h3>Ollama の qwen3-coder を Claude Code で使うには?</h3>
<p>Ollama で pull してから、magpie のプロバイダ編集画面で「モデルを取得」を押し(または <code>magpie provider refresh ollama</code> を実行し)、Claude Code の行で選びます。magpie での ID は <code>ollama/</code> に Ollama が表示する名前(タグ込み)を続けたものです。コンテキストウィンドウも設定してください。Claude Code は知らないモデルを 200K とみなします。</p>
<h3>別のマシンの Ollama を使えますか?</h3>
<p>使えます。プロバイダのサーバーアドレスをそのマシンに変えます。たとえば <code>magpie provider set ollama address=192.168.1.20:11434</code> です。自分のネットワーク内のサーバーには、設定やシステムのプロキシを通さず直接つなぎます。</p>
<h3>Ollama Cloud にも対応していますか?</h3>
<p>対応しています。<code>ollama.com/settings/keys</code> で作ったキーで Ollama Cloud を追加すると、magpie はそのキーで使えるモデルを一覧にし、models.dev の価格で計算し、アカウントのプランに含まれる枠と購入したクレジットを表示します。</p>
<h3>ローカルの Ollama に API キーは要りますか?</h3>
<p>要りません。Ollama のプリセットはキーなしで使えます。Ollama Cloud にはキーが要ります。</p>
<p>LM Studio・oMLX・vLLM・llama.cpp など他のローカルサーバーは <a href="/docs/ja/local-models">ローカルモデル</a> を見てください。ローカルモデルにリクエストを分類させてルーティングを決めるには <a href="/docs/ja/intent">インテントルーティング</a> を見てください。</p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/mistral">Mistral</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a></p>
<p style="margin-top:48px">ツールごとのガイド:<a href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>、<a href="/docs/ja/codex-models">Codex で他のモデル</a>、<a href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>、<a href="/docs/ja/opencode-models">OpenCode で他のモデル</a>。困ったときは <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> で質問してください。</p>
</article>
</main>
<footer><div class="wrap">
<span>© 2026 magpie · MIT</span>
<div class="links">
<a href="/ja/">ホーム</a>
<a href="/docs/ja/intent">インテントルーティング</a>
<a href="/docs/ja/plugins">プラグイン</a>
<a href="/docs/ja/remote">リモート magpie</a>
<a href="/docs/ja/docker">Docker</a>
<a href="/docs/ja/privacy">プライバシー</a>
<a href="/docs/ja/masking">プライバシーマスキング</a>
<a href="/docs/ja/mcp-router">MCP ルーター</a>
<a href="/docs/ja/library">ライブラリ</a>
<a href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>
<a href="/docs/ja/codex-models">Codex で他のモデル</a>
<a href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>
<a href="/docs/ja/subscriptions">サブスクを任意のエージェントで</a>
<a href="/docs/ja/local-models">ローカルモデル</a>
<a href="/docs/ja/opencode-models">OpenCode で他のモデル</a>
<a href="/docs/ja/alternatives">CC Switch・CCR との比較</a>
<a href="/docs/ja/import">magpie に追加</a>
<a href="/docs/integrate">アプリ連携</a>
<a href="https://github.com/yetone/magpie">GitHub</a>
<a href="https://discord.gg/vGSnD3ZKQF">Discord</a>
<a href="/docs/ja/contributors">コントリビューター</a>
<a href="https://github.com/yetone/magpie-releases/releases">リリース</a>
</div>
</div></footer>
<script>
(() => {
const next = { system: "light", light: "dark", dark: "system" };
document.querySelectorAll("button.theme").forEach((b) => {
b.dataset.mode = themeMode();
b.title = "Theme: " + themeMode();
b.addEventListener("click", () => setTheme(next[themeMode()]));
});
document.querySelectorAll(".copy").forEach((b) => b.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(document.getElementById(b.dataset.copy).textContent);
b.textContent = "コピーしました"; setTimeout(() => (b.textContent = "コピー"), 1400);
} catch {}
}));
})();
</script>
<script src="/docs.js"></script>
</body>
</html>
+1 -1
View File
@@ -239,7 +239,7 @@ magpie visible opencode all # すべてに戻す</pre></div>
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-oc-back">コピー</button><pre id="ex-oc-back">magpie opencode default</pre></div>
<p>magpie を使う前の <code>model</code> と <code>small_model</code> が戻り、<code>magpie</code> プロバイダがファイルから取り除かれます。</p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a></p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/mistral">Mistral</a> · <a href="/docs/ja/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a> · <a href="/docs/ja/ollama">Ollama</a></p>
<h2 id="faq"><a class="anchor" href="#faq">よくある質問</a></h2>
<h3>OpenCode で DeepSeek を使うには?</h3>
+1 -1
View File
@@ -288,7 +288,7 @@ magpie group set opus-anywhere stays=session models+=openrouter/anthropic/claude
<h3>magpie が OpenRouter のモデル一覧を /api/v1 から取るのはなぜ?</h3>
<p>Anthropic のベース URL で一覧を求めると、OpenRouter は <code>anthropic/</code> の下に並べたカタログを返しますが、その ID では提供していません。magpie は Chat Completions のベース URL <code>https://openrouter.ai/api/v1</code> から一覧を取り、OpenRouter の Anthropic のベース URL しかないプロバイダには、この Chat の URL を足すよう案内します。</p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/copilot">GitHub Copilot</a></p>
<p><b>プロバイダ別:</b><a href="/docs/ja/deepseek">DeepSeek</a> · <a href="/docs/ja/kimi">Kimi と Kimi Code</a> · <a href="/docs/ja/glm">GLM Coding Plan</a> · <a href="/docs/ja/qwen">Qwen</a> · <a href="/docs/ja/minimax">MiniMax</a> · <a href="/docs/ja/gemini">Gemini</a> · <a href="/docs/ja/grok">Grok</a> · <a href="/docs/ja/mistral">Mistral</a> · <a href="/docs/ja/copilot">GitHub Copilot</a> · <a href="/docs/ja/ollama">Ollama</a></p>
<p style="margin-top:48px">ツールごとのガイド:<a href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>、<a href="/docs/ja/codex-models">Codex で他のモデル</a>、<a href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>、<a href="/docs/ja/opencode-models">OpenCode で他のモデル</a>。困ったときは <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> で質問してください。</p>
</article>
</main>
+331
View File
@@ -0,0 +1,331 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mistral in Claude Code, Codex, Gemini CLI and OpenCode · magpie</title>
<meta name="description" content="Use Mistral&#x27;s models, Devstral and Codestral included, in Claude Code, Codex, Gemini CLI and OpenCode with magpie: add your Mistral API key once, pick a model per agent, and let magpie translate each agent&#x27;s requests to Mistral&#x27;s API, keep its thinking, show a Le Chat plan&#x27;s Vibe month, count cost and spread requests over several keys.">
<meta name="color-scheme" content="light dark">
<meta name="theme-color" content="#fafafa">
<script>
(() => {
let mode = "system";
try { mode = localStorage.getItem("theme") || "system"; } catch {}
const q = matchMedia("(prefers-color-scheme: dark)");
const apply = () => {
const t = mode === "system" ? (q.matches ? "dark" : "light") : mode;
document.documentElement.dataset.theme = t;
document.querySelector('meta[name="theme-color"]').content = t === "dark" ? "#0b0b0c" : "#fafafa";
document.querySelectorAll("button.theme").forEach((b) => { b.dataset.mode = mode; b.title = "Theme: " + mode; });
};
q.addEventListener("change", () => mode === "system" && apply());
window.setTheme = (m) => { mode = m; try { m === "system" ? localStorage.removeItem("theme") : localStorage.setItem("theme", m); } catch {} apply(); };
window.themeMode = () => mode;
apply();
})();
</script>
<script>try{if(/Linux/.test(navigator.userAgent)&&!/Android/.test(navigator.userAgent)||localStorage.getItem("omarchy")||/[?&]omarchy=/.test(location.search))document.write('<script src="/omarchy.js"><\/script>')}catch(e){}</script>
<link rel="icon" href="/favicon.png" type="image/png">
<link rel="apple-touch-icon" href="/img/icon-256.png">
<link rel="alternate" hreflang="en" href="https://usemagpie.ai/docs/mistral">
<link rel="alternate" hreflang="zh" href="https://usemagpie.ai/docs/zh/mistral">
<link rel="alternate" hreflang="ja" href="https://usemagpie.ai/docs/ja/mistral">
<link rel="alternate" hreflang="x-default" href="https://usemagpie.ai/docs/mistral">
<link rel="canonical" href="https://usemagpie.ai/docs/mistral">
<link rel="stylesheet" href="/docs.css">
<meta property="og:site_name" content="magpie">
<meta property="og:title" content="Mistral in Claude Code, Codex, Gemini CLI and OpenCode">
<meta property="og:description" content="Use Mistral&#x27;s models, Devstral and Codestral included, in Claude Code, Codex, Gemini CLI and OpenCode with magpie: add your Mistral API key once, pick a model per agent, and let magpie translate each agent&#x27;s requests to Mistral&#x27;s API, keep its thinking, show a Le Chat plan&#x27;s Vibe month, count cost and spread requests over several keys.">
<meta property="og:image" content="https://usemagpie.ai/img/og.png">
<meta property="og:url" content="https://usemagpie.ai/docs/mistral">
<meta name="twitter:card" content="summary_large_image">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "TechArticle",
"headline": "Mistral in Claude Code, Codex, Gemini CLI and OpenCode",
"description": "Use Mistral's models, Devstral and Codestral included, in Claude Code, Codex, Gemini CLI and OpenCode with magpie: add your Mistral API key once, pick a model per agent, and let magpie translate each agent's requests to Mistral's API, keep its thinking, show a Le Chat plan's Vibe month, count cost and spread requests over several keys.",
"inLanguage": "en",
"url": "https://usemagpie.ai/docs/mistral",
"about": {
"@type": "SoftwareApplication",
"name": "magpie",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "macOS, Windows, Linux"
},
"publisher": {
"@type": "Organization",
"name": "magpie",
"url": "https://usemagpie.ai/"
}
},
{
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "How do I use Mistral in Claude Code?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Add your Mistral API key in magpie (Providers, Add provider, Mistral), then pick a Mistral model such as mistral-large-4 on Claude Code’s row, or run magpie claude mistral/mistral-large-4. Mistral serves Chat Completions only, so magpie translates Claude Code’s Anthropic Messages requests to https://api.mistral.ai/v1 and the replies back, thinking included."
}
},
{
"@type": "Question",
"name": "Can Codex use Devstral and other Mistral models?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Yes. Codex can use any model your Mistral key lists, Devstral among them. Codex speaks OpenAI Responses, which Mistral doesn’t serve, so magpie translates each request to Chat Completions, offers Codex’s custom tools such as apply_patch as functions, and gives the calls back the way Codex runs them."
}
},
{
"@type": "Question",
"name": "How do I use Codestral or other Mistral models in OpenCode?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Pick the model in magpie, or run magpie opencode mistral/mistral-large-4; Codestral and Devstral work the same way when your key lists them. OpenCode speaks Chat Completions, so its requests go to Mistral as they are, with what Mistral would refuse fixed on the way: OpenCode’s store field, and earlier turns’ thinking sent back in reasoning_content."
}
},
{
"@type": "Question",
"name": "Can Gemini CLI use Mistral?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Yes. Gemini CLI speaks Google’s Gemini API, so magpie translates its requests to Mistral’s Chat Completions and the replies back, streaming and tool calls included. Run magpie gemini model mistral/mistral-large-4."
}
},
{
"@type": "Question",
"name": "Why does Mistral answer 422 extra_forbidden?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Mistral turns away any field it doesn’t know. magpie sends an earlier turn’s thinking as the thinking part Mistral takes, leaves out Ollama options some agents add, and asks again without an optional field Mistral names, such as OpenCode’s store, then stops sending it."
}
},
{
"@type": "Question",
"name": "Does magpie show my Le Chat plan’s Vibe budget?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Yes. A Vibe key from a Le Chat plan (Pro, Student or Team) shows how much of the month’s Vibe budget is used, in the currency Mistral bills in, and when it resets, with the plan’s name. A Studio key made in the console shows the organization’s API budget instead, as “API · Month”."
}
}
]
}
]
}
</script>
</head>
<body>
<nav><div class="wrap">
<a class="brand" href="/"><img class="bird" src="/img/magpie-small.svg" alt="">magpie <small>Docs</small></a>
<div class="links">
<a href="/">Home</a>
<a href="/docs/start">Get started</a>
<a href="/docs/intent">Intent routing</a>
<a href="/docs/plugins">Plugins</a>
<a class="toc-only" href="/docs/remote">Remote magpie</a>
<a class="toc-only" href="/docs/docker">Docker</a>
<a class="toc-only" href="/docs/privacy">Privacy</a>
<a class="toc-only" href="/docs/masking">Privacy masking</a>
<a class="toc-only" href="/docs/mcp-router">MCP router</a>
<a class="toc-only" href="/docs/library">Library</a>
<a class="toc-only" href="/docs/claude-code-models">Models in Claude Code</a>
<a class="toc-only" href="/docs/codex-models">Models in Codex</a>
<a class="toc-only" href="/docs/gemini-cli-models">Models in Gemini CLI</a>
<a class="toc-only" href="/docs/subscriptions">Subscriptions in any agent</a>
<a class="toc-only" href="/docs/local-models">Local models</a>
<a class="toc-only" href="/docs/opencode-models">Models in OpenCode</a>
<a class="toc-only" href="/docs/alternatives">magpie vs CC Switch vs CCR</a>
<a href="/docs/import">Add to magpie</a>
<a href="/docs/integrate">Integrate</a>
<a href="https://github.com/yetone/magpie-releases/releases">Releases</a>
</div>
<div class="langs">
<button class="icon-btn lang" type="button" aria-label="Language" title="Language" aria-haspopup="true" aria-expanded="false" aria-controls="langs"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="8" cy="8" r="6.25"/><path d="M1.75 8h12.5M8 1.75c1.7 1.75 2.55 3.83 2.55 6.25S9.7 12.5 8 14.25M8 1.75C6.3 3.5 5.45 5.58 5.45 8S6.3 12.5 8 14.25"/></svg></button>
<div class="lang-menu" id="langs" hidden>
<a href="/docs/mistral" hreflang="en" lang="en">English</a>
<a href="/docs/zh/mistral" hreflang="zh" lang="zh">中文</a>
<a href="/docs/ja/mistral" hreflang="ja" lang="ja">日本語</a>
</div>
</div>
<a class="icon-btn" href="https://discord.gg/vGSnD3ZKQF" aria-label="magpie on Discord" title="Join us on Discord"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"/></svg></a>
<a class="icon-btn" href="https://github.com/yetone/magpie" aria-label="magpie on GitHub" title="Source on GitHub"><svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"/></svg></a>
<button class="icon-btn theme" type="button" aria-label="Theme" title="Theme: system"><svg class="i-system" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1.75" y="2.75" width="12.5" height="8.5" rx="1.5"/><path d="M5.5 14h5M8 11.25V14"/></svg><svg class="i-light" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="8" cy="8" r="3"/><path d="M8 1v1.5M8 13.5V15M1 8h1.5M13.5 8H15M3 3l1 1M12 12l1 1M3 13l1-1M12 4l1-1"/></svg><svg class="i-dark" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"><path d="M13.5 9.5A5.5 5.5 0 0 1 6.5 2.5a5.5 5.5 0 1 0 7 7Z"/></svg></button>
<a class="btn small" href="/#get">Download</a>
</div></nav>
<main class="wrap doc">
<aside class="toc">
<p>On this page</p>
<a href="#add">Add it</a>
<a href="#endpoints">Endpoints</a>
<a href="#models">Model list</a>
<a href="#agents">In each agent</a>
<a href="#shaping">What magpie fixes</a>
<a href="#reasoning">Reasoning</a>
<a href="#search">Web search</a>
<a href="#cost">Vibe, cost and usage</a>
<a href="#keys">Several keys</a>
<a href="#trouble">Troubleshooting</a>
<a href="#faq">FAQ</a>
</aside>
<article>
<p class="eyebrow" id="overview">Docs · Provider</p>
<h1>Mistral in Claude Code, Codex, Gemini CLI and OpenCode</h1>
<p class="lede">Mistral serves its models on one API, OpenAI-style Chat Completions, at <code>api.mistral.ai</code>. Add a Mistral API key to magpie once, and Claude Code, Codex, Gemini CLI, OpenCode and every other agent you connect can use Mistral through magpie’s local gateway at <code>127.0.0.1:3425</code>, each agent with a model of its own. Agents that speak another API are translated on the way.</p>
<h2 id="add"><a class="anchor" href="#add">Add Mistral</a></h2>
<ol class="steps">
<li><b>Get a key</b>Make one on <a href="https://console.mistral.ai/api-keys">console.mistral.ai</a>. A Le Chat plan’s Vibe key goes in the same provider.</li>
<li><b>Add the provider</b>In magpie’s <span class="ui">Providers</span> tab, press <span class="ui">+ Add provider</span>, pick <span class="ui">Mistral</span>, paste the key and save. magpie asks Mistral which models the key can use.</li>
<li><b>Pick it for an agent</b>In the <span class="ui">Agents</span> tab, click the model on the agent’s row and choose a Mistral model such as <code>mistral-large-4</code>.</li>
</ol>
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-add">Copy</button><pre id="ex-add">magpie provider add mistral &lt;key&gt;
magpie provider test mistral</pre></div>
<p>Model ids in magpie are <code>provider/model</code>, so Mistral’s read <code>mistral/mistral-large-4</code>: the provider, then Mistral’s own id. The key is kept in magpie’s settings; magpie doesn’t take it from your shell.</p>
<p>Already set Mistral up in OpenCode or Alma? magpie’s import from those apps brings it in as the Mistral provider. An app that keeps one entry per key (“Mistral #0001”, “Mistral #0002”…) becomes one Mistral provider with that many keys, listed once in every agent’s picker.</p>
<h2 id="endpoints"><a class="anchor" href="#endpoints">Endpoints</a></h2>
<div class="table-wrap"><table>
<tr><th>API</th><th>Address</th><th>Used for</th></tr>
<tr><td>Chat Completions</td><td><code>https://api.mistral.ai/v1</code></td><td>the model list and every agent’s requests: OpenCode’s as they are, Claude Code’s, Codex’s and Gemini CLI’s translated</td></tr>
<tr><td>Billing</td><td><code>https://api.mistral.ai/v1/billing/budget</code>, <code>/v1/billing/subscription</code></td><td>a key’s month of Vibe or API budget, and the plan it is on</td></tr>
</table></div>
<p>magpie’s Mistral provider has no Anthropic Messages or Responses address, so an agent that speaks either is translated to Chat Completions and the reply translated back, streaming and tool calls included.</p>
<h2 id="models"><a class="anchor" href="#models">Model list</a></h2>
<p>magpie fetches the list from Mistral, at <code>https://api.mistral.ai/v1/models</code>, so agents see the models your key can use. Names, reasoning levels and prices come from models.dev’s <code>mistral</code> catalog, and Devstral, Codestral and Magistral models carry Mistral’s logo in every picker. Mistral also serves models from other labs, such as GLM and DeepSeek’s <code>deepseek-v4.1-flash-1017</code>; they come through the same key, and the fixes below apply to them too. Pick the models agents see in the provider’s model list, or from the terminal:</p>
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-models">Copy</button><pre id="ex-models">magpie provider models mistral +mistral-large-4 +mistral-medium-3.5
magpie provider refresh-every mistral 1d</pre></div>
<h2 id="agents"><a class="anchor" href="#agents">In each agent</a></h2>
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-agents">Copy</button><pre id="ex-agents">magpie claude mistral/mistral-large-4
magpie codex mistral/mistral-large-4
magpie gemini model mistral/mistral-large-4
magpie opencode mistral/mistral-large-4</pre></div>
<ul>
<li><b>Claude Code</b> speaks Anthropic Messages, which Mistral doesn’t serve. magpie translates each request to Chat Completions and the reply back; a reasoning model’s thinking reaches Claude Code as thinking, then the text. <a href="/docs/claude-code-models">Models in Claude Code</a>.</li>
<li><b>Codex</b> speaks OpenAI Responses, which Mistral doesn’t serve either, so its requests are translated too. Codex’s custom tools, such as <code>apply_patch</code>, are offered to the model as functions, and its calls come back as the custom tool calls Codex runs. <a href="/docs/codex-models">Models in Codex</a>.</li>
<li><b>Gemini CLI</b> speaks Google’s Gemini API. magpie translates each request to Chat Completions and the reply back. <a href="/docs/gemini-cli-models">Models in Gemini CLI</a>.</li>
<li><b>OpenCode</b> speaks Chat Completions, so its requests go to Mistral as they are, with the fixes below. <a href="/docs/opencode-models">Models in OpenCode</a>.</li>
</ul>
<h2 id="shaping"><a class="anchor" href="#shaping">What magpie fixes for Mistral</a></h2>
<p>Mistral’s API is strict about what it takes and sends a reasoning model’s thinking in a shape of its own. magpie changes both on the way, on requests it passes on and on those it translates alike:</p>
<ul>
<li><b>Thinking in typed parts.</b> Mistral sends a reasoning model’s thinking as typed parts in <code>content</code>, thinking and text sometimes in one chunk, where the Chat contract has a string. OpenCode turned the first such chunk away (“Invalid … stream event”). magpie moves the thinking to <code>reasoning_content</code> and the text to a plain string, streamed or not.</li>
<li><b>Thinking sent back.</b> OpenCode sends an earlier turn’s thinking back in <code>reasoning_content</code>, which Mistral refuses with 422 <code>extra_forbidden</code>. magpie puts it in the thinking part Mistral itself returns, ahead of the turn’s text, so the thinking stays in context. Translated requests get the same, so a Codex tool loop keeps going on a DeepSeek model served by Mistral.</li>
<li><b>Fields Mistral doesn’t know.</b> OpenCode’s <code>store</code> and Kimi Code’s thinking switch got 422 <code>extra_forbidden</code>. magpie asks again without the optional fields Mistral named, and doesn’t send them to it again once that works.</li>
<li><b>Ollama options.</b> An agent that took the gateway for an Ollama server, such as Hermes Agent, sends Ollama’s <code>options</code> (its <code>num_ctx</code>) beside the Chat fields. magpie leaves them out, so Mistral never sees them.</li>
</ul>
<h2 id="reasoning"><a class="anchor" href="#reasoning">Reasoning</a></h2>
<ul>
<li><b>Effort.</b> The effort an agent asks for is fitted to the nearest level the model has, as the catalog lists them. A model whose levels aren’t known is asked as the agent asked.</li>
<li><b>Reasoning off.</b> When an agent whose requests magpie translates, such as Gemini CLI, turns reasoning off and the model lists <code>none</code> among its levels, magpie asks for none.</li>
<li><b>Thinking across turns.</b> Each agent sees a reasoning model’s thinking in its own shape: <code>reasoning_content</code> for OpenCode, thinking blocks for Claude Code, reasoning for Codex. When it comes back in a later turn, Mistral gets it as a thinking part; see <a href="#shaping">What magpie fixes</a>.</li>
</ul>
<h2 id="search"><a class="anchor" href="#search">Web search</a></h2>
<p>Mistral’s Chat Completions API doesn’t search the web for magpie, so magpie gives the model its own search tool in every agent, answered by the searcher chosen in Settings, or by one magpie picks when none is chosen.</p>
<h2 id="cost"><a class="anchor" href="#cost">Vibe, cost and usage</a></h2>
<ul>
<li><b>Vibe month.</b> A Le Chat plan (Pro, Student or Team) comes with a month of Mistral Vibe. Its Vibe key’s row shows how much of the month’s budget is used, in the currency Mistral bills in, when it resets, and the plan’s name.</li>
<li><b>API month.</b> A Studio key made in the console shows the organization’s API budget, as “API · Month”, apart from a Vibe month. The budget is the organization’s, so every key of one organization shows the same numbers. A key with no budget has no card.</li>
<li><b>Pay as you go.</b> With pay-as-you-go on, what goes past the budget is billed rather than stopped, so a used-up month doesn’t stop the key’s models.</li>
<li><b>Cache tokens.</b> When a reply reports cached prompt tokens, the <span class="ui">Usage</span> tab counts them apart from the rest of the prompt.</li>
<li><b>Keeping the cache.</b> With several keys, a conversation stays on its key while its cache is worth keeping, 1,024 tokens or more, and still warm, read within the last five minutes.</li>
<li><b>Cost.</b> The Usage tab prices each call with Mistral’s prices from models.dev. magpie reads no balance from Mistral; type it in with <code>key-balance</code>, and the Usage page shows it less what magpie has priced the key’s calls at since.</li>
</ul>
<h2 id="keys"><a class="anchor" href="#keys">Several keys and failover</a></h2>
<p>One Mistral provider can hold several keys: press <span class="ui">Add another key</span> under it, or paste several at once. Requests go to the first key that’s on, and when it runs out or is rate limited the next one takes over.</p>
<ul>
<li><b>Spend caps.</b> <code>spend-cap</code> stops a key at a dollar amount a day, a month or in all, as the Usage tab prices its calls; routing then goes on to the other keys and the fallbacks.</li>
<li><b>Fallbacks.</b> <code>fallback</code> names where requests go when Mistral is out of quota or down: another provider’s model or a routing group.</li>
</ul>
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-keys">Copy</button><pre id="ex-keys">magpie provider spend-cap mistral &lt;key&gt; 20 month
magpie provider key-balance mistral &lt;key&gt; 25
magpie provider fallback mistral deepseek/deepseek-v4-pro</pre></div>
<h2 id="trouble"><a class="anchor" href="#trouble">Troubleshooting</a></h2>
<ul>
<li><b>422 <code>extra_forbidden</code>, “Extra inputs are not permitted”.</b> Mistral turned away a field it doesn’t know. magpie fixes the ones agents are known to send and asks again without an optional field Mistral names; see <a href="#shaping">What magpie fixes</a>.</li>
<li><b>“Invalid … stream event” in OpenCode.</b> That was Mistral’s thinking in typed parts. magpie sends OpenCode the thinking in <code>reasoning_content</code> and the text as a string.</li>
<li><b>No Vibe card.</b> magpie shows the month only for a key Mistral says is a Vibe key or a Studio key, and only when its budget is more than zero.</li>
<li><b>Checking a key.</b> <code>magpie provider test mistral</code> sends a tiny request through each endpoint, or to each model you name. Add <code>--as codex</code> or <code>--as claude-code</code> to send it the way that agent would.</li>
</ul>
<h2 id="faq"><a class="anchor" href="#faq">FAQ</a></h2>
<h3>How do I use Mistral in Claude Code?</h3>
<p>Add your Mistral API key in magpie (Providers, Add provider, Mistral), then pick a Mistral model such as <code>mistral-large-4</code> on Claude Code’s row, or run <code>magpie claude mistral/mistral-large-4</code>. Mistral serves Chat Completions only, so magpie translates Claude Code’s Anthropic Messages requests to <code>https://api.mistral.ai/v1</code> and the replies back, thinking included.</p>
<h3>Can Codex use Devstral and other Mistral models?</h3>
<p>Yes. Codex can use any model your Mistral key lists, Devstral among them. Codex speaks OpenAI Responses, which Mistral doesn’t serve, so magpie translates each request to Chat Completions, offers Codex’s custom tools such as apply_patch as functions, and gives the calls back the way Codex runs them.</p>
<h3>How do I use Codestral or other Mistral models in OpenCode?</h3>
<p>Pick the model in magpie, or run <code>magpie opencode mistral/mistral-large-4</code>; Codestral and Devstral work the same way when your key lists them. OpenCode speaks Chat Completions, so its requests go to Mistral as they are, with what Mistral would refuse fixed on the way: OpenCode’s <code>store</code> field, and earlier turns’ thinking sent back in <code>reasoning_content</code>.</p>
<h3>Can Gemini CLI use Mistral?</h3>
<p>Yes. Gemini CLI speaks Google’s Gemini API, so magpie translates its requests to Mistral’s Chat Completions and the replies back, streaming and tool calls included. Run <code>magpie gemini model mistral/mistral-large-4</code>.</p>
<h3>Why does Mistral answer 422 extra_forbidden?</h3>
<p>Mistral turns away any field it doesn’t know. magpie sends an earlier turn’s thinking as the thinking part Mistral takes, leaves out Ollama options some agents add, and asks again without an optional field Mistral names, such as OpenCode’s <code>store</code>, then stops sending it.</p>
<h3>Does magpie show my Le Chat plan’s Vibe budget?</h3>
<p>Yes. A Vibe key from a Le Chat plan (Pro, Student or Team) shows how much of the month’s Vibe budget is used, in the currency Mistral bills in, and when it resets, with the plan’s name. A Studio key made in the console shows the organization’s API budget instead, as “API · Month”.</p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a> · <a href="/docs/ollama">Ollama</a></p>
<p style="margin-top:48px">Every agent: <a href="/docs/claude-code-models">Models in Claude Code</a>, <a href="/docs/codex-models">Models in Codex</a>, <a href="/docs/gemini-cli-models">Models in Gemini CLI</a>, <a href="/docs/opencode-models">Models in OpenCode</a>. Ask on <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> if you get stuck.</p>
</article>
</main>
<footer><div class="wrap">
<span>© 2026 magpie · MIT</span>
<div class="links">
<a href="/">Home</a>
<a href="/docs/intent">Intent routing</a>
<a href="/docs/plugins">Plugins</a>
<a href="/docs/remote">Remote magpie</a>
<a href="/docs/docker">Docker</a>
<a href="/docs/privacy">Privacy</a>
<a href="/docs/masking">Privacy masking</a>
<a href="/docs/mcp-router">MCP router</a>
<a href="/docs/library">Library</a>
<a href="/docs/claude-code-models">Models in Claude Code</a>
<a href="/docs/codex-models">Models in Codex</a>
<a href="/docs/gemini-cli-models">Models in Gemini CLI</a>
<a href="/docs/subscriptions">Subscriptions in any agent</a>
<a href="/docs/local-models">Local models</a>
<a href="/docs/opencode-models">Models in OpenCode</a>
<a href="/docs/alternatives">magpie vs CC Switch vs CCR</a>
<a href="/docs/import">Add to magpie</a>
<a href="/docs/integrate">Integrate</a>
<a href="https://github.com/yetone/magpie">GitHub</a>
<a href="https://discord.gg/vGSnD3ZKQF">Discord</a>
<a href="/docs/contributors">Contributors</a>
<a href="https://github.com/yetone/magpie-releases/releases">Releases</a>
</div>
</div></footer>
<script>
(() => {
const next = { system: "light", light: "dark", dark: "system" };
document.querySelectorAll("button.theme").forEach((b) => {
b.dataset.mode = themeMode();
b.title = "Theme: " + themeMode();
b.addEventListener("click", () => setTheme(next[themeMode()]));
});
document.querySelectorAll(".copy").forEach((b) => b.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(document.getElementById(b.dataset.copy).textContent);
b.textContent = "Copied"; setTimeout(() => (b.textContent = "Copy"), 1400);
} catch {}
}));
})();
</script>
<script src="/docs.js"></script>
</body>
</html>
+377
View File
@@ -0,0 +1,377 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ollama in Claude Code, Codex, Gemini CLI and OpenCode · magpie</title>
<meta name="description" content="Use Ollama, on your computer or another one, and Ollama Cloud in Claude Code, Codex, Gemini CLI and OpenCode with magpie: add it once, pick a model such as qwen3 per agent, and let magpie translate each agent&#x27;s API, pass on the context window, and count usage and Ollama Cloud&#x27;s allowance.">
<meta name="color-scheme" content="light dark">
<meta name="theme-color" content="#fafafa">
<script>
(() => {
let mode = "system";
try { mode = localStorage.getItem("theme") || "system"; } catch {}
const q = matchMedia("(prefers-color-scheme: dark)");
const apply = () => {
const t = mode === "system" ? (q.matches ? "dark" : "light") : mode;
document.documentElement.dataset.theme = t;
document.querySelector('meta[name="theme-color"]').content = t === "dark" ? "#0b0b0c" : "#fafafa";
document.querySelectorAll("button.theme").forEach((b) => { b.dataset.mode = mode; b.title = "Theme: " + mode; });
};
q.addEventListener("change", () => mode === "system" && apply());
window.setTheme = (m) => { mode = m; try { m === "system" ? localStorage.removeItem("theme") : localStorage.setItem("theme", m); } catch {} apply(); };
window.themeMode = () => mode;
apply();
})();
</script>
<script>try{if(/Linux/.test(navigator.userAgent)&&!/Android/.test(navigator.userAgent)||localStorage.getItem("omarchy")||/[?&]omarchy=/.test(location.search))document.write('<script src="/omarchy.js"><\/script>')}catch(e){}</script>
<link rel="icon" href="/favicon.png" type="image/png">
<link rel="apple-touch-icon" href="/img/icon-256.png">
<link rel="alternate" hreflang="en" href="https://usemagpie.ai/docs/ollama">
<link rel="alternate" hreflang="zh" href="https://usemagpie.ai/docs/zh/ollama">
<link rel="alternate" hreflang="ja" href="https://usemagpie.ai/docs/ja/ollama">
<link rel="alternate" hreflang="x-default" href="https://usemagpie.ai/docs/ollama">
<link rel="canonical" href="https://usemagpie.ai/docs/ollama">
<link rel="stylesheet" href="/docs.css">
<meta property="og:site_name" content="magpie">
<meta property="og:title" content="Ollama in Claude Code, Codex, Gemini CLI and OpenCode">
<meta property="og:description" content="Use Ollama, on your computer or another one, and Ollama Cloud in Claude Code, Codex, Gemini CLI and OpenCode with magpie: add it once, pick a model such as qwen3 per agent, and let magpie translate each agent&#x27;s API, pass on the context window, and count usage and Ollama Cloud&#x27;s allowance.">
<meta property="og:image" content="https://usemagpie.ai/img/og.png">
<meta property="og:url" content="https://usemagpie.ai/docs/ollama">
<meta name="twitter:card" content="summary_large_image">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "TechArticle",
"headline": "Ollama in Claude Code, Codex, Gemini CLI and OpenCode",
"description": "Use Ollama, on your computer or another one, and Ollama Cloud in Claude Code, Codex, Gemini CLI and OpenCode with magpie: add it once, pick a model such as qwen3 per agent, and let magpie translate each agent's API, pass on the context window, and count usage and Ollama Cloud's allowance.",
"inLanguage": "en",
"url": "https://usemagpie.ai/docs/ollama",
"about": {
"@type": "SoftwareApplication",
"name": "magpie",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "macOS, Windows, Linux"
},
"publisher": {
"@type": "Organization",
"name": "magpie",
"url": "https://usemagpie.ai/"
}
},
{
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "How do I use Ollama in Claude Code?",
"acceptedAnswer": {
"@type": "Answer",
"text": "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."
}
},
{
"@type": "Question",
"name": "Can Codex use Ollama?",
"acceptedAnswer": {
"@type": "Answer",
"text": "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."
}
},
{
"@type": "Question",
"name": "Can Gemini CLI and OpenCode use Ollama?",
"acceptedAnswer": {
"@type": "Answer",
"text": "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."
}
},
{
"@type": "Question",
"name": "How do I run qwen3-coder from Ollama in Claude Code?",
"acceptedAnswer": {
"@type": "Answer",
"text": "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."
}
},
{
"@type": "Question",
"name": "Can magpie use Ollama on another computer?",
"acceptedAnswer": {
"@type": "Answer",
"text": "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."
}
},
{
"@type": "Question",
"name": "Does magpie work with Ollama Cloud?",
"acceptedAnswer": {
"@type": "Answer",
"text": "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."
}
},
{
"@type": "Question",
"name": "Do I need an API key for a local Ollama?",
"acceptedAnswer": {
"@type": "Answer",
"text": "No. The Ollama preset takes none. Ollama Cloud needs one."
}
}
]
}
]
}
</script>
</head>
<body>
<nav><div class="wrap">
<a class="brand" href="/"><img class="bird" src="/img/magpie-small.svg" alt="">magpie <small>Docs</small></a>
<div class="links">
<a href="/">Home</a>
<a href="/docs/start">Get started</a>
<a href="/docs/intent">Intent routing</a>
<a href="/docs/plugins">Plugins</a>
<a class="toc-only" href="/docs/remote">Remote magpie</a>
<a class="toc-only" href="/docs/docker">Docker</a>
<a class="toc-only" href="/docs/privacy">Privacy</a>
<a class="toc-only" href="/docs/masking">Privacy masking</a>
<a class="toc-only" href="/docs/mcp-router">MCP router</a>
<a class="toc-only" href="/docs/library">Library</a>
<a class="toc-only" href="/docs/claude-code-models">Models in Claude Code</a>
<a class="toc-only" href="/docs/codex-models">Models in Codex</a>
<a class="toc-only" href="/docs/gemini-cli-models">Models in Gemini CLI</a>
<a class="toc-only" href="/docs/subscriptions">Subscriptions in any agent</a>
<a class="toc-only" href="/docs/local-models">Local models</a>
<a class="toc-only" href="/docs/opencode-models">Models in OpenCode</a>
<a class="toc-only" href="/docs/alternatives">magpie vs CC Switch vs CCR</a>
<a href="/docs/import">Add to magpie</a>
<a href="/docs/integrate">Integrate</a>
<a href="https://github.com/yetone/magpie-releases/releases">Releases</a>
</div>
<div class="langs">
<button class="icon-btn lang" type="button" aria-label="Language" title="Language" aria-haspopup="true" aria-expanded="false" aria-controls="langs"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="8" cy="8" r="6.25"/><path d="M1.75 8h12.5M8 1.75c1.7 1.75 2.55 3.83 2.55 6.25S9.7 12.5 8 14.25M8 1.75C6.3 3.5 5.45 5.58 5.45 8S6.3 12.5 8 14.25"/></svg></button>
<div class="lang-menu" id="langs" hidden>
<a href="/docs/ollama" hreflang="en" lang="en">English</a>
<a href="/docs/zh/ollama" hreflang="zh" lang="zh">中文</a>
<a href="/docs/ja/ollama" hreflang="ja" lang="ja">日本語</a>
</div>
</div>
<a class="icon-btn" href="https://discord.gg/vGSnD3ZKQF" aria-label="magpie on Discord" title="Join us on Discord"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"/></svg></a>
<a class="icon-btn" href="https://github.com/yetone/magpie" aria-label="magpie on GitHub" title="Source on GitHub"><svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"/></svg></a>
<button class="icon-btn theme" type="button" aria-label="Theme" title="Theme: system"><svg class="i-system" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1.75" y="2.75" width="12.5" height="8.5" rx="1.5"/><path d="M5.5 14h5M8 11.25V14"/></svg><svg class="i-light" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="8" cy="8" r="3"/><path d="M8 1v1.5M8 13.5V15M1 8h1.5M13.5 8H15M3 3l1 1M12 12l1 1M3 13l1-1M12 4l1-1"/></svg><svg class="i-dark" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"><path d="M13.5 9.5A5.5 5.5 0 0 1 6.5 2.5a5.5 5.5 0 1 0 7 7Z"/></svg></button>
<a class="btn small" href="/#get">Download</a>
</div></nav>
<main class="wrap doc">
<aside class="toc">
<p>On this page</p>
<a href="#add">Add Ollama</a>
<a href="#remote">Another computer</a>
<a href="#cloud">Ollama Cloud</a>
<a href="#endpoints">Endpoints</a>
<a href="#models">Model list</a>
<a href="#agents">In each agent</a>
<a href="#window">Context window</a>
<a href="#reasoning">Reasoning</a>
<a href="#tools">Tool calls</a>
<a href="#masking">Privacy masking</a>
<a href="#cost">Usage and cost</a>
<a href="#server">As an Ollama server</a>
<a href="#trouble">Troubleshooting</a>
<a href="#faq">FAQ</a>
</aside>
<article>
<p class="eyebrow" id="overview">Docs · Provider</p>
<h1>Ollama in Claude Code, Codex, Gemini CLI and OpenCode</h1>
<p class="lede">Ollama serves the models you pull on two APIs, OpenAI Chat Completions and Anthropic Messages, at <code>http://localhost:11434</code>. Ollama Cloud serves its models the same way at <code>ollama.com</code>, 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 <code>127.0.0.1:3425</code>, each agent with a model of its own.</p>
<h2 id="add"><a class="anchor" href="#add">Add Ollama</a></h2>
<ol class="steps">
<li><b>Pull a model</b>Pull a model in Ollama, such as <code>qwen3</code>, and leave the server running.</li>
<li><b>Add the provider</b>In magpie’s <span class="ui">Providers</span> tab, press <span class="ui">+ Add provider</span> and pick Ollama under <span class="ui">On this machine</span>. No key is needed. magpie asks the server which models it has, and they show as <code>ollama/…</code>.</li>
<li><b>Pick it for an agent</b>In the <span class="ui">Agents</span> tab, click the model on the agent’s row and choose an Ollama model.</li>
</ol>
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-add">Copy</button><pre id="ex-add">ollama pull qwen3
magpie provider add ollama
magpie provider test ollama</pre></div>
<p>Model ids in magpie are <code>provider/model</code>, so a model you pulled as <code>qwen3</code> reads <code>ollama/qwen3</code>. A tag stays in the id, as in <code>ollama/qwen3:8b</code>. 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 <a href="/docs/local-models">Local models</a>.</p>
<h2 id="remote"><a class="anchor" href="#remote">Another port or another computer</a></h2>
<p>If Ollama listens on another port, or runs on another computer such as a GPU box or a NAS, change <span class="ui">Server address</span> in the provider’s editor. Only the scheme, host and port change; each API keeps its path. The scheme can be left out, and <code>http</code> is taken; a path pasted with the address, such as <code>/v1</code>, is dropped.</p>
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-remote">Copy</button><pre id="ex-remote">magpie provider set ollama address=192.168.1.20:11434
magpie provider set ollama address= # back to the default</pre></div>
<ul>
<li><b>Proxies.</b> 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.</li>
<li><b>HTTPS.</b> An Ollama behind HTTPS with a self-signed certificate can be reached with <span class="ui">Don't check its certificate</span> in the editor. It applies to that provider’s own hosts only.</li>
</ul>
<h2 id="cloud"><a class="anchor" href="#cloud">Ollama Cloud</a></h2>
<ol class="steps">
<li><b>Get a key</b>Make one at <a href="https://ollama.com/settings/keys">ollama.com/settings/keys</a>.</li>
<li><b>Add the provider</b>In the <span class="ui">Providers</span> tab, press <span class="ui">+ Add provider</span>, pick <span class="ui">Ollama Cloud</span>, paste the key and save. magpie asks Ollama Cloud which models the key can use.</li>
<li><b>Pick it for an agent</b>Choose an Ollama Cloud model, such as <code>deepseek-v4-pro</code>, on the agent’s row.</li>
</ol>
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-cloud">Copy</button><pre id="ex-cloud">magpie provider add ollama-cloud &lt;key&gt;
magpie claude ollama-cloud/deepseek-v4-pro</pre></div>
<p>Names, reasoning levels and prices come from models.dev’s <code>ollama-cloud</code> catalog. The key is kept in magpie’s settings.</p>
<h2 id="endpoints"><a class="anchor" href="#endpoints">Endpoints</a></h2>
<div class="table-wrap"><table>
<tr><th>Provider</th><th>Chat Completions</th><th>Anthropic Messages</th></tr>
<tr><td>Ollama</td><td><code>http://localhost:11434/v1</code></td><td><code>http://localhost:11434</code></td></tr>
<tr><td>Ollama Cloud</td><td><code>https://ollama.com/v1</code></td><td><code>https://ollama.com</code></td></tr>
</table></div>
<p>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.</p>
<h2 id="models"><a class="anchor" href="#models">Model list</a></h2>
<p>magpie asks the server for its list at the Chat Completions base: <code>http://localhost:11434/v1/models</code>, or <code>https://ollama.com/v1/models</code> for Ollama Cloud. A model shows in magpie once Ollama has it. After you pull another, press <span class="ui">Fetch models</span> in the provider’s editor, or run <code>magpie provider refresh ollama</code>. Pick the models agents see in the provider’s model list, or from the terminal:</p>
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-models">Copy</button><pre id="ex-models">magpie provider refresh ollama
magpie provider models ollama +qwen3</pre></div>
<p>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 <code>/api/tags</code> as well, and a model marked there as a decision model becomes one of the provider’s decision models for <a href="/docs/intent">intent routing</a>, never an agent’s model. An older Ollama lists none.</p>
<h2 id="agents"><a class="anchor" href="#agents">In each agent</a></h2>
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-agents">Copy</button><pre id="ex-agents">magpie claude ollama/qwen3
magpie codex ollama/qwen3
magpie gemini model ollama/qwen3
magpie opencode ollama/qwen3</pre></div>
<ul>
<li><b>Claude Code</b> speaks Anthropic Messages, and so does Ollama at <code>http://localhost:11434</code>, so its requests go there as they are. <a href="/docs/claude-code-models">Models in Claude Code</a>.</li>
<li><b>Codex</b> 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. <a href="/docs/codex-models">Models in Codex</a>.</li>
<li><b>Gemini CLI</b> speaks Google’s Gemini API. magpie translates each request to Chat Completions and the reply back. <a href="/docs/gemini-cli-models">Models in Gemini CLI</a>.</li>
<li><b>OpenCode</b> speaks Chat Completions, so its requests go to Ollama’s <code>/v1</code> as they are. <a href="/docs/opencode-models">Models in OpenCode</a>.</li>
</ul>
<p>Inside the agent, Claude Code’s and Codex’s <code>/model</code> 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 <code>magpie claude default</code> or <code>magpie codex default</code>.</p>
<h2 id="window"><a class="anchor" href="#window">Context window and num_ctx</a></h2>
<p>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: <span class="ui">Context window</span> under <span class="ui">Advanced</span> in the provider’s editor, for every model or one of them. magpie passes it on to the agents.</p>
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-window">Copy</button><pre id="ex-window">magpie provider set ollama context=32k
magpie provider set ollama context.qwen3=128k</pre></div>
<ul>
<li><b><code>num_ctx</code>.</b> Some clients send Ollama’s per-request options, such as <code>{"num_ctx": …}</code>, beside the Chat Completions fields. magpie leaves them out of every request it sends on: no Chat Completions API reads them, Ollama’s own <code>/v1</code> included. The window the model runs with is Ollama’s to set; give magpie the same number.</li>
<li><b>Too long.</b> When a conversation outgrows the window, Ollama answers “exceeded max context length”. magpie tells the agent so the way it understands, <code>context_length_exceeded</code> or Anthropic’s “prompt is too long”, so the agent compacts and tries again.</li>
</ul>
<h2 id="reasoning"><a class="anchor" href="#reasoning">Reasoning</a></h2>
<ul>
<li><b>Effort.</b> 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.</li>
<li><b>Reasoning off.</b> When an agent whose requests magpie translates, such as Codex or Gemini CLI, turns reasoning off and the model lists <code>none</code> among its levels, magpie asks for none.</li>
<li><b>Your own levels.</b> <code>magpie model efforts</code> offers only the levels you name, or sends a model no reasoning field at all.</li>
</ul>
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-efforts">Copy</button><pre id="ex-efforts">magpie model efforts ollama/qwen3 low,medium,high
magpie model efforts ollama/qwen3 off</pre></div>
<h2 id="tools"><a class="anchor" href="#tools">Tool calls</a></h2>
<p>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.</p>
<h2 id="masking"><a class="anchor" href="#masking">Privacy masking</a></h2>
<p>magpie’s <a href="/docs/masking">privacy masking</a> 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 <span class="ui">Send requests unmasked</span> in its editor, or run <code>magpie provider set ollama unmasked=yes</code>.</p>
<ul>
<li><b>Cloud models.</b> 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.</li>
<li><b>Tool arguments.</b> In a request in Ollama’s own format, a tool call’s arguments are masked as tool arguments, as in every other API.</li>
<li><b>Anonymous stats.</b> magpie’s daily stats name an Ollama model only when models.dev knows it; any other counts as “other”. See <a href="/docs/privacy">Privacy</a>.</li>
</ul>
<h2 id="cost"><a class="anchor" href="#cost">Usage and cost</a></h2>
<ul>
<li><b>Usage.</b> The <span class="ui">Usage</span> 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.</li>
<li><b>Free first.</b> <code>free=yes</code> counts 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.</li>
<li><b>Ollama Cloud’s allowance.</b> 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.</li>
<li><b>Peak hours.</b> On Ollama Cloud, <code>deepseek-v4.1-flash</code> and <code>deepseek-v4-pro</code> (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.</li>
<li><b>Out of allowance.</b> 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. <code>quota-rest</code> sets how long, up to 8 days. With several keys (<span class="ui">Add another key</span>) the next one takes over; when every key is out, the gateway answers at once with Retry-After.</li>
</ul>
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-cost">Copy</button><pre id="ex-cost">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</pre></div>
<h2 id="server"><a class="anchor" href="#server">magpie as an Ollama server</a></h2>
<p>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 <code>ollama</code> CLI. Point them at magpie’s gateway, <code>http://127.0.0.1:3425</code>, and they see magpie’s models, from every provider, not only Ollama.</p>
<ul>
<li><b>Routes.</b> magpie answers <code>/api/version</code>, <code>/api/tags</code>, <code>/api/show</code>, <code>/api/chat</code> and <code>/api/generate</code>.</li>
<li><b>The same path.</b> A chat there is served as <code>/v1/chat/completions</code> is, so key limits, routing, fallbacks and usage are the same. A gateway key held to some models lists only those.</li>
<li><b>What it tells.</b> <code>/api/tags</code> and <code>/api/show</code> mark tools, vision when the model reads images, and thinking when it reasons. <code>/api/show</code> also gives the model’s window, or 32768 for one magpie doesn’t know. The <code>ollama</code> CLI’s <code>name:latest</code> finds a model called <code>name</code>.</li>
</ul>
<h2 id="trouble"><a class="anchor" href="#trouble">Troubleshooting</a></h2>
<ul>
<li><b>A model you pulled isn’t listed.</b> The list comes from the server. Press <span class="ui">Fetch models</span>, or run <code>magpie provider refresh ollama</code>, and pick it in the provider’s model list. Use the name Ollama lists, tag included.</li>
<li><b>Ollama isn’t running.</b> <code>magpie provider test ollama</code> sends a tiny request through each endpoint, or to each model you name; add <code>--as codex</code> or <code>--as claude-code</code> to send it the way that agent would. Start Ollama, or check <span class="ui">Server address</span>. <code>fallback</code> names where requests go while it is down.</li>
<li><b>“exceeded max context length”.</b> The conversation is longer than the model was loaded for. Set the real <span class="ui">Context window</span> on the provider, and the agents compact before they reach it.</li>
<li><b>Another computer can’t be reached.</b> Check the address and port in <span class="ui">Server address</span>; for HTTPS with a self-signed certificate, turn on <span class="ui">Don't check its certificate</span>.</li>
</ul>
<h2 id="faq"><a class="anchor" href="#faq">FAQ</a></h2>
<h3>How do I use Ollama in Claude Code?</h3>
<p>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 <code>magpie claude ollama/qwen3</code>. Claude Code’s requests go through magpie’s gateway to Ollama’s Anthropic Messages API at <code>http://localhost:11434</code> as they are.</p>
<h3>Can Codex use Ollama?</h3>
<p>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 <code>magpie codex ollama/qwen3</code>.</p>
<h3>Can Gemini CLI and OpenCode use Ollama?</h3>
<p>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 <code>magpie gemini model ollama/qwen3</code> or <code>magpie opencode ollama/qwen3</code>.</p>
<h3>How do I run qwen3-coder from Ollama in Claude Code?</h3>
<p>Pull it in Ollama, press Fetch models in the provider’s editor in magpie (or run <code>magpie provider refresh ollama</code>), and pick it on Claude Code’s row. Its id in magpie is <code>ollama/</code> 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.</p>
<h3>Can magpie use Ollama on another computer?</h3>
<p>Yes. Set the provider’s Server address to that computer, such as <code>magpie provider set ollama address=192.168.1.20:11434</code>. A server on your own network is reached directly, not through a proxy set in Settings or the system.</p>
<h3>Does magpie work with Ollama Cloud?</h3>
<p>Yes. Add Ollama Cloud with a key from <code>ollama.com/settings/keys</code>. 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.</p>
<h3>Do I need an API key for a local Ollama?</h3>
<p>No. The Ollama preset takes none. Ollama Cloud needs one.</p>
<p>Other local servers, such as LM Studio, oMLX, vLLM and llama.cpp’s server, are in <a href="/docs/local-models">Local models</a>. To let a local model classify each request for routing, see <a href="/docs/intent">Intent routing</a>.</p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/mistral">Mistral</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a></p>
<p style="margin-top:48px">Every agent: <a href="/docs/claude-code-models">Models in Claude Code</a>, <a href="/docs/codex-models">Models in Codex</a>, <a href="/docs/gemini-cli-models">Models in Gemini CLI</a>, <a href="/docs/opencode-models">Models in OpenCode</a>. Ask on <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> if you get stuck.</p>
</article>
</main>
<footer><div class="wrap">
<span>© 2026 magpie · MIT</span>
<div class="links">
<a href="/">Home</a>
<a href="/docs/intent">Intent routing</a>
<a href="/docs/plugins">Plugins</a>
<a href="/docs/remote">Remote magpie</a>
<a href="/docs/docker">Docker</a>
<a href="/docs/privacy">Privacy</a>
<a href="/docs/masking">Privacy masking</a>
<a href="/docs/mcp-router">MCP router</a>
<a href="/docs/library">Library</a>
<a href="/docs/claude-code-models">Models in Claude Code</a>
<a href="/docs/codex-models">Models in Codex</a>
<a href="/docs/gemini-cli-models">Models in Gemini CLI</a>
<a href="/docs/subscriptions">Subscriptions in any agent</a>
<a href="/docs/local-models">Local models</a>
<a href="/docs/opencode-models">Models in OpenCode</a>
<a href="/docs/alternatives">magpie vs CC Switch vs CCR</a>
<a href="/docs/import">Add to magpie</a>
<a href="/docs/integrate">Integrate</a>
<a href="https://github.com/yetone/magpie">GitHub</a>
<a href="https://discord.gg/vGSnD3ZKQF">Discord</a>
<a href="/docs/contributors">Contributors</a>
<a href="https://github.com/yetone/magpie-releases/releases">Releases</a>
</div>
</div></footer>
<script>
(() => {
const next = { system: "light", light: "dark", dark: "system" };
document.querySelectorAll("button.theme").forEach((b) => {
b.dataset.mode = themeMode();
b.title = "Theme: " + themeMode();
b.addEventListener("click", () => setTheme(next[themeMode()]));
});
document.querySelectorAll(".copy").forEach((b) => b.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(document.getElementById(b.dataset.copy).textContent);
b.textContent = "Copied"; setTimeout(() => (b.textContent = "Copy"), 1400);
} catch {}
}));
})();
</script>
<script src="/docs.js"></script>
</body>
</html>
+1 -1
View File
@@ -239,7 +239,7 @@ magpie visible opencode all # every model again</pre></div>
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-oc-back">Copy</button><pre id="ex-oc-back">magpie opencode default</pre></div>
<p>It puts back the <code>model</code> and <code>small_model</code> OpenCode had before magpie, and takes the <code>magpie</code> provider out of the file.</p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a></p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/mistral">Mistral</a> · <a href="/docs/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a> · <a href="/docs/ollama">Ollama</a></p>
<h2 id="faq"><a class="anchor" href="#faq">FAQ</a></h2>
<h3>How do I use DeepSeek in OpenCode?</h3>
+1 -1
View File
@@ -288,7 +288,7 @@ magpie group set opus-anywhere stays=session models+=openrouter/anthropic/claude
<h3>Why does magpie fetch OpenRouter’s model list from /api/v1?</h3>
<p>Asked at the Anthropic base, OpenRouter answers with its catalog under <code>anthropic/</code> names it doesn’t serve. magpie fetches the list from the Chat Completions base, <code>https://openrouter.ai/api/v1</code>, and a provider given only OpenRouter’s Anthropic base is told to add that Chat base.</p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/copilot">GitHub Copilot</a></p>
<p><b>By provider:</b> <a href="/docs/deepseek">DeepSeek</a> · <a href="/docs/kimi">Kimi and Kimi Code</a> · <a href="/docs/glm">GLM Coding Plan</a> · <a href="/docs/qwen">Qwen</a> · <a href="/docs/minimax">MiniMax</a> · <a href="/docs/gemini">Gemini</a> · <a href="/docs/grok">Grok</a> · <a href="/docs/mistral">Mistral</a> · <a href="/docs/copilot">GitHub Copilot</a> · <a href="/docs/ollama">Ollama</a></p>
<p style="margin-top:48px">Every agent: <a href="/docs/claude-code-models">Models in Claude Code</a>, <a href="/docs/codex-models">Models in Codex</a>, <a href="/docs/gemini-cli-models">Models in Gemini CLI</a>, <a href="/docs/opencode-models">Models in OpenCode</a>. Ask on <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> if you get stuck.</p>
</article>
</main>
+1 -1
View File
@@ -251,7 +251,7 @@ magpie claude codex/gpt-5.5</pre></div>
</ul>
<p>各种路由方式见 <a href="/docs/zh/start#routing">快速上手</a>。</p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a></p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/mistral">Mistral</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a> · <a href="/docs/zh/ollama">Ollama</a></p>
<h2 id="faq"><a class="anchor" href="#faq">常见问题</a></h2>
<h3>需要自己设置 <code>ANTHROPIC_BASE_URL</code> 吗?</h3>
+1 -1
View File
@@ -251,7 +251,7 @@ magpie codex claude/…</pre></div>
</ul>
<p>各种路由方式见 <a href="/docs/zh/start#routing">快速上手</a>。</p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a></p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/mistral">Mistral</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a> · <a href="/docs/zh/ollama">Ollama</a></p>
<h2 id="faq"><a class="anchor" href="#faq">常见问题</a></h2>
<h3>需要自己写 <code>[model_providers]</code> 吗?</h3>
+1 -1
View File
@@ -297,7 +297,7 @@ magpie opencode copilot/claude-opus-5.5</pre></div>
<h3>为什么我的列表里少了某个 Copilot 模型?</h3>
<p>magpie 列出的是 Copilot 的 <code>/models</code> 给这个账号的模型:只有对话模型,不含任何模型选择器都不提供的,也不含这个账号无法开启的。被 Copilot 用“The requested model is not supported.”拒绝的模型会被隐藏 6 小时,之后再试,以防你的套餐已经变了。</p>
<p style="margin-top:48px"><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/openrouter">OpenRouter</a></p>
<p style="margin-top:48px"><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/mistral">Mistral</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/ollama">Ollama</a></p>
<p>各个工具的指南:<a href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>、<a href="/docs/zh/codex-models">Codex 接入其他模型</a>、<a href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>、<a href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>。遇到问题可以在 <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> 提问。</p>
</article>
</main>
+1 -1
View File
@@ -235,7 +235,7 @@ magpie gemini model codex/gpt-5.5</pre></div>
</ul>
<p>路由方式和规则详见 <a href="/docs/zh/start#routing">快速上手</a>。</p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a></p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/mistral">Mistral</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a> · <a href="/docs/zh/ollama">Ollama</a></p>
<h2 id="faq"><a class="anchor" href="#faq">常见问题</a></h2>
<h3>Gemini CLI 能用 Gemini 以外的模型吗?</h3>
+1 -1
View File
@@ -310,7 +310,7 @@ magpie claude google-vertex/gemini-3.1-pro-preview</pre></div>
<h3>能用 Gemini Code Assist 或 Antigravity 的登录吗?</h3>
<p>能。两者都是订阅:运行 <code>magpie accounts add gemini</code> 或 <code>magpie accounts add antigravity</code>,然后选 <code>gemini/…</code> 或 <code>antigravity/…</code> 模型。Code Assist 需要有自己 Google Cloud 项目的 Standard 或 Enterprise 账号。</p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a></p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/mistral">Mistral</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a> · <a href="/docs/zh/ollama">Ollama</a></p>
<p style="margin-top:48px">各个工具的指南:<a href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>、<a href="/docs/zh/codex-models">Codex 接入其他模型</a>、<a href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>、<a href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>。遇到问题可以在 <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> 提问。</p>
</article>
</main>
+1 -1
View File
@@ -283,7 +283,7 @@ magpie provider fallback xai deepseek/deepseek-v4-pro</pre></div>
<h3>magpie 能显示 xAI 的余额吗?</h3>
<p>不能。用量页会统计每次 Grok 调用的 token、缓存和费用,按 models.dev 的价格计价,但 magpie 不会从 xAI 读取余额。你可以用 <code>magpie provider key-balance</code> 自己填上余额,用量页会显示它减去 magpie 此后算出的费用。</p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a></p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/mistral">Mistral</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a> · <a href="/docs/zh/ollama">Ollama</a></p>
<p style="margin-top:48px">各个工具的指南:<a href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>、<a href="/docs/zh/codex-models">Codex 接入其他模型</a>、<a href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>、<a href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>。遇到问题可以在 <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> 提问。</p>
</article>
</main>
+331
View File
@@ -0,0 +1,331 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mistral 接入 Claude Code、Codex、Gemini CLI 和 OpenCode · magpie</title>
<meta name="description" content="用 magpie 把 Mistral 的模型(包括 Devstral 和 Codestral)接入 Claude Code、Codex、Gemini CLI 和 OpenCode:Mistral API Key 只添加一次,每个工具各选一个模型,magpie 负责把各工具的请求转换成 Mistral 接口能接受的样子,保住思考内容,显示 Le Chat 套餐的 Vibe 月度额度,统计费用,并在多个 Key 之间分配请求。">
<meta name="color-scheme" content="light dark">
<meta name="theme-color" content="#fafafa">
<script>
(() => {
let mode = "system";
try { mode = localStorage.getItem("theme") || "system"; } catch {}
const q = matchMedia("(prefers-color-scheme: dark)");
const apply = () => {
const t = mode === "system" ? (q.matches ? "dark" : "light") : mode;
document.documentElement.dataset.theme = t;
document.querySelector('meta[name="theme-color"]').content = t === "dark" ? "#0b0b0c" : "#fafafa";
document.querySelectorAll("button.theme").forEach((b) => { b.dataset.mode = mode; b.title = "Theme: " + mode; });
};
q.addEventListener("change", () => mode === "system" && apply());
window.setTheme = (m) => { mode = m; try { m === "system" ? localStorage.removeItem("theme") : localStorage.setItem("theme", m); } catch {} apply(); };
window.themeMode = () => mode;
apply();
})();
</script>
<script>try{if(/Linux/.test(navigator.userAgent)&&!/Android/.test(navigator.userAgent)||localStorage.getItem("omarchy")||/[?&]omarchy=/.test(location.search))document.write('<script src="/omarchy.js"><\/script>')}catch(e){}</script>
<link rel="icon" href="/favicon.png" type="image/png">
<link rel="apple-touch-icon" href="/img/icon-256.png">
<link rel="alternate" hreflang="en" href="https://usemagpie.ai/docs/mistral">
<link rel="alternate" hreflang="zh" href="https://usemagpie.ai/docs/zh/mistral">
<link rel="alternate" hreflang="ja" href="https://usemagpie.ai/docs/ja/mistral">
<link rel="alternate" hreflang="x-default" href="https://usemagpie.ai/docs/mistral">
<link rel="canonical" href="https://usemagpie.ai/docs/zh/mistral">
<link rel="stylesheet" href="/docs.css">
<meta property="og:site_name" content="magpie">
<meta property="og:title" content="Mistral 接入 Claude Code、Codex、Gemini CLI 和 OpenCode">
<meta property="og:description" content="用 magpie 把 Mistral 的模型(包括 Devstral 和 Codestral)接入 Claude Code、Codex、Gemini CLI 和 OpenCode:Mistral API Key 只添加一次,每个工具各选一个模型,magpie 负责把各工具的请求转换成 Mistral 接口能接受的样子,保住思考内容,显示 Le Chat 套餐的 Vibe 月度额度,统计费用,并在多个 Key 之间分配请求。">
<meta property="og:image" content="https://usemagpie.ai/img/og.png">
<meta property="og:url" content="https://usemagpie.ai/docs/zh/mistral">
<meta name="twitter:card" content="summary_large_image">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "TechArticle",
"headline": "Mistral 接入 Claude Code、Codex、Gemini CLI 和 OpenCode",
"description": "用 magpie 把 Mistral 的模型(包括 Devstral 和 Codestral)接入 Claude Code、Codex、Gemini CLI 和 OpenCode:Mistral API Key 只添加一次,每个工具各选一个模型,magpie 负责把各工具的请求转换成 Mistral 接口能接受的样子,保住思考内容,显示 Le Chat 套餐的 Vibe 月度额度,统计费用,并在多个 Key 之间分配请求。",
"inLanguage": "zh-CN",
"url": "https://usemagpie.ai/docs/zh/mistral",
"about": {
"@type": "SoftwareApplication",
"name": "magpie",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "macOS, Windows, Linux"
},
"publisher": {
"@type": "Organization",
"name": "magpie",
"url": "https://usemagpie.ai/"
}
},
{
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "怎么在 Claude Code 里用 Mistral?",
"acceptedAnswer": {
"@type": "Answer",
"text": "在 magpie 里添加 Mistral API Key(供应商、添加供应商、Mistral),然后在 Claude Code 那一行选一个 Mistral 模型,比如 mistral-large-4,或者运行 magpie claude mistral/mistral-large-4。Mistral 只提供 Chat Completions 接口,所以 magpie 把 Claude Code 的 Anthropic Messages 请求转换后发到 https://api.mistral.ai/v1,再把回复转换回来,思考内容也一样。"
}
},
{
"@type": "Question",
"name": "Codex 能用 Devstral 等 Mistral 模型吗?",
"acceptedAnswer": {
"@type": "Answer",
"text": "能。你的 Mistral Key 列出的模型,包括 Devstral,Codex 都能用。Codex 说的是 OpenAI Responses 接口,Mistral 不提供,所以 magpie 把每个请求转换成 Chat Completions,把 apply_patch 这类 Codex 自定义工具当作函数交给模型,再把调用按 Codex 能执行的方式还回去。"
}
},
{
"@type": "Question",
"name": "怎么在 OpenCode 里用 Codestral 等 Mistral 模型?",
"acceptedAnswer": {
"@type": "Answer",
"text": "在 magpie 里选好模型,或者运行 magpie opencode mistral/mistral-large-4;只要你的 Key 列出了 Codestral 或 Devstral,用法完全一样。OpenCode 说的是 Chat Completions,请求原样发给 Mistral,只在路上修掉 Mistral 会拒绝的内容:OpenCode 的 store 字段,以及放在 reasoning_content 里回传的上一轮思考。"
}
},
{
"@type": "Question",
"name": "Gemini CLI 能用 Mistral 吗?",
"acceptedAnswer": {
"@type": "Answer",
"text": "能。Gemini CLI 说的是 Google 的 Gemini 接口,magpie 会把它的请求转换成 Mistral 的 Chat Completions,再把回复转换回来,流式输出和工具调用都包括在内。运行 magpie gemini model mistral/mistral-large-4 即可。"
}
},
{
"@type": "Question",
"name": "Mistral 为什么回 422 extra_forbidden?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Mistral 会拒绝它不认识的任何字段。magpie 会把上一轮的思考改成 Mistral 接受的思考片段,去掉部分工具附带的 Ollama 参数;遇到 Mistral 点名的可选字段(比如 OpenCode 的 store),就去掉它重新请求,之后也不再发送。"
}
},
{
"@type": "Question",
"name": "magpie 能显示 Le Chat 套餐的 Vibe 额度吗?",
"acceptedAnswer": {
"@type": "Answer",
"text": "能。Le Chat 套餐(Pro、Student 或 Team)的 Vibe Key 会显示本月 Vibe 额度用了多少、按 Mistral 计费的币种计、什么时候重置,以及套餐名称。在控制台创建的 Studio Key 则显示组织的 API 额度,名为 “API · Month”。"
}
}
]
}
]
}
</script>
</head>
<body>
<nav><div class="wrap">
<a class="brand" href="/zh/"><img class="bird" src="/img/magpie-small.svg" alt="">magpie <small>文档</small></a>
<div class="links">
<a href="/zh/">首页</a>
<a href="/docs/zh/start">快速上手</a>
<a href="/docs/zh/intent">意图路由</a>
<a href="/docs/zh/plugins">插件开发</a>
<a class="toc-only" href="/docs/zh/remote">远程 magpie</a>
<a class="toc-only" href="/docs/zh/docker">Docker</a>
<a class="toc-only" href="/docs/zh/privacy">隐私</a>
<a class="toc-only" href="/docs/zh/masking">本地脱敏</a>
<a class="toc-only" href="/docs/zh/mcp-router">MCP 路由</a>
<a class="toc-only" href="/docs/zh/library">资源库</a>
<a class="toc-only" href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>
<a class="toc-only" href="/docs/zh/codex-models">Codex 接入其他模型</a>
<a class="toc-only" href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>
<a class="toc-only" href="/docs/zh/subscriptions">订阅用于任意 Agent</a>
<a class="toc-only" href="/docs/zh/local-models">本地模型</a>
<a class="toc-only" href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>
<a class="toc-only" href="/docs/zh/alternatives">与 CC Switch、CCR 对比</a>
<a href="/docs/zh/import">Add to magpie</a>
<a href="/docs/zh/integrate">接入应用</a>
<a href="https://github.com/yetone/magpie-releases/releases">版本发布</a>
</div>
<div class="langs">
<button class="icon-btn lang" type="button" aria-label="语言" title="语言" aria-haspopup="true" aria-expanded="false" aria-controls="langs"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="8" cy="8" r="6.25"/><path d="M1.75 8h12.5M8 1.75c1.7 1.75 2.55 3.83 2.55 6.25S9.7 12.5 8 14.25M8 1.75C6.3 3.5 5.45 5.58 5.45 8S6.3 12.5 8 14.25"/></svg></button>
<div class="lang-menu" id="langs" hidden>
<a href="/docs/mistral" hreflang="en" lang="en">English</a>
<a href="/docs/zh/mistral" hreflang="zh" lang="zh">中文</a>
<a href="/docs/ja/mistral" hreflang="ja" lang="ja">日本語</a>
</div>
</div>
<a class="icon-btn" href="https://discord.gg/vGSnD3ZKQF" aria-label="magpie on Discord" title="Join us on Discord"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"/></svg></a>
<a class="icon-btn" href="https://github.com/yetone/magpie" aria-label="magpie on GitHub" title="Source on GitHub"><svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"/></svg></a>
<button class="icon-btn theme" type="button" aria-label="Theme" title="Theme: system"><svg class="i-system" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1.75" y="2.75" width="12.5" height="8.5" rx="1.5"/><path d="M5.5 14h5M8 11.25V14"/></svg><svg class="i-light" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="8" cy="8" r="3"/><path d="M8 1v1.5M8 13.5V15M1 8h1.5M13.5 8H15M3 3l1 1M12 12l1 1M3 13l1-1M12 4l1-1"/></svg><svg class="i-dark" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"><path d="M13.5 9.5A5.5 5.5 0 0 1 6.5 2.5a5.5 5.5 0 1 0 7 7Z"/></svg></button>
<a class="btn small" href="/#get">下载</a>
</div></nav>
<main class="wrap doc">
<aside class="toc">
<p>本页内容</p>
<a href="#add">添加</a>
<a href="#endpoints">接口地址</a>
<a href="#models">模型列表</a>
<a href="#agents">在各个工具里用</a>
<a href="#shaping">magpie 替你修正的请求</a>
<a href="#reasoning">推理</a>
<a href="#search">联网搜索</a>
<a href="#cost">Vibe、费用与用量</a>
<a href="#keys">多个 Key</a>
<a href="#trouble">常见报错</a>
<a href="#faq">常见问题</a>
</aside>
<article>
<p class="eyebrow" id="overview">文档 · 供应商</p>
<h1>Mistral 接入 Claude Code、Codex、Gemini CLI 和 OpenCode</h1>
<p class="lede">Mistral 的模型只通过一种接口提供:<code>api.mistral.ai</code> 上的 OpenAI 风格 Chat Completions。把 Mistral 的 API Key 添加到 magpie 一次,Claude Code、Codex、Gemini CLI、OpenCode 以及你接入的其他工具,都能通过 magpie 的本地网关 <code>127.0.0.1:3425</code> 使用 Mistral,每个工具各用各的模型。说其他接口的工具,magpie 会在路上替它转换。</p>
<h2 id="add"><a class="anchor" href="#add">添加 Mistral</a></h2>
<ol class="steps">
<li><b>拿到 Key</b>在 <a href="https://console.mistral.ai/api-keys">console.mistral.ai</a> 创建。Le Chat 套餐的 Vibe Key 也加在同一个供应商里。</li>
<li><b>添加供应商</b>在 magpie 的 <span class="ui">供应商</span> 页点 <span class="ui">+ 添加供应商</span>,选 <span class="ui">Mistral</span>,粘贴 Key 并保存。magpie 会向 Mistral 查询这个 Key 能用哪些模型。</li>
<li><b>给工具选上</b>在 <span class="ui">Agent</span> 页点工具那一行的模型,选一个 Mistral 模型,比如 <code>mistral-large-4</code>。</li>
</ol>
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-add">复制</button><pre id="ex-add">magpie provider add mistral &lt;key&gt;
magpie provider test mistral</pre></div>
<p>magpie 里的模型 id 是 <code>供应商/模型</code>,所以 Mistral 的模型写作 <code>mistral/mistral-large-4</code>:前面是供应商,后面是 Mistral 自己的 id。Key 保存在 magpie 的设置里,magpie 不会从 shell 里读取它。</p>
<p>已经在 OpenCode 或 Alma 里配好了 Mistral?magpie 从这些应用导入时,会把它变成 Mistral 供应商。有的应用一个 Key 存一条(“Mistral #0001”“Mistral #0002”……),导入后会合并成一个 Mistral 供应商,里面放着同样多的 Key,在每个工具的模型选择器里只出现一次。</p>
<h2 id="endpoints"><a class="anchor" href="#endpoints">接口地址</a></h2>
<div class="table-wrap"><table>
<tr><th>接口</th><th>地址</th><th>用途</th></tr>
<tr><td>Chat Completions</td><td><code>https://api.mistral.ai/v1</code></td><td>模型列表和所有工具的请求:OpenCode 的原样发送,Claude Code、Codex 和 Gemini CLI 的转换后发送</td></tr>
<tr><td>计费</td><td><code>https://api.mistral.ai/v1/billing/budget</code>、<code>/v1/billing/subscription</code></td><td>Key 当月的 Vibe 或 API 额度,以及所在的套餐</td></tr>
</table></div>
<p>magpie 的 Mistral 供应商没有 Anthropic Messages 或 Responses 地址,所以说这两种接口的工具,请求都会转换成 Chat Completions,回复再转换回去,流式输出和工具调用都包括在内。</p>
<h2 id="models"><a class="anchor" href="#models">模型列表</a></h2>
<p>magpie 从 Mistral 的 <code>https://api.mistral.ai/v1/models</code> 拉取列表,所以工具里看到的就是这个 Key 能用的模型。名称、推理档位和价格来自 models.dev 的 <code>mistral</code> 目录;Devstral、Codestral 和 Magistral 模型在每个选择器里都带着 Mistral 的图标。Mistral 也提供其他厂商的模型,比如 GLM 和 DeepSeek 的 <code>deepseek-v4.1-flash-1017</code>,它们走同一个 Key,下面的修正对它们同样有效。工具能看到哪些模型,可以在供应商的模型列表里挑,也可以在终端里设置:</p>
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-models">复制</button><pre id="ex-models">magpie provider models mistral +mistral-large-4 +mistral-medium-3.5
magpie provider refresh-every mistral 1d</pre></div>
<h2 id="agents"><a class="anchor" href="#agents">在各个工具里用</a></h2>
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-agents">复制</button><pre id="ex-agents">magpie claude mistral/mistral-large-4
magpie codex mistral/mistral-large-4
magpie gemini model mistral/mistral-large-4
magpie opencode mistral/mistral-large-4</pre></div>
<ul>
<li><b>Claude Code</b> 说的是 Anthropic Messages,Mistral 不提供这个接口。magpie 把每个请求转换成 Chat Completions,再把回复转换回来;推理模型的思考会先以思考内容出现在 Claude Code 里,然后才是正文。<a href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>。</li>
<li><b>Codex</b> 说的是 OpenAI Responses,Mistral 同样不提供,所以它的请求也要转换。<code>apply_patch</code> 这类 Codex 自定义工具会以函数的形式交给模型,模型的调用再以 Codex 能执行的自定义工具调用还回去。<a href="/docs/zh/codex-models">Codex 接入其他模型</a>。</li>
<li><b>Gemini CLI</b> 说的是 Google 的 Gemini 接口。magpie 把每个请求转换成 Chat Completions,再把回复转换回来。<a href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>。</li>
<li><b>OpenCode</b> 说的是 Chat Completions,所以请求原样发给 Mistral,只做下面这些修正。<a href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>。</li>
</ul>
<h2 id="shaping"><a class="anchor" href="#shaping">magpie 替你修正的请求</a></h2>
<p>Mistral 的接口对收到的内容很严格,推理模型的思考也用它自己的格式返回。magpie 在路上把两边都调整好,原样转发的请求和转换过的请求都一样:</p>
<ul>
<li><b>分段的思考内容。</b>Mistral 把推理模型的思考放进 <code>content</code>,写成带类型的分段,思考和正文有时还挤在同一个 chunk 里,而 Chat 接口约定这里是字符串。OpenCode 收到第一个这样的 chunk 就报错(“Invalid … stream event”)。magpie 把思考移到 <code>reasoning_content</code>,正文改成普通字符串,流式和非流式回复都一样。</li>
<li><b>回传的思考。</b>OpenCode 会把上一轮的思考放在 <code>reasoning_content</code> 里传回去,Mistral 对此回 422 <code>extra_forbidden</code>。magpie 把它改成 Mistral 自己返回时用的思考片段,放在这一轮正文前面,思考就还留在上下文里。转换过的请求也这样处理,所以在 Mistral 上跑 DeepSeek 模型时,Codex 的工具调用循环能一直走下去。</li>
<li><b>Mistral 不认识的字段。</b>OpenCode 的 <code>store</code> 和 Kimi Code 的思考开关都会换来 422 <code>extra_forbidden</code>。magpie 去掉 Mistral 点名的可选字段重新请求,成功之后就不再给它发这些字段。</li>
<li><b>Ollama 参数。</b>有的工具把网关当成了 Ollama 服务器(比如 Hermes Agent),会在 Chat 字段旁边带上 Ollama 的 <code>options</code>(其中的 <code>num_ctx</code>)。magpie 会把它们去掉,Mistral 根本看不到。</li>
</ul>
<h2 id="reasoning"><a class="anchor" href="#reasoning">推理</a></h2>
<ul>
<li><b>推理强度。</b>工具要求的推理强度,会按目录里列出的档位,换成这个模型最接近的一档。不知道档位的模型,按工具的原始要求发送。</li>
<li><b>关闭推理。</b>需要 magpie 转换请求的工具(比如 Gemini CLI)关掉推理时,如果模型的档位里有 <code>none</code>,magpie 就请求 none。</li>
<li><b>跨轮次的思考。</b>每个工具都以自己的格式看到推理模型的思考:OpenCode 是 <code>reasoning_content</code>,Claude Code 是思考块,Codex 是推理内容。下一轮传回来时,Mistral 收到的是思考片段,见 <a href="#shaping">magpie 替你修正的请求</a>。</li>
</ul>
<h2 id="search"><a class="anchor" href="#search">联网搜索</a></h2>
<p>Mistral 的 Chat Completions 接口不会替 magpie 联网搜索,所以在每个工具里,magpie 都给模型提供自己的搜索工具,由设置里指定的搜索服务回答;没指定时,由 magpie 自己挑一个。</p>
<h2 id="cost"><a class="anchor" href="#cost">Vibe、费用与用量</a></h2>
<ul>
<li><b>Vibe 月度额度。</b>Le Chat 套餐(Pro、Student 或 Team)附带一个月的 Mistral Vibe。它的 Vibe Key 那一行会显示本月额度用了多少(按 Mistral 计费的币种)、什么时候重置,以及套餐名称。</li>
<li><b>API 月度额度。</b>在控制台创建的 Studio Key 显示组织的 API 额度,名为 “API · Month”,和 Vibe 的额度分开。额度是整个组织的,所以同一个组织的每个 Key 显示的数字都一样。没有额度的 Key 不显示卡片。</li>
<li><b>按量付费。</b>开了按量付费时,超出额度的部分照常计费而不会被停掉,所以用完当月额度也不会让这个 Key 的模型停用。</li>
<li><b>缓存 token。</b>回复里报告了缓存命中的提示 token 时,<span class="ui">用量</span> 页会把它们和其余的提示分开统计。</li>
<li><b>保住缓存。</b>有多个 Key 时,只要一段对话的缓存值得保留(1,024 个 token 以上),而且还热着(五分钟内读过),它就一直用同一个 Key。</li>
<li><b>费用。</b>用量页按 models.dev 上 Mistral 的价格给每次调用计价。magpie 不会从 Mistral 读取余额;可以用 <code>key-balance</code> 自己填上,用量页会显示它减去 magpie 此后给这个 Key 的调用算出的费用。</li>
</ul>
<h2 id="keys"><a class="anchor" href="#keys">多个 Key 与故障切换</a></h2>
<p>一个 Mistral 供应商可以放多个 Key:在它下面点 <span class="ui">添加另一个密钥</span>,也可以一次粘贴好几个。请求先走第一个开着的 Key,它用完或被限流时由下一个接替。</p>
<ul>
<li><b>花费上限。</b><code>spend-cap</code> 给某个 Key 设一个每天、每月或总计的美元上限,按用量页的计价算;到了上限,路由就转去其他 Key 和备用模型。</li>
<li><b>备用模型。</b><code>fallback</code> 指定 Mistral 额度用完或挂掉时请求去哪:另一个供应商的模型,或一个路由分组。</li>
</ul>
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-keys">复制</button><pre id="ex-keys">magpie provider spend-cap mistral &lt;key&gt; 20 month
magpie provider key-balance mistral &lt;key&gt; 25
magpie provider fallback mistral deepseek/deepseek-v4-pro</pre></div>
<h2 id="trouble"><a class="anchor" href="#trouble">常见报错</a></h2>
<ul>
<li><b>422 <code>extra_forbidden</code>,“Extra inputs are not permitted”。</b>Mistral 拒绝了它不认识的字段。工具常发的那些 magpie 已经处理好了;遇到 Mistral 点名的可选字段,magpie 会去掉它重新请求,见 <a href="#shaping">magpie 替你修正的请求</a>。</li>
<li><b>OpenCode 里出现 “Invalid … stream event”。</b>这是 Mistral 分段返回的思考内容造成的。magpie 会把思考放进 <code>reasoning_content</code>、正文改成字符串再交给 OpenCode。</li>
<li><b>没有 Vibe 卡片。</b>只有 Mistral 认定为 Vibe Key 或 Studio Key、并且额度大于零的 Key,magpie 才显示当月额度。</li>
<li><b>检查 Key。</b><code>magpie provider test mistral</code> 会向每个接口发一个很小的请求,或者发给你指定的每个模型。加上 <code>--as codex</code> 或 <code>--as claude-code</code>,就按那个工具的方式发送。</li>
</ul>
<h2 id="faq"><a class="anchor" href="#faq">常见问题</a></h2>
<h3>怎么在 Claude Code 里用 Mistral?</h3>
<p>在 magpie 里添加 Mistral API Key(供应商、添加供应商、Mistral),然后在 Claude Code 那一行选一个 Mistral 模型,比如 <code>mistral-large-4</code>,或者运行 <code>magpie claude mistral/mistral-large-4</code>。Mistral 只提供 Chat Completions 接口,所以 magpie 把 Claude Code 的 Anthropic Messages 请求转换后发到 <code>https://api.mistral.ai/v1</code>,再把回复转换回来,思考内容也一样。</p>
<h3>Codex 能用 Devstral 等 Mistral 模型吗?</h3>
<p>能。你的 Mistral Key 列出的模型,包括 Devstral,Codex 都能用。Codex 说的是 OpenAI Responses 接口,Mistral 不提供,所以 magpie 把每个请求转换成 Chat Completions,把 apply_patch 这类 Codex 自定义工具当作函数交给模型,再把调用按 Codex 能执行的方式还回去。</p>
<h3>怎么在 OpenCode 里用 Codestral 等 Mistral 模型?</h3>
<p>在 magpie 里选好模型,或者运行 <code>magpie opencode mistral/mistral-large-4</code>;只要你的 Key 列出了 Codestral 或 Devstral,用法完全一样。OpenCode 说的是 Chat Completions,请求原样发给 Mistral,只在路上修掉 Mistral 会拒绝的内容:OpenCode 的 <code>store</code> 字段,以及放在 <code>reasoning_content</code> 里回传的上一轮思考。</p>
<h3>Gemini CLI 能用 Mistral 吗?</h3>
<p>能。Gemini CLI 说的是 Google 的 Gemini 接口,magpie 会把它的请求转换成 Mistral 的 Chat Completions,再把回复转换回来,流式输出和工具调用都包括在内。运行 <code>magpie gemini model mistral/mistral-large-4</code> 即可。</p>
<h3>Mistral 为什么回 422 extra_forbidden?</h3>
<p>Mistral 会拒绝它不认识的任何字段。magpie 会把上一轮的思考改成 Mistral 接受的思考片段,去掉部分工具附带的 Ollama 参数;遇到 Mistral 点名的可选字段(比如 OpenCode 的 <code>store</code>),就去掉它重新请求,之后也不再发送。</p>
<h3>magpie 能显示 Le Chat 套餐的 Vibe 额度吗?</h3>
<p>能。Le Chat 套餐(Pro、Student 或 Team)的 Vibe Key 会显示本月 Vibe 额度用了多少、按 Mistral 计费的币种计、什么时候重置,以及套餐名称。在控制台创建的 Studio Key 则显示组织的 API 额度,名为 “API · Month”。</p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a> · <a href="/docs/zh/ollama">Ollama</a></p>
<p style="margin-top:48px">各个工具的指南:<a href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>、<a href="/docs/zh/codex-models">Codex 接入其他模型</a>、<a href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>、<a href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>。遇到问题可以在 <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> 提问。</p>
</article>
</main>
<footer><div class="wrap">
<span>© 2026 magpie · MIT</span>
<div class="links">
<a href="/zh/">首页</a>
<a href="/docs/zh/intent">意图路由</a>
<a href="/docs/zh/plugins">插件开发</a>
<a href="/docs/zh/remote">远程 magpie</a>
<a href="/docs/zh/docker">Docker</a>
<a href="/docs/zh/privacy">隐私</a>
<a href="/docs/zh/masking">本地脱敏</a>
<a href="/docs/zh/mcp-router">MCP 路由</a>
<a href="/docs/zh/library">资源库</a>
<a href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>
<a href="/docs/zh/codex-models">Codex 接入其他模型</a>
<a href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>
<a href="/docs/zh/subscriptions">订阅用于任意 Agent</a>
<a href="/docs/zh/local-models">本地模型</a>
<a href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>
<a href="/docs/zh/alternatives">与 CC Switch、CCR 对比</a>
<a href="/docs/zh/import">Add to magpie</a>
<a href="/docs/zh/integrate">接入应用</a>
<a href="https://github.com/yetone/magpie">GitHub</a>
<a href="https://discord.gg/vGSnD3ZKQF">Discord</a>
<a href="/docs/zh/contributors">贡献墙</a>
<a href="https://github.com/yetone/magpie-releases/releases">版本发布</a>
</div>
</div></footer>
<script>
(() => {
const next = { system: "light", light: "dark", dark: "system" };
document.querySelectorAll("button.theme").forEach((b) => {
b.dataset.mode = themeMode();
b.title = "Theme: " + themeMode();
b.addEventListener("click", () => setTheme(next[themeMode()]));
});
document.querySelectorAll(".copy").forEach((b) => b.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(document.getElementById(b.dataset.copy).textContent);
b.textContent = "已复制"; setTimeout(() => (b.textContent = "复制"), 1400);
} catch {}
}));
})();
</script>
<script src="/docs.js"></script>
</body>
</html>
+377
View File
@@ -0,0 +1,377 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ollama 接入 Claude Code、Codex、Gemini CLI 和 OpenCode · magpie</title>
<meta name="description" content="用 magpie 把 Ollama(本机或另一台电脑上的)和 Ollama Cloud 接入 Claude Code、Codex、Gemini CLI 和 OpenCode:只添加一次,每个工具各选一个模型(比如 qwen3),magpie 负责翻译各工具的接口、告知上下文窗口,并统计用量和 Ollama Cloud 的额度。">
<meta name="color-scheme" content="light dark">
<meta name="theme-color" content="#fafafa">
<script>
(() => {
let mode = "system";
try { mode = localStorage.getItem("theme") || "system"; } catch {}
const q = matchMedia("(prefers-color-scheme: dark)");
const apply = () => {
const t = mode === "system" ? (q.matches ? "dark" : "light") : mode;
document.documentElement.dataset.theme = t;
document.querySelector('meta[name="theme-color"]').content = t === "dark" ? "#0b0b0c" : "#fafafa";
document.querySelectorAll("button.theme").forEach((b) => { b.dataset.mode = mode; b.title = "Theme: " + mode; });
};
q.addEventListener("change", () => mode === "system" && apply());
window.setTheme = (m) => { mode = m; try { m === "system" ? localStorage.removeItem("theme") : localStorage.setItem("theme", m); } catch {} apply(); };
window.themeMode = () => mode;
apply();
})();
</script>
<script>try{if(/Linux/.test(navigator.userAgent)&&!/Android/.test(navigator.userAgent)||localStorage.getItem("omarchy")||/[?&]omarchy=/.test(location.search))document.write('<script src="/omarchy.js"><\/script>')}catch(e){}</script>
<link rel="icon" href="/favicon.png" type="image/png">
<link rel="apple-touch-icon" href="/img/icon-256.png">
<link rel="alternate" hreflang="en" href="https://usemagpie.ai/docs/ollama">
<link rel="alternate" hreflang="zh" href="https://usemagpie.ai/docs/zh/ollama">
<link rel="alternate" hreflang="ja" href="https://usemagpie.ai/docs/ja/ollama">
<link rel="alternate" hreflang="x-default" href="https://usemagpie.ai/docs/ollama">
<link rel="canonical" href="https://usemagpie.ai/docs/zh/ollama">
<link rel="stylesheet" href="/docs.css">
<meta property="og:site_name" content="magpie">
<meta property="og:title" content="Ollama 接入 Claude Code、Codex、Gemini CLI 和 OpenCode">
<meta property="og:description" content="用 magpie 把 Ollama(本机或另一台电脑上的)和 Ollama Cloud 接入 Claude Code、Codex、Gemini CLI 和 OpenCode:只添加一次,每个工具各选一个模型(比如 qwen3),magpie 负责翻译各工具的接口、告知上下文窗口,并统计用量和 Ollama Cloud 的额度。">
<meta property="og:image" content="https://usemagpie.ai/img/og.png">
<meta property="og:url" content="https://usemagpie.ai/docs/zh/ollama">
<meta name="twitter:card" content="summary_large_image">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "TechArticle",
"headline": "Ollama 接入 Claude Code、Codex、Gemini CLI 和 OpenCode",
"description": "用 magpie 把 Ollama(本机或另一台电脑上的)和 Ollama Cloud 接入 Claude Code、Codex、Gemini CLI 和 OpenCode:只添加一次,每个工具各选一个模型(比如 qwen3),magpie 负责翻译各工具的接口、告知上下文窗口,并统计用量和 Ollama Cloud 的额度。",
"inLanguage": "zh-CN",
"url": "https://usemagpie.ai/docs/zh/ollama",
"about": {
"@type": "SoftwareApplication",
"name": "magpie",
"applicationCategory": "DeveloperApplication",
"operatingSystem": "macOS, Windows, Linux"
},
"publisher": {
"@type": "Organization",
"name": "magpie",
"url": "https://usemagpie.ai/"
}
},
{
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "Claude Code 怎么用 Ollama 的本地模型?",
"acceptedAnswer": {
"@type": "Answer",
"text": "在 magpie 里添加 Ollama(供应商 → 添加供应商 → 本机下的 Ollama),然后在 Claude Code 那一行选它的模型,或者运行 magpie claude ollama/qwen3。Claude Code 的请求经过 magpie 网关,原样发到 Ollama 在 http://localhost:11434 的 Anthropic Messages 接口。"
}
},
{
"@type": "Question",
"name": "Codex 能用 Ollama 吗?",
"acceptedAnswer": {
"@type": "Answer",
"text": "能。Codex 只会说 Responses 接口,magpie 会把它的请求转成 Chat Completions 发给 Ollama,再把回复转回来,工具调用也一样。运行 magpie codex ollama/qwen3 即可。"
}
},
{
"@type": "Question",
"name": "Gemini CLI 和 OpenCode 能用 Ollama 吗?",
"acceptedAnswer": {
"@type": "Answer",
"text": "能。Gemini CLI 说的是 Google 的接口,magpie 把它的请求翻译成 Ollama 的 Chat Completions,再把回复翻译回去。OpenCode 本身说 Chat Completions,请求原样发给 Ollama。运行 magpie gemini model ollama/qwen3 或 magpie opencode ollama/qwen3。"
}
},
{
"@type": "Question",
"name": "怎么在 Claude Code 里用 Ollama 的 qwen3-coder?",
"acceptedAnswer": {
"@type": "Answer",
"text": "先在 Ollama 里拉取它,再在 magpie 的供应商编辑页点「获取模型」(或运行 magpie provider refresh ollama),然后在 Claude Code 那一行选中它。它在 magpie 里的 ID 是 ollama/ 加上 Ollama 列出的名字,标签也算在内。记得同时设好它的上下文窗口:Claude Code 会把不认识的模型当作 200K。"
}
},
{
"@type": "Question",
"name": "magpie 能用另一台电脑上的 Ollama 吗?",
"acceptedAnswer": {
"@type": "Answer",
"text": "能。把供应商的服务器地址改成那台电脑,比如 magpie provider set ollama address=192.168.1.20:11434。局域网里的服务器会直接连接,不走设置或系统里的代理。"
}
},
{
"@type": "Question",
"name": "magpie 支持 Ollama Cloud 吗?",
"acceptedAnswer": {
"@type": "Answer",
"text": "支持。用 ollama.com/settings/keys 上创建的 Key 添加 Ollama Cloud,magpie 会列出这个 Key 能用的模型,按 models.dev 的价格计费,并显示账户套餐内的额度和你购买的余额。"
}
},
{
"@type": "Question",
"name": "本地 Ollama 需要 API Key 吗?",
"acceptedAnswer": {
"@type": "Answer",
"text": "不需要,Ollama 预设不用 Key。Ollama Cloud 需要。"
}
}
]
}
]
}
</script>
</head>
<body>
<nav><div class="wrap">
<a class="brand" href="/zh/"><img class="bird" src="/img/magpie-small.svg" alt="">magpie <small>文档</small></a>
<div class="links">
<a href="/zh/">首页</a>
<a href="/docs/zh/start">快速上手</a>
<a href="/docs/zh/intent">意图路由</a>
<a href="/docs/zh/plugins">插件开发</a>
<a class="toc-only" href="/docs/zh/remote">远程 magpie</a>
<a class="toc-only" href="/docs/zh/docker">Docker</a>
<a class="toc-only" href="/docs/zh/privacy">隐私</a>
<a class="toc-only" href="/docs/zh/masking">本地脱敏</a>
<a class="toc-only" href="/docs/zh/mcp-router">MCP 路由</a>
<a class="toc-only" href="/docs/zh/library">资源库</a>
<a class="toc-only" href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>
<a class="toc-only" href="/docs/zh/codex-models">Codex 接入其他模型</a>
<a class="toc-only" href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>
<a class="toc-only" href="/docs/zh/subscriptions">订阅用于任意 Agent</a>
<a class="toc-only" href="/docs/zh/local-models">本地模型</a>
<a class="toc-only" href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>
<a class="toc-only" href="/docs/zh/alternatives">与 CC Switch、CCR 对比</a>
<a href="/docs/zh/import">Add to magpie</a>
<a href="/docs/zh/integrate">接入应用</a>
<a href="https://github.com/yetone/magpie-releases/releases">版本发布</a>
</div>
<div class="langs">
<button class="icon-btn lang" type="button" aria-label="语言" title="语言" aria-haspopup="true" aria-expanded="false" aria-controls="langs"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="8" cy="8" r="6.25"/><path d="M1.75 8h12.5M8 1.75c1.7 1.75 2.55 3.83 2.55 6.25S9.7 12.5 8 14.25M8 1.75C6.3 3.5 5.45 5.58 5.45 8S6.3 12.5 8 14.25"/></svg></button>
<div class="lang-menu" id="langs" hidden>
<a href="/docs/ollama" hreflang="en" lang="en">English</a>
<a href="/docs/zh/ollama" hreflang="zh" lang="zh">中文</a>
<a href="/docs/ja/ollama" hreflang="ja" lang="ja">日本語</a>
</div>
</div>
<a class="icon-btn" href="https://discord.gg/vGSnD3ZKQF" aria-label="magpie on Discord" title="Join us on Discord"><svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"/></svg></a>
<a class="icon-btn" href="https://github.com/yetone/magpie" aria-label="magpie on GitHub" title="Source on GitHub"><svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"/></svg></a>
<button class="icon-btn theme" type="button" aria-label="Theme" title="Theme: system"><svg class="i-system" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1.75" y="2.75" width="12.5" height="8.5" rx="1.5"/><path d="M5.5 14h5M8 11.25V14"/></svg><svg class="i-light" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="8" cy="8" r="3"/><path d="M8 1v1.5M8 13.5V15M1 8h1.5M13.5 8H15M3 3l1 1M12 12l1 1M3 13l1-1M12 4l1-1"/></svg><svg class="i-dark" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"><path d="M13.5 9.5A5.5 5.5 0 0 1 6.5 2.5a5.5 5.5 0 1 0 7 7Z"/></svg></button>
<a class="btn small" href="/#get">下载</a>
</div></nav>
<main class="wrap doc">
<aside class="toc">
<p>本页内容</p>
<a href="#add">添加 Ollama</a>
<a href="#remote">换端口或换电脑</a>
<a href="#cloud">Ollama Cloud</a>
<a href="#endpoints">接口地址</a>
<a href="#models">模型列表</a>
<a href="#agents">在各个工具里用</a>
<a href="#window">上下文窗口</a>
<a href="#reasoning">推理</a>
<a href="#tools">工具调用</a>
<a href="#masking">脱敏</a>
<a href="#cost">用量与费用</a>
<a href="#server">当作 Ollama 服务</a>
<a href="#trouble">常见报错</a>
<a href="#faq">常见问题</a>
</aside>
<article>
<p class="eyebrow" id="overview">文档 · 供应商</p>
<h1>Ollama 接入 Claude Code、Codex、Gemini CLI 和 OpenCode</h1>
<p class="lede">Ollama 在 <code>http://localhost:11434</code> 上用两种接口提供你拉取的模型:OpenAI Chat Completions 和 Anthropic Messages。Ollama Cloud 在 <code>ollama.com</code> 上以同样的方式提供云端模型,需要 API Key。把其中任意一个添加到 magpie 一次,Claude Code、Codex、Gemini CLI、OpenCode 以及你接入的其他工具,就都能通过 magpie 的本地网关 <code>127.0.0.1:3425</code> 使用它们,每个工具各用各的模型。</p>
<h2 id="add"><a class="anchor" href="#add">添加 Ollama</a></h2>
<ol class="steps">
<li><b>拉取模型</b>在 Ollama 里拉取一个模型,比如 <code>qwen3</code>,并保持服务运行。</li>
<li><b>添加供应商</b>在 magpie 的 <span class="ui">供应商</span> 页点 <span class="ui">+ 添加供应商</span>,在 <span class="ui">本机</span> 下选 Ollama。不需要 Key。magpie 会向服务询问有哪些模型,它们显示为 <code>ollama/…</code>。</li>
<li><b>给工具选模型</b>在 <span class="ui">Agent</span> 页点工具那一行的模型,选一个 Ollama 模型。</li>
</ol>
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-add">复制</button><pre id="ex-add">ollama pull qwen3
magpie provider add ollama
magpie provider test ollama</pre></div>
<p>magpie 里的模型 ID 写作 <code>供应商/模型</code>,所以拉取的 <code>qwen3</code> 就是 <code>ollama/qwen3</code>。标签也留在 ID 里,比如 <code>ollama/qwen3:8b</code>。在终端界面里添加时,magpie 会问你服务器地址。LM Studio、oMLX、vLLM 和 llama.cpp 的服务见 <a href="/docs/zh/local-models">本地模型</a>。</p>
<h2 id="remote"><a class="anchor" href="#remote">换端口或换电脑</a></h2>
<p>如果 Ollama 监听的是别的端口,或者跑在另一台电脑上(比如 GPU 主机或 NAS),在供应商编辑页修改 <span class="ui">服务器地址</span>。只有协议、主机和端口会变,每个接口的路径保持不变。协议可以省略,默认按 <code>http</code>;地址后面带的路径(比如 <code>/v1</code>)会被去掉。</p>
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-remote">复制</button><pre id="ex-remote">magpie provider set ollama address=192.168.1.20:11434
magpie provider set ollama address= # 恢复默认地址</pre></div>
<ul>
<li><b>代理。</b>局域网里的服务器会直接连接,不管设置或系统里指定了什么代理。给这个供应商单独设的代理仍然有效。</li>
<li><b>HTTPS。</b>Ollama 放在自签名证书的 HTTPS 后面时,在编辑页打开 <span class="ui">不校验它的证书</span> 即可连上。它只对这个供应商自己的主机生效。</li>
</ul>
<h2 id="cloud"><a class="anchor" href="#cloud">Ollama Cloud</a></h2>
<ol class="steps">
<li><b>创建 Key</b>在 <a href="https://ollama.com/settings/keys">ollama.com/settings/keys</a> 创建一个。</li>
<li><b>添加供应商</b>在 <span class="ui">供应商</span> 页点 <span class="ui">+ 添加供应商</span>,选 <span class="ui">Ollama Cloud</span>,粘贴 Key 并保存。magpie 会向 Ollama Cloud 询问这个 Key 能用哪些模型。</li>
<li><b>给工具选模型</b>在工具那一行选一个 Ollama Cloud 模型,比如 <code>deepseek-v4-pro</code>。</li>
</ol>
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-cloud">复制</button><pre id="ex-cloud">magpie provider add ollama-cloud &lt;key&gt;
magpie claude ollama-cloud/deepseek-v4-pro</pre></div>
<p>模型名称、推理档位和价格来自 models.dev 的 <code>ollama-cloud</code> 目录。Key 保存在 magpie 的设置里。</p>
<h2 id="endpoints"><a class="anchor" href="#endpoints">接口地址</a></h2>
<div class="table-wrap"><table>
<tr><th>供应商</th><th>Chat Completions</th><th>Anthropic Messages</th></tr>
<tr><td>Ollama</td><td><code>http://localhost:11434/v1</code></td><td><code>http://localhost:11434</code></td></tr>
<tr><td>Ollama Cloud</td><td><code>https://ollama.com/v1</code></td><td><code>https://ollama.com</code></td></tr>
</table></div>
<p>工具说的接口 Ollama 本身就支持时,请求直接交给那个接口。两者在 magpie 里都没有 Responses 接口,所以需要翻译时,magpie 用 Chat Completions:只有 OpenAI 自家的模型优先用 Responses,只有 Claude 模型优先用 Messages。</p>
<h2 id="models"><a class="anchor" href="#models">模型列表</a></h2>
<p>magpie 从 Chat Completions 的地址获取模型列表:<code>http://localhost:11434/v1/models</code>,Ollama Cloud 则是 <code>https://ollama.com/v1/models</code>。Ollama 里有了某个模型,magpie 里才会出现它。拉取新模型后,在供应商编辑页点 <span class="ui">获取模型</span>,或运行 <code>magpie provider refresh ollama</code>。工具能看到哪些模型,可以在供应商的模型列表里勾选,也可以在终端里设置:</p>
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-models">复制</button><pre id="ex-models">magpie provider refresh ollama
magpie provider models ollama +qwen3</pre></div>
<p>Ollama 0.35.0 及以后的版本(云端模型要 0.40.5)还提供决策模型,比如 Nimble、Clef 和 Tev。magpie 也会读取 Ollama 的 <code>/api/tags</code>,其中标为决策模型的,会成为这个供应商用于 <a href="/docs/zh/intent">意图路由</a> 的决策模型,不会作为工具的模型。更早的 Ollama 不会列出这类模型。</p>
<h2 id="agents"><a class="anchor" href="#agents">在各个工具里用</a></h2>
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-agents">复制</button><pre id="ex-agents">magpie claude ollama/qwen3
magpie codex ollama/qwen3
magpie gemini model ollama/qwen3
magpie opencode ollama/qwen3</pre></div>
<ul>
<li><b>Claude Code</b> 说的是 Anthropic Messages,Ollama 在 <code>http://localhost:11434</code> 也支持,所以请求原样发过去。见 <a href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>。</li>
<li><b>Codex</b> 说的是 OpenAI Responses,magpie 不会把它发给 Ollama,而是把每个请求转成 Chat Completions,再把回复转回来,流式输出和工具调用都包括在内。见 <a href="/docs/zh/codex-models">Codex 接入其他模型</a>。</li>
<li><b>Gemini CLI</b> 说的是 Google 的 Gemini 接口。magpie 把每个请求翻译成 Chat Completions,再把回复翻译回去。见 <a href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>。</li>
<li><b>OpenCode</b> 说的是 Chat Completions,请求原样发到 Ollama 的 <code>/v1</code>。见 <a href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>。</li>
</ul>
<p>在工具里面,Claude Code 和 Codex 的 <code>/model</code> 也会列出 magpie 的模型,可以在本地模型和云端模型之间切换。想换回工具自带的模型,运行 <code>magpie claude default</code> 或 <code>magpie codex default</code>。</p>
<h2 id="window"><a class="anchor" href="#window">上下文窗口与 num_ctx</a></h2>
<p>工具会按模型能接受多长的请求来安排对话。Claude Code 把不认识的模型当作 200K,Codex 在被告知的窗口用到 90% 时压缩对话。magpie 不会读取 Ollama 聊天模型的窗口,所以要把真实的窗口告诉它:供应商编辑页 <span class="ui">高级</span> 里的 <span class="ui">上下文窗口</span>,可以给全部模型设,也可以单独给某个模型设。magpie 会告知各个工具。</p>
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-window">复制</button><pre id="ex-window">magpie provider set ollama context=32k
magpie provider set ollama context.qwen3=128k</pre></div>
<ul>
<li><b><code>num_ctx</code>。</b>有些客户端会在 Chat Completions 字段旁边带上 Ollama 的单次请求选项,比如 <code>{"num_ctx": …}</code>。magpie 转发任何请求前都会去掉它们:没有哪个 Chat Completions 接口会读它们,Ollama 自己的 <code>/v1</code> 也不读。模型实际用多大的窗口由 Ollama 决定,在 magpie 里填同一个数即可。</li>
<li><b>超长。</b>对话超出窗口时,Ollama 会回 “exceeded max context length”。magpie 用工具能理解的方式转告它,即 <code>context_length_exceeded</code> 或 Anthropic 的 “prompt is too long”,工具就会压缩后重试。</li>
</ul>
<h2 id="reasoning"><a class="anchor" href="#reasoning">推理</a></h2>
<ul>
<li><b>思考强度。</b>工具要求的强度会对到模型已有档位里最接近的一档,档位以目录为准。magpie 不知道档位的模型,就按工具的原样请求。</li>
<li><b>关闭推理。</b>由 magpie 翻译请求的工具(比如 Codex、Gemini CLI)关闭推理,而模型的档位里有 <code>none</code> 时,magpie 会请求 none。</li>
<li><b>自己定档位。</b><code>magpie model efforts</code> 可以只开放你指定的档位,或者完全不给模型发推理字段。</li>
</ul>
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-efforts">复制</button><pre id="ex-efforts">magpie model efforts ollama/qwen3 low,medium,high
magpie model efforts ollama/qwen3 off</pre></div>
<h2 id="tools"><a class="anchor" href="#tools">工具调用</a></h2>
<p>Claude Code 和 OpenCode 的工具调用按工具写的原样到达 Ollama。Codex 和 Gemini CLI 的工具定义、模型发起的调用和调用结果,magpie 都会翻译成 Chat Completions 再翻译回来,流式回复也一样。</p>
<h2 id="masking"><a class="anchor" href="#masking">脱敏</a></h2>
<p>magpie 的 <a href="/docs/zh/masking">本地脱敏</a> 会在请求离开网关前把 Key、Token 等敏感信息换成占位符,发给本地 Ollama 的请求也一样。模型就跑在你自己的电脑或局域网里时,可以在编辑页打开 <span class="ui">请求不脱敏</span>,或运行 <code>magpie provider set ollama unmasked=yes</code>。</p>
<ul>
<li><b>云端模型。</b>Ollama 的云端模型不管地址是什么,都会把请求转给厂商,所以这由你决定。给非本地的供应商(比如 Ollama Cloud)打开时,编辑页会提醒你。</li>
<li><b>工具参数。</b>Ollama 自己格式的请求里,工具调用的参数和其他接口一样,按工具参数脱敏。</li>
<li><b>匿名统计。</b>magpie 的每日统计只有在 models.dev 认识某个 Ollama 模型时才写出它的名字,其他一律记为 “other”。见 <a href="/docs/zh/privacy">隐私</a>。</li>
</ul>
<h2 id="cost"><a class="anchor" href="#cost">用量与费用</a></h2>
<ul>
<li><b>用量。</b><span class="ui">用量</span> 页会统计每次 Ollama 调用的 token。模型按 magpie 为它的 ID 找到的价格计价,本地模型可能用的是模型厂商的标价。想让本地模型不计费,给它设一个你自己的价格。</li>
<li><b>免费优先。</b><code>free=yes</code> 让这个供应商的所有模型都算作免费,<span class="ui">免费优先</span> 的路由会先用它再用付费的。价格和用量页的费用仍按标价显示。</li>
<li><b>Ollama Cloud 的额度。</b>magpie 会从 Ollama Cloud 读取账户余额。套餐内的额度显示为套餐,写明已用多少美元和何时重置;早期套餐则显示会话限额和每周限额。你购买的额度显示为余额。超出套餐额度后 Ollama Cloud 会扣购买的额度,所以套餐额度用完但还有余额时,Key 不会停用。</li>
<li><b>高峰时段。</b>在 Ollama Cloud 上,<code>deepseek-v4.1-flash</code> 和 <code>deepseek-v4-pro</code>(及其带标签的版本)在 UTC 时间周一至周五 12:00 到 18:00 按两倍计费。models.dev 列的是非高峰价格,用量页在这些时段会按两倍计算,<span class="ui">最便宜优先</span> 的路由也会算进去。</li>
<li><b>额度用完。</b>Ollama Cloud 说某个 Key 额度用完、却没说何时恢复时(比如每周限额),magpie 会让这个 Key 休息 15 分钟。<code>quota-rest</code> 可以设休息多久,最长 8 天。有多个 Key 时(<span class="ui">添加另一个密钥</span>)由下一个接替;所有 Key 都用完时,网关会立即带上 Retry-After 回复。</li>
</ul>
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-cost">复制</button><pre id="ex-cost">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</pre></div>
<h2 id="server"><a class="anchor" href="#server">把 magpie 当作 Ollama 服务</a></h2>
<p>有些应用只能以 Ollama 服务的形式接入自定义模型:VS Code Copilot 的 Ollama 供应商、Visual Studio Copilot 的 BYOK、Zed 的 Ollama 供应商,还有 <code>ollama</code> 命令行。把它们指向 magpie 的网关 <code>http://127.0.0.1:3425</code>,就能看到 magpie 的模型,而且是所有供应商的,不只是 Ollama 的。</p>
<ul>
<li><b>路由。</b>magpie 响应 <code>/api/version</code>、<code>/api/tags</code>、<code>/api/show</code>、<code>/api/chat</code> 和 <code>/api/generate</code>。</li>
<li><b>同一条路径。</b>这里的对话和 <code>/v1/chat/completions</code> 走同一套处理,所以 Key 限制、路由、备用模型和用量统计都一样。只允许用部分模型的网关 Key,只会列出那些模型。</li>
<li><b>告诉客户端的信息。</b><code>/api/tags</code> 和 <code>/api/show</code> 会标明工具调用、读图(模型能读图片时)和思考(模型会推理时)。<code>/api/show</code> 还会给出模型的窗口,magpie 不认识的模型给 32768。<code>ollama</code> 命令行的 <code>name:latest</code> 会找到名为 <code>name</code> 的模型。</li>
</ul>
<h2 id="trouble"><a class="anchor" href="#trouble">常见报错</a></h2>
<ul>
<li><b>拉取的模型不在列表里。</b>列表来自服务本身。点 <span class="ui">获取模型</span> 或运行 <code>magpie provider refresh ollama</code>,再在供应商的模型列表里勾选它。名字要和 Ollama 列出的一致,标签也算在内。</li>
<li><b>Ollama 没在运行。</b><code>magpie provider test ollama</code> 会通过每个接口发一个很小的请求,也可以指定模型;加上 <code>--as codex</code> 或 <code>--as claude-code</code> 就按那个工具的方式发。启动 Ollama,或检查 <span class="ui">服务器地址</span>。<code>fallback</code> 可以指定它挂掉时请求去哪。</li>
<li><b>“exceeded max context length”。</b>对话超出了模型加载时的长度。在供应商上设好真实的 <span class="ui">上下文窗口</span>,工具会在到达之前压缩。</li>
<li><b>连不上另一台电脑。</b>检查 <span class="ui">服务器地址</span> 里的地址和端口;自签名证书的 HTTPS 要打开 <span class="ui">不校验它的证书</span>。</li>
</ul>
<h2 id="faq"><a class="anchor" href="#faq">常见问题</a></h2>
<h3>Claude Code 怎么用 Ollama 的本地模型?</h3>
<p>在 magpie 里添加 Ollama(供应商 → 添加供应商 → 本机下的 Ollama),然后在 Claude Code 那一行选它的模型,或者运行 <code>magpie claude ollama/qwen3</code>。Claude Code 的请求经过 magpie 网关,原样发到 Ollama 在 <code>http://localhost:11434</code> 的 Anthropic Messages 接口。</p>
<h3>Codex 能用 Ollama 吗?</h3>
<p>能。Codex 只会说 Responses 接口,magpie 会把它的请求转成 Chat Completions 发给 Ollama,再把回复转回来,工具调用也一样。运行 <code>magpie codex ollama/qwen3</code> 即可。</p>
<h3>Gemini CLI 和 OpenCode 能用 Ollama 吗?</h3>
<p>能。Gemini CLI 说的是 Google 的接口,magpie 把它的请求翻译成 Ollama 的 Chat Completions,再把回复翻译回去。OpenCode 本身说 Chat Completions,请求原样发给 Ollama。运行 <code>magpie gemini model ollama/qwen3</code> 或 <code>magpie opencode ollama/qwen3</code>。</p>
<h3>怎么在 Claude Code 里用 Ollama 的 qwen3-coder?</h3>
<p>先在 Ollama 里拉取它,再在 magpie 的供应商编辑页点「获取模型」(或运行 <code>magpie provider refresh ollama</code>),然后在 Claude Code 那一行选中它。它在 magpie 里的 ID 是 <code>ollama/</code> 加上 Ollama 列出的名字,标签也算在内。记得同时设好它的上下文窗口:Claude Code 会把不认识的模型当作 200K。</p>
<h3>magpie 能用另一台电脑上的 Ollama 吗?</h3>
<p>能。把供应商的服务器地址改成那台电脑,比如 <code>magpie provider set ollama address=192.168.1.20:11434</code>。局域网里的服务器会直接连接,不走设置或系统里的代理。</p>
<h3>magpie 支持 Ollama Cloud 吗?</h3>
<p>支持。用 <code>ollama.com/settings/keys</code> 上创建的 Key 添加 Ollama Cloud,magpie 会列出这个 Key 能用的模型,按 models.dev 的价格计费,并显示账户套餐内的额度和你购买的余额。</p>
<h3>本地 Ollama 需要 API Key 吗?</h3>
<p>不需要,Ollama 预设不用 Key。Ollama Cloud 需要。</p>
<p>LM Studio、oMLX、vLLM、llama.cpp 等其他本地服务见 <a href="/docs/zh/local-models">本地模型</a>。想让本地模型给每个请求分类、决定路由,见 <a href="/docs/zh/intent">意图路由</a>。</p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/mistral">Mistral</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a></p>
<p style="margin-top:48px">各个工具的指南:<a href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>、<a href="/docs/zh/codex-models">Codex 接入其他模型</a>、<a href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>、<a href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>。遇到问题可以在 <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> 提问。</p>
</article>
</main>
<footer><div class="wrap">
<span>© 2026 magpie · MIT</span>
<div class="links">
<a href="/zh/">首页</a>
<a href="/docs/zh/intent">意图路由</a>
<a href="/docs/zh/plugins">插件开发</a>
<a href="/docs/zh/remote">远程 magpie</a>
<a href="/docs/zh/docker">Docker</a>
<a href="/docs/zh/privacy">隐私</a>
<a href="/docs/zh/masking">本地脱敏</a>
<a href="/docs/zh/mcp-router">MCP 路由</a>
<a href="/docs/zh/library">资源库</a>
<a href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>
<a href="/docs/zh/codex-models">Codex 接入其他模型</a>
<a href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>
<a href="/docs/zh/subscriptions">订阅用于任意 Agent</a>
<a href="/docs/zh/local-models">本地模型</a>
<a href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>
<a href="/docs/zh/alternatives">与 CC Switch、CCR 对比</a>
<a href="/docs/zh/import">Add to magpie</a>
<a href="/docs/zh/integrate">接入应用</a>
<a href="https://github.com/yetone/magpie">GitHub</a>
<a href="https://discord.gg/vGSnD3ZKQF">Discord</a>
<a href="/docs/zh/contributors">贡献墙</a>
<a href="https://github.com/yetone/magpie-releases/releases">版本发布</a>
</div>
</div></footer>
<script>
(() => {
const next = { system: "light", light: "dark", dark: "system" };
document.querySelectorAll("button.theme").forEach((b) => {
b.dataset.mode = themeMode();
b.title = "Theme: " + themeMode();
b.addEventListener("click", () => setTheme(next[themeMode()]));
});
document.querySelectorAll(".copy").forEach((b) => b.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(document.getElementById(b.dataset.copy).textContent);
b.textContent = "已复制"; setTimeout(() => (b.textContent = "复制"), 1400);
} catch {}
}));
})();
</script>
<script src="/docs.js"></script>
</body>
</html>
+1 -1
View File
@@ -239,7 +239,7 @@ magpie visible opencode all # 恢复显示全部</pre></div>
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-oc-back">复制</button><pre id="ex-oc-back">magpie opencode default</pre></div>
<p>它会恢复接入 magpie 之前的 <code>model</code> 和 <code>small_model</code>,并把 <code>magpie</code> 供应商从文件里删掉。</p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a></p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/mistral">Mistral</a> · <a href="/docs/zh/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a> · <a href="/docs/zh/ollama">Ollama</a></p>
<h2 id="faq"><a class="anchor" href="#faq">常见问题</a></h2>
<h3>OpenCode 怎么用 DeepSeek?</h3>
+1 -1
View File
@@ -288,7 +288,7 @@ magpie group set opus-anywhere stays=session models+=openrouter/anthropic/claude
<h3>为什么 magpie 从 /api/v1 拉取 OpenRouter 的模型列表?</h3>
<p>在 Anthropic 地址上拉列表,OpenRouter 返回的是挂在 <code>anthropic/</code> 前缀下的目录,里面的 id 它并不提供服务。magpie 从 Chat Completions 地址 <code>https://openrouter.ai/api/v1</code> 拉列表;只填了 OpenRouter Anthropic 地址的供应商,会提示你补上这个 Chat 地址。</p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/copilot">GitHub Copilot</a></p>
<p><b>按供应商:</b><a href="/docs/zh/deepseek">DeepSeek</a> · <a href="/docs/zh/kimi">Kimi 与 Kimi Code</a> · <a href="/docs/zh/glm">GLM 编程套餐</a> · <a href="/docs/zh/qwen">通义千问</a> · <a href="/docs/zh/minimax">MiniMax</a> · <a href="/docs/zh/gemini">Gemini</a> · <a href="/docs/zh/grok">Grok</a> · <a href="/docs/zh/mistral">Mistral</a> · <a href="/docs/zh/copilot">GitHub Copilot</a> · <a href="/docs/zh/ollama">Ollama</a></p>
<p style="margin-top:48px">各个工具的指南:<a href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>、<a href="/docs/zh/codex-models">Codex 接入其他模型</a>、<a href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>、<a href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>。遇到问题可以在 <a href="https://discord.gg/vGSnD3ZKQF">Discord</a> 提问。</p>
</article>
</main>
+325 -8
View File
@@ -413,7 +413,7 @@ With several keys or accounts, magpie can spread Claude Code’s requests over t
The routing modes are in [Get started](https://usemagpie.ai/docs/start#routing).
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot)
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [Mistral](https://usemagpie.ai/docs/mistral) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot) · [Ollama](https://usemagpie.ai/docs/ollama)
## FAQ
@@ -545,7 +545,7 @@ Requests on a Claude subscription run through the Claude Code installed on your
The routing modes are in [Get started](https://usemagpie.ai/docs/start#routing).
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot)
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [Mistral](https://usemagpie.ai/docs/mistral) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot) · [Ollama](https://usemagpie.ai/docs/ollama)
## FAQ
@@ -662,7 +662,7 @@ Gemini CLI still speaks the Gemini API; magpie translates each request for the m
The routing modes and rules are in [Get started](https://usemagpie.ai/docs/start#routing).
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot)
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [Mistral](https://usemagpie.ai/docs/mistral) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot) · [Ollama](https://usemagpie.ai/docs/ollama)
## FAQ
@@ -995,7 +995,7 @@ magpie opencode default
It puts back the `model` and `small_model` OpenCode had before magpie, and takes the `magpie` provider out of the file.
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot)
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [Mistral](https://usemagpie.ai/docs/mistral) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot) · [Ollama](https://usemagpie.ai/docs/ollama)
## FAQ
@@ -1667,7 +1667,7 @@ Yes. magpie reads OpenRouter’s credits endpoint and shows what is left in doll
Asked at the Anthropic base, OpenRouter answers with its catalog under `anthropic/` names it doesn’t serve. magpie fetches the list from the Chat Completions base, `https://openrouter.ai/api/v1`, and a provider given only OpenRouter’s Anthropic base is told to add that Chat base.
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [GitHub Copilot](https://usemagpie.ai/docs/copilot)
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [Mistral](https://usemagpie.ai/docs/mistral) · [GitHub Copilot](https://usemagpie.ai/docs/copilot) · [Ollama](https://usemagpie.ai/docs/ollama)
Every agent: [Models in Claude Code](https://usemagpie.ai/docs/claude-code-models), [Models in Codex](https://usemagpie.ai/docs/codex-models), [Models in Gemini CLI](https://usemagpie.ai/docs/gemini-cli-models), [Models in OpenCode](https://usemagpie.ai/docs/opencode-models). Ask on [Discord](https://discord.gg/vGSnD3ZKQF) if you get stuck.
@@ -1814,7 +1814,7 @@ Yes. magpie reads the plan from GitHub: Free, Pro, Pro+, Max, Education, Busines
magpie lists what Copilot’s `/models` gives the account: chat models only, without the ones no model picker offers or the account can’t turn on. A model Copilot answered with “The requested model is not supported.” is left out for 6 hours, then tried again in case your plan changed.
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [OpenRouter](https://usemagpie.ai/docs/openrouter)
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [Mistral](https://usemagpie.ai/docs/mistral) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [Ollama](https://usemagpie.ai/docs/ollama)
Every agent: [Models in Claude Code](https://usemagpie.ai/docs/claude-code-models), [Models in Codex](https://usemagpie.ai/docs/codex-models), [Models in Gemini CLI](https://usemagpie.ai/docs/gemini-cli-models), [Models in OpenCode](https://usemagpie.ai/docs/opencode-models). Ask on [Discord](https://discord.gg/vGSnD3ZKQF) if you get stuck.
@@ -1970,7 +1970,7 @@ Yes. Add the Google Vertex AI preset with your project’s id, for example `magp
Yes. Both are subscriptions: `magpie accounts add gemini` or `magpie accounts add antigravity`, then pick a `gemini/…` or `antigravity/…` model. Code Assist needs a Standard or Enterprise account with a Google Cloud project of its own.
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Grok](https://usemagpie.ai/docs/grok) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot)
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Grok](https://usemagpie.ai/docs/grok) · [Mistral](https://usemagpie.ai/docs/mistral) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot) · [Ollama](https://usemagpie.ai/docs/ollama)
Every agent: [Models in Claude Code](https://usemagpie.ai/docs/claude-code-models), [Models in Codex](https://usemagpie.ai/docs/codex-models), [Models in Gemini CLI](https://usemagpie.ai/docs/gemini-cli-models), [Models in OpenCode](https://usemagpie.ai/docs/opencode-models). Ask on [Discord](https://discord.gg/vGSnD3ZKQF) if you get stuck.
@@ -2108,7 +2108,324 @@ xAI can’t read reasoning that another vendor sealed, and answers “Could not
No. The Usage tab counts tokens, cache and cost for every Grok call, priced from models.dev, but magpie reads no balance from xAI. You can type the balance in with `magpie provider key-balance`, and the Usage page shows it less what magpie has priced since.
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot)
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Mistral](https://usemagpie.ai/docs/mistral) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot) · [Ollama](https://usemagpie.ai/docs/ollama)
Every agent: [Models in Claude Code](https://usemagpie.ai/docs/claude-code-models), [Models in Codex](https://usemagpie.ai/docs/codex-models), [Models in Gemini CLI](https://usemagpie.ai/docs/gemini-cli-models), [Models in OpenCode](https://usemagpie.ai/docs/opencode-models). Ask on [Discord](https://discord.gg/vGSnD3ZKQF) if you get stuck.
---
Source: https://usemagpie.ai/docs/mistral
# Mistral in Claude Code, Codex, Gemini CLI and OpenCode
Mistral serves its models on one API, OpenAI-style Chat Completions, at `api.mistral.ai`. Add a Mistral API key to magpie once, and Claude Code, Codex, Gemini CLI, OpenCode and every other agent you connect can use Mistral through magpie’s local gateway at `127.0.0.1:3425`, each agent with a model of its own. Agents that speak another API are translated on the way.
## Add Mistral
1. **Get a key.** Make one on [console.mistral.ai](https://console.mistral.ai/api-keys). A Le Chat plan’s Vibe key goes in the same provider.
2. **Add the provider.** In magpie’s Providers tab, press + Add provider, pick Mistral, paste the key and save. magpie asks Mistral which models the key can use.
3. **Pick it for an agent.** In the Agents tab, click the model on the agent’s row and choose a Mistral model such as `mistral-large-4`.
```
magpie provider add mistral <key>
magpie provider test mistral
```
Model ids in magpie are `provider/model`, so Mistral’s read `mistral/mistral-large-4`: the provider, then Mistral’s own id. The key is kept in magpie’s settings; magpie doesn’t take it from your shell.
Already set Mistral up in OpenCode or Alma? magpie’s import from those apps brings it in as the Mistral provider. An app that keeps one entry per key (“Mistral #0001”, “Mistral #0002”…) becomes one Mistral provider with that many keys, listed once in every agent’s picker.
## Endpoints
| API | Address | Used for |
| --- | --- | --- |
| Chat Completions | `https://api.mistral.ai/v1` | the model list and every agent’s requests: OpenCode’s as they are, Claude Code’s, Codex’s and Gemini CLI’s translated |
| Billing | `https://api.mistral.ai/v1/billing/budget`, `/v1/billing/subscription` | a key’s month of Vibe or API budget, and the plan it is on |
magpie’s Mistral provider has no Anthropic Messages or Responses address, so an agent that speaks either is translated to Chat Completions and the reply translated back, streaming and tool calls included.
## Model list
magpie fetches the list from Mistral, at `https://api.mistral.ai/v1/models`, so agents see the models your key can use. Names, reasoning levels and prices come from models.dev’s `mistral` catalog, and Devstral, Codestral and Magistral models carry Mistral’s logo in every picker. Mistral also serves models from other labs, such as GLM and DeepSeek’s `deepseek-v4.1-flash-1017`; they come through the same key, and the fixes below apply to them too. Pick the models agents see in the provider’s model list, or from the terminal:
```
magpie provider models mistral +mistral-large-4 +mistral-medium-3.5
magpie provider refresh-every mistral 1d
```
## In each agent
```
magpie claude mistral/mistral-large-4
magpie codex mistral/mistral-large-4
magpie gemini model mistral/mistral-large-4
magpie opencode mistral/mistral-large-4
```
- **Claude Code.** speaks Anthropic Messages, which Mistral doesn’t serve. magpie translates each request to Chat Completions and the reply back; a reasoning model’s thinking reaches Claude Code as thinking, then the text. [Models in Claude Code](https://usemagpie.ai/docs/claude-code-models).
- **Codex.** speaks OpenAI Responses, which Mistral doesn’t serve either, so its requests are translated too. Codex’s custom tools, such as `apply_patch`, are offered to the model as functions, and its calls come back as the custom tool calls Codex runs. [Models in Codex](https://usemagpie.ai/docs/codex-models).
- **Gemini CLI.** speaks Google’s Gemini API. magpie translates each request to Chat Completions and the reply back. [Models in Gemini CLI](https://usemagpie.ai/docs/gemini-cli-models).
- **OpenCode.** speaks Chat Completions, so its requests go to Mistral as they are, with the fixes below. [Models in OpenCode](https://usemagpie.ai/docs/opencode-models).
## What magpie fixes for Mistral
Mistral’s API is strict about what it takes and sends a reasoning model’s thinking in a shape of its own. magpie changes both on the way, on requests it passes on and on those it translates alike:
- **Thinking in typed parts..** Mistral sends a reasoning model’s thinking as typed parts in `content`, thinking and text sometimes in one chunk, where the Chat contract has a string. OpenCode turned the first such chunk away (“Invalid … stream event”). magpie moves the thinking to `reasoning_content` and the text to a plain string, streamed or not.
- **Thinking sent back..** OpenCode sends an earlier turn’s thinking back in `reasoning_content`, which Mistral refuses with 422 `extra_forbidden`. magpie puts it in the thinking part Mistral itself returns, ahead of the turn’s text, so the thinking stays in context. Translated requests get the same, so a Codex tool loop keeps going on a DeepSeek model served by Mistral.
- **Fields Mistral doesn’t know..** OpenCode’s `store` and Kimi Code’s thinking switch got 422 `extra_forbidden`. magpie asks again without the optional fields Mistral named, and doesn’t send them to it again once that works.
- **Ollama options..** An agent that took the gateway for an Ollama server, such as Hermes Agent, sends Ollama’s `options` (its `num_ctx`) beside the Chat fields. magpie leaves them out, so Mistral never sees them.
## 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 aren’t known is asked as the agent asked.
- **Reasoning off..** When an agent whose requests magpie translates, such as Gemini CLI, turns reasoning off and the model lists `none` among its levels, magpie asks for none.
- **Thinking across turns..** Each agent sees a reasoning model’s thinking in its own shape: `reasoning_content` for OpenCode, thinking blocks for Claude Code, reasoning for Codex. When it comes back in a later turn, Mistral gets it as a thinking part; see What magpie fixes.
## Web search
Mistral’s Chat Completions API doesn’t search the web for magpie, so magpie gives the model its own search tool in every agent, answered by the searcher chosen in Settings, or by one magpie picks when none is chosen.
## Vibe, cost and usage
- **Vibe month..** A Le Chat plan (Pro, Student or Team) comes with a month of Mistral Vibe. Its Vibe key’s row shows how much of the month’s budget is used, in the currency Mistral bills in, when it resets, and the plan’s name.
- **API month..** A Studio key made in the console shows the organization’s API budget, as “API · Month”, apart from a Vibe month. The budget is the organization’s, so every key of one organization shows the same numbers. A key with no budget has no card.
- **Pay as you go..** With pay-as-you-go on, what goes past the budget is billed rather than stopped, so a used-up month doesn’t stop the key’s models.
- **Cache tokens..** When a reply reports cached prompt tokens, the Usage tab counts them apart from the rest of the prompt.
- **Keeping the cache..** With several keys, a conversation stays on its key while its cache is worth keeping, 1,024 tokens or more, and still warm, read within the last five minutes.
- **Cost..** The Usage tab prices each call with Mistral’s prices from models.dev. magpie reads no balance from Mistral; type it in with `key-balance`, and the Usage page shows it less what magpie has priced the key’s calls at since.
## Several keys and failover
One Mistral provider can hold several keys: press Add another key under it, or paste several at once. Requests go to the first key that’s on, and when it runs out or is rate limited the next one takes over.
- **Spend caps..** `spend-cap` stops a key at a dollar amount a day, a month or in all, as the Usage tab prices its calls; routing then goes on to the other keys and the fallbacks.
- **Fallbacks..** `fallback` names where requests go when Mistral is out of quota or down: another provider’s model or a routing group.
```
magpie provider spend-cap mistral <key> 20 month
magpie provider key-balance mistral <key> 25
magpie provider fallback mistral deepseek/deepseek-v4-pro
```
## Troubleshooting
- **422 `extra_forbidden`, “Extra inputs are not permitted”..** Mistral turned away a field it doesn’t know. magpie fixes the ones agents are known to send and asks again without an optional field Mistral names; see What magpie fixes.
- **“Invalid … stream event” in OpenCode..** That was Mistral’s thinking in typed parts. magpie sends OpenCode the thinking in `reasoning_content` and the text as a string.
- **No Vibe card..** magpie shows the month only for a key Mistral says is a Vibe key or a Studio key, and only when its budget is more than zero.
- **Checking a key..** `magpie provider test mistral` sends a tiny request through each endpoint, or to each model you name. Add `--as codex` or `--as claude-code` to send it the way that agent would.
## FAQ
### How do I use Mistral in Claude Code?
Add your Mistral API key in magpie (Providers, Add provider, Mistral), then pick a Mistral model such as `mistral-large-4` on Claude Code’s row, or run `magpie claude mistral/mistral-large-4`. Mistral serves Chat Completions only, so magpie translates Claude Code’s Anthropic Messages requests to `https://api.mistral.ai/v1` and the replies back, thinking included.
### Can Codex use Devstral and other Mistral models?
Yes. Codex can use any model your Mistral key lists, Devstral among them. Codex speaks OpenAI Responses, which Mistral doesn’t serve, so magpie translates each request to Chat Completions, offers Codex’s custom tools such as apply_patch as functions, and gives the calls back the way Codex runs them.
### How do I use Codestral or other Mistral models in OpenCode?
Pick the model in magpie, or run `magpie opencode mistral/mistral-large-4`; Codestral and Devstral work the same way when your key lists them. OpenCode speaks Chat Completions, so its requests go to Mistral as they are, with what Mistral would refuse fixed on the way: OpenCode’s `store` field, and earlier turns’ thinking sent back in `reasoning_content`.
### Can Gemini CLI use Mistral?
Yes. Gemini CLI speaks Google’s Gemini API, so magpie translates its requests to Mistral’s Chat Completions and the replies back, streaming and tool calls included. Run `magpie gemini model mistral/mistral-large-4`.
### Why does Mistral answer 422 extra_forbidden?
Mistral turns away any field it doesn’t know. magpie sends an earlier turn’s thinking as the thinking part Mistral takes, leaves out Ollama options some agents add, and asks again without an optional field Mistral names, such as OpenCode’s `store`, then stops sending it.
### Does magpie show my Le Chat plan’s Vibe budget?
Yes. A Vibe key from a Le Chat plan (Pro, Student or Team) shows how much of the month’s Vibe budget is used, in the currency Mistral bills in, and when it resets, with the plan’s name. A Studio key made in the console shows the organization’s API budget instead, as “API · Month”.
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot) · [Ollama](https://usemagpie.ai/docs/ollama)
Every agent: [Models in Claude Code](https://usemagpie.ai/docs/claude-code-models), [Models in Codex](https://usemagpie.ai/docs/codex-models), [Models in Gemini CLI](https://usemagpie.ai/docs/gemini-cli-models), [Models in OpenCode](https://usemagpie.ai/docs/opencode-models). Ask on [Discord](https://discord.gg/vGSnD3ZKQF) if you get stuck.
---
Source: https://usemagpie.ai/docs/ollama
# 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 model.** Pull a model in Ollama, such as `qwen3`, and leave the server running.
2. **Add the provider.** In 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 agent.** In 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](https://usemagpie.ai/docs/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
1. **Get a key.** Make one at [ollama.com/settings/keys](https://ollama.com/settings/keys).
2. **Add the provider.** In 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 agent.** Choose 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](https://usemagpie.ai/docs/intent), 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](https://usemagpie.ai/docs/claude-code-models).
- **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](https://usemagpie.ai/docs/codex-models).
- **Gemini CLI.** speaks Google’s Gemini API. magpie translates each request to Chat Completions and the reply back. [Models in Gemini CLI](https://usemagpie.ai/docs/gemini-cli-models).
- **OpenCode.** speaks Chat Completions, so its requests go to Ollama’s `/v1` as they are. [Models in OpenCode](https://usemagpie.ai/docs/opencode-models).
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 `/v1` included. 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_exceeded` or 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 `none` among its levels, magpie asks for none.
- **Your own levels..** `magpie model efforts` offers 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](https://usemagpie.ai/docs/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](https://usemagpie.ai/docs/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=yes` counts 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-flash` and `deepseek-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-rest` sets 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/chat` and `/api/generate`.
- **The same path..** A chat there is served as `/v1/chat/completions` is, so key limits, routing, fallbacks and usage are the same. A gateway key held to some models lists only those.
- **What it tells..** `/api/tags` and `/api/show` mark tools, vision when the model reads images, and thinking when it reasons. `/api/show` also gives the model’s window, or 32768 for one magpie doesn’t know. The `ollama` CLI’s `name:latest` finds a model called `name`.
## 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 ollama` sends a tiny request through each endpoint, or to each model you name; add `--as codex` or `--as claude-code` to send it the way that agent would. Start Ollama, or check Server address. `fallback` names 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](https://usemagpie.ai/docs/local-models). To let a local model classify each request for routing, see [Intent routing](https://usemagpie.ai/docs/intent).
**By provider:** [DeepSeek](https://usemagpie.ai/docs/deepseek) · [Kimi and Kimi Code](https://usemagpie.ai/docs/kimi) · [GLM Coding Plan](https://usemagpie.ai/docs/glm) · [Qwen](https://usemagpie.ai/docs/qwen) · [MiniMax](https://usemagpie.ai/docs/minimax) · [Gemini](https://usemagpie.ai/docs/gemini) · [Grok](https://usemagpie.ai/docs/grok) · [Mistral](https://usemagpie.ai/docs/mistral) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot)
Every agent: [Models in Claude Code](https://usemagpie.ai/docs/claude-code-models), [Models in Codex](https://usemagpie.ai/docs/codex-models), [Models in Gemini CLI](https://usemagpie.ai/docs/gemini-cli-models), [Models in OpenCode](https://usemagpie.ai/docs/opencode-models). Ask on [Discord](https://discord.gg/vGSnD3ZKQF) if you get stuck.
+2
View File
@@ -53,6 +53,8 @@ DeepSeek, Kimi (Moonshot), GLM (Zhipu), Qwen, MiniMax, Anthropic (Claude), OpenA
- [GitHub Copilot in every agent](https://usemagpie.ai/docs/copilot): a Copilot seat's models in Claude Code, Codex, Gemini CLI and OpenCode; signing in (editors, Copilot CLI, GHE.com), Copilot Auto, premium requests, several accounts and errors.
- [Gemini in every agent](https://usemagpie.ai/docs/gemini): a Google AI Studio key (or Vertex AI) in Claude Code, Codex, Gemini CLI and OpenCode; endpoints, thinking levels, thought signatures across tool calls, tool schemas, search and rate limits.
- [Grok in every agent](https://usemagpie.ai/docs/grok): an xAI API key in Claude Code, Codex, Gemini CLI and OpenCode; which API each agent's requests use, what magpie fixes for xAI, reasoning effort, web search, prompt cache and several keys.
- [Mistral in every agent](https://usemagpie.ai/docs/mistral): a Mistral API key in Claude Code, Codex, Gemini CLI and OpenCode; the model list, what magpie fixes for Mistral (thinking parts, refused fields), effort, search, cache and the plan card.
- [Ollama in every agent](https://usemagpie.ai/docs/ollama): local Ollama, Ollama on another computer and Ollama Cloud in Claude Code, Codex, Gemini CLI and OpenCode; addresses, model list, context window, reasoning, tools, masking, pricing, and magpie as an Ollama server.
- [Intent routing](https://usemagpie.ai/docs/intent): how a turn is routed by what the user asks for.
- [Privacy masking](https://usemagpie.ai/docs/masking): what is masked before a request leaves the computer and how values come back.
- [Library](https://usemagpie.ai/docs/library): instructions, MCP servers, skills, hooks and subagents for each agent.
+6
View File
@@ -32,6 +32,8 @@
<url><loc>https://usemagpie.ai/docs/copilot</loc></url>
<url><loc>https://usemagpie.ai/docs/gemini</loc></url>
<url><loc>https://usemagpie.ai/docs/grok</loc></url>
<url><loc>https://usemagpie.ai/docs/mistral</loc></url>
<url><loc>https://usemagpie.ai/docs/ollama</loc></url>
<url><loc>https://usemagpie.ai/docs/zh/claude-code-models</loc></url>
<url><loc>https://usemagpie.ai/docs/zh/codex-models</loc></url>
<url><loc>https://usemagpie.ai/docs/zh/contributors</loc></url>
@@ -60,6 +62,8 @@
<url><loc>https://usemagpie.ai/docs/zh/copilot</loc></url>
<url><loc>https://usemagpie.ai/docs/zh/gemini</loc></url>
<url><loc>https://usemagpie.ai/docs/zh/grok</loc></url>
<url><loc>https://usemagpie.ai/docs/zh/mistral</loc></url>
<url><loc>https://usemagpie.ai/docs/zh/ollama</loc></url>
<url><loc>https://usemagpie.ai/docs/ja/claude-code-models</loc></url>
<url><loc>https://usemagpie.ai/docs/ja/codex-models</loc></url>
<url><loc>https://usemagpie.ai/docs/ja/contributors</loc></url>
@@ -87,4 +91,6 @@
<url><loc>https://usemagpie.ai/docs/ja/copilot</loc></url>
<url><loc>https://usemagpie.ai/docs/ja/gemini</loc></url>
<url><loc>https://usemagpie.ai/docs/ja/grok</loc></url>
<url><loc>https://usemagpie.ai/docs/ja/mistral</loc></url>
<url><loc>https://usemagpie.ai/docs/ja/ollama</loc></url>
</urlset>