site: Gemini and Grok pages in en, zh and ja
New docs pages /docs/gemini and /docs/grok (with zh/ and ja/), each linked from every "By provider" line (the four agent guides, OpenRouter and Copilot in all three languages), sitemap.xml and llms.txt; llms-full.txt rebuilt. Gemini facts and their sources: - preset "google", AI Studio keys, models.dev google catalog (internal/provider/presets.go); Chat and native Gemini endpoints, only Gemini clients on the native API (provider/gemini_api.go). - thinking_config with include_thoughts, Gemini 2 budgets, xhigh/max sent as high (gateway/chat.go aiStudioThinking); a refused level is retried at the nearest one, a refused thinking_config falls back to reasoning_effort (gateway.go geminiRefusedLevel, refusesThinkingConfig). - thought signatures kept 90 days and returned only to their provider (gemini_sigstore.go sigKeep, gemini_signature.go); tool schema clean-up (gemini_schema.go); search only without function tools (search.go geminiKeySearches); per-minute 429s as rate limits (routing.go). - Vertex AI preset and options (provider/vertex.go, cli/providers_cli.go). - Code Assist and Antigravity worded as docs/subscriptions. Grok facts and their sources: - xai preset: Chat and Responses at api.x.ai/v1, Messages at api.x.ai (presets.go); Claude Code, Codex, OpenCode go as they are, Gemini CLI translated to Chat (provider.go Speaks, gateway.go usable). - fixes for xAI: xai_body.go, grok_schema.go (#2317), object_root.go (#1271), lone tool_choice (#378), additional_tools (#350), grok_integral.go (#1431), custom_tool.go. - effort fitting (decide.go fitFor), search (search.go), cache stickiness (affinity.go cacheWorth/cacheCold), errors (gateway.go tooLongRe, fallback.go shapeRefused). Grok Build's ~/.grok/config.toml (agent/grok.go). - The Grok subscription and its community plugin are left out on purpose. Run: mote-run `node --test worker.test.mjs install.test.mjs` in site/, 71 pass; JSON-LD of all six pages parsed with node on mote. Deployed (version f785815d) and curl-checked: all six pages 200, sitemap lists them. Not tried: no real Gemini or xAI request was made for this page; header names, vendor terms, free-tier numbers and xAI's own rate limits are left out because the source doesn't state them.
This commit is contained in:
@@ -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/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/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a></p>
|
||||
|
||||
<h2 id="faq"><a class="anchor" href="#faq">FAQ</a></h2>
|
||||
<h3>Do I set <code>ANTHROPIC_BASE_URL</code> myself?</h3>
|
||||
|
||||
@@ -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/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/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a></p>
|
||||
|
||||
<h2 id="faq"><a class="anchor" href="#faq">FAQ</a></h2>
|
||||
<h3>Do I write <code>[model_providers]</code> myself?</h3>
|
||||
|
||||
@@ -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/openrouter">OpenRouter</a> · <a href="/docs/subscriptions">Claude, ChatGPT and other subscriptions</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/openrouter">OpenRouter</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>
|
||||
|
||||
@@ -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/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/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a></p>
|
||||
|
||||
<h2 id="faq"><a class="anchor" href="#faq">FAQ</a></h2>
|
||||
<h3>Can Gemini CLI use models that aren’t Gemini?</h3>
|
||||
|
||||
@@ -0,0 +1,365 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Gemini in Claude Code, Codex, Gemini CLI and OpenCode · magpie</title>
|
||||
<meta name="description" content="Use Google’s Gemini models in Claude Code, Codex, Gemini CLI and OpenCode with magpie: add a Gemini API key or a Vertex AI project once, pick a Gemini model per agent, and let magpie translate each agent’s API, carry Gemini 3’s thinking levels and thought signatures, 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/gemini">
|
||||
<link rel="alternate" hreflang="zh" href="https://usemagpie.ai/docs/zh/gemini">
|
||||
<link rel="alternate" hreflang="ja" href="https://usemagpie.ai/docs/ja/gemini">
|
||||
<link rel="alternate" hreflang="x-default" href="https://usemagpie.ai/docs/gemini">
|
||||
<link rel="canonical" href="https://usemagpie.ai/docs/gemini">
|
||||
<link rel="stylesheet" href="/docs.css">
|
||||
<meta property="og:site_name" content="magpie">
|
||||
<meta property="og:title" content="Gemini in Claude Code, Codex, Gemini CLI and OpenCode">
|
||||
<meta property="og:description" content="Use Google’s Gemini models in Claude Code, Codex, Gemini CLI and OpenCode with magpie: add a Gemini API key or a Vertex AI project once, pick a Gemini model per agent, and let magpie translate each agent’s API, carry Gemini 3’s thinking levels and thought signatures, 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/gemini">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@graph": [
|
||||
{
|
||||
"@type": "TechArticle",
|
||||
"headline": "Gemini in Claude Code, Codex, Gemini CLI and OpenCode",
|
||||
"description": "Use Google’s Gemini models in Claude Code, Codex, Gemini CLI and OpenCode with magpie: add a Gemini API key or a Vertex AI project once, pick a Gemini model per agent, and let magpie translate each agent’s API, carry Gemini 3’s thinking levels and thought signatures, and spread requests over several keys.",
|
||||
"inLanguage": "en",
|
||||
"url": "https://usemagpie.ai/docs/gemini",
|
||||
"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 Gemini in Claude Code?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "Add a Gemini API key in magpie (Providers, Add provider, Google Gemini), then pick a model such as gemini-3.1-pro-preview on Claude Code’s row, or run magpie claude google/gemini-3.1-pro-preview. magpie writes Claude Code’s settings.json and translates each Messages request to Gemini’s Chat Completions, tool calls and streaming included."
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Can Codex use Gemini models?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "Yes. Codex speaks only the Responses API. magpie translates each Codex request to Gemini’s Chat Completions and the reply back to Responses. Run magpie codex google/gemini-3.1-pro-preview, or pick the model on Codex’s row."
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Does Gemini 3 Pro keep working across tool calls in Claude Code?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "Yes. Gemini 3 signs its function calls and refuses the next request without the signature. magpie carries each signature in the call id the agent gets and puts it back on the way to Gemini, so tool loops keep going, and a call from another model is sent as unsigned."
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Can Gemini CLI and OpenCode use my Gemini key through magpie?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "Yes. Gemini CLI’s requests go to the Gemini API as it sends them, Google Search included. OpenCode speaks Chat Completions, so its requests go to Gemini’s OpenAI-compatible API as they are."
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Why does Gemini answer 429 with “Please retry in 33s”?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "That is a per-minute limit, not a spent quota. magpie reads it as a rate limit and rests the key briefly. Run magpie provider rpm google 10, with your own limit, and magpie holds requests to that rate."
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Can I use Gemini through Vertex AI instead of an API key?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "Yes. Add the Google Vertex AI preset with your project’s id, for example magpie provider add google-vertex project=my-project. magpie signs with gcloud’s Application Default Credentials or a credentials file, and your project is billed."
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Can I use my Gemini Code Assist or Antigravity sign-in instead?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "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."
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
</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/gemini" hreflang="en" lang="en">English</a>
|
||||
<a href="/docs/zh/gemini" hreflang="zh" lang="zh">中文</a>
|
||||
<a href="/docs/ja/gemini" 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="#thinking">Thinking</a>
|
||||
<a href="#signatures">Thought signatures and tools</a>
|
||||
<a href="#cost">Cache, cost and search</a>
|
||||
<a href="#keys">Several keys and rate limits</a>
|
||||
<a href="#vertex">Vertex AI</a>
|
||||
<a href="#signins">Google sign-ins</a>
|
||||
<a href="#trouble">Troubleshooting</a>
|
||||
<a href="#faq">FAQ</a>
|
||||
</aside>
|
||||
|
||||
<article>
|
||||
<p class="eyebrow" id="overview">Docs · Provider</p>
|
||||
<h1>Gemini in Claude Code, Codex, Gemini CLI and OpenCode</h1>
|
||||
<p class="lede">Google serves Gemini on the Gemini Developer API, the one an AI Studio key opens, and on Vertex AI in your own Google Cloud project. Add either to magpie once, and Claude Code, Codex, Gemini CLI, OpenCode and every other agent you connect can use Gemini 3 models such as <code>gemini-3.1-pro-preview</code> through magpie’s gateway at <code>127.0.0.1:3425</code>, each agent on a model of its own.</p>
|
||||
|
||||
<h2 id="add"><a class="anchor" href="#add">Add a Gemini API key</a></h2>
|
||||
<ol class="steps">
|
||||
<li><b>Get a key</b>Make one on <a href="https://aistudio.google.com/apikey">aistudio.google.com/apikey</a>.</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">Google Gemini</span>, paste the key and save. magpie asks Google which models it serves.</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 Gemini model such as <code>gemini-3.1-pro-preview</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 google AIza…
|
||||
magpie provider test google</pre></div>
|
||||
<p>Model ids in magpie are <code>provider/model</code>, so the Gemini API’s read <code>google/gemini-3.1-pro-preview</code>: the provider, then Google’s own id. The key is kept in magpie’s settings; magpie doesn’t take it from your shell.</p>
|
||||
|
||||
<h2 id="endpoints"><a class="anchor" href="#endpoints">Endpoints</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<tr><th>API</th><th>Base URL</th><th>Used for</th></tr>
|
||||
<tr><td>Chat Completions (OpenAI-compatible)</td><td><code>https://generativelanguage.googleapis.com/v1beta/openai</code></td><td>the model list, and requests from Claude Code, Codex, OpenCode and other agents</td></tr>
|
||||
<tr><td>Gemini API</td><td><code>https://generativelanguage.googleapis.com/v1beta</code></td><td>Gemini CLI’s requests, Google Search, image models</td></tr>
|
||||
</table></div>
|
||||
<p>The preset fills in the Gemini API URL once. If you clear it, it stays empty. Every request that doesn’t come from a Gemini client goes to Chat Completions.</p>
|
||||
|
||||
<h2 id="models"><a class="anchor" href="#models">Model list</a></h2>
|
||||
<ul>
|
||||
<li><b>Where it comes from.</b> magpie asks the OpenAI-compatible endpoint for the list once. It is the Gemini API’s list too, so magpie doesn’t ask twice. Names, reasoning levels and prices come from the <code>google</code> catalog on models.dev.</li>
|
||||
<li><b>Image models.</b> At Google, a Gemini image model draws on the Gemini API. Choose one in <span class="ui">Settings → Models → Images</span>.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="agents"><a class="anchor" href="#agents">In each agent</a></h2>
|
||||
<p>Pick the model on an agent’s row in the <span class="ui">Agents</span> tab, or from a terminal. Each guide says what magpie writes in that agent’s config and how to switch back.</p>
|
||||
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-agents">Copy</button><pre id="ex-agents">magpie claude google/gemini-3.1-pro-preview
|
||||
magpie codex google/gemini-3.1-pro-preview
|
||||
magpie gemini model google/gemini-3.8-flash
|
||||
magpie opencode google/gemini-3.1-pro-preview</pre></div>
|
||||
<ul>
|
||||
<li><b>Claude Code</b> speaks Anthropic Messages. magpie translates each request to Gemini’s Chat Completions and the reply back to Messages, streaming and tool calls included. <a href="/docs/claude-code-models">Models in Claude Code</a>.</li>
|
||||
<li><b>Codex</b> speaks only OpenAI Responses. magpie translates it to Chat Completions the same way, and the reply comes back to Codex as Responses. <a href="/docs/codex-models">Models in Codex</a>.</li>
|
||||
<li><b>Gemini CLI</b> speaks Gemini’s own API, so its requests go to the Gemini API as it sends them, and its Google Search runs there. <a href="/docs/gemini-cli-models">Models in Gemini CLI</a>.</li>
|
||||
<li><b>OpenCode</b> speaks Chat Completions, so its requests go to Google as they are. <a href="/docs/opencode-models">Models in OpenCode</a>.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="thinking"><a class="anchor" href="#thinking">Thinking</a></h2>
|
||||
<ul>
|
||||
<li><b>Visible thoughts.</b> Gemini’s OpenAI-compatible API gives the model’s thoughts only when asked in <code>thinking_config</code>. When an agent asks for visible reasoning, magpie asks for the thoughts with <code>include_thoughts</code>, so a long think shows as thinking instead of a first word that comes late.</li>
|
||||
<li><b>Levels and budgets.</b> Gemini 3 and later are sent a thinking level. Gemini 2 models are sent a budget instead: 1024 tokens for minimal and low, 8192 for medium and 24576 for high. xhigh and max are sent as high, and an effort with no level is left to the model.</li>
|
||||
<li><b>Reasoning off.</b> Gemini 3 can’t stop thinking. When an agent turns reasoning off, magpie asks for the model’s lowest level instead.</li>
|
||||
<li><b>A level the model doesn’t have.</b> Not every Gemini 3 has every level: <code>gemini-3.8-flash</code> has no minimal. When Google turns a level away with a 400, magpie asks again at the nearest level the model has and remembers it until magpie restarts.</li>
|
||||
<li><b><code>thinking_config</code> turned away.</b> That is a different 400: a server in front of Gemini that refuses the field itself. magpie asks again with <code>reasoning_effort</code> alone and stops sending <code>thinking_config</code> there.</li>
|
||||
<li><b>Proxies.</b> A Gemini model behind a proxy on this computer or your network, such as one on <code>localhost</code> or a private address, is handled the same way.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="signatures"><a class="anchor" href="#signatures">Thought signatures and tools</a></h2>
|
||||
<ul>
|
||||
<li><b>Thought signatures.</b> Gemini 3 signs the first function call of each step, and the next request fails with 400 “Function call is missing a thought_signature in functionCall parts” if the signature is gone. Agents don’t keep it. magpie carries it in the call id the agent gets, as a short reference to a file in magpie’s folder, and puts it back on the way to Gemini. Signatures are kept for 90 days.</li>
|
||||
<li><b>Calls Gemini didn’t sign.</b> A call from another model earlier in the conversation, or one whose id an agent shortened, goes with Google’s documented <code>skip_thought_signature_validator</code>, so a conversation can move to Gemini halfway.</li>
|
||||
<li><b>One provider’s signature.</b> A signature goes back only to the provider that gave it. In a routing group of Vertex AI and the Gemini API, the other provider gets the call as unsigned history instead of answering “Corrupted thought signature”.</li>
|
||||
<li><b>Tool schemas.</b> magpie gives each untyped schema in an agent’s tools a type, which Vertex AI needs, and removes boolean schemas and <code>x-</code> keywords such as MCP’s <code>x-mcp-header</code>. Tools that need none of this go as they came.</li>
|
||||
<li><b>The end of a stream.</b> Gemini’s OpenAI-compatible API sends a whole function call in one chunk and its <code>finish_reason</code> in the next. If that reason is lost after the usage arrived, magpie fills it in; without the usage, the reply is reported as cut off rather than passed on as complete.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="cost"><a class="anchor" href="#cost">Cache, cost and search</a></h2>
|
||||
<ul>
|
||||
<li><b>Prompt cache.</b> Gemini keeps a prompt cached without saying so on that turn. magpie counts such a turn as a cache write and keeps the next turn on the same provider and key, and remembers which one answered across restarts.</li>
|
||||
<li><b>Cached and thinking tokens.</b> magpie reads cached tokens and reasoning tokens from each reply, on Chat Completions and on the Gemini API alike, and the <span class="ui">Usage</span> tab counts them.</li>
|
||||
<li><b>Cost.</b> The Usage tab prices each call from the <code>google</code> catalog on models.dev.</li>
|
||||
<li><b>Web search.</b> Gemini runs Google Search on the Gemini API only for a request that declares no function tools. Claude Code’s and Codex’s requests declare tools, so their web search is magpie’s own, which the Google provider answers itself on your key: those searches spend your Gemini API credit.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="keys"><a class="anchor" href="#keys">Several keys and rate limits</a></h2>
|
||||
<p>One Google Gemini 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. The provider’s routing can also rotate, weight or drain them instead.</p>
|
||||
<ul>
|
||||
<li><b>Per-minute 429s.</b> Gemini’s 429 “You exceeded your current quota … Please retry in 33s” for a per-minute limit is read as a rate limit, not a used-up plan, and so is Vertex AI’s <code>requests_per_minute_per_project</code>. The key rests from a minute, doubling, up to <code>rest-cap</code>.</li>
|
||||
<li><b>Holding to a rate.</b> <code>rpm</code> holds each key to a number of requests a minute: one request more waits for room, up to 2 minutes, then gets a 429.</li>
|
||||
<li><b>Out of quota.</b> <code>quota-rest</code> sets how long a key rests once its quota is spent: 15 minutes by default, up to 8 days, or until a time of day.</li>
|
||||
<li><b>Spend caps and fallbacks.</b> <code>spend-cap</code> stops a key at a dollar amount a day, a month or in all, and <code>fallback</code> names where requests go when Gemini is out of quota or down.</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 rpm google 10
|
||||
magpie provider spend-cap google <key> 20 month
|
||||
magpie provider fallback google google-vertex/gemini-3.1-pro-preview</pre></div>
|
||||
|
||||
<h2 id="vertex"><a class="anchor" href="#vertex">Vertex AI</a></h2>
|
||||
<p>The <span class="ui">Google Vertex AI</span> preset asks Gemini in your Google Cloud project, with no API key. Give it the project’s id; the project in each request is the one billed.</p>
|
||||
<div class="code"><span class="lang">Terminal</span><button class="copy" data-copy="ex-vertex">Copy</button><pre id="ex-vertex">gcloud auth application-default login
|
||||
magpie provider add google-vertex project=my-project
|
||||
magpie claude google-vertex/gemini-3.1-pro-preview</pre></div>
|
||||
<ul>
|
||||
<li><b>Credentials.</b> magpie signs with gcloud’s Application Default Credentials, or with the file <code>credentials=</code> names by its full path: a user sign-in, a service account key or an impersonated service account. <code>impersonate=</code> takes a service account’s email, and needs <code>roles/iam.serviceAccountTokenCreator</code> on it. The metadata server, workload identity federation and Vertex AI’s express-mode API keys aren’t read.</li>
|
||||
<li><b>Location.</b> <code>location=</code> is <code>global</code> (the default), <code>us</code>, <code>eu</code> or a region such as <code>us-central1</code>.</li>
|
||||
<li><b>Models.</b> The preset has its own list, among them <code>gemini-3.8-flash</code>, <code>gemini-3.1-pro-preview</code>, <code>gemini-2.5-pro</code>, partner models such as <code>zai-org/glm-5.2-maas</code>, and Claude models such as <code>claude-opus-5-5</code>. Gemini goes to Vertex AI’s Gemini API, a partner model to its OpenAI-compatible chat completions, and Claude to Anthropic’s Messages API, all in your project.</li>
|
||||
<li><b>Thinking on Vertex AI.</b> A Gemini 3 level is fitted to the levels that model has, and reasoning off asks for its lowest. Gemini 2.5 takes a budget: Pro from 128 to 32768 tokens (128 when off), Flash up to 24576 (0 when off), Flash-Lite from 512 to 24576 (0 when off).</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="signins"><a class="anchor" href="#signins">Google sign-ins</a></h2>
|
||||
<p>Two Google sign-ins give Gemini models without a key. They are subscriptions, set up as on <a href="/docs/subscriptions">Subscriptions in any agent</a>.</p>
|
||||
<ul>
|
||||
<li><b>Gemini (Code Assist).</b> Gemini CLI’s Google sign-in, as <code>gemini/…</code>: <code>magpie accounts add gemini</code>. Google answers it only for a Code Assist Standard or Enterprise account with a Google Cloud project of its own; <code>magpie accounts project gemini <email> <project></code> names the project.</li>
|
||||
<li><b>Antigravity.</b> As <code>antigravity/…</code>: <code>magpie accounts add antigravity</code>. Its sign-in gives Antigravity’s Claude and Gemini models.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="trouble"><a class="anchor" href="#trouble">Troubleshooting</a></h2>
|
||||
<ul>
|
||||
<li><b>“Thinking level MINIMAL is not supported for this model”.</b> The model has no minimal level. magpie asks again at the nearest level it has, so the agent gets its answer, and remembers the level until magpie restarts. Only when no level is left does the error reach the agent as Google sent it.</li>
|
||||
<li><b>“Function call is missing a thought_signature in functionCall parts”.</b> A Gemini 3 call lost its signature. Through magpie the signature rides in the call id and is put back, and a call with none goes with <code>skip_thought_signature_validator</code>.</li>
|
||||
<li><b>“Corrupted thought signature”.</b> The signature was cut short or came from another provider. magpie sends a signature only to the provider that gave it.</li>
|
||||
<li><b>429 with “Please retry in 33s”.</b> A per-minute limit, not a spent plan. The key rests for a short while, and <code>rpm</code> keeps requests under the limit from then on.</li>
|
||||
<li><b>Vertex AI: a schema “didn’t specify the schema type field”.</b> magpie types every untyped tool schema it sends to Gemini, so this shouldn’t reach the agent.</li>
|
||||
<li><b>Vertex AI won’t save.</b> “Google Vertex AI needs the id of your Google Cloud project”: add <code>project=</code>. A credentials file has to be given by its full path.</li>
|
||||
<li><b>Checking a key.</b> <code>magpie provider test google</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 Gemini in Claude Code?</h3>
|
||||
<p>Add a Gemini API key in magpie (Providers, Add provider, Google Gemini), then pick a model such as <code>gemini-3.1-pro-preview</code> on Claude Code’s row, or run <code>magpie claude google/gemini-3.1-pro-preview</code>. magpie writes Claude Code’s <code>settings.json</code> and translates each Messages request to Gemini’s Chat Completions, tool calls and streaming included.</p>
|
||||
<h3>Can Codex use Gemini models?</h3>
|
||||
<p>Yes. Codex speaks only the Responses API. magpie translates each Codex request to Gemini’s Chat Completions and the reply back to Responses. Run <code>magpie codex google/gemini-3.1-pro-preview</code>, or pick the model on Codex’s row.</p>
|
||||
<h3>Does Gemini 3 Pro keep working across tool calls in Claude Code?</h3>
|
||||
<p>Yes. Gemini 3 signs its function calls and refuses the next request without the signature. magpie carries each signature in the call id the agent gets and puts it back on the way to Gemini, so tool loops keep going, and a call from another model is sent as unsigned.</p>
|
||||
<h3>Can Gemini CLI and OpenCode use my Gemini key through magpie?</h3>
|
||||
<p>Yes. Gemini CLI’s requests go to the Gemini API as it sends them, Google Search included. OpenCode speaks Chat Completions, so its requests go to Gemini’s OpenAI-compatible API as they are.</p>
|
||||
<h3>Why does Gemini answer 429 with “Please retry in 33s”?</h3>
|
||||
<p>That is a per-minute limit, not a spent quota. magpie reads it as a rate limit and rests the key briefly. Run <code>magpie provider rpm google 10</code>, with your own limit, and magpie holds requests to that rate.</p>
|
||||
<h3>Can I use Gemini through Vertex AI instead of an API key?</h3>
|
||||
<p>Yes. Add the Google Vertex AI preset with your project’s id, for example <code>magpie provider add google-vertex project=my-project</code>. magpie signs with gcloud’s Application Default Credentials or a credentials file, and your project is billed.</p>
|
||||
<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 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>
|
||||
@@ -0,0 +1,338 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Grok in Claude Code, Codex, Gemini CLI and OpenCode · magpie</title>
|
||||
<meta name="description" content="Use xAI's Grok in Claude Code, Codex, Gemini CLI and OpenCode with magpie: add your xAI API key once, pick a Grok model per agent, and let magpie fit each agent's requests to xAI's API, search the web, count cache and 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/grok">
|
||||
<link rel="alternate" hreflang="zh" href="https://usemagpie.ai/docs/zh/grok">
|
||||
<link rel="alternate" hreflang="ja" href="https://usemagpie.ai/docs/ja/grok">
|
||||
<link rel="alternate" hreflang="x-default" href="https://usemagpie.ai/docs/grok">
|
||||
<link rel="canonical" href="https://usemagpie.ai/docs/grok">
|
||||
<link rel="stylesheet" href="/docs.css">
|
||||
<meta property="og:site_name" content="magpie">
|
||||
<meta property="og:title" content="Grok in Claude Code, Codex, Gemini CLI and OpenCode">
|
||||
<meta property="og:description" content="Use xAI's Grok in Claude Code, Codex, Gemini CLI and OpenCode with magpie: add your xAI API key once, pick a Grok model per agent, and let magpie fit each agent's requests to xAI's API, search the web, count cache and 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/grok">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@graph": [
|
||||
{
|
||||
"@type": "TechArticle",
|
||||
"headline": "Grok in Claude Code, Codex, Gemini CLI and OpenCode",
|
||||
"description": "Use xAI's Grok in Claude Code, Codex, Gemini CLI and OpenCode with magpie: add your xAI API key once, pick a Grok model per agent, and let magpie fit each agent's requests to xAI's API, search the web, count cache and cost, and spread requests over several keys.",
|
||||
"inLanguage": "en",
|
||||
"url": "https://usemagpie.ai/docs/grok",
|
||||
"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 Grok in Claude Code?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "Add your xAI API key in magpie (Providers, Add provider, xAI), then pick a Grok model such as grok-4.7 on Claude Code’s row, or run magpie claude xai/grok-4.7. Claude Code’s requests go through magpie’s gateway to xAI’s Anthropic Messages endpoint, https://api.x.ai."
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Can Codex use Grok 4?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "Yes. xAI serves the Responses API that Codex speaks, so magpie codex xai/grok-4.7 sends Codex’s requests to https://api.x.ai/v1 as they are, with what xAI would refuse fixed on the way: tool schemas, a tool choice with no tools, and whole numbers Grok writes as 2500.0."
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Can Gemini CLI and OpenCode use Grok?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "Yes. Gemini CLI speaks Google’s API, so magpie translates its requests to xAI’s Chat Completions and the replies back. OpenCode speaks Chat Completions, so its requests go to xAI as they are. Run magpie gemini model xai/grok-4.7 or magpie opencode xai/grok-4.7."
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Does web search work with Grok?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "Yes. Codex’s web search is run by xAI itself on its Responses API. For Claude Code, Gemini CLI and OpenCode, magpie gives the model its own search tool, answered by the searcher chosen in Settings, or by one magpie picks."
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Why did Codex fail after switching from GPT to Grok mid-conversation?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "xAI can’t read reasoning that another vendor sealed, and answers “Could not decrypt the provided encrypted_content”. magpie asks again without those items and leaves them out for the rest of the conversation."
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Does magpie show my xAI balance?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "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."
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
</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/grok" hreflang="en" lang="en">English</a>
|
||||
<a href="/docs/zh/grok" hreflang="zh" lang="zh">中文</a>
|
||||
<a href="/docs/ja/grok" 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">Cache, 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>Grok in Claude Code, Codex, Gemini CLI and OpenCode</h1>
|
||||
<p class="lede">xAI serves its Grok models on three APIs at once: OpenAI Chat Completions, OpenAI Responses and Anthropic Messages. Add an xAI API key to magpie once, and Claude Code, Codex, Gemini CLI, OpenCode and every other agent you connect can use Grok 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 xAI</a></h2>
|
||||
<ol class="steps">
|
||||
<li><b>Get a key</b>Make one on <a href="https://console.x.ai">console.x.ai</a>.</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">xAI</span>, paste the key and save. magpie asks xAI 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 Grok model such as <code>grok-4.7</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 xai xai-…
|
||||
magpie provider test xai</pre></div>
|
||||
<p>Model ids in magpie are <code>provider/model</code>, so xAI’s read <code>xai/grok-4.7</code>: the provider, then xAI’s own id. The key is kept in magpie’s settings; magpie doesn’t take it from your shell.</p>
|
||||
|
||||
<h2 id="endpoints"><a class="anchor" href="#endpoints">Endpoints</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<tr><th>API</th><th>Base URL</th><th>Used for</th></tr>
|
||||
<tr><td>Chat Completions</td><td><code>https://api.x.ai/v1</code></td><td>the model list, OpenCode’s requests, and every request magpie translates, Gemini CLI’s among them</td></tr>
|
||||
<tr><td>Responses</td><td><code>https://api.x.ai/v1</code></td><td>Codex’s requests, and web search that xAI runs itself</td></tr>
|
||||
<tr><td>Anthropic Messages</td><td><code>https://api.x.ai</code></td><td>Claude Code’s requests</td></tr>
|
||||
</table></div>
|
||||
<p>An agent whose API xAI serves is passed on to that API. When magpie has to translate, it uses Chat Completions: it keeps Responses first only for OpenAI’s own models at OpenAI, and Messages first only for Claude models, and Grok is neither.</p>
|
||||
|
||||
<h2 id="models"><a class="anchor" href="#models">Model list</a></h2>
|
||||
<p>magpie fetches the list from xAI, at <code>https://api.x.ai/v1/models</code>, so agents see the models your key can use. Names, reasoning levels and prices come from models.dev’s <code>xai</code> catalog. 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 xai +grok-4.7
|
||||
magpie provider refresh-every xai 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 xai/grok-4.7
|
||||
magpie codex xai/grok-4.7
|
||||
magpie gemini model xai/grok-4.7
|
||||
magpie opencode xai/grok-4.7</pre></div>
|
||||
<ul>
|
||||
<li><b>Claude Code</b> speaks Anthropic Messages, and so does xAI at <code>https://api.x.ai</code>, so its requests go there as they are, with the fixes below. <a href="/docs/claude-code-models">Models in Claude Code</a>.</li>
|
||||
<li><b>Codex</b> speaks OpenAI Responses, which xAI serves at <code>https://api.x.ai/v1</code>, so its requests go there as they are too. If xAI turns away Codex’s custom tools (“unknown variant <code>custom</code>”), magpie translates that model’s Codex requests from then on and offers those tools as ordinary functions. <a href="/docs/codex-models">Models in Codex</a>.</li>
|
||||
<li><b>Gemini CLI</b> speaks Google’s Gemini API, which xAI doesn’t serve. magpie translates each request to Chat Completions and the reply back, streaming and tool calls included. <a href="/docs/gemini-cli-models">Models in Gemini CLI</a>.</li>
|
||||
<li><b>OpenCode</b> speaks Chat Completions, so its requests go to xAI as they are. <a href="/docs/opencode-models">Models in OpenCode</a>.</li>
|
||||
</ul>
|
||||
<p>Grok Build, xAI’s own CLI, can take magpie’s models too: magpie adds them to <code>~/.grok/config.toml</code>, so they join its <code>/model</code> picker.</p>
|
||||
|
||||
<h2 id="shaping"><a class="anchor" href="#shaping">What magpie fixes for xAI</a></h2>
|
||||
<p>xAI’s API turns away a few things that agents send. magpie changes them on the way, on requests it passes on and on those it translates alike, so the agent never sees these errors:</p>
|
||||
<ul>
|
||||
<li><b>Tool patterns.</b> xAI reads a tool’s <code>pattern</code> with a different regex engine, so a pattern such as Claude Code’s <code>^[^\s[\]]+$</code> on Windows failed with “Schema validation failed: … is not a "regex"”. magpie escapes it so xAI reads it as JavaScript does.</li>
|
||||
<li><b>Tool roots.</b> A tool whose parameters start with <code>anyOf</code>, <code>oneOf</code> or <code>allOf</code>, such as a Codex desktop automation tool, is folded into an object from the first request. xAI otherwise answers “tool parameter root must be an object type”.</li>
|
||||
<li><b>Empty fields.</b> <code>"required": null</code> in a tool’s schema, and <code>"content": null</code> on a Codex reasoning item, are left out. xAI otherwise answers “/required: null is not of type "array"” or “Could not decode the compaction blob”.</li>
|
||||
<li><b>System turns.</b> Claude Code’s system turns in the middle of a conversation are folded into the top-level system prompt. xAI otherwise answers “Invalid request content: Invalid message role.”</li>
|
||||
<li><b>A tool choice with no tools.</b> A request that sets <code>tool_choice</code> but offers no tools, such as Codex’s compaction summary, goes without it. xAI otherwise answers “A tool_choice was set on the request but no tools were specified”.</li>
|
||||
<li><b>Codex’s added tools.</b> xAI’s Responses API doesn’t know Codex’s <code>additional_tools</code> items, so magpie puts their tools in the request’s <code>tools</code>.</li>
|
||||
<li><b>Whole numbers.</b> Grok writes whole numbers in tool-call arguments with a fraction, such as <code>2500.0</code>, which Codex’s whole-number fields refuse. magpie writes <code>2500</code>, in streamed replies too.</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>Switching models mid-conversation.</b> xAI reads only the sealed reasoning it wrote itself. When a Codex conversation moves to Grok from GPT or from another account, xAI answers “Could not decrypt the provided encrypted_content”. magpie asks again without those items at once, and leaves them out for the rest of that conversation.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="search"><a class="anchor" href="#search">Web search</a></h2>
|
||||
<ul>
|
||||
<li><b>Codex.</b> xAI runs web search itself on its Responses API, so Codex’s <code>web_search</code> is done by xAI.</li>
|
||||
<li><b>Claude Code, Gemini CLI and OpenCode.</b> xAI’s Messages and Chat Completions APIs don’t search, so magpie gives the model its own search tool, answered by the searcher chosen in Settings, or by one magpie picks when none is chosen.</li>
|
||||
<li><b>xAI as the searcher.</b> Because xAI searches by itself, magpie can pick an xAI key to search for models that can’t.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="cost"><a class="anchor" href="#cost">Cache, cost and usage</a></h2>
|
||||
<ul>
|
||||
<li><b>Cache tokens.</b> magpie reads the cached tokens xAI reports in each reply, so the <span class="ui">Usage</span> tab counts cache hits 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, so a turn isn’t sent to a key with a cold cache.</li>
|
||||
<li><b>Cost.</b> The Usage tab prices each Grok call with xAI’s prices from models.dev.</li>
|
||||
<li><b>Balance.</b> magpie reads no balance from xAI. Type it in yourself 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 xAI 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 xAI is out of quota or down: another provider’s model or a routing group.</li>
|
||||
<li><b>A request xAI can’t read.</b> When xAI answers 422 “Failed to deserialize the JSON body … unknown item type”, the request goes to the next member of the routing group, and the key isn’t rested for it.</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 xai <key> 20 month
|
||||
magpie provider key-balance xai <key> 25
|
||||
magpie provider fallback xai deepseek/deepseek-v4-pro</pre></div>
|
||||
|
||||
<h2 id="trouble"><a class="anchor" href="#trouble">Troubleshooting</a></h2>
|
||||
<ul>
|
||||
<li><b>“maximum prompt length is …”.</b> The conversation is longer than the model takes. 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>
|
||||
<li><b>“Could not decrypt the provided encrypted_content”.</b> Codex moved to Grok mid-conversation with another vendor’s reasoning in it. magpie asks again without it; see <a href="#reasoning">Reasoning</a>.</li>
|
||||
<li><b>“unknown variant <code>custom</code>”.</b> xAI turned away Codex’s custom tools. magpie translates that model’s Codex requests from then on; the first refusal is the last.</li>
|
||||
<li><b>Checking a key.</b> <code>magpie provider test xai</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 Grok in Claude Code?</h3>
|
||||
<p>Add your xAI API key in magpie (Providers, Add provider, xAI), then pick a Grok model such as <code>grok-4.7</code> on Claude Code’s row, or run <code>magpie claude xai/grok-4.7</code>. Claude Code’s requests go through magpie’s gateway to xAI’s Anthropic Messages endpoint, <code>https://api.x.ai</code>.</p>
|
||||
<h3>Can Codex use Grok 4?</h3>
|
||||
<p>Yes. xAI serves the Responses API that Codex speaks, so <code>magpie codex xai/grok-4.7</code> sends Codex’s requests to <code>https://api.x.ai/v1</code> as they are, with what xAI would refuse fixed on the way: tool schemas, a tool choice with no tools, and whole numbers Grok writes as <code>2500.0</code>.</p>
|
||||
<h3>Can Gemini CLI and OpenCode use Grok?</h3>
|
||||
<p>Yes. Gemini CLI speaks Google’s API, so magpie translates its requests to xAI’s Chat Completions and the replies back. OpenCode speaks Chat Completions, so its requests go to xAI as they are. Run <code>magpie gemini model xai/grok-4.7</code> or <code>magpie opencode xai/grok-4.7</code>.</p>
|
||||
<h3>Does web search work with Grok?</h3>
|
||||
<p>Yes. Codex’s web search is run by xAI itself on its Responses API. For Claude Code, Gemini CLI and OpenCode, magpie gives the model its own search tool, answered by the searcher chosen in Settings, or by one magpie picks.</p>
|
||||
<h3>Why did Codex fail after switching from GPT to Grok mid-conversation?</h3>
|
||||
<p>xAI can’t read reasoning that another vendor sealed, and answers “Could not decrypt the provided encrypted_content”. magpie asks again without those items and leaves them out for the rest of the conversation.</p>
|
||||
<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 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>
|
||||
@@ -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/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/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a></p>
|
||||
|
||||
<h2 id="faq"><a class="anchor" href="#faq">よくある質問</a></h2>
|
||||
<h3><code>ANTHROPIC_BASE_URL</code> は自分で設定しますか?</h3>
|
||||
|
||||
@@ -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/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/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a></p>
|
||||
|
||||
<h2 id="faq"><a class="anchor" href="#faq">よくある質問</a></h2>
|
||||
<h3><code>[model_providers]</code> は自分で書きますか?</h3>
|
||||
|
||||
@@ -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/openrouter">OpenRouter</a> · <a href="/docs/ja/subscriptions">Claude・ChatGPT などのサブスク</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/openrouter">OpenRouter</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>
|
||||
|
||||
@@ -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/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/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a></p>
|
||||
|
||||
<h2 id="faq"><a class="anchor" href="#faq">よくある質問</a></h2>
|
||||
<h3>Gemini CLI で Gemini 以外のモデルを使えますか?</h3>
|
||||
|
||||
@@ -0,0 +1,365 @@
|
||||
<!doctype html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Gemini を Claude Code・Codex・Gemini CLI・OpenCode で使う · magpie</title>
|
||||
<meta name="description" content="magpie で Google の Gemini モデルを Claude Code・Codex・Gemini CLI・OpenCode で使えます。Gemini API キーか Vertex AI のプロジェクトを一度追加し、ツールごとに Gemini モデルを選ぶだけ。API の変換、Gemini 3 の思考レベルと思考シグネチャ、複数キーへの振り分けは 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/gemini">
|
||||
<link rel="alternate" hreflang="zh" href="https://usemagpie.ai/docs/zh/gemini">
|
||||
<link rel="alternate" hreflang="ja" href="https://usemagpie.ai/docs/ja/gemini">
|
||||
<link rel="alternate" hreflang="x-default" href="https://usemagpie.ai/docs/gemini">
|
||||
<link rel="canonical" href="https://usemagpie.ai/docs/ja/gemini">
|
||||
<link rel="stylesheet" href="/docs.css">
|
||||
<meta property="og:site_name" content="magpie">
|
||||
<meta property="og:title" content="Gemini を Claude Code・Codex・Gemini CLI・OpenCode で使う">
|
||||
<meta property="og:description" content="magpie で Google の Gemini モデルを Claude Code・Codex・Gemini CLI・OpenCode で使えます。Gemini API キーか Vertex AI のプロジェクトを一度追加し、ツールごとに Gemini モデルを選ぶだけ。API の変換、Gemini 3 の思考レベルと思考シグネチャ、複数キーへの振り分けは magpie が受け持ちます。">
|
||||
<meta property="og:image" content="https://usemagpie.ai/img/og.png">
|
||||
<meta property="og:url" content="https://usemagpie.ai/docs/ja/gemini">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@graph": [
|
||||
{
|
||||
"@type": "TechArticle",
|
||||
"headline": "Gemini を Claude Code・Codex・Gemini CLI・OpenCode で使う",
|
||||
"description": "magpie で Google の Gemini モデルを Claude Code・Codex・Gemini CLI・OpenCode で使えます。Gemini API キーか Vertex AI のプロジェクトを一度追加し、ツールごとに Gemini モデルを選ぶだけ。API の変換、Gemini 3 の思考レベルと思考シグネチャ、複数キーへの振り分けは magpie が受け持ちます。",
|
||||
"inLanguage": "ja",
|
||||
"url": "https://usemagpie.ai/docs/ja/gemini",
|
||||
"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 で Gemini を使うには?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "magpie に Gemini API キーを追加し(プロバイダ、プロバイダを追加、Google Gemini)、Claude Code の行で gemini-3.1-pro-preview などのモデルを選ぶか、magpie claude google/gemini-3.1-pro-preview を実行します。magpie が Claude Code の settings.json を書き、Messages のリクエストを一つずつ Gemini の Chat Completions に変換します。ツール呼び出しもストリーミングもそのまま使えます。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Codex で Gemini のモデルは使えますか?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "使えます。Codex が話すのは Responses API だけなので、magpie が Codex のリクエストを一つずつ Gemini の Chat Completions に変換し、返答を Responses に戻します。magpie codex google/gemini-3.1-pro-preview を実行するか、Codex の行でモデルを選びます。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Claude Code で Gemini 3 Pro にツールを続けて呼ばせても大丈夫ですか?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "大丈夫です。Gemini 3 は関数呼び出しに署名し、シグネチャのない次のリクエストを断ります。magpie はシグネチャをツールに渡す呼び出し ID に入れて運び、Gemini に送るときに戻すので、ツールのループは止まりません。別のモデルが出した呼び出しは署名なしとして送ります。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Gemini CLI や OpenCode でも magpie 経由で Gemini のキーを使えますか?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "使えます。Gemini CLI のリクエストは Google 検索も含めてそのまま Gemini API に渡ります。OpenCode は Chat Completions を話すので、リクエストはそのまま Gemini の OpenAI 互換 API に渡ります。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Gemini が 429 で “Please retry in 33s” と返すのはなぜですか?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "1 分あたりの上限で、クォータを使い切ったわけではありません。magpie はレート制限として扱い、キーを少し休ませます。magpie provider rpm google 10 のように自分の上限で実行すれば、magpie がリクエストをその速さに抑えます。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "API キーではなく Vertex AI で Gemini を使えますか?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "使えます。プロジェクト ID を付けて Google Vertex AI プリセットを追加します。たとえば magpie provider add google-vertex project=my-project。magpie は gcloud のアプリケーションのデフォルト認証情報か認証情報ファイルで署名し、課金はあなたのプロジェクトに入ります。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Gemini Code Assist や Antigravity のサインインは使えますか?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "使えます。どちらもサブスクです。magpie accounts add gemini か magpie accounts add antigravity を実行し、gemini/… か antigravity/… のモデルを選びます。Code Assist には、専用の Google Cloud プロジェクトを持つ Standard または Enterprise のアカウントが必要です。"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
</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/gemini" hreflang="en" lang="en">English</a>
|
||||
<a href="/docs/zh/gemini" hreflang="zh" lang="zh">中文</a>
|
||||
<a href="/docs/ja/gemini" 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="#thinking">思考</a>
|
||||
<a href="#signatures">思考シグネチャとツール</a>
|
||||
<a href="#cost">キャッシュ・費用・検索</a>
|
||||
<a href="#keys">複数のキーとレート制限</a>
|
||||
<a href="#vertex">Vertex AI</a>
|
||||
<a href="#signins">Google のサインイン</a>
|
||||
<a href="#trouble">うまくいかないとき</a>
|
||||
<a href="#faq">よくある質問</a>
|
||||
</aside>
|
||||
|
||||
<article>
|
||||
<p class="eyebrow" id="overview">ドキュメント · プロバイダ</p>
|
||||
<h1>Gemini を Claude Code・Codex・Gemini CLI・OpenCode で使う</h1>
|
||||
<p class="lede">Google は Gemini を二つの形で提供しています。AI Studio のキーで使う Gemini Developer API と、自分の Google Cloud プロジェクトで使う Vertex AI です。どちらかを magpie に一度追加すれば、Claude Code・Codex・Gemini CLI・OpenCode などつないだすべてのツールが、magpie のゲートウェイ <code>127.0.0.1:3425</code> 経由で <code>gemini-3.1-pro-preview</code> などの Gemini 3 モデルを使えます。ツールごとに別のモデルを選べます。</p>
|
||||
|
||||
<h2 id="add"><a class="anchor" href="#add">Gemini API キーを追加する</a></h2>
|
||||
<ol class="steps">
|
||||
<li><b>キーを取得</b><a href="https://aistudio.google.com/apikey">aistudio.google.com/apikey</a> で作ります。</li>
|
||||
<li><b>プロバイダを追加</b>magpie の <span class="ui">プロバイダ</span> で <span class="ui">+ プロバイダを追加</span> を押し、<span class="ui">Google Gemini</span> を選んでキーを貼り付け、保存します。magpie が Google に提供モデルを問い合わせます。</li>
|
||||
<li><b>ツールで選ぶ</b><span class="ui">エージェント</span> タブで、ツールの行の <code>gemini-3.1-pro-preview</code> などの Gemini モデルを選びます。</li>
|
||||
</ol>
|
||||
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-add">コピー</button><pre id="ex-add">magpie provider add google AIza…
|
||||
magpie provider test google</pre></div>
|
||||
<p>magpie のモデル ID は <code>プロバイダ/モデル</code> の形なので、Gemini API のモデルは <code>google/gemini-3.1-pro-preview</code> のようになります。前がプロバイダ、後ろが Google 自身の ID です。キーは magpie の設定に保存され、magpie がシェルから読むことはありません。</p>
|
||||
|
||||
<h2 id="endpoints"><a class="anchor" href="#endpoints">エンドポイント</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<tr><th>API</th><th>ベース URL</th><th>用途</th></tr>
|
||||
<tr><td>Chat Completions(OpenAI 互換)</td><td><code>https://generativelanguage.googleapis.com/v1beta/openai</code></td><td>モデル一覧、Claude Code・Codex・OpenCode などのリクエスト</td></tr>
|
||||
<tr><td>Gemini API</td><td><code>https://generativelanguage.googleapis.com/v1beta</code></td><td>Gemini CLI のリクエスト、Google 検索、画像モデル</td></tr>
|
||||
</table></div>
|
||||
<p>プリセットが Gemini API の URL を入れるのは一度だけです。消すと空のままになります。Gemini のクライアント以外から来たリクエストは、すべて Chat Completions に送られます。</p>
|
||||
|
||||
<h2 id="models"><a class="anchor" href="#models">モデル一覧</a></h2>
|
||||
<ul>
|
||||
<li><b>一覧の取得元。</b>magpie は OpenAI 互換エンドポイントに一覧を一度だけ問い合わせます。これは Gemini API の一覧でもあるので、二度は聞きません。モデル名・推論レベル・価格は models.dev の <code>google</code> カタログから取ります。</li>
|
||||
<li><b>画像モデル。</b>Google では、Gemini の画像モデルは Gemini API で画像を作ります。<span class="ui">設定 → モデル → 画像</span> で選びます。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="agents"><a class="anchor" href="#agents">ツールごとの使い方</a></h2>
|
||||
<p><span class="ui">エージェント</span> タブでツールの行からモデルを選ぶか、ターミナルで切り替えます。各ガイドには、magpie がそのツールの設定に何を書き込むか、元に戻す方法が書いてあります。</p>
|
||||
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-agents">コピー</button><pre id="ex-agents">magpie claude google/gemini-3.1-pro-preview
|
||||
magpie codex google/gemini-3.1-pro-preview
|
||||
magpie gemini model google/gemini-3.8-flash
|
||||
magpie opencode google/gemini-3.1-pro-preview</pre></div>
|
||||
<ul>
|
||||
<li><b>Claude Code</b> は Anthropic Messages を話します。magpie がリクエストを一つずつ Gemini の Chat Completions に変換し、返答を Messages に戻します。ストリーミングもツール呼び出しもそのまま使えます。<a href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>。</li>
|
||||
<li><b>Codex</b> が話すのは OpenAI Responses だけです。magpie が同じように Chat Completions に変換し、返答は Responses に戻して Codex に渡します。<a href="/docs/ja/codex-models">Codex で他のモデル</a>。</li>
|
||||
<li><b>Gemini CLI</b> は Gemini 自身の API を話すので、リクエストはそのまま Gemini API に渡り、Google 検索もそこで動きます。<a href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>。</li>
|
||||
<li><b>OpenCode</b> は Chat Completions を話すので、リクエストはそのまま Google に渡ります。<a href="/docs/ja/opencode-models">OpenCode で他のモデル</a>。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="thinking"><a class="anchor" href="#thinking">思考</a></h2>
|
||||
<ul>
|
||||
<li><b>思考の表示。</b>Gemini の OpenAI 互換 API は、<code>thinking_config</code> で求めたときだけモデルの思考を返します。ツールが推論の表示を求めると、magpie は <code>include_thoughts</code> を付けて思考を求めます。長く考えている間も、最初の一文字が遅れて届くのではなく、考え中として表示されます。</li>
|
||||
<li><b>レベルと予算。</b>Gemini 3 以降には思考レベルを送ります。Gemini 2 のモデルにはレベルの代わりに予算を送ります。minimal と low は 1024 トークン、medium は 8192、high は 24576 です。xhigh と max は high として送り、対応するレベルのない強さはモデルに任せます。</li>
|
||||
<li><b>推論オフ。</b>Gemini 3 は考えるのを止められません。ツールが推論をオフにすると、magpie はそのモデルのいちばん低いレベルを求めます。</li>
|
||||
<li><b>モデルにないレベル。</b>どの Gemini 3 にもすべてのレベルがあるわけではなく、<code>gemini-3.8-flash</code> には minimal がありません。Google がレベルを 400 で断ると、magpie はそのモデルにあるいちばん近いレベルで問い合わせ直し、magpie を再起動するまで覚えておきます。</li>
|
||||
<li><b><code>thinking_config</code> を断られたとき。</b>これは別の 400 で、Gemini の前に立つサーバーがこのフィールド自体を受け付けない場合です。magpie は <code>reasoning_effort</code> だけで問い合わせ直し、以後そこには <code>thinking_config</code> を送りません。</li>
|
||||
<li><b>プロキシ。</b>このコンピューターや LAN のプロキシ(<code>localhost</code> やプライベートアドレス上のものなど)の後ろにある Gemini モデルも、同じように扱います。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="signatures"><a class="anchor" href="#signatures">思考シグネチャとツール</a></h2>
|
||||
<ul>
|
||||
<li><b>思考シグネチャ。</b>Gemini 3 は各ステップの最初の関数呼び出しに署名し、それがないと次のリクエストは 400 “Function call is missing a thought_signature in functionCall parts” で失敗します。ツールはシグネチャを保持しません。magpie はそれをツールに渡す呼び出し ID の中に入れて運び(magpie のフォルダにあるファイルへの短い参照です)、Gemini に送るときに戻します。シグネチャは 90 日間保存されます。</li>
|
||||
<li><b>Gemini が署名していない呼び出し。</b>会話の前のほうで別のモデルが出した呼び出しや、ツールが ID を短くした呼び出しは、Google がドキュメントに載せている <code>skip_thought_signature_validator</code> を付けて送ります。会話の途中から Gemini に切り替えても続けられます。</li>
|
||||
<li><b>シグネチャは出したプロバイダにだけ。</b>シグネチャは、それを出したプロバイダにだけ返します。Vertex AI と Gemini API を含むルーティンググループでは、もう一方のプロバイダには署名なしの履歴として送るので、“Corrupted thought signature” にはなりません。</li>
|
||||
<li><b>ツールのスキーマ。</b>magpie は、ツールのスキーマのうち型のないものに型を付け(Vertex AI では必須です)、真偽値のスキーマと、MCP の <code>x-mcp-header</code> のような <code>x-</code> キーワードを取り除きます。手を入れる必要のないツールはそのまま送ります。</li>
|
||||
<li><b>ストリームの終わり。</b>Gemini の OpenAI 互換 API は、関数呼び出しを一つのチャンクで丸ごと送り、<code>finish_reason</code> を次のチャンクで送ります。使用量が届いたあとにその終了理由が失われた場合、magpie が補います。使用量も届いていなければ、完了した返答として渡さず、途中で切れたと報告します。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="cost"><a class="anchor" href="#cost">キャッシュ・費用・検索</a></h2>
|
||||
<ul>
|
||||
<li><b>プロンプトキャッシュ。</b>Gemini はプロンプトをキャッシュしても、そのターンではそう報告しません。magpie はそのターンをキャッシュ書き込みとして数え、次のターンも同じプロバイダとキーに送ります。どれが答えたかは再起動しても覚えています。</li>
|
||||
<li><b>キャッシュと思考のトークン。</b>Chat Completions でも Gemini API でも、magpie は返答ごとにキャッシュされたトークンと推論トークンを読み、<span class="ui">使用量</span> タブで数えます。</li>
|
||||
<li><b>費用。</b>使用量タブは、models.dev の <code>google</code> カタログの価格で呼び出しごとの費用を計算します。</li>
|
||||
<li><b>Web 検索。</b>Gemini API で Google 検索が動くのは、関数ツールを宣言していないリクエストだけです。Claude Code と Codex のリクエストはツールを宣言しているので、その Web 検索は magpie 自身の検索になり、Google プロバイダがあなたのキーで答えます。その検索は Gemini API の利用分になります。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="keys"><a class="anchor" href="#keys">複数のキーとレート制限</a></h2>
|
||||
<p>一つの Google Gemini プロバイダに複数のキーを入れられます。その下の <span class="ui">別のキーを追加</span> を押すか、まとめて貼り付けます。リクエストはオンになっている最初のキーに行き、そのキーが尽きるかレート制限にかかると次のキーが引き継ぎます。プロバイダのルーティングを、順番に回す・重みで分ける・一つを使い切ってから次へ、に変えることもできます。</p>
|
||||
<ul>
|
||||
<li><b>1 分あたりの制限による 429。</b>1 分あたりの上限で返る Gemini の 429 “You exceeded your current quota … Please retry in 33s” は、プランの使い切りではなくレート制限として扱います。Vertex AI の <code>requests_per_minute_per_project</code> も同じです。キーは 1 分休み、そのたびに倍になり、<code>rest-cap</code> まで延びます。</li>
|
||||
<li><b>速さを抑える。</b><code>rpm</code> はキーごとに 1 分あたりのリクエスト数を抑えます。超えた分は空きを待ち、2 分待っても空かなければ 429 を返します。</li>
|
||||
<li><b>クォータ切れ。</b><code>quota-rest</code> は、クォータを使い切ったキーを休ませる長さです。既定は 15 分、最長 8 日で、時刻を指定してそこまで休ませることもできます。</li>
|
||||
<li><b>支出上限とフォールバック。</b><code>spend-cap</code> はキーを 1 日・1 か月・合計のドル額で止め、<code>fallback</code> は Gemini がクォータ切れや停止のときのリクエストの行き先を決めます。</li>
|
||||
</ul>
|
||||
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-keys">コピー</button><pre id="ex-keys">magpie provider rpm google 10
|
||||
magpie provider spend-cap google <key> 20 month
|
||||
magpie provider fallback google google-vertex/gemini-3.1-pro-preview</pre></div>
|
||||
|
||||
<h2 id="vertex"><a class="anchor" href="#vertex">Vertex AI</a></h2>
|
||||
<p><span class="ui">Google Vertex AI</span> プリセットは、API キーなしで、自分の Google Cloud プロジェクトの Gemini を呼びます。プロジェクト ID を指定すれば、リクエストに入ったそのプロジェクトに課金されます。</p>
|
||||
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-vertex">コピー</button><pre id="ex-vertex">gcloud auth application-default login
|
||||
magpie provider add google-vertex project=my-project
|
||||
magpie claude google-vertex/gemini-3.1-pro-preview</pre></div>
|
||||
<ul>
|
||||
<li><b>認証情報。</b>magpie は gcloud のアプリケーションのデフォルト認証情報(Application Default Credentials)で署名します。<code>credentials=</code> にフルパスでファイルを指定すれば、そちらを使います。ユーザーのサインイン、サービスアカウントキー、なりすましのサービスアカウントのどれでも構いません。<code>impersonate=</code> にはサービスアカウントのメールアドレスを指定し、そのアカウントに対する <code>roles/iam.serviceAccountTokenCreator</code> が必要です。メタデータサーバー、Workload Identity 連携、Vertex AI のエクスプレスモードの API キーは読みません。</li>
|
||||
<li><b>ロケーション。</b><code>location=</code> は <code>global</code>(既定)、<code>us</code>、<code>eu</code>、または <code>us-central1</code> などのリージョンです。</li>
|
||||
<li><b>モデル。</b>このプリセットには独自のモデル一覧があり、<code>gemini-3.8-flash</code>、<code>gemini-3.1-pro-preview</code>、<code>gemini-2.5-pro</code>、<code>zai-org/glm-5.2-maas</code> のようなパートナーモデル、<code>claude-opus-5-5</code> のような Claude モデルが入っています。Gemini は Vertex AI の Gemini API へ、パートナーモデルは OpenAI 互換の Chat Completions へ、Claude は Anthropic の Messages API へ送られ、どれもあなたのプロジェクトで動きます。</li>
|
||||
<li><b>Vertex AI での思考。</b>Gemini 3 のレベルはそのモデルにあるレベルに合わせ、推論オフではいちばん低いレベルを求めます。Gemini 2.5 は予算で、Pro は 128〜32768 トークン(オフで 128)、Flash は 24576 まで(オフで 0)、Flash-Lite は 512〜24576(オフで 0)です。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="signins"><a class="anchor" href="#signins">Google のサインイン</a></h2>
|
||||
<p>キーなしで Gemini モデルを使える Google のサインインが二つあります。どちらもサブスクで、設定は <a href="/docs/ja/subscriptions">サブスクを任意のエージェントで</a> のとおりです。</p>
|
||||
<ul>
|
||||
<li><b>Gemini(Code Assist)。</b>Gemini CLI の Google サインインで、モデルは <code>gemini/…</code> です。<code>magpie accounts add gemini</code> で追加します。Google が応じるのは、専用の Google Cloud プロジェクトを持つ Code Assist Standard または Enterprise のアカウントだけです。プロジェクトは <code>magpie accounts project gemini <email> <project></code> で指定します。</li>
|
||||
<li><b>Antigravity。</b>モデルは <code>antigravity/…</code> で、<code>magpie accounts add antigravity</code> で追加します。サインインすると Antigravity の Claude と Gemini のモデルが使えます。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="trouble"><a class="anchor" href="#trouble">うまくいかないとき</a></h2>
|
||||
<ul>
|
||||
<li><b>“Thinking level MINIMAL is not supported for this model”。</b>そのモデルには minimal がありません。magpie がいちばん近いレベルで問い合わせ直すのでツールには返答が届き、magpie を再起動するまでそのレベルを覚えておきます。試せるレベルが残っていないときだけ、Google のエラーがそのままツールに届きます。</li>
|
||||
<li><b>“Function call is missing a thought_signature in functionCall parts”。</b>Gemini 3 の呼び出しがシグネチャを失っています。magpie を通るときは、シグネチャは呼び出し ID に入って運ばれ、送るときに戻されます。シグネチャのない呼び出しには <code>skip_thought_signature_validator</code> が付きます。</li>
|
||||
<li><b>“Corrupted thought signature”。</b>シグネチャが途中で切れているか、別のプロバイダのものです。magpie はシグネチャを、それを出したプロバイダにだけ送ります。</li>
|
||||
<li><b>429 で “Please retry in 33s”。</b>1 分あたりの上限で、プランを使い切ったわけではありません。キーは少し休みます。<code>rpm</code> を使えば、それ以降のリクエストを上限の内に抑えられます。</li>
|
||||
<li><b>Vertex AI でスキーマが “didn’t specify the schema type field”。</b>magpie は Gemini に送るツールのスキーマすべてに型を付けるので、このエラーがツールまで届くことはないはずです。</li>
|
||||
<li><b>Vertex AI が保存できない。</b>“Google Vertex AI needs the id of your Google Cloud project” と出たら <code>project=</code> を付けます。認証情報のファイルはフルパスで指定してください。</li>
|
||||
<li><b>キーの確認。</b><code>magpie provider test google</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 で Gemini を使うには?</h3>
|
||||
<p>magpie に Gemini API キーを追加し(プロバイダ、プロバイダを追加、Google Gemini)、Claude Code の行で <code>gemini-3.1-pro-preview</code> などのモデルを選ぶか、<code>magpie claude google/gemini-3.1-pro-preview</code> を実行します。magpie が Claude Code の <code>settings.json</code> を書き、Messages のリクエストを一つずつ Gemini の Chat Completions に変換します。ツール呼び出しもストリーミングもそのまま使えます。</p>
|
||||
<h3>Codex で Gemini のモデルは使えますか?</h3>
|
||||
<p>使えます。Codex が話すのは Responses API だけなので、magpie が Codex のリクエストを一つずつ Gemini の Chat Completions に変換し、返答を Responses に戻します。<code>magpie codex google/gemini-3.1-pro-preview</code> を実行するか、Codex の行でモデルを選びます。</p>
|
||||
<h3>Claude Code で Gemini 3 Pro にツールを続けて呼ばせても大丈夫ですか?</h3>
|
||||
<p>大丈夫です。Gemini 3 は関数呼び出しに署名し、シグネチャのない次のリクエストを断ります。magpie はシグネチャをツールに渡す呼び出し ID に入れて運び、Gemini に送るときに戻すので、ツールのループは止まりません。別のモデルが出した呼び出しは署名なしとして送ります。</p>
|
||||
<h3>Gemini CLI や OpenCode でも magpie 経由で Gemini のキーを使えますか?</h3>
|
||||
<p>使えます。Gemini CLI のリクエストは Google 検索も含めてそのまま Gemini API に渡ります。OpenCode は Chat Completions を話すので、リクエストはそのまま Gemini の OpenAI 互換 API に渡ります。</p>
|
||||
<h3>Gemini が 429 で “Please retry in 33s” と返すのはなぜですか?</h3>
|
||||
<p>1 分あたりの上限で、クォータを使い切ったわけではありません。magpie はレート制限として扱い、キーを少し休ませます。<code>magpie provider rpm google 10</code> のように自分の上限で実行すれば、magpie がリクエストをその速さに抑えます。</p>
|
||||
<h3>API キーではなく Vertex AI で Gemini を使えますか?</h3>
|
||||
<p>使えます。プロジェクト ID を付けて Google Vertex AI プリセットを追加します。たとえば <code>magpie provider add google-vertex project=my-project</code>。magpie は gcloud のアプリケーションのデフォルト認証情報か認証情報ファイルで署名し、課金はあなたのプロジェクトに入ります。</p>
|
||||
<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 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>
|
||||
@@ -0,0 +1,338 @@
|
||||
<!doctype html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Grok を Claude Code・Codex・Gemini CLI・OpenCode で使う · magpie</title>
|
||||
<meta name="description" content="magpie で xAI の Grok を Claude Code・Codex・Gemini CLI・OpenCode から使う方法:xAI の API キーは一度追加するだけ。ツールごとに Grok のモデルを選べて、各ツールのリクエストを xAI の API に合わせる調整、Web 検索、キャッシュと費用の集計、複数キーへの振り分けは 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/grok">
|
||||
<link rel="alternate" hreflang="zh" href="https://usemagpie.ai/docs/zh/grok">
|
||||
<link rel="alternate" hreflang="ja" href="https://usemagpie.ai/docs/ja/grok">
|
||||
<link rel="alternate" hreflang="x-default" href="https://usemagpie.ai/docs/grok">
|
||||
<link rel="canonical" href="https://usemagpie.ai/docs/ja/grok">
|
||||
<link rel="stylesheet" href="/docs.css">
|
||||
<meta property="og:site_name" content="magpie">
|
||||
<meta property="og:title" content="Grok を Claude Code・Codex・Gemini CLI・OpenCode で使う">
|
||||
<meta property="og:description" content="magpie で xAI の Grok を Claude Code・Codex・Gemini CLI・OpenCode から使う方法:xAI の API キーは一度追加するだけ。ツールごとに Grok のモデルを選べて、各ツールのリクエストを xAI の API に合わせる調整、Web 検索、キャッシュと費用の集計、複数キーへの振り分けは magpie が受け持ちます。">
|
||||
<meta property="og:image" content="https://usemagpie.ai/img/og.png">
|
||||
<meta property="og:url" content="https://usemagpie.ai/docs/ja/grok">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@graph": [
|
||||
{
|
||||
"@type": "TechArticle",
|
||||
"headline": "Grok を Claude Code・Codex・Gemini CLI・OpenCode で使う",
|
||||
"description": "magpie で xAI の Grok を Claude Code・Codex・Gemini CLI・OpenCode から使う方法:xAI の API キーは一度追加するだけ。ツールごとに Grok のモデルを選べて、各ツールのリクエストを xAI の API に合わせる調整、Web 検索、キャッシュと費用の集計、複数キーへの振り分けは magpie が受け持ちます。",
|
||||
"inLanguage": "ja",
|
||||
"url": "https://usemagpie.ai/docs/ja/grok",
|
||||
"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 で Grok を使うには?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "magpie で xAI の API キーを追加し(プロバイダ、プロバイダを追加、xAI)、Claude Code の行で grok-4.7 などの Grok モデルを選ぶか、magpie claude xai/grok-4.7 を実行します。Claude Code のリクエストは magpie のゲートウェイを通って xAI の Anthropic Messages エンドポイント https://api.x.ai に届きます。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Codex で Grok 4 は使えますか?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "使えます。xAI は Codex が話す Responses API を提供しているので、magpie codex xai/grok-4.7 で Codex のリクエストは https://api.x.ai/v1 にそのまま届きます。ツールのスキーマ、ツールのない tool_choice、Grok が 2500.0 と書く整数など、xAI が拒否するものは途中で直します。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Gemini CLI と OpenCode で Grok は使えますか?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "使えます。Gemini CLI は Google の API を話すので、magpie がリクエストを xAI の Chat Completions に変換し、返答を戻します。OpenCode は Chat Completions を話すので、リクエストはそのまま xAI に届きます。magpie gemini model xai/grok-4.7 か magpie opencode xai/grok-4.7 を実行してください。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Grok で Web 検索はできますか?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "できます。Codex の Web 検索は xAI が Responses API で自ら行います。Claude Code・Gemini CLI・OpenCode では、magpie がモデルに自前の検索ツールを渡し、設定で指定した検索サービスか magpie が選んだものが答えます。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Codex の会話の途中で GPT から Grok に替えたらエラーになるのはなぜ?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "xAI はほかのベンダーが封じた推論を読めず、“Could not decrypt the provided encrypted_content” を返します。magpie はそのアイテムを外して問い合わせ直し、その会話の残りでも外したままにします。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "magpie で xAI の残高は見られますか?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "見られません。使用量タブは Grok の呼び出しごとにトークン・キャッシュ・費用を models.dev の価格で数えますが、magpie は xAI から残高を読みません。magpie provider key-balance で残高を入力すると、使用量ページはそこから magpie がそれ以降に計算した費用を引いて表示します。"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
</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/grok" hreflang="en" lang="en">English</a>
|
||||
<a href="/docs/zh/grok" hreflang="zh" lang="zh">中文</a>
|
||||
<a href="/docs/ja/grok" 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">キャッシュ・費用・使用量</a>
|
||||
<a href="#keys">複数のキー</a>
|
||||
<a href="#trouble">うまくいかないとき</a>
|
||||
<a href="#faq">よくある質問</a>
|
||||
</aside>
|
||||
|
||||
<article>
|
||||
<p class="eyebrow" id="overview">ドキュメント · プロバイダ</p>
|
||||
<h1>Grok を Claude Code・Codex・Gemini CLI・OpenCode で使う</h1>
|
||||
<p class="lede">xAI は Grok のモデルを OpenAI Chat Completions・OpenAI Responses・Anthropic Messages の三つの API で提供しています。xAI の API キーを magpie に一度追加すれば、Claude Code・Codex・Gemini CLI・OpenCode などつないだすべてのツールが、magpie のゲートウェイ <code>127.0.0.1:3425</code> 経由で Grok を使えます。ツールごとに別のモデルを選べます。</p>
|
||||
|
||||
<h2 id="add"><a class="anchor" href="#add">xAI を追加する</a></h2>
|
||||
<ol class="steps">
|
||||
<li><b>キーを取得</b><a href="https://console.x.ai">console.x.ai</a> で作ります。</li>
|
||||
<li><b>プロバイダを追加</b>magpie の <span class="ui">プロバイダ</span> で <span class="ui">+ プロバイダを追加</span> を押し、<span class="ui">xAI</span> を選んでキーを貼り付け、保存します。magpie がそのキーで使えるモデルを xAI に問い合わせます。</li>
|
||||
<li><b>ツールで選ぶ</b><span class="ui">エージェント</span> タブで、ツールの行のモデルを押し、<code>grok-4.7</code> などの Grok モデルを選びます。</li>
|
||||
</ol>
|
||||
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-add">コピー</button><pre id="ex-add">magpie provider add xai xai-…
|
||||
magpie provider test xai</pre></div>
|
||||
<p>magpie のモデル ID は <code>プロバイダ/モデル</code> の形なので、xAI のモデルは <code>xai/grok-4.7</code> のようになります。前がプロバイダ、後ろが xAI 自身の ID です。キーは magpie の設定に保存され、magpie がシェルから読むことはありません。</p>
|
||||
|
||||
<h2 id="endpoints"><a class="anchor" href="#endpoints">エンドポイント</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<tr><th>API</th><th>ベース URL</th><th>用途</th></tr>
|
||||
<tr><td>Chat Completions</td><td><code>https://api.x.ai/v1</code></td><td>モデル一覧、OpenCode のリクエスト、magpie が変換するすべてのリクエスト(Gemini CLI のものを含む)</td></tr>
|
||||
<tr><td>Responses</td><td><code>https://api.x.ai/v1</code></td><td>Codex のリクエストと、xAI 自身が行う Web 検索</td></tr>
|
||||
<tr><td>Anthropic Messages</td><td><code>https://api.x.ai</code></td><td>Claude Code のリクエスト</td></tr>
|
||||
</table></div>
|
||||
<p>ツールの話す API を xAI が提供していれば、リクエストはその API にそのまま渡します。変換が必要なときは Chat Completions を使います。Responses を優先するのは OpenAI での OpenAI 自身のモデルだけ、Messages を優先するのは Claude モデルだけで、Grok はどちらでもないからです。</p>
|
||||
|
||||
<h2 id="models"><a class="anchor" href="#models">モデル一覧</a></h2>
|
||||
<p>magpie は一覧を xAI の <code>https://api.x.ai/v1/models</code> から取得するので、ツールにはそのキーで使えるモデルが並びます。名前・推論レベル・価格は models.dev の <code>xai</code> カタログから取ります。ツールに見せるモデルは、プロバイダのモデル一覧かターミナルで選べます。</p>
|
||||
<div class="code"><span class="lang">ターミナル</span><button class="copy" data-copy="ex-models">コピー</button><pre id="ex-models">magpie provider models xai +grok-4.7
|
||||
magpie provider refresh-every xai 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 xai/grok-4.7
|
||||
magpie codex xai/grok-4.7
|
||||
magpie gemini model xai/grok-4.7
|
||||
magpie opencode xai/grok-4.7</pre></div>
|
||||
<ul>
|
||||
<li><b>Claude Code</b> は Anthropic Messages を話し、xAI も <code>https://api.x.ai</code> で同じ API を提供しているので、リクエストはそのまま送ります。手を入れるのは下に挙げた点だけです。<a href="/docs/ja/claude-code-models">Claude Code で他のモデル</a>。</li>
|
||||
<li><b>Codex</b> は OpenAI Responses を話し、xAI はそれを <code>https://api.x.ai/v1</code> で提供しているので、こちらもそのまま送ります。xAI が Codex のカスタムツールを拒否した場合(“unknown variant <code>custom</code>”)、magpie はそれ以降そのモデルへの Codex のリクエストを変換し、それらのツールを通常の関数として渡します。<a href="/docs/ja/codex-models">Codex で他のモデル</a>。</li>
|
||||
<li><b>Gemini CLI</b> は Google の Gemini API を話しますが、xAI はこれを提供していません。magpie が各リクエストを Chat Completions に変換し、返答を戻します。ストリーミングとツール呼び出しも含みます。<a href="/docs/ja/gemini-cli-models">Gemini CLI で他のモデル</a>。</li>
|
||||
<li><b>OpenCode</b> は Chat Completions を話すので、リクエストはそのまま xAI に送ります。<a href="/docs/ja/opencode-models">OpenCode で他のモデル</a>。</li>
|
||||
</ul>
|
||||
<p>xAI 自身の CLI である Grok Build でも magpie のモデルを使えます。magpie がそれらを <code>~/.grok/config.toml</code> に書き込むので、<code>/model</code> の選択肢に並びます。</p>
|
||||
|
||||
<h2 id="shaping"><a class="anchor" href="#shaping">magpie が xAI 向けに直すもの</a></h2>
|
||||
<p>ツールが送るもののうち、いくつかは xAI の API に拒否されます。magpie はそのまま渡すリクエストでも変換するリクエストでも途中でそれを直すので、ツールがこれらのエラーを見ることはありません。</p>
|
||||
<ul>
|
||||
<li><b>ツールの正規表現。</b>xAI はツールの <code>pattern</code> を別の正規表現エンジンで読むため、Windows の Claude Code が使う <code>^[^\s[\]]+$</code> のようなパターンが “Schema validation failed: … is not a "regex"” で失敗していました。magpie はこれをエスケープし、xAI が JavaScript と同じように読めるようにします。</li>
|
||||
<li><b>ツール引数のルート。</b>引数が <code>anyOf</code>・<code>oneOf</code>・<code>allOf</code> で始まるツール(Codex デスクトップ版の自動化ツールなど)は、最初のリクエストから object にまとめて送ります。そうしないと xAI は “tool parameter root must be an object type” を返します。</li>
|
||||
<li><b>空のフィールド。</b>ツールのスキーマにある <code>"required": null</code> と、Codex の推論アイテムにある <code>"content": null</code> は外して送ります。そうしないと xAI は “/required: null is not of type "array"” や “Could not decode the compaction blob” を返します。</li>
|
||||
<li><b>会話の途中のシステムメッセージ。</b>Claude Code が会話の途中に入れるシステムメッセージは、先頭のシステムプロンプトにまとめます。そうしないと xAI は “Invalid request content: Invalid message role.” を返します。</li>
|
||||
<li><b>ツールのない tool_choice。</b><code>tool_choice</code> を指定しながらツールを一つも渡さないリクエスト(Codex がコンテキストを圧縮するときの要約など)は、それを外して送ります。そうしないと xAI は “A tool_choice was set on the request but no tools were specified” を返します。</li>
|
||||
<li><b>Codex が追加するツール。</b>xAI の Responses API は Codex の <code>additional_tools</code> アイテムを知らないので、magpie はそのツールをリクエストの <code>tools</code> に入れます。</li>
|
||||
<li><b>整数。</b>Grok はツール呼び出しの引数で整数を <code>2500.0</code> のように小数付きで書き、Codex の整数フィールドはそれを受け付けません。magpie は <code>2500</code> に書き直します。ストリーミングの返答でも同じです。</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>xAI が読めるのは自分で封じた推論だけです。Codex の会話を GPT や別のアカウントから Grok に移すと、xAI は “Could not decrypt the provided encrypted_content” を返します。magpie はすぐにそのアイテムを外して問い合わせ直し、その会話のあとのリクエストからも外します。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="search"><a class="anchor" href="#search">Web 検索</a></h2>
|
||||
<ul>
|
||||
<li><b>Codex。</b>xAI は Responses API で自ら Web を検索するので、Codex の <code>web_search</code> は xAI が行います。</li>
|
||||
<li><b>Claude Code・Gemini CLI・OpenCode。</b>xAI の Messages と Chat Completions の API は検索しないので、magpie がモデルに自前の検索ツールを渡します。答えるのは設定で指定した検索サービスで、指定がなければ magpie が選んだものです。</li>
|
||||
<li><b>xAI を検索役に。</b>xAI は自分で検索できるので、magpie は検索できないモデルのために xAI のキーを検索役に選ぶことがあります。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="cost"><a class="anchor" href="#cost">キャッシュ・費用・使用量</a></h2>
|
||||
<ul>
|
||||
<li><b>キャッシュのトークン。</b>magpie は xAI が返答ごとに報告するキャッシュ済みトークンを読むので、<span class="ui">使用量</span> タブではキャッシュヒットをプロンプトの残りと分けて数えます。</li>
|
||||
<li><b>キャッシュを生かす。</b>キーが複数あるとき、会話のキャッシュに残す価値があり(1,024 トークン以上)、まだ温かい(5 分以内に読まれた)あいだは、その会話は同じキーを使い続けます。キャッシュの冷えたキーにターンを送ることはありません。</li>
|
||||
<li><b>費用。</b>使用量タブは、models.dev にある xAI の価格で Grok の呼び出しごとに費用を計算します。</li>
|
||||
<li><b>残高。</b>magpie は xAI から残高を読みません。<code>key-balance</code> で自分で入力すると、使用量ページはそこから magpie がそれ以降のキーの呼び出しに付けた費用を引いて表示します。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="keys"><a class="anchor" href="#keys">複数のキーとフェイルオーバー</a></h2>
|
||||
<p>一つの xAI プロバイダに複数のキーを入れられます。その下の <span class="ui">別のキーを追加</span> を押すか、まとめて貼り付けます。リクエストはオンになっている最初のキーに行き、そのキーが尽きるかレート制限にかかると次のキーが引き継ぎます。</p>
|
||||
<ul>
|
||||
<li><b>支出上限。</b><code>spend-cap</code> で、キーごとに 1 日・1 か月・累計のドル上限を決められます。金額は使用量タブの計算で数え、上限に達するとルーティングはほかのキーとフォールバックに移ります。</li>
|
||||
<li><b>フォールバック。</b><code>fallback</code> で、xAI の枠が尽きたときや落ちたときの行き先を決めます。別のプロバイダのモデルか、ルーティンググループです。</li>
|
||||
<li><b>xAI が読めないリクエスト。</b>xAI が 422 “Failed to deserialize the JSON body … unknown item type” を返したときは、ルーティンググループの次のメンバーに回します。そのためにキーが休むことはありません。</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 xai <key> 20 month
|
||||
magpie provider key-balance xai <key> 25
|
||||
magpie provider fallback xai deepseek/deepseek-v4-pro</pre></div>
|
||||
|
||||
<h2 id="trouble"><a class="anchor" href="#trouble">うまくいかないとき</a></h2>
|
||||
<ul>
|
||||
<li><b>“maximum prompt length is …”。</b>会話がモデルの受け付ける長さを超えています。magpie はこれをツールが理解できる形、<code>context_length_exceeded</code> や Anthropic の “prompt is too long” で伝えるので、ツールはコンテキストを圧縮してやり直します。</li>
|
||||
<li><b>“Could not decrypt the provided encrypted_content”。</b>Codex が別ベンダーの推論を含んだまま、会話の途中で Grok に移りました。magpie はそれを外して問い合わせ直します。<a href="#reasoning">推論</a>を参照してください。</li>
|
||||
<li><b>“unknown variant <code>custom</code>”。</b>xAI が Codex のカスタムツールを拒否しました。magpie はそれ以降そのモデルへの Codex のリクエストを変換するので、このエラーが出るのは一度だけです。</li>
|
||||
<li><b>キーの確認。</b><code>magpie provider test xai</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 で Grok を使うには?</h3>
|
||||
<p>magpie で xAI の API キーを追加し(プロバイダ、プロバイダを追加、xAI)、Claude Code の行で <code>grok-4.7</code> などの Grok モデルを選ぶか、<code>magpie claude xai/grok-4.7</code> を実行します。Claude Code のリクエストは magpie のゲートウェイを通って xAI の Anthropic Messages エンドポイント <code>https://api.x.ai</code> に届きます。</p>
|
||||
<h3>Codex で Grok 4 は使えますか?</h3>
|
||||
<p>使えます。xAI は Codex が話す Responses API を提供しているので、<code>magpie codex xai/grok-4.7</code> で Codex のリクエストは <code>https://api.x.ai/v1</code> にそのまま届きます。ツールのスキーマ、ツールのない tool_choice、Grok が <code>2500.0</code> と書く整数など、xAI が拒否するものは途中で直します。</p>
|
||||
<h3>Gemini CLI と OpenCode で Grok は使えますか?</h3>
|
||||
<p>使えます。Gemini CLI は Google の API を話すので、magpie がリクエストを xAI の Chat Completions に変換し、返答を戻します。OpenCode は Chat Completions を話すので、リクエストはそのまま xAI に届きます。<code>magpie gemini model xai/grok-4.7</code> か <code>magpie opencode xai/grok-4.7</code> を実行してください。</p>
|
||||
<h3>Grok で Web 検索はできますか?</h3>
|
||||
<p>できます。Codex の Web 検索は xAI が Responses API で自ら行います。Claude Code・Gemini CLI・OpenCode では、magpie がモデルに自前の検索ツールを渡し、設定で指定した検索サービスか magpie が選んだものが答えます。</p>
|
||||
<h3>Codex の会話の途中で GPT から Grok に替えたらエラーになるのはなぜ?</h3>
|
||||
<p>xAI はほかのベンダーが封じた推論を読めず、“Could not decrypt the provided encrypted_content” を返します。magpie はそのアイテムを外して問い合わせ直し、その会話の残りでも外したままにします。</p>
|
||||
<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 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>
|
||||
@@ -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/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/openrouter">OpenRouter</a> · <a href="/docs/ja/copilot">GitHub Copilot</a></p>
|
||||
|
||||
<h2 id="faq"><a class="anchor" href="#faq">よくある質問</a></h2>
|
||||
<h3>OpenCode で DeepSeek を使うには?</h3>
|
||||
|
||||
@@ -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/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/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>
|
||||
|
||||
@@ -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/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/openrouter">OpenRouter</a> · <a href="/docs/copilot">GitHub Copilot</a></p>
|
||||
|
||||
<h2 id="faq"><a class="anchor" href="#faq">FAQ</a></h2>
|
||||
<h3>How do I use DeepSeek in OpenCode?</h3>
|
||||
|
||||
@@ -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/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/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>
|
||||
|
||||
@@ -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/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/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a></p>
|
||||
|
||||
<h2 id="faq"><a class="anchor" href="#faq">常见问题</a></h2>
|
||||
<h3>需要自己设置 <code>ANTHROPIC_BASE_URL</code> 吗?</h3>
|
||||
|
||||
@@ -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/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/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a></p>
|
||||
|
||||
<h2 id="faq"><a class="anchor" href="#faq">常见问题</a></h2>
|
||||
<h3>需要自己写 <code>[model_providers]</code> 吗?</h3>
|
||||
|
||||
@@ -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/openrouter">OpenRouter</a> · <a href="/docs/zh/subscriptions">Claude、ChatGPT 等订阅</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/openrouter">OpenRouter</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>
|
||||
|
||||
@@ -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/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/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a></p>
|
||||
|
||||
<h2 id="faq"><a class="anchor" href="#faq">常见问题</a></h2>
|
||||
<h3>Gemini CLI 能用 Gemini 以外的模型吗?</h3>
|
||||
|
||||
@@ -0,0 +1,365 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Gemini 接入 Claude Code、Codex、Gemini CLI 和 OpenCode · magpie</title>
|
||||
<meta name="description" content="用 magpie 在 Claude Code、Codex、Gemini CLI 和 OpenCode 里使用 Google 的 Gemini 模型:Gemini API Key 或 Vertex AI 项目只添加一次,每个工具各选一个 Gemini 模型,magpie 负责协议转换、Gemini 3 的思考档位和思维签名,还能在多个 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/gemini">
|
||||
<link rel="alternate" hreflang="zh" href="https://usemagpie.ai/docs/zh/gemini">
|
||||
<link rel="alternate" hreflang="ja" href="https://usemagpie.ai/docs/ja/gemini">
|
||||
<link rel="alternate" hreflang="x-default" href="https://usemagpie.ai/docs/gemini">
|
||||
<link rel="canonical" href="https://usemagpie.ai/docs/zh/gemini">
|
||||
<link rel="stylesheet" href="/docs.css">
|
||||
<meta property="og:site_name" content="magpie">
|
||||
<meta property="og:title" content="Gemini 接入 Claude Code、Codex、Gemini CLI 和 OpenCode">
|
||||
<meta property="og:description" content="用 magpie 在 Claude Code、Codex、Gemini CLI 和 OpenCode 里使用 Google 的 Gemini 模型:Gemini API Key 或 Vertex AI 项目只添加一次,每个工具各选一个 Gemini 模型,magpie 负责协议转换、Gemini 3 的思考档位和思维签名,还能在多个 Key 之间分配请求。">
|
||||
<meta property="og:image" content="https://usemagpie.ai/img/og.png">
|
||||
<meta property="og:url" content="https://usemagpie.ai/docs/zh/gemini">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@graph": [
|
||||
{
|
||||
"@type": "TechArticle",
|
||||
"headline": "Gemini 接入 Claude Code、Codex、Gemini CLI 和 OpenCode",
|
||||
"description": "用 magpie 在 Claude Code、Codex、Gemini CLI 和 OpenCode 里使用 Google 的 Gemini 模型:Gemini API Key 或 Vertex AI 项目只添加一次,每个工具各选一个 Gemini 模型,magpie 负责协议转换、Gemini 3 的思考档位和思维签名,还能在多个 Key 之间分配请求。",
|
||||
"inLanguage": "zh-CN",
|
||||
"url": "https://usemagpie.ai/docs/zh/gemini",
|
||||
"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 怎么用 Gemini?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "在 magpie 里添加 Gemini API Key(供应商页,添加供应商,选 Google Gemini),然后在 Claude Code 那一行选一个模型,比如 gemini-3.1-pro-preview,或者运行 magpie claude google/gemini-3.1-pro-preview。magpie 会写好 Claude Code 的 settings.json,把每个 Messages 请求转换成 Gemini 的 Chat Completions,工具调用和流式输出都保留。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Codex 能用 Gemini 模型吗?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "能。Codex 只说 Responses API,magpie 会把每个 Codex 请求转换成 Gemini 的 Chat Completions,回复再转回 Responses。运行 magpie codex google/gemini-3.1-pro-preview,或者在 Codex 那一行选模型。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Gemini 3 Pro 在 Claude Code 里连续调用工具会出错吗?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "不会。Gemini 3 会给函数调用签名,下一个请求缺了签名就会被拒。magpie 把每个签名放进交给工具的调用 id 里,发往 Gemini 时再放回去,所以工具循环能一直进行;其他模型发出的调用会按无签名发送。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Gemini CLI 和 OpenCode 能通过 magpie 用我的 Gemini Key 吗?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "能。Gemini CLI 的请求按原样发给 Gemini API,Google 搜索也一样。OpenCode 说 Chat Completions,请求原样发给 Gemini 的 OpenAI 兼容接口。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Gemini 为什么返回 429 并提示 “Please retry in 33s”?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "这是每分钟的限额,不是额度用完。magpie 把它当作限流,让 Key 短暂暂停。运行 magpie provider rpm google 10(换成你自己的限额),magpie 就会把请求压在这个速度以内。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "不用 API Key,能通过 Vertex AI 用 Gemini 吗?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "能。用项目 id 添加 Google Vertex AI 预设,比如 magpie provider add google-vertex project=my-project。magpie 用 gcloud 的应用默认凭据或凭据文件签名,费用记在你的项目上。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "能用 Gemini Code Assist 或 Antigravity 的登录吗?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "能。两者都是订阅:运行 magpie accounts add gemini 或 magpie accounts add antigravity,然后选 gemini/… 或 antigravity/… 模型。Code Assist 需要有自己 Google Cloud 项目的 Standard 或 Enterprise 账号。"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
</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/gemini" hreflang="en" lang="en">English</a>
|
||||
<a href="/docs/zh/gemini" hreflang="zh" lang="zh">中文</a>
|
||||
<a href="/docs/ja/gemini" 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="#thinking">思考</a>
|
||||
<a href="#signatures">思维签名与工具</a>
|
||||
<a href="#cost">缓存、费用与搜索</a>
|
||||
<a href="#keys">多个 Key 与限流</a>
|
||||
<a href="#vertex">Vertex AI</a>
|
||||
<a href="#signins">Google 登录</a>
|
||||
<a href="#trouble">常见报错</a>
|
||||
<a href="#faq">常见问题</a>
|
||||
</aside>
|
||||
|
||||
<article>
|
||||
<p class="eyebrow" id="overview">文档 · 供应商</p>
|
||||
<h1>Gemini 接入 Claude Code、Codex、Gemini CLI 和 OpenCode</h1>
|
||||
<p class="lede">Google 通过两条路提供 Gemini:一是 Gemini Developer API,也就是 AI Studio 的 Key 能用的那个;二是你自己 Google Cloud 项目里的 Vertex AI。任选一个添加到 magpie 一次,Claude Code、Codex、Gemini CLI、OpenCode 以及你接入的其他工具,都能通过 magpie 的本地网关 <code>127.0.0.1:3425</code> 使用 <code>gemini-3.1-pro-preview</code> 等 Gemini 3 模型,每个工具各用各的模型。</p>
|
||||
|
||||
<h2 id="add"><a class="anchor" href="#add">添加 Gemini API Key</a></h2>
|
||||
<ol class="steps">
|
||||
<li><b>拿到 Key</b>在 <a href="https://aistudio.google.com/apikey">aistudio.google.com/apikey</a> 创建。</li>
|
||||
<li><b>添加供应商</b>在 magpie 的 <span class="ui">供应商</span> 页点 <span class="ui">+ 添加供应商</span>,选 <span class="ui">Google Gemini</span>,粘贴 Key 并保存。magpie 会向 Google 查询它提供哪些模型。</li>
|
||||
<li><b>给工具选上</b>在 <span class="ui">Agent</span> 页点工具那一行的模型,选一个 Gemini 模型,比如 <code>gemini-3.1-pro-preview</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 google AIza…
|
||||
magpie provider test google</pre></div>
|
||||
<p>magpie 里的模型 id 是 <code>供应商/模型</code>,所以 Gemini API 的模型写作 <code>google/gemini-3.1-pro-preview</code>:前面是供应商,后面是 Google 自己的 id。Key 保存在 magpie 的设置里,magpie 不会从 shell 里读取它。</p>
|
||||
|
||||
<h2 id="endpoints"><a class="anchor" href="#endpoints">接口地址</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<tr><th>接口</th><th>Base URL</th><th>用途</th></tr>
|
||||
<tr><td>Chat Completions(OpenAI 兼容)</td><td><code>https://generativelanguage.googleapis.com/v1beta/openai</code></td><td>模型列表,以及 Claude Code、Codex、OpenCode 等工具的请求</td></tr>
|
||||
<tr><td>Gemini API</td><td><code>https://generativelanguage.googleapis.com/v1beta</code></td><td>Gemini CLI 的请求、Google 搜索、图像模型</td></tr>
|
||||
</table></div>
|
||||
<p>预设只会自动填一次 Gemini API 的地址;你清空之后,它就一直空着。不是 Gemini 客户端发来的请求,都走 Chat Completions。</p>
|
||||
|
||||
<h2 id="models"><a class="anchor" href="#models">模型列表</a></h2>
|
||||
<ul>
|
||||
<li><b>列表从哪来。</b>magpie 只向 OpenAI 兼容接口拉一次列表,这份列表同样适用于 Gemini API,不用再拉第二次。模型名、推理档位和价格来自 models.dev 上的 <code>google</code> 目录。</li>
|
||||
<li><b>图像模型。</b>在 Google 这里,Gemini 的图像模型通过 Gemini API 出图。在 <span class="ui">设置 → 模型 → 图像</span> 里选用。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="agents"><a class="anchor" href="#agents">在各个工具里用</a></h2>
|
||||
<p>在 <span class="ui">Agent</span> 页点工具那一行选模型,或者在终端里切换。每篇指南都写了 magpie 会改工具配置里的哪些内容,以及怎么切回去。</p>
|
||||
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-agents">复制</button><pre id="ex-agents">magpie claude google/gemini-3.1-pro-preview
|
||||
magpie codex google/gemini-3.1-pro-preview
|
||||
magpie gemini model google/gemini-3.8-flash
|
||||
magpie opencode google/gemini-3.1-pro-preview</pre></div>
|
||||
<ul>
|
||||
<li><b>Claude Code</b> 说的是 Anthropic Messages。magpie 把每个请求转换成 Gemini 的 Chat Completions,回复再转回 Messages,流式输出和工具调用都保留。<a href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>。</li>
|
||||
<li><b>Codex</b> 只说 OpenAI Responses。magpie 同样把它转换成 Chat Completions,回复再转回 Responses 交给 Codex。<a href="/docs/zh/codex-models">Codex 接入其他模型</a>。</li>
|
||||
<li><b>Gemini CLI</b> 说 Gemini 自己的 API,请求按原样发给 Gemini API,它的 Google 搜索也在那里执行。<a href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>。</li>
|
||||
<li><b>OpenCode</b> 说 Chat Completions,请求原样发给 Google。<a href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="thinking"><a class="anchor" href="#thinking">思考</a></h2>
|
||||
<ul>
|
||||
<li><b>显示思考过程。</b>Gemini 的 OpenAI 兼容接口只有在 <code>thinking_config</code> 里明确要求时才返回模型的思考内容。工具要求显示推理时,magpie 会带上 <code>include_thoughts</code> 去要,这样长时间的思考会显示成思考中,而不是迟迟等不到第一个字。</li>
|
||||
<li><b>档位与预算。</b>Gemini 3 及之后的模型收到的是思考档位;Gemini 2 系列收到的是预算:minimal 和 low 为 1024 个 token,medium 为 8192,high 为 24576。xhigh 和 max 按 high 发送;没有对应档位的强度交给模型自己决定。</li>
|
||||
<li><b>关闭推理。</b>Gemini 3 没法完全不思考。工具关闭推理时,magpie 改为要求该模型最低的档位。</li>
|
||||
<li><b>模型没有的档位。</b>不是每个 Gemini 3 都有全部档位,比如 <code>gemini-3.8-flash</code> 就没有 minimal。Google 用 400 拒绝某个档位时,magpie 会换成该模型最接近的档位再问一次,并在 magpie 重启前一直记住。</li>
|
||||
<li><b><code>thinking_config</code> 被拒。</b>这是另一种 400:挡在 Gemini 前面的服务不认这个字段本身。magpie 会只带 <code>reasoning_effort</code> 再问一次,之后不再向它发送 <code>thinking_config</code>。</li>
|
||||
<li><b>代理。</b>放在本机或局域网代理后面的 Gemini 模型,比如 <code>localhost</code> 或内网地址上的,也按同样的方式处理。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="signatures"><a class="anchor" href="#signatures">思维签名与工具</a></h2>
|
||||
<ul>
|
||||
<li><b>思维签名。</b>Gemini 3 会给每一步的第一个函数调用签名;签名丢了,下一个请求就会失败,报 400 “Function call is missing a thought_signature in functionCall parts”。工具本身不会保存签名,magpie 把它放进交给工具的调用 id 里(一个指向 magpie 目录中某个文件的简短引用),发往 Gemini 时再放回去。签名保留 90 天。</li>
|
||||
<li><b>Gemini 没签名的调用。</b>对话前面其他模型发出的调用,或者 id 被工具截短的调用,会带上 Google 文档里写明的 <code>skip_thought_signature_validator</code> 发送,所以对话中途换成 Gemini 也没问题。</li>
|
||||
<li><b>签名只回到原供应商。</b>签名只会发回给出它的那个供应商。在同时有 Vertex AI 和 Gemini API 的路由分组里,另一个供应商收到的是不带签名的历史调用,而不会报 “Corrupted thought signature”。</li>
|
||||
<li><b>工具的 schema。</b>magpie 会给工具里没写类型的 schema 补上类型(Vertex AI 要求必须有),并去掉布尔型 schema 和 <code>x-</code> 开头的关键字,比如 MCP 的 <code>x-mcp-header</code>。不需要处理的工具原样发送。</li>
|
||||
<li><b>流的结尾。</b>Gemini 的 OpenAI 兼容接口会把整个函数调用放在一个 chunk 里,<code>finish_reason</code> 放在下一个。如果用量已经收到而这个结束原因丢了,magpie 会补上;连用量都没收到,就把回复报告为被截断,而不是当作完整的交出去。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="cost"><a class="anchor" href="#cost">缓存、费用与搜索</a></h2>
|
||||
<ul>
|
||||
<li><b>提示缓存。</b>Gemini 缓存了提示,却不会在当轮说出来。magpie 把这样的一轮记为缓存写入,让下一轮继续走同一个供应商和 Key;是谁回答的也会记下来,重启后依然有效。</li>
|
||||
<li><b>缓存与思考 token。</b>无论走 Chat Completions 还是 Gemini API,magpie 都会从每个回复里读取缓存 token 和推理 token,<span class="ui">用量</span> 页会统计它们。</li>
|
||||
<li><b>费用。</b>用量页按 models.dev 上的 <code>google</code> 目录给每次调用计价。</li>
|
||||
<li><b>联网搜索。</b>Gemini API 只对没有声明函数工具的请求执行 Google 搜索。Claude Code 和 Codex 的请求都带工具,所以它们的联网搜索用的是 magpie 自己的搜索,由 Google 供应商用你的 Key 来回答:这些搜索会消耗你的 Gemini API 额度。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="keys"><a class="anchor" href="#keys">多个 Key 与限流</a></h2>
|
||||
<p>一个 Google Gemini 供应商可以放多个 Key:在它下面点 <span class="ui">添加另一个密钥</span>,也可以一次粘贴好几个。请求先走第一个开着的 Key,它用完或被限流时由下一个接替。也可以把供应商的路由方式改成轮流、按权重或用完一个再换下一个。</p>
|
||||
<ul>
|
||||
<li><b>每分钟限流的 429。</b>Gemini 因每分钟限额返回的 429 “You exceeded your current quota … Please retry in 33s”,magpie 视为限流而不是额度用完;Vertex AI 的 <code>requests_per_minute_per_project</code> 也一样。Key 先暂停一分钟,之后每次翻倍,最长到 <code>rest-cap</code>。</li>
|
||||
<li><b>控制速度。</b><code>rpm</code> 给每个 Key 限定每分钟的请求数:超出的请求排队等空位,最多等 2 分钟,再等不到就返回 429。</li>
|
||||
<li><b>额度用完。</b><code>quota-rest</code> 设定额度用完后 Key 暂停多久:默认 15 分钟,最长 8 天,也可以暂停到某个时刻。</li>
|
||||
<li><b>花费上限与备用模型。</b><code>spend-cap</code> 给 Key 设一个每天、每月或总计的美元上限;<code>fallback</code> 指定 Gemini 额度用完或挂掉时请求去哪。</li>
|
||||
</ul>
|
||||
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-keys">复制</button><pre id="ex-keys">magpie provider rpm google 10
|
||||
magpie provider spend-cap google <key> 20 month
|
||||
magpie provider fallback google google-vertex/gemini-3.1-pro-preview</pre></div>
|
||||
|
||||
<h2 id="vertex"><a class="anchor" href="#vertex">Vertex AI</a></h2>
|
||||
<p><span class="ui">Google Vertex AI</span> 预设在你自己的 Google Cloud 项目里调用 Gemini,不需要 API Key。填上项目 id 即可,费用记在请求里的这个项目上。</p>
|
||||
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-vertex">复制</button><pre id="ex-vertex">gcloud auth application-default login
|
||||
magpie provider add google-vertex project=my-project
|
||||
magpie claude google-vertex/gemini-3.1-pro-preview</pre></div>
|
||||
<ul>
|
||||
<li><b>凭据。</b>magpie 用 gcloud 的应用默认凭据(Application Default Credentials)签名,或者用 <code>credentials=</code> 以完整路径指定的文件:用户登录、服务账号密钥或模拟的服务账号都行。<code>impersonate=</code> 填服务账号的邮箱,需要你在该账号上有 <code>roles/iam.serviceAccountTokenCreator</code>。元数据服务器、工作负载身份联合以及 Vertex AI 快速模式的 API Key 都不会读取。</li>
|
||||
<li><b>区域。</b><code>location=</code> 可以是 <code>global</code>(默认)、<code>us</code>、<code>eu</code>,或 <code>us-central1</code> 这样的具体区域。</li>
|
||||
<li><b>模型。</b>这个预设有自己的模型列表,包括 <code>gemini-3.8-flash</code>、<code>gemini-3.1-pro-preview</code>、<code>gemini-2.5-pro</code>,<code>zai-org/glm-5.2-maas</code> 这类合作方模型,以及 <code>claude-opus-5-5</code> 这类 Claude 模型。Gemini 走 Vertex AI 的 Gemini API,合作方模型走它的 OpenAI 兼容 Chat Completions,Claude 走 Anthropic 的 Messages API,全都在你的项目里。</li>
|
||||
<li><b>Vertex AI 上的思考。</b>Gemini 3 的档位会对齐到该模型实际有的档位,关闭推理时用最低档。Gemini 2.5 用预算:Pro 为 128 到 32768 个 token(关闭时 128),Flash 最多 24576(关闭时 0),Flash-Lite 为 512 到 24576(关闭时 0)。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="signins"><a class="anchor" href="#signins">Google 登录</a></h2>
|
||||
<p>另有两种 Google 登录不用 Key 也能用 Gemini 模型。它们属于订阅,设置方法见 <a href="/docs/zh/subscriptions">订阅用于任意 Agent</a>。</p>
|
||||
<ul>
|
||||
<li><b>Gemini(Code Assist)。</b>这是 Gemini CLI 的 Google 登录,模型为 <code>gemini/…</code>:<code>magpie accounts add gemini</code>。Google 只对有自己 Google Cloud 项目的 Code Assist Standard 或 Enterprise 账号提供服务;用 <code>magpie accounts project gemini <邮箱> <项目></code> 指定项目。</li>
|
||||
<li><b>Antigravity。</b>模型为 <code>antigravity/…</code>:<code>magpie accounts add antigravity</code>。登录后可以用 Antigravity 的 Claude 和 Gemini 模型。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="trouble"><a class="anchor" href="#trouble">常见报错</a></h2>
|
||||
<ul>
|
||||
<li><b>“Thinking level MINIMAL is not supported for this model”。</b>这个模型没有 minimal 档位。magpie 会换成它最接近的档位再问一次,工具照样拿到回复,并在 magpie 重启前记住这个档位。只有在没有档位可换时,报错才会原样交给工具。</li>
|
||||
<li><b>“Function call is missing a thought_signature in functionCall parts”。</b>某个 Gemini 3 调用丢了签名。经过 magpie 时,签名放在调用 id 里并会被放回去,没有签名的调用会带上 <code>skip_thought_signature_validator</code>。</li>
|
||||
<li><b>“Corrupted thought signature”。</b>签名不完整,或者来自另一个供应商。magpie 只把签名发回给出它的供应商。</li>
|
||||
<li><b>429,提示 “Please retry in 33s”。</b>这是每分钟的限额,不是额度用完。Key 会短暂暂停;用 <code>rpm</code> 可以让之后的请求保持在限额以内。</li>
|
||||
<li><b>Vertex AI 报 schema “didn’t specify the schema type field”。</b>magpie 发给 Gemini 的每个工具 schema 都会补上类型,这个报错不应再传到工具那里。</li>
|
||||
<li><b>Vertex AI 保存不了。</b>提示 “Google Vertex AI needs the id of your Google Cloud project” 时,加上 <code>project=</code>。凭据文件必须写完整路径。</li>
|
||||
<li><b>检查 Key。</b><code>magpie provider test google</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 怎么用 Gemini?</h3>
|
||||
<p>在 magpie 里添加 Gemini API Key(供应商页,添加供应商,选 Google Gemini),然后在 Claude Code 那一行选一个模型,比如 <code>gemini-3.1-pro-preview</code>,或者运行 <code>magpie claude google/gemini-3.1-pro-preview</code>。magpie 会写好 Claude Code 的 <code>settings.json</code>,把每个 Messages 请求转换成 Gemini 的 Chat Completions,工具调用和流式输出都保留。</p>
|
||||
<h3>Codex 能用 Gemini 模型吗?</h3>
|
||||
<p>能。Codex 只说 Responses API,magpie 会把每个 Codex 请求转换成 Gemini 的 Chat Completions,回复再转回 Responses。运行 <code>magpie codex google/gemini-3.1-pro-preview</code>,或者在 Codex 那一行选模型。</p>
|
||||
<h3>Gemini 3 Pro 在 Claude Code 里连续调用工具会出错吗?</h3>
|
||||
<p>不会。Gemini 3 会给函数调用签名,下一个请求缺了签名就会被拒。magpie 把每个签名放进交给工具的调用 id 里,发往 Gemini 时再放回去,所以工具循环能一直进行;其他模型发出的调用会按无签名发送。</p>
|
||||
<h3>Gemini CLI 和 OpenCode 能通过 magpie 用我的 Gemini Key 吗?</h3>
|
||||
<p>能。Gemini CLI 的请求按原样发给 Gemini API,Google 搜索也一样。OpenCode 说 Chat Completions,请求原样发给 Gemini 的 OpenAI 兼容接口。</p>
|
||||
<h3>Gemini 为什么返回 429 并提示 “Please retry in 33s”?</h3>
|
||||
<p>这是每分钟的限额,不是额度用完。magpie 把它当作限流,让 Key 短暂暂停。运行 <code>magpie provider rpm google 10</code>(换成你自己的限额),magpie 就会把请求压在这个速度以内。</p>
|
||||
<h3>不用 API Key,能通过 Vertex AI 用 Gemini 吗?</h3>
|
||||
<p>能。用项目 id 添加 Google Vertex AI 预设,比如 <code>magpie provider add google-vertex project=my-project</code>。magpie 用 gcloud 的应用默认凭据或凭据文件签名,费用记在你的项目上。</p>
|
||||
<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 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>
|
||||
@@ -0,0 +1,338 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Grok 接入 Claude Code、Codex、Gemini CLI 和 OpenCode · magpie</title>
|
||||
<meta name="description" content="用 magpie 把 xAI 的 Grok 接入 Claude Code、Codex、Gemini CLI 和 OpenCode:xAI API Key 只添加一次,每个工具各选一个 Grok 模型,magpie 负责把各工具的请求调成 xAI 接口能接受的样子,还能联网搜索、统计缓存和费用,并在多个 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/grok">
|
||||
<link rel="alternate" hreflang="zh" href="https://usemagpie.ai/docs/zh/grok">
|
||||
<link rel="alternate" hreflang="ja" href="https://usemagpie.ai/docs/ja/grok">
|
||||
<link rel="alternate" hreflang="x-default" href="https://usemagpie.ai/docs/grok">
|
||||
<link rel="canonical" href="https://usemagpie.ai/docs/zh/grok">
|
||||
<link rel="stylesheet" href="/docs.css">
|
||||
<meta property="og:site_name" content="magpie">
|
||||
<meta property="og:title" content="Grok 接入 Claude Code、Codex、Gemini CLI 和 OpenCode">
|
||||
<meta property="og:description" content="用 magpie 把 xAI 的 Grok 接入 Claude Code、Codex、Gemini CLI 和 OpenCode:xAI API Key 只添加一次,每个工具各选一个 Grok 模型,magpie 负责把各工具的请求调成 xAI 接口能接受的样子,还能联网搜索、统计缓存和费用,并在多个 Key 之间分配请求。">
|
||||
<meta property="og:image" content="https://usemagpie.ai/img/og.png">
|
||||
<meta property="og:url" content="https://usemagpie.ai/docs/zh/grok">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@graph": [
|
||||
{
|
||||
"@type": "TechArticle",
|
||||
"headline": "Grok 接入 Claude Code、Codex、Gemini CLI 和 OpenCode",
|
||||
"description": "用 magpie 把 xAI 的 Grok 接入 Claude Code、Codex、Gemini CLI 和 OpenCode:xAI API Key 只添加一次,每个工具各选一个 Grok 模型,magpie 负责把各工具的请求调成 xAI 接口能接受的样子,还能联网搜索、统计缓存和费用,并在多个 Key 之间分配请求。",
|
||||
"inLanguage": "zh-CN",
|
||||
"url": "https://usemagpie.ai/docs/zh/grok",
|
||||
"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 怎么用 Grok?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "在 magpie 里添加 xAI 的 API Key(供应商页,添加供应商,选 xAI),然后在 Claude Code 那一行选一个 Grok 模型,比如 grok-4.7,或者运行 magpie claude xai/grok-4.7。Claude Code 的请求经过 magpie 的网关,发到 xAI 的 Anthropic Messages 接口 https://api.x.ai。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Codex 能用 Grok 4 吗?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "能。xAI 提供 Codex 说的 Responses 接口,所以 magpie codex xai/grok-4.7 会把 Codex 的请求原样发到 https://api.x.ai/v1,途中修正 xAI 不接受的内容:工具 schema、没有工具的 tool_choice,以及 Grok 写成 2500.0 的整数。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Gemini CLI 和 OpenCode 能用 Grok 吗?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "能。Gemini CLI 说 Google 的接口,magpie 把它的请求转成 xAI 的 Chat Completions,再把回复转回来。OpenCode 说 Chat Completions,请求原样发给 xAI。运行 magpie gemini model xai/grok-4.7 或 magpie opencode xai/grok-4.7 即可。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "用 Grok 能联网搜索吗?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "能。Codex 的联网搜索由 xAI 在自己的 Responses 接口上完成。Claude Code、Gemini CLI 和 OpenCode 则由 magpie 给模型提供自己的搜索工具,由设置里指定的搜索服务回答,或者由 magpie 自己挑一个。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "Codex 对话中途从 GPT 换到 Grok 为什么报错?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "xAI 读不了别家加密的推理内容,会回 “Could not decrypt the provided encrypted_content”。magpie 会去掉这些条目重新请求,并在这段对话后面都不再带上。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@type": "Question",
|
||||
"name": "magpie 能显示 xAI 的余额吗?",
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": "不能。用量页会统计每次 Grok 调用的 token、缓存和费用,按 models.dev 的价格计价,但 magpie 不会从 xAI 读取余额。你可以用 magpie provider key-balance 自己填上余额,用量页会显示它减去 magpie 此后算出的费用。"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
</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/grok" hreflang="en" lang="en">English</a>
|
||||
<a href="/docs/zh/grok" hreflang="zh" lang="zh">中文</a>
|
||||
<a href="/docs/ja/grok" 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">缓存、费用与用量</a>
|
||||
<a href="#keys">多个 Key</a>
|
||||
<a href="#trouble">常见报错</a>
|
||||
<a href="#faq">常见问题</a>
|
||||
</aside>
|
||||
|
||||
<article>
|
||||
<p class="eyebrow" id="overview">文档 · 供应商</p>
|
||||
<h1>Grok 接入 Claude Code、Codex、Gemini CLI 和 OpenCode</h1>
|
||||
<p class="lede">xAI 的 Grok 模型同时提供三种接口:OpenAI Chat Completions、OpenAI Responses 和 Anthropic Messages。把 xAI 的 API Key 添加到 magpie 一次,Claude Code、Codex、Gemini CLI、OpenCode 以及你接入的其他工具,都能通过 magpie 的本地网关 <code>127.0.0.1:3425</code> 使用 Grok,每个工具各用各的模型。</p>
|
||||
|
||||
<h2 id="add"><a class="anchor" href="#add">添加 xAI</a></h2>
|
||||
<ol class="steps">
|
||||
<li><b>拿到 Key</b>在 <a href="https://console.x.ai">console.x.ai</a> 创建。</li>
|
||||
<li><b>添加供应商</b>在 magpie 的 <span class="ui">供应商</span> 页点 <span class="ui">+ 添加供应商</span>,选 <span class="ui">xAI</span>,粘贴 Key 并保存。magpie 会向 xAI 查询这个 Key 能用哪些模型。</li>
|
||||
<li><b>给工具选上</b>在 <span class="ui">Agent</span> 页点工具那一行的模型,选一个 Grok 模型,比如 <code>grok-4.7</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 xai xai-…
|
||||
magpie provider test xai</pre></div>
|
||||
<p>magpie 里的模型 id 是 <code>供应商/模型</code>,所以 xAI 的模型写作 <code>xai/grok-4.7</code>:前面是供应商,后面是 xAI 自己的 id。Key 保存在 magpie 的设置里,magpie 不会从 shell 里读取它。</p>
|
||||
|
||||
<h2 id="endpoints"><a class="anchor" href="#endpoints">接口地址</a></h2>
|
||||
<div class="table-wrap"><table>
|
||||
<tr><th>接口</th><th>Base URL</th><th>用途</th></tr>
|
||||
<tr><td>Chat Completions</td><td><code>https://api.x.ai/v1</code></td><td>模型列表、OpenCode 的请求,以及 magpie 转换过的所有请求,Gemini CLI 的请求也在其中</td></tr>
|
||||
<tr><td>Responses</td><td><code>https://api.x.ai/v1</code></td><td>Codex 的请求,以及由 xAI 自己执行的联网搜索</td></tr>
|
||||
<tr><td>Anthropic Messages</td><td><code>https://api.x.ai</code></td><td>Claude Code 的请求</td></tr>
|
||||
</table></div>
|
||||
<p>工具说的接口如果 xAI 提供,请求就直接交给那个接口。需要转换时,magpie 用 Chat Completions:只有 OpenAI 官方的 OpenAI 模型优先走 Responses,只有 Claude 模型优先走 Messages,Grok 两者都不是。</p>
|
||||
|
||||
<h2 id="models"><a class="anchor" href="#models">模型列表</a></h2>
|
||||
<p>magpie 从 xAI 的 <code>https://api.x.ai/v1/models</code> 拉取模型列表,所以工具里看到的就是你这个 Key 能用的模型。模型名称、推理档位和价格来自 models.dev 的 <code>xai</code> 目录。想让工具看到哪些模型,可以在供应商的模型列表里勾选,也可以在终端里设置:</p>
|
||||
<div class="code"><span class="lang">终端</span><button class="copy" data-copy="ex-models">复制</button><pre id="ex-models">magpie provider models xai +grok-4.7
|
||||
magpie provider refresh-every xai 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 xai/grok-4.7
|
||||
magpie codex xai/grok-4.7
|
||||
magpie gemini model xai/grok-4.7
|
||||
magpie opencode xai/grok-4.7</pre></div>
|
||||
<ul>
|
||||
<li><b>Claude Code</b> 说 Anthropic Messages,xAI 在 <code>https://api.x.ai</code> 也提供这个接口,所以它的请求原样发过去,只做下面列出的修正。<a href="/docs/zh/claude-code-models">Claude Code 接入其他模型</a>。</li>
|
||||
<li><b>Codex</b> 说 OpenAI Responses,xAI 在 <code>https://api.x.ai/v1</code> 提供这个接口,所以它的请求也原样发过去。如果 xAI 拒绝 Codex 的自定义工具(“unknown variant <code>custom</code>”),magpie 之后会把这个模型的 Codex 请求转换后再发,并把这些工具当作普通函数提供。<a href="/docs/zh/codex-models">Codex 接入其他模型</a>。</li>
|
||||
<li><b>Gemini CLI</b> 说 Google 的 Gemini 接口,xAI 不提供。magpie 把每个请求转成 Chat Completions,再把回复转回来,流式输出和工具调用都包括在内。<a href="/docs/zh/gemini-cli-models">Gemini CLI 接入其他模型</a>。</li>
|
||||
<li><b>OpenCode</b> 说 Chat Completions,所以它的请求原样发给 xAI。<a href="/docs/zh/opencode-models">OpenCode 接入其他模型</a>。</li>
|
||||
</ul>
|
||||
<p>xAI 自己的命令行工具 Grok Build 也能用 magpie 的模型:magpie 把它们写进 <code>~/.grok/config.toml</code>,它们就会出现在 <code>/model</code> 的选择列表里。</p>
|
||||
|
||||
<h2 id="shaping"><a class="anchor" href="#shaping">magpie 替你修正的请求</a></h2>
|
||||
<p>工具发出的有些内容,xAI 的接口不接受。magpie 会在转发途中改好,原样转发的请求和转换过的请求都一样,工具不会再碰到这些报错:</p>
|
||||
<ul>
|
||||
<li><b>工具的正则。</b>xAI 用另一种正则引擎读工具的 <code>pattern</code>,像 Claude Code 在 Windows 上的 <code>^[^\s[\]]+$</code> 就会报 “Schema validation failed: … is not a "regex"”。magpie 会把它转义,让 xAI 按 JavaScript 的方式理解。</li>
|
||||
<li><b>工具参数的根。</b>参数以 <code>anyOf</code>、<code>oneOf</code> 或 <code>allOf</code> 开头的工具,比如 Codex 桌面版的自动化工具,从第一个请求起就被包成一个 object。不然 xAI 会回 “tool parameter root must be an object type”。</li>
|
||||
<li><b>空字段。</b>工具 schema 里的 <code>"required": null</code>,以及 Codex 推理条目上的 <code>"content": null</code>,都会被去掉。不然 xAI 会回 “/required: null is not of type "array"” 或 “Could not decode the compaction blob”。</li>
|
||||
<li><b>对话中途的系统消息。</b>Claude Code 在对话中间插入的系统消息,会并入最前面的系统提示。不然 xAI 会回 “Invalid request content: Invalid message role.”</li>
|
||||
<li><b>没有工具的 tool_choice。</b>设了 <code>tool_choice</code> 却没带任何工具的请求,比如 Codex 压缩上下文时的总结请求,会去掉这个字段再发。不然 xAI 会回 “A tool_choice was set on the request but no tools were specified”。</li>
|
||||
<li><b>Codex 追加的工具。</b>xAI 的 Responses 接口不认识 Codex 的 <code>additional_tools</code> 条目,magpie 会把其中的工具放进请求的 <code>tools</code> 里。</li>
|
||||
<li><b>整数。</b>Grok 在工具调用参数里写整数时会带小数部分,比如 <code>2500.0</code>,Codex 要求整数的字段不接受。magpie 会改写成 <code>2500</code>,流式回复里也一样。</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>xAI 只认它自己加密的推理内容。Codex 的对话从 GPT 或另一个账号换到 Grok 时,xAI 会回 “Could not decrypt the provided encrypted_content”。magpie 会立刻去掉这些条目重新请求,并在这段对话后面的请求里都不再带上。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="search"><a class="anchor" href="#search">联网搜索</a></h2>
|
||||
<ul>
|
||||
<li><b>Codex。</b>xAI 在自己的 Responses 接口上执行联网搜索,所以 Codex 的 <code>web_search</code> 由 xAI 完成。</li>
|
||||
<li><b>Claude Code、Gemini CLI 和 OpenCode。</b>xAI 的 Messages 和 Chat Completions 接口不会搜索,所以 magpie 给模型提供自己的搜索工具,由设置里指定的搜索服务回答;没指定时,由 magpie 自己挑一个。</li>
|
||||
<li><b>用 xAI 来搜索。</b>因为 xAI 能自己搜索,magpie 也可以挑一个 xAI 的 Key,替不会搜索的模型联网搜索。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="cost"><a class="anchor" href="#cost">缓存、费用与用量</a></h2>
|
||||
<ul>
|
||||
<li><b>缓存 token。</b>magpie 读取 xAI 在每次回复里报告的缓存 token,所以 <span class="ui">用量</span> 页会把缓存命中和其余的提示分开统计。</li>
|
||||
<li><b>保住缓存。</b>有多个 Key 时,只要一段对话的缓存值得保留(1,024 个 token 以上),而且还热着(五分钟内读过),它就一直用同一个 Key,不会把某一轮发给缓存已经凉了的 Key。</li>
|
||||
<li><b>费用。</b>用量页按 models.dev 上 xAI 的价格给每次 Grok 调用计价。</li>
|
||||
<li><b>余额。</b>magpie 不会从 xAI 读取余额。可以用 <code>key-balance</code> 自己填上,用量页会显示它减去 magpie 此后给这个 Key 的调用算出的费用。</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="keys"><a class="anchor" href="#keys">多个 Key 与故障切换</a></h2>
|
||||
<p>一个 xAI 供应商可以放多个 Key:在它下面点 <span class="ui">添加另一个密钥</span>,也可以一次粘贴好几个。请求先走第一个开着的 Key,它用完或被限流时由下一个接替。</p>
|
||||
<ul>
|
||||
<li><b>花费上限。</b><code>spend-cap</code> 给某个 Key 设一个每天、每月或总计的美元上限,按用量页的计价算;到了上限,路由就转去其他 Key 和备用模型。</li>
|
||||
<li><b>备用模型。</b><code>fallback</code> 指定 xAI 额度用完或挂掉时请求去哪:另一个供应商的模型,或一个路由分组。</li>
|
||||
<li><b>xAI 读不懂的请求。</b>xAI 回 422 “Failed to deserialize the JSON body … unknown item type” 时,请求会交给路由分组里的下一个成员,这个 Key 不会因此暂停。</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 xai <key> 20 month
|
||||
magpie provider key-balance xai <key> 25
|
||||
magpie provider fallback xai deepseek/deepseek-v4-pro</pre></div>
|
||||
|
||||
<h2 id="trouble"><a class="anchor" href="#trouble">常见报错</a></h2>
|
||||
<ul>
|
||||
<li><b>“maximum prompt length is …”。</b>对话超出了模型能接受的长度。magpie 会用工具看得懂的方式告诉它,也就是 <code>context_length_exceeded</code> 或 Anthropic 的 “prompt is too long”,工具就会压缩上下文再试。</li>
|
||||
<li><b>“Could not decrypt the provided encrypted_content”。</b>Codex 在对话中途换到了 Grok,对话里还带着别家的推理内容。magpie 会去掉它重新请求,见<a href="#reasoning">推理</a>。</li>
|
||||
<li><b>“unknown variant <code>custom</code>”。</b>xAI 拒绝了 Codex 的自定义工具。之后 magpie 会转换这个模型的 Codex 请求,这个报错只会出现一次。</li>
|
||||
<li><b>检查 Key。</b><code>magpie provider test xai</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 怎么用 Grok?</h3>
|
||||
<p>在 magpie 里添加 xAI 的 API Key(供应商页,添加供应商,选 xAI),然后在 Claude Code 那一行选一个 Grok 模型,比如 <code>grok-4.7</code>,或者运行 <code>magpie claude xai/grok-4.7</code>。Claude Code 的请求经过 magpie 的网关,发到 xAI 的 Anthropic Messages 接口 <code>https://api.x.ai</code>。</p>
|
||||
<h3>Codex 能用 Grok 4 吗?</h3>
|
||||
<p>能。xAI 提供 Codex 说的 Responses 接口,所以 <code>magpie codex xai/grok-4.7</code> 会把 Codex 的请求原样发到 <code>https://api.x.ai/v1</code>,途中修正 xAI 不接受的内容:工具 schema、没有工具的 tool_choice,以及 Grok 写成 <code>2500.0</code> 的整数。</p>
|
||||
<h3>Gemini CLI 和 OpenCode 能用 Grok 吗?</h3>
|
||||
<p>能。Gemini CLI 说 Google 的接口,magpie 把它的请求转成 xAI 的 Chat Completions,再把回复转回来。OpenCode 说 Chat Completions,请求原样发给 xAI。运行 <code>magpie gemini model xai/grok-4.7</code> 或 <code>magpie opencode xai/grok-4.7</code> 即可。</p>
|
||||
<h3>用 Grok 能联网搜索吗?</h3>
|
||||
<p>能。Codex 的联网搜索由 xAI 在自己的 Responses 接口上完成。Claude Code、Gemini CLI 和 OpenCode 则由 magpie 给模型提供自己的搜索工具,由设置里指定的搜索服务回答,或者由 magpie 自己挑一个。</p>
|
||||
<h3>Codex 对话中途从 GPT 换到 Grok 为什么报错?</h3>
|
||||
<p>xAI 读不了别家加密的推理内容,会回 “Could not decrypt the provided encrypted_content”。magpie 会去掉这些条目重新请求,并在这段对话后面都不再带上。</p>
|
||||
<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 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>
|
||||
@@ -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/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/openrouter">OpenRouter</a> · <a href="/docs/zh/copilot">GitHub Copilot</a></p>
|
||||
|
||||
<h2 id="faq"><a class="anchor" href="#faq">常见问题</a></h2>
|
||||
<h3>OpenCode 怎么用 DeepSeek?</h3>
|
||||
|
||||
@@ -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/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/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>
|
||||
|
||||
+300
-6
@@ -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) · [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) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot)
|
||||
|
||||
## 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) · [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) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot)
|
||||
|
||||
## 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) · [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) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot)
|
||||
|
||||
## 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) · [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) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [GitHub Copilot](https://usemagpie.ai/docs/copilot)
|
||||
|
||||
## 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) · [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) · [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.
|
||||
|
||||
@@ -1814,7 +1814,301 @@ 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) · [OpenRouter](https://usemagpie.ai/docs/openrouter) · [Claude, ChatGPT and other subscriptions](https://usemagpie.ai/docs/subscriptions)
|
||||
**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)
|
||||
|
||||
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/gemini
|
||||
|
||||
# Gemini in Claude Code, Codex, Gemini CLI and OpenCode
|
||||
|
||||
Google serves Gemini on the Gemini Developer API, the one an AI Studio key opens, and on Vertex AI in your own Google Cloud project. Add either to magpie once, and Claude Code, Codex, Gemini CLI, OpenCode and every other agent you connect can use Gemini 3 models such as `gemini-3.1-pro-preview` through magpie’s gateway at `127.0.0.1:3425`, each agent on a model of its own.
|
||||
|
||||
## Add a Gemini API key
|
||||
|
||||
1. **Get a key.** Make one on [aistudio.google.com/apikey](https://aistudio.google.com/apikey).
|
||||
2. **Add the provider.** In magpie’s Providers tab, press + Add provider, pick Google Gemini, paste the key and save. magpie asks Google which models it serves.
|
||||
3. **Pick it for an agent.** In the Agents tab, click the model on the agent’s row and choose a Gemini model such as `gemini-3.1-pro-preview`.
|
||||
|
||||
```
|
||||
magpie provider add google AIza…
|
||||
magpie provider test google
|
||||
```
|
||||
|
||||
Model ids in magpie are `provider/model`, so the Gemini API’s read `google/gemini-3.1-pro-preview`: the provider, then Google’s own id. The key is kept in magpie’s settings; magpie doesn’t take it from your shell.
|
||||
|
||||
## Endpoints
|
||||
|
||||
| API | Base URL | Used for |
|
||||
| --- | --- | --- |
|
||||
| Chat Completions (OpenAI-compatible) | `https://generativelanguage.googleapis.com/v1beta/openai` | the model list, and requests from Claude Code, Codex, OpenCode and other agents |
|
||||
| Gemini API | `https://generativelanguage.googleapis.com/v1beta` | Gemini CLI’s requests, Google Search, image models |
|
||||
|
||||
The preset fills in the Gemini API URL once. If you clear it, it stays empty. Every request that doesn’t come from a Gemini client goes to Chat Completions.
|
||||
|
||||
## Model list
|
||||
|
||||
- **Where it comes from..** magpie asks the OpenAI-compatible endpoint for the list once. It is the Gemini API’s list too, so magpie doesn’t ask twice. Names, reasoning levels and prices come from the `google` catalog on models.dev.
|
||||
- **Image models..** At Google, a Gemini image model draws on the Gemini API. Choose one in Settings → Models → Images.
|
||||
|
||||
## In each agent
|
||||
|
||||
Pick the model on an agent’s row in the Agents tab, or from a terminal. Each guide says what magpie writes in that agent’s config and how to switch back.
|
||||
|
||||
```
|
||||
magpie claude google/gemini-3.1-pro-preview
|
||||
magpie codex google/gemini-3.1-pro-preview
|
||||
magpie gemini model google/gemini-3.8-flash
|
||||
magpie opencode google/gemini-3.1-pro-preview
|
||||
```
|
||||
|
||||
- **Claude Code.** speaks Anthropic Messages. magpie translates each request to Gemini’s Chat Completions and the reply back to Messages, streaming and tool calls included. [Models in Claude Code](https://usemagpie.ai/docs/claude-code-models).
|
||||
- **Codex.** speaks only OpenAI Responses. magpie translates it to Chat Completions the same way, and the reply comes back to Codex as Responses. [Models in Codex](https://usemagpie.ai/docs/codex-models).
|
||||
- **Gemini CLI.** speaks Gemini’s own API, so its requests go to the Gemini API as it sends them, and its Google Search runs there. [Models in Gemini CLI](https://usemagpie.ai/docs/gemini-cli-models).
|
||||
- **OpenCode.** speaks Chat Completions, so its requests go to Google as they are. [Models in OpenCode](https://usemagpie.ai/docs/opencode-models).
|
||||
|
||||
## Thinking
|
||||
|
||||
- **Visible thoughts..** Gemini’s OpenAI-compatible API gives the model’s thoughts only when asked in `thinking_config`. When an agent asks for visible reasoning, magpie asks for the thoughts with `include_thoughts`, so a long think shows as thinking instead of a first word that comes late.
|
||||
- **Levels and budgets..** Gemini 3 and later are sent a thinking level. Gemini 2 models are sent a budget instead: 1024 tokens for minimal and low, 8192 for medium and 24576 for high. xhigh and max are sent as high, and an effort with no level is left to the model.
|
||||
- **Reasoning off..** Gemini 3 can’t stop thinking. When an agent turns reasoning off, magpie asks for the model’s lowest level instead.
|
||||
- **A level the model doesn’t have..** Not every Gemini 3 has every level: `gemini-3.8-flash` has no minimal. When Google turns a level away with a 400, magpie asks again at the nearest level the model has and remembers it until magpie restarts.
|
||||
- **`thinking_config` turned away..** That is a different 400: a server in front of Gemini that refuses the field itself. magpie asks again with `reasoning_effort` alone and stops sending `thinking_config` there.
|
||||
- **Proxies..** A Gemini model behind a proxy on this computer or your network, such as one on `localhost` or a private address, is handled the same way.
|
||||
|
||||
## Thought signatures and tools
|
||||
|
||||
- **Thought signatures..** Gemini 3 signs the first function call of each step, and the next request fails with 400 “Function call is missing a thought_signature in functionCall parts” if the signature is gone. Agents don’t keep it. magpie carries it in the call id the agent gets, as a short reference to a file in magpie’s folder, and puts it back on the way to Gemini. Signatures are kept for 90 days.
|
||||
- **Calls Gemini didn’t sign..** A call from another model earlier in the conversation, or one whose id an agent shortened, goes with Google’s documented `skip_thought_signature_validator`, so a conversation can move to Gemini halfway.
|
||||
- **One provider’s signature..** A signature goes back only to the provider that gave it. In a routing group of Vertex AI and the Gemini API, the other provider gets the call as unsigned history instead of answering “Corrupted thought signature”.
|
||||
- **Tool schemas..** magpie gives each untyped schema in an agent’s tools a type, which Vertex AI needs, and removes boolean schemas and `x-` keywords such as MCP’s `x-mcp-header`. Tools that need none of this go as they came.
|
||||
- **The end of a stream..** Gemini’s OpenAI-compatible API sends a whole function call in one chunk and its `finish_reason` in the next. If that reason is lost after the usage arrived, magpie fills it in; without the usage, the reply is reported as cut off rather than passed on as complete.
|
||||
|
||||
## Cache, cost and search
|
||||
|
||||
- **Prompt cache..** Gemini keeps a prompt cached without saying so on that turn. magpie counts such a turn as a cache write and keeps the next turn on the same provider and key, and remembers which one answered across restarts.
|
||||
- **Cached and thinking tokens..** magpie reads cached tokens and reasoning tokens from each reply, on Chat Completions and on the Gemini API alike, and the Usage tab counts them.
|
||||
- **Cost..** The Usage tab prices each call from the `google` catalog on models.dev.
|
||||
- **Web search..** Gemini runs Google Search on the Gemini API only for a request that declares no function tools. Claude Code’s and Codex’s requests declare tools, so their web search is magpie’s own, which the Google provider answers itself on your key: those searches spend your Gemini API credit.
|
||||
|
||||
## Several keys and rate limits
|
||||
|
||||
One Google Gemini 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. The provider’s routing can also rotate, weight or drain them instead.
|
||||
|
||||
- **Per-minute 429s..** Gemini’s 429 “You exceeded your current quota … Please retry in 33s” for a per-minute limit is read as a rate limit, not a used-up plan, and so is Vertex AI’s `requests_per_minute_per_project`. The key rests from a minute, doubling, up to `rest-cap`.
|
||||
- **Holding to a rate..** `rpm` holds each key to a number of requests a minute: one request more waits for room, up to 2 minutes, then gets a 429.
|
||||
- **Out of quota..** `quota-rest` sets how long a key rests once its quota is spent: 15 minutes by default, up to 8 days, or until a time of day.
|
||||
- **Spend caps and fallbacks..** `spend-cap` stops a key at a dollar amount a day, a month or in all, and `fallback` names where requests go when Gemini is out of quota or down.
|
||||
|
||||
```
|
||||
magpie provider rpm google 10
|
||||
magpie provider spend-cap google <key> 20 month
|
||||
magpie provider fallback google google-vertex/gemini-3.1-pro-preview
|
||||
```
|
||||
|
||||
## Vertex AI
|
||||
|
||||
The Google Vertex AI preset asks Gemini in your Google Cloud project, with no API key. Give it the project’s id; the project in each request is the one billed.
|
||||
|
||||
```
|
||||
gcloud auth application-default login
|
||||
magpie provider add google-vertex project=my-project
|
||||
magpie claude google-vertex/gemini-3.1-pro-preview
|
||||
```
|
||||
|
||||
- **Credentials..** magpie signs with gcloud’s Application Default Credentials, or with the file `credentials=` names by its full path: a user sign-in, a service account key or an impersonated service account. `impersonate=` takes a service account’s email, and needs `roles/iam.serviceAccountTokenCreator` on it. The metadata server, workload identity federation and Vertex AI’s express-mode API keys aren’t read.
|
||||
- **Location..** `location=` is `global` (the default), `us`, `eu` or a region such as `us-central1`.
|
||||
- **Models..** The preset has its own list, among them `gemini-3.8-flash`, `gemini-3.1-pro-preview`, `gemini-2.5-pro`, partner models such as `zai-org/glm-5.2-maas`, and Claude models such as `claude-opus-5-5`. Gemini goes to Vertex AI’s Gemini API, a partner model to its OpenAI-compatible chat completions, and Claude to Anthropic’s Messages API, all in your project.
|
||||
- **Thinking on Vertex AI..** A Gemini 3 level is fitted to the levels that model has, and reasoning off asks for its lowest. Gemini 2.5 takes a budget: Pro from 128 to 32768 tokens (128 when off), Flash up to 24576 (0 when off), Flash-Lite from 512 to 24576 (0 when off).
|
||||
|
||||
## Google sign-ins
|
||||
|
||||
Two Google sign-ins give Gemini models without a key. They are subscriptions, set up as on [Subscriptions in any agent](https://usemagpie.ai/docs/subscriptions).
|
||||
|
||||
- **Gemini (Code Assist)..** Gemini CLI’s Google sign-in, as `gemini/…`: `magpie accounts add gemini`. Google answers it only for a Code Assist Standard or Enterprise account with a Google Cloud project of its own; `magpie accounts project gemini <email> <project>` names the project.
|
||||
- **Antigravity..** As `antigravity/…`: `magpie accounts add antigravity`. Its sign-in gives Antigravity’s Claude and Gemini models.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **“Thinking level MINIMAL is not supported for this model”..** The model has no minimal level. magpie asks again at the nearest level it has, so the agent gets its answer, and remembers the level until magpie restarts. Only when no level is left does the error reach the agent as Google sent it.
|
||||
- **“Function call is missing a thought_signature in functionCall parts”..** A Gemini 3 call lost its signature. Through magpie the signature rides in the call id and is put back, and a call with none goes with `skip_thought_signature_validator`.
|
||||
- **“Corrupted thought signature”..** The signature was cut short or came from another provider. magpie sends a signature only to the provider that gave it.
|
||||
- **429 with “Please retry in 33s”..** A per-minute limit, not a spent plan. The key rests for a short while, and `rpm` keeps requests under the limit from then on.
|
||||
- **Vertex AI: a schema “didn’t specify the schema type field”..** magpie types every untyped tool schema it sends to Gemini, so this shouldn’t reach the agent.
|
||||
- **Vertex AI won’t save..** “Google Vertex AI needs the id of your Google Cloud project”: add `project=`. A credentials file has to be given by its full path.
|
||||
- **Checking a key..** `magpie provider test google` 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 Gemini in Claude Code?
|
||||
|
||||
Add a Gemini API key in magpie (Providers, Add provider, Google Gemini), then pick a model such as `gemini-3.1-pro-preview` on Claude Code’s row, or run `magpie claude google/gemini-3.1-pro-preview`. magpie writes Claude Code’s `settings.json` and translates each Messages request to Gemini’s Chat Completions, tool calls and streaming included.
|
||||
|
||||
### Can Codex use Gemini models?
|
||||
|
||||
Yes. Codex speaks only the Responses API. magpie translates each Codex request to Gemini’s Chat Completions and the reply back to Responses. Run `magpie codex google/gemini-3.1-pro-preview`, or pick the model on Codex’s row.
|
||||
|
||||
### Does Gemini 3 Pro keep working across tool calls in Claude Code?
|
||||
|
||||
Yes. Gemini 3 signs its function calls and refuses the next request without the signature. magpie carries each signature in the call id the agent gets and puts it back on the way to Gemini, so tool loops keep going, and a call from another model is sent as unsigned.
|
||||
|
||||
### Can Gemini CLI and OpenCode use my Gemini key through magpie?
|
||||
|
||||
Yes. Gemini CLI’s requests go to the Gemini API as it sends them, Google Search included. OpenCode speaks Chat Completions, so its requests go to Gemini’s OpenAI-compatible API as they are.
|
||||
|
||||
### Why does Gemini answer 429 with “Please retry in 33s”?
|
||||
|
||||
That is a per-minute limit, not a spent quota. magpie reads it as a rate limit and rests the key briefly. Run `magpie provider rpm google 10`, with your own limit, and magpie holds requests to that rate.
|
||||
|
||||
### Can I use Gemini through Vertex AI instead of an API key?
|
||||
|
||||
Yes. Add the Google Vertex AI preset with your project’s id, for example `magpie provider add google-vertex project=my-project`. magpie signs with gcloud’s Application Default Credentials or a credentials file, and your project is billed.
|
||||
|
||||
### Can I use my Gemini Code Assist or Antigravity sign-in instead?
|
||||
|
||||
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)
|
||||
|
||||
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/grok
|
||||
|
||||
# Grok in Claude Code, Codex, Gemini CLI and OpenCode
|
||||
|
||||
xAI serves its Grok models on three APIs at once: OpenAI Chat Completions, OpenAI Responses and Anthropic Messages. Add an xAI API key to magpie once, and Claude Code, Codex, Gemini CLI, OpenCode and every other agent you connect can use Grok through magpie’s local gateway at `127.0.0.1:3425`, each agent with a model of its own.
|
||||
|
||||
## Add xAI
|
||||
|
||||
1. **Get a key.** Make one on [console.x.ai](https://console.x.ai).
|
||||
2. **Add the provider.** In magpie’s Providers tab, press + Add provider, pick xAI, paste the key and save. magpie asks xAI 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 Grok model such as `grok-4.7`.
|
||||
|
||||
```
|
||||
magpie provider add xai xai-…
|
||||
magpie provider test xai
|
||||
```
|
||||
|
||||
Model ids in magpie are `provider/model`, so xAI’s read `xai/grok-4.7`: the provider, then xAI’s own id. The key is kept in magpie’s settings; magpie doesn’t take it from your shell.
|
||||
|
||||
## Endpoints
|
||||
|
||||
| API | Base URL | Used for |
|
||||
| --- | --- | --- |
|
||||
| Chat Completions | `https://api.x.ai/v1` | the model list, OpenCode’s requests, and every request magpie translates, Gemini CLI’s among them |
|
||||
| Responses | `https://api.x.ai/v1` | Codex’s requests, and web search that xAI runs itself |
|
||||
| Anthropic Messages | `https://api.x.ai` | Claude Code’s requests |
|
||||
|
||||
An agent whose API xAI serves is passed on to that API. When magpie has to translate, it uses Chat Completions: it keeps Responses first only for OpenAI’s own models at OpenAI, and Messages first only for Claude models, and Grok is neither.
|
||||
|
||||
## Model list
|
||||
|
||||
magpie fetches the list from xAI, at `https://api.x.ai/v1/models`, so agents see the models your key can use. Names, reasoning levels and prices come from models.dev’s `xai` catalog. Pick the models agents see in the provider’s model list, or from the terminal:
|
||||
|
||||
```
|
||||
magpie provider models xai +grok-4.7
|
||||
magpie provider refresh-every xai 1d
|
||||
```
|
||||
|
||||
## In each agent
|
||||
|
||||
```
|
||||
magpie claude xai/grok-4.7
|
||||
magpie codex xai/grok-4.7
|
||||
magpie gemini model xai/grok-4.7
|
||||
magpie opencode xai/grok-4.7
|
||||
```
|
||||
|
||||
- **Claude Code.** speaks Anthropic Messages, and so does xAI at `https://api.x.ai`, so its requests go there as they are, with the fixes below. [Models in Claude Code](https://usemagpie.ai/docs/claude-code-models).
|
||||
- **Codex.** speaks OpenAI Responses, which xAI serves at `https://api.x.ai/v1`, so its requests go there as they are too. If xAI turns away Codex’s custom tools (“unknown variant `custom`”), magpie translates that model’s Codex requests from then on and offers those tools as ordinary functions. [Models in Codex](https://usemagpie.ai/docs/codex-models).
|
||||
- **Gemini CLI.** speaks Google’s Gemini API, which xAI doesn’t serve. magpie translates each request to Chat Completions and the reply back, streaming and tool calls included. [Models in Gemini CLI](https://usemagpie.ai/docs/gemini-cli-models).
|
||||
- **OpenCode.** speaks Chat Completions, so its requests go to xAI as they are. [Models in OpenCode](https://usemagpie.ai/docs/opencode-models).
|
||||
|
||||
Grok Build, xAI’s own CLI, can take magpie’s models too: magpie adds them to `~/.grok/config.toml`, so they join its `/model` picker.
|
||||
|
||||
## What magpie fixes for xAI
|
||||
|
||||
xAI’s API turns away a few things that agents send. magpie changes them on the way, on requests it passes on and on those it translates alike, so the agent never sees these errors:
|
||||
|
||||
- **Tool patterns..** xAI reads a tool’s `pattern` with a different regex engine, so a pattern such as Claude Code’s `^[^\s[\]]+$` on Windows failed with “Schema validation failed: … is not a "regex"”. magpie escapes it so xAI reads it as JavaScript does.
|
||||
- **Tool roots..** A tool whose parameters start with `anyOf`, `oneOf` or `allOf`, such as a Codex desktop automation tool, is folded into an object from the first request. xAI otherwise answers “tool parameter root must be an object type”.
|
||||
- **Empty fields..** `"required": null` in a tool’s schema, and `"content": null` on a Codex reasoning item, are left out. xAI otherwise answers “/required: null is not of type "array"” or “Could not decode the compaction blob”.
|
||||
- **System turns..** Claude Code’s system turns in the middle of a conversation are folded into the top-level system prompt. xAI otherwise answers “Invalid request content: Invalid message role.”
|
||||
- **A tool choice with no tools..** A request that sets `tool_choice` but offers no tools, such as Codex’s compaction summary, goes without it. xAI otherwise answers “A tool_choice was set on the request but no tools were specified”.
|
||||
- **Codex’s added tools..** xAI’s Responses API doesn’t know Codex’s `additional_tools` items, so magpie puts their tools in the request’s `tools`.
|
||||
- **Whole numbers..** Grok writes whole numbers in tool-call arguments with a fraction, such as `2500.0`, which Codex’s whole-number fields refuse. magpie writes `2500`, in streamed replies too.
|
||||
|
||||
## 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.
|
||||
- **Switching models mid-conversation..** xAI reads only the sealed reasoning it wrote itself. When a Codex conversation moves to Grok from GPT or from another account, xAI answers “Could not decrypt the provided encrypted_content”. magpie asks again without those items at once, and leaves them out for the rest of that conversation.
|
||||
|
||||
## Web search
|
||||
|
||||
- **Codex..** xAI runs web search itself on its Responses API, so Codex’s `web_search` is done by xAI.
|
||||
- **Claude Code, Gemini CLI and OpenCode..** xAI’s Messages and Chat Completions APIs don’t search, so magpie gives the model its own search tool, answered by the searcher chosen in Settings, or by one magpie picks when none is chosen.
|
||||
- **xAI as the searcher..** Because xAI searches by itself, magpie can pick an xAI key to search for models that can’t.
|
||||
|
||||
## Cache, cost and usage
|
||||
|
||||
- **Cache tokens..** magpie reads the cached tokens xAI reports in each reply, so the Usage tab counts cache hits 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, so a turn isn’t sent to a key with a cold cache.
|
||||
- **Cost..** The Usage tab prices each Grok call with xAI’s prices from models.dev.
|
||||
- **Balance..** magpie reads no balance from xAI. Type it in yourself 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 xAI 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 xAI is out of quota or down: another provider’s model or a routing group.
|
||||
- **A request xAI can’t read..** When xAI answers 422 “Failed to deserialize the JSON body … unknown item type”, the request goes to the next member of the routing group, and the key isn’t rested for it.
|
||||
|
||||
```
|
||||
magpie provider spend-cap xai <key> 20 month
|
||||
magpie provider key-balance xai <key> 25
|
||||
magpie provider fallback xai deepseek/deepseek-v4-pro
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **“maximum prompt length is …”..** The conversation is longer than the model takes. 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.
|
||||
- **“Could not decrypt the provided encrypted_content”..** Codex moved to Grok mid-conversation with another vendor’s reasoning in it. magpie asks again without it; see Reasoning.
|
||||
- **“unknown variant `custom`”..** xAI turned away Codex’s custom tools. magpie translates that model’s Codex requests from then on; the first refusal is the last.
|
||||
- **Checking a key..** `magpie provider test xai` 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 Grok in Claude Code?
|
||||
|
||||
Add your xAI API key in magpie (Providers, Add provider, xAI), then pick a Grok model such as `grok-4.7` on Claude Code’s row, or run `magpie claude xai/grok-4.7`. Claude Code’s requests go through magpie’s gateway to xAI’s Anthropic Messages endpoint, `https://api.x.ai`.
|
||||
|
||||
### Can Codex use Grok 4?
|
||||
|
||||
Yes. xAI serves the Responses API that Codex speaks, so `magpie codex xai/grok-4.7` sends Codex’s requests to `https://api.x.ai/v1` as they are, with what xAI would refuse fixed on the way: tool schemas, a tool choice with no tools, and whole numbers Grok writes as `2500.0`.
|
||||
|
||||
### Can Gemini CLI and OpenCode use Grok?
|
||||
|
||||
Yes. Gemini CLI speaks Google’s API, so magpie translates its requests to xAI’s Chat Completions and the replies back. OpenCode speaks Chat Completions, so its requests go to xAI as they are. Run `magpie gemini model xai/grok-4.7` or `magpie opencode xai/grok-4.7`.
|
||||
|
||||
### Does web search work with Grok?
|
||||
|
||||
Yes. Codex’s web search is run by xAI itself on its Responses API. For Claude Code, Gemini CLI and OpenCode, magpie gives the model its own search tool, answered by the searcher chosen in Settings, or by one magpie picks.
|
||||
|
||||
### Why did Codex fail after switching from GPT to Grok mid-conversation?
|
||||
|
||||
xAI can’t read reasoning that another vendor sealed, and answers “Could not decrypt the provided encrypted_content”. magpie asks again without those items and leaves them out for the rest of the conversation.
|
||||
|
||||
### Does magpie show my xAI balance?
|
||||
|
||||
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)
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@ DeepSeek, Kimi (Moonshot), GLM (Zhipu), Qwen, MiniMax, Anthropic (Claude), OpenA
|
||||
- [MiniMax and the Coding Plan in every agent](https://usemagpie.ai/docs/minimax): MiniMax M3 and M2.7, pay as you go or Coding Plan keys, global and China endpoints, interleaved thinking, effort and the plan's usage windows.
|
||||
- [OpenRouter in every agent](https://usemagpie.ai/docs/openrouter): one OpenRouter key for Claude Code, Codex, Gemini CLI and OpenCode; which endpoint each agent's requests use, the model list, reasoning, Claude's prompt cache, cost and credits, several keys and free models.
|
||||
- [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.
|
||||
- [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.
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
<url><loc>https://usemagpie.ai/docs/minimax</loc></url>
|
||||
<url><loc>https://usemagpie.ai/docs/openrouter</loc></url>
|
||||
<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/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>
|
||||
@@ -56,6 +58,8 @@
|
||||
<url><loc>https://usemagpie.ai/docs/zh/minimax</loc></url>
|
||||
<url><loc>https://usemagpie.ai/docs/zh/openrouter</loc></url>
|
||||
<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/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>
|
||||
@@ -81,4 +85,6 @@
|
||||
<url><loc>https://usemagpie.ai/docs/ja/minimax</loc></url>
|
||||
<url><loc>https://usemagpie.ai/docs/ja/openrouter</loc></url>
|
||||
<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>
|
||||
</urlset>
|
||||
|
||||
Reference in New Issue
Block a user