diff --git a/site/public/docs/claude-code-models.html b/site/public/docs/claude-code-models.html index c4723af55..e684450d1 100644 --- a/site/public/docs/claude-code-models.html +++ b/site/public/docs/claude-code-models.html @@ -251,7 +251,7 @@ magpie claude codex/gpt-5.5

The routing modes are in Get started.

-

By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · OpenRouter · GitHub Copilot

+

By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · OpenRouter · GitHub Copilot

FAQ

Do I set ANTHROPIC_BASE_URL myself?

diff --git a/site/public/docs/codex-models.html b/site/public/docs/codex-models.html index 0bb96c7ea..974363b9d 100644 --- a/site/public/docs/codex-models.html +++ b/site/public/docs/codex-models.html @@ -251,7 +251,7 @@ magpie codex claude/…

The routing modes are in Get started.

-

By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · OpenRouter · GitHub Copilot

+

By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · OpenRouter · GitHub Copilot

FAQ

Do I write [model_providers] myself?

diff --git a/site/public/docs/copilot.html b/site/public/docs/copilot.html index 09fb7bb81..5f13d5f5b 100644 --- a/site/public/docs/copilot.html +++ b/site/public/docs/copilot.html @@ -297,7 +297,7 @@ magpie opencode copilot/claude-opus-5.5

Why is a Copilot model missing from my list?

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 · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · OpenRouter · Claude, ChatGPT and other subscriptions

+

By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · OpenRouter

Every agent: Models in Claude Code, Models in Codex, Models in Gemini CLI, Models in OpenCode. Ask on Discord if you get stuck.

diff --git a/site/public/docs/gemini-cli-models.html b/site/public/docs/gemini-cli-models.html index 4c50ab8c6..91479bb59 100644 --- a/site/public/docs/gemini-cli-models.html +++ b/site/public/docs/gemini-cli-models.html @@ -235,7 +235,7 @@ magpie gemini model codex/gpt-5.5

The routing modes and rules are in Get started.

-

By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · OpenRouter · GitHub Copilot

+

By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · OpenRouter · GitHub Copilot

FAQ

Can Gemini CLI use models that aren’t Gemini?

diff --git a/site/public/docs/gemini.html b/site/public/docs/gemini.html new file mode 100644 index 000000000..70c410577 --- /dev/null +++ b/site/public/docs/gemini.html @@ -0,0 +1,365 @@ + + + + + +Gemini in Claude Code, Codex, Gemini CLI and OpenCode · magpie + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+

Docs · Provider

+

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 keyMake one on aistudio.google.com/apikey.
  2. +
  3. Add the providerIn magpie’s Providers tab, press + Add provider, pick Google Gemini, paste the key and save. magpie asks Google which models it serves.
  4. +
  5. Pick it for an agentIn the Agents tab, click the model on the agent’s row and choose a Gemini model such as gemini-3.1-pro-preview.
  6. +
+
Terminal
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

+
+ + + +
APIBase URLUsed for
Chat Completions (OpenAI-compatible)https://generativelanguage.googleapis.com/v1beta/openaithe model list, and requests from Claude Code, Codex, OpenCode and other agents
Gemini APIhttps://generativelanguage.googleapis.com/v1betaGemini 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

+ + +

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.

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

Thinking

+ + +

Thought signatures and tools

+ + +

Cache, cost and search

+ + +

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.

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

+
Terminal
gcloud auth application-default login
+magpie provider add google-vertex project=my-project
+magpie claude google-vertex/gemini-3.1-pro-preview
+ + +

Google sign-ins

+

Two Google sign-ins give Gemini models without a key. They are subscriptions, set up as on Subscriptions in any agent.

+ + +

Troubleshooting

+ + +

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 · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · Grok · OpenRouter · GitHub Copilot

+

Every agent: Models in Claude Code, Models in Codex, Models in Gemini CLI, Models in OpenCode. Ask on Discord if you get stuck.

+
+
+ + + + + + + diff --git a/site/public/docs/grok.html b/site/public/docs/grok.html new file mode 100644 index 000000000..1679bf52e --- /dev/null +++ b/site/public/docs/grok.html @@ -0,0 +1,338 @@ + + + + + +Grok in Claude Code, Codex, Gemini CLI and OpenCode · magpie + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+

Docs · Provider

+

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 keyMake one on console.x.ai.
  2. +
  3. Add the providerIn magpie’s Providers tab, press + Add provider, pick xAI, paste the key and save. magpie asks xAI which models the key can use.
  4. +
  5. Pick it for an agentIn the Agents tab, click the model on the agent’s row and choose a Grok model such as grok-4.7.
  6. +
+
Terminal
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

+
+ + + + +
APIBase URLUsed for
Chat Completionshttps://api.x.ai/v1the model list, OpenCode’s requests, and every request magpie translates, Gemini CLI’s among them
Responseshttps://api.x.ai/v1Codex’s requests, and web search that xAI runs itself
Anthropic Messageshttps://api.x.aiClaude 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:

+
Terminal
magpie provider models xai +grok-4.7
+magpie provider refresh-every xai 1d
+ +

In each agent

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

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:

+ + +

Reasoning

+ + + + + +

Cache, cost and usage

+ + +

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.

+ +
Terminal
magpie provider spend-cap xai <key> 20 month
+magpie provider key-balance xai <key> 25
+magpie provider fallback xai deepseek/deepseek-v4-pro
+ +

Troubleshooting

+ + +

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 · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · OpenRouter · GitHub Copilot

+

Every agent: Models in Claude Code, Models in Codex, Models in Gemini CLI, Models in OpenCode. Ask on Discord if you get stuck.

+
+
+ + + + + + + diff --git a/site/public/docs/ja/claude-code-models.html b/site/public/docs/ja/claude-code-models.html index f72ed846a..334f777e7 100644 --- a/site/public/docs/ja/claude-code-models.html +++ b/site/public/docs/ja/claude-code-models.html @@ -251,7 +251,7 @@ magpie claude codex/gpt-5.5

ルーティングモードははじめにで説明しています。

-

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · OpenRouter · GitHub Copilot

+

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · OpenRouter · GitHub Copilot

よくある質問

ANTHROPIC_BASE_URL は自分で設定しますか?

diff --git a/site/public/docs/ja/codex-models.html b/site/public/docs/ja/codex-models.html index 711083878..00a655d78 100644 --- a/site/public/docs/ja/codex-models.html +++ b/site/public/docs/ja/codex-models.html @@ -251,7 +251,7 @@ magpie codex claude/…

ルーティングモードははじめにで説明しています。

-

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · OpenRouter · GitHub Copilot

+

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · OpenRouter · GitHub Copilot

よくある質問

[model_providers] は自分で書きますか?

diff --git a/site/public/docs/ja/copilot.html b/site/public/docs/ja/copilot.html index e0917256b..be5e5ecf2 100644 --- a/site/public/docs/ja/copilot.html +++ b/site/public/docs/ja/copilot.html @@ -297,7 +297,7 @@ magpie opencode copilot/claude-opus-5.5

Copilot のモデルが一覧にないのはなぜですか?

magpie が並べるのは、Copilot の /models がそのアカウントに返すモデルです。チャットモデルだけで、どのモデルピッカーにも出ないものと、そのアカウントで有効にできないものは除きます。Copilot が「The requested model is not supported.」で断ったモデルは 6 時間外し、プランが変わった場合に備えてその後もう一度試します。

-

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · OpenRouter · Claude・ChatGPT などのサブスク

+

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · OpenRouter

ツールごとのガイド:Claude Code で他のモデル、Codex で他のモデル、Gemini CLI で他のモデル、OpenCode で他のモデル。困ったときは Discord で質問してください。

diff --git a/site/public/docs/ja/gemini-cli-models.html b/site/public/docs/ja/gemini-cli-models.html index 704917205..3600b1f81 100644 --- a/site/public/docs/ja/gemini-cli-models.html +++ b/site/public/docs/ja/gemini-cli-models.html @@ -235,7 +235,7 @@ magpie gemini model codex/gpt-5.5

ルーティングモードとルールははじめにで説明しています。

-

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · OpenRouter · GitHub Copilot

+

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · OpenRouter · GitHub Copilot

よくある質問

Gemini CLI で Gemini 以外のモデルを使えますか?

diff --git a/site/public/docs/ja/gemini.html b/site/public/docs/ja/gemini.html new file mode 100644 index 000000000..3d189189f --- /dev/null +++ b/site/public/docs/ja/gemini.html @@ -0,0 +1,365 @@ + + + + + +Gemini を Claude Code・Codex・Gemini CLI・OpenCode で使う · magpie + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+

ドキュメント · プロバイダ

+

Gemini を Claude Code・Codex・Gemini CLI・OpenCode で使う

+

Google は Gemini を二つの形で提供しています。AI Studio のキーで使う Gemini Developer API と、自分の Google Cloud プロジェクトで使う Vertex AI です。どちらかを magpie に一度追加すれば、Claude Code・Codex・Gemini CLI・OpenCode などつないだすべてのツールが、magpie のゲートウェイ 127.0.0.1:3425 経由で gemini-3.1-pro-preview などの Gemini 3 モデルを使えます。ツールごとに別のモデルを選べます。

+ +

Gemini API キーを追加する

+
    +
  1. キーを取得aistudio.google.com/apikey で作ります。
  2. +
  3. プロバイダを追加magpie の プロバイダ で + プロバイダを追加 を押し、Google Gemini を選んでキーを貼り付け、保存します。magpie が Google に提供モデルを問い合わせます。
  4. +
  5. ツールで選ぶエージェント タブで、ツールの行の gemini-3.1-pro-preview などの Gemini モデルを選びます。
  6. +
+
ターミナル
magpie provider add google AIza…
+magpie provider test google
+

magpie のモデル ID は プロバイダ/モデル の形なので、Gemini API のモデルは google/gemini-3.1-pro-preview のようになります。前がプロバイダ、後ろが Google 自身の ID です。キーは magpie の設定に保存され、magpie がシェルから読むことはありません。

+ +

エンドポイント

+
+ + + +
APIベース URL用途
Chat Completions(OpenAI 互換)https://generativelanguage.googleapis.com/v1beta/openaiモデル一覧、Claude Code・Codex・OpenCode などのリクエスト
Gemini APIhttps://generativelanguage.googleapis.com/v1betaGemini CLI のリクエスト、Google 検索、画像モデル
+

プリセットが Gemini API の URL を入れるのは一度だけです。消すと空のままになります。Gemini のクライアント以外から来たリクエストは、すべて Chat Completions に送られます。

+ +

モデル一覧

+ + +

ツールごとの使い方

+

エージェント タブでツールの行からモデルを選ぶか、ターミナルで切り替えます。各ガイドには、magpie がそのツールの設定に何を書き込むか、元に戻す方法が書いてあります。

+
ターミナル
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
+ + +

思考

+ + +

思考シグネチャとツール

+ + +

キャッシュ・費用・検索

+ + +

複数のキーとレート制限

+

一つの Google Gemini プロバイダに複数のキーを入れられます。その下の 別のキーを追加 を押すか、まとめて貼り付けます。リクエストはオンになっている最初のキーに行き、そのキーが尽きるかレート制限にかかると次のキーが引き継ぎます。プロバイダのルーティングを、順番に回す・重みで分ける・一つを使い切ってから次へ、に変えることもできます。

+ +
ターミナル
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

+

Google Vertex AI プリセットは、API キーなしで、自分の Google Cloud プロジェクトの Gemini を呼びます。プロジェクト ID を指定すれば、リクエストに入ったそのプロジェクトに課金されます。

+
ターミナル
gcloud auth application-default login
+magpie provider add google-vertex project=my-project
+magpie claude google-vertex/gemini-3.1-pro-preview
+ + +

Google のサインイン

+

キーなしで Gemini モデルを使える Google のサインインが二つあります。どちらもサブスクで、設定は サブスクを任意のエージェントで のとおりです。

+ + +

うまくいかないとき

+ + +

よくある質問

+

Claude Code で Gemini を使うには?

+

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 に変換します。ツール呼び出しもストリーミングもそのまま使えます。

+

Codex で Gemini のモデルは使えますか?

+

使えます。Codex が話すのは Responses API だけなので、magpie が Codex のリクエストを一つずつ Gemini の Chat Completions に変換し、返答を Responses に戻します。magpie codex google/gemini-3.1-pro-preview を実行するか、Codex の行でモデルを選びます。

+

Claude Code で Gemini 3 Pro にツールを続けて呼ばせても大丈夫ですか?

+

大丈夫です。Gemini 3 は関数呼び出しに署名し、シグネチャのない次のリクエストを断ります。magpie はシグネチャをツールに渡す呼び出し ID に入れて運び、Gemini に送るときに戻すので、ツールのループは止まりません。別のモデルが出した呼び出しは署名なしとして送ります。

+

Gemini CLI や OpenCode でも magpie 経由で Gemini のキーを使えますか?

+

使えます。Gemini CLI のリクエストは Google 検索も含めてそのまま Gemini API に渡ります。OpenCode は Chat Completions を話すので、リクエストはそのまま Gemini の OpenAI 互換 API に渡ります。

+

Gemini が 429 で “Please retry in 33s” と返すのはなぜですか?

+

1 分あたりの上限で、クォータを使い切ったわけではありません。magpie はレート制限として扱い、キーを少し休ませます。magpie provider rpm google 10 のように自分の上限で実行すれば、magpie がリクエストをその速さに抑えます。

+

API キーではなく Vertex AI で Gemini を使えますか?

+

使えます。プロジェクト ID を付けて Google Vertex AI プリセットを追加します。たとえば magpie provider add google-vertex project=my-project。magpie は gcloud のアプリケーションのデフォルト認証情報か認証情報ファイルで署名し、課金はあなたのプロジェクトに入ります。

+

Gemini Code Assist や Antigravity のサインインは使えますか?

+

使えます。どちらもサブスクです。magpie accounts add gemini か magpie accounts add antigravity を実行し、gemini/… か antigravity/… のモデルを選びます。Code Assist には、専用の Google Cloud プロジェクトを持つ Standard または Enterprise のアカウントが必要です。

+ +

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · Grok · OpenRouter · GitHub Copilot

+

ツールごとのガイド:Claude Code で他のモデル、Codex で他のモデル、Gemini CLI で他のモデル、OpenCode で他のモデル。困ったときは Discord で質問してください。

+
+
+ + + + + + + diff --git a/site/public/docs/ja/grok.html b/site/public/docs/ja/grok.html new file mode 100644 index 000000000..3fb9d10fb --- /dev/null +++ b/site/public/docs/ja/grok.html @@ -0,0 +1,338 @@ + + + + + +Grok を Claude Code・Codex・Gemini CLI・OpenCode で使う · magpie + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+

ドキュメント · プロバイダ

+

Grok を Claude Code・Codex・Gemini CLI・OpenCode で使う

+

xAI は Grok のモデルを OpenAI Chat Completions・OpenAI Responses・Anthropic Messages の三つの API で提供しています。xAI の API キーを magpie に一度追加すれば、Claude Code・Codex・Gemini CLI・OpenCode などつないだすべてのツールが、magpie のゲートウェイ 127.0.0.1:3425 経由で Grok を使えます。ツールごとに別のモデルを選べます。

+ +

xAI を追加する

+
    +
  1. キーを取得console.x.ai で作ります。
  2. +
  3. プロバイダを追加magpie の プロバイダ で + プロバイダを追加 を押し、xAI を選んでキーを貼り付け、保存します。magpie がそのキーで使えるモデルを xAI に問い合わせます。
  4. +
  5. ツールで選ぶエージェント タブで、ツールの行のモデルを押し、grok-4.7 などの Grok モデルを選びます。
  6. +
+
ターミナル
magpie provider add xai xai-…
+magpie provider test xai
+

magpie のモデル ID は プロバイダ/モデル の形なので、xAI のモデルは xai/grok-4.7 のようになります。前がプロバイダ、後ろが xAI 自身の ID です。キーは magpie の設定に保存され、magpie がシェルから読むことはありません。

+ +

エンドポイント

+
+ + + + +
APIベース URL用途
Chat Completionshttps://api.x.ai/v1モデル一覧、OpenCode のリクエスト、magpie が変換するすべてのリクエスト(Gemini CLI のものを含む)
Responseshttps://api.x.ai/v1Codex のリクエストと、xAI 自身が行う Web 検索
Anthropic Messageshttps://api.x.aiClaude Code のリクエスト
+

ツールの話す API を xAI が提供していれば、リクエストはその API にそのまま渡します。変換が必要なときは Chat Completions を使います。Responses を優先するのは OpenAI での OpenAI 自身のモデルだけ、Messages を優先するのは Claude モデルだけで、Grok はどちらでもないからです。

+ +

モデル一覧

+

magpie は一覧を xAI の https://api.x.ai/v1/models から取得するので、ツールにはそのキーで使えるモデルが並びます。名前・推論レベル・価格は models.dev の xai カタログから取ります。ツールに見せるモデルは、プロバイダのモデル一覧かターミナルで選べます。

+
ターミナル
magpie provider models xai +grok-4.7
+magpie provider refresh-every xai 1d
+ +

ツールごとの使い方

+
ターミナル
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
+ +

xAI 自身の CLI である Grok Build でも magpie のモデルを使えます。magpie がそれらを ~/.grok/config.toml に書き込むので、/model の選択肢に並びます。

+ +

magpie が xAI 向けに直すもの

+

ツールが送るもののうち、いくつかは xAI の API に拒否されます。magpie はそのまま渡すリクエストでも変換するリクエストでも途中でそれを直すので、ツールがこれらのエラーを見ることはありません。

+ + +

推論

+ + + + + +

キャッシュ・費用・使用量

+ + +

複数のキーとフェイルオーバー

+

一つの xAI プロバイダに複数のキーを入れられます。その下の 別のキーを追加 を押すか、まとめて貼り付けます。リクエストはオンになっている最初のキーに行き、そのキーが尽きるかレート制限にかかると次のキーが引き継ぎます。

+ +
ターミナル
magpie provider spend-cap xai <key> 20 month
+magpie provider key-balance xai <key> 25
+magpie provider fallback xai deepseek/deepseek-v4-pro
+ +

うまくいかないとき

+ + +

よくある質問

+

Claude Code で Grok を使うには?

+

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 に届きます。

+

Codex で Grok 4 は使えますか?

+

使えます。xAI は Codex が話す Responses API を提供しているので、magpie codex xai/grok-4.7 で Codex のリクエストは https://api.x.ai/v1 にそのまま届きます。ツールのスキーマ、ツールのない tool_choice、Grok が 2500.0 と書く整数など、xAI が拒否するものは途中で直します。

+

Gemini CLI と OpenCode で Grok は使えますか?

+

使えます。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 を実行してください。

+

Grok で Web 検索はできますか?

+

できます。Codex の Web 検索は xAI が Responses API で自ら行います。Claude Code・Gemini CLI・OpenCode では、magpie がモデルに自前の検索ツールを渡し、設定で指定した検索サービスか magpie が選んだものが答えます。

+

Codex の会話の途中で GPT から Grok に替えたらエラーになるのはなぜ?

+

xAI はほかのベンダーが封じた推論を読めず、“Could not decrypt the provided encrypted_content” を返します。magpie はそのアイテムを外して問い合わせ直し、その会話の残りでも外したままにします。

+

magpie で xAI の残高は見られますか?

+

見られません。使用量タブは Grok の呼び出しごとにトークン・キャッシュ・費用を models.dev の価格で数えますが、magpie は xAI から残高を読みません。magpie provider key-balance で残高を入力すると、使用量ページはそこから magpie がそれ以降に計算した費用を引いて表示します。

+ +

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · OpenRouter · GitHub Copilot

+

ツールごとのガイド:Claude Code で他のモデル、Codex で他のモデル、Gemini CLI で他のモデル、OpenCode で他のモデル。困ったときは Discord で質問してください。

+
+
+ + + + + + + diff --git a/site/public/docs/ja/opencode-models.html b/site/public/docs/ja/opencode-models.html index aaf325d27..24f6e4d59 100644 --- a/site/public/docs/ja/opencode-models.html +++ b/site/public/docs/ja/opencode-models.html @@ -239,7 +239,7 @@ magpie visible opencode all # すべてに戻す
ターミナル
magpie opencode default

magpie を使う前の model と small_model が戻り、magpie プロバイダがファイルから取り除かれます。

-

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · OpenRouter · GitHub Copilot

+

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · OpenRouter · GitHub Copilot

よくある質問

OpenCode で DeepSeek を使うには?

diff --git a/site/public/docs/ja/openrouter.html b/site/public/docs/ja/openrouter.html index 3a5148ebe..b932f4d9b 100644 --- a/site/public/docs/ja/openrouter.html +++ b/site/public/docs/ja/openrouter.html @@ -288,7 +288,7 @@ magpie group set opus-anywhere stays=session models+=openrouter/anthropic/claude

magpie が OpenRouter のモデル一覧を /api/v1 から取るのはなぜ?

Anthropic のベース URL で一覧を求めると、OpenRouter は anthropic/ の下に並べたカタログを返しますが、その ID では提供していません。magpie は Chat Completions のベース URL https://openrouter.ai/api/v1 から一覧を取り、OpenRouter の Anthropic のベース URL しかないプロバイダには、この Chat の URL を足すよう案内します。

-

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · GitHub Copilot

+

プロバイダ別:DeepSeek · Kimi と Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · GitHub Copilot

ツールごとのガイド:Claude Code で他のモデル、Codex で他のモデル、Gemini CLI で他のモデル、OpenCode で他のモデル。困ったときは Discord で質問してください。

diff --git a/site/public/docs/opencode-models.html b/site/public/docs/opencode-models.html index 32641e8d7..4f7545823 100644 --- a/site/public/docs/opencode-models.html +++ b/site/public/docs/opencode-models.html @@ -239,7 +239,7 @@ magpie visible opencode all # every model again
Terminal
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 · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · OpenRouter · GitHub Copilot

+

By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · OpenRouter · GitHub Copilot

FAQ

How do I use DeepSeek in OpenCode?

diff --git a/site/public/docs/openrouter.html b/site/public/docs/openrouter.html index 88613a74f..d70d1eb02 100644 --- a/site/public/docs/openrouter.html +++ b/site/public/docs/openrouter.html @@ -288,7 +288,7 @@ magpie group set opus-anywhere stays=session models+=openrouter/anthropic/claude

Why does magpie fetch OpenRouter’s model list from /api/v1?

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 · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · GitHub Copilot

+

By provider: DeepSeek · Kimi and Kimi Code · GLM Coding Plan · Qwen · MiniMax · Gemini · Grok · GitHub Copilot

Every agent: Models in Claude Code, Models in Codex, Models in Gemini CLI, Models in OpenCode. Ask on Discord if you get stuck.

diff --git a/site/public/docs/zh/claude-code-models.html b/site/public/docs/zh/claude-code-models.html index dcc48b747..ac64d6c5b 100644 --- a/site/public/docs/zh/claude-code-models.html +++ b/site/public/docs/zh/claude-code-models.html @@ -251,7 +251,7 @@ magpie claude codex/gpt-5.5

各种路由方式见 快速上手。

-

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · OpenRouter · GitHub Copilot

+

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · Gemini · Grok · OpenRouter · GitHub Copilot

常见问题

需要自己设置 ANTHROPIC_BASE_URL 吗?

diff --git a/site/public/docs/zh/codex-models.html b/site/public/docs/zh/codex-models.html index 128424765..964ae07ac 100644 --- a/site/public/docs/zh/codex-models.html +++ b/site/public/docs/zh/codex-models.html @@ -251,7 +251,7 @@ magpie codex claude/…

各种路由方式见 快速上手。

-

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · OpenRouter · GitHub Copilot

+

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · Gemini · Grok · OpenRouter · GitHub Copilot

常见问题

需要自己写 [model_providers] 吗?

diff --git a/site/public/docs/zh/copilot.html b/site/public/docs/zh/copilot.html index d8874edf9..786b77fea 100644 --- a/site/public/docs/zh/copilot.html +++ b/site/public/docs/zh/copilot.html @@ -297,7 +297,7 @@ magpie opencode copilot/claude-opus-5.5

为什么我的列表里少了某个 Copilot 模型?

magpie 列出的是 Copilot 的 /models 给这个账号的模型:只有对话模型,不含任何模型选择器都不提供的,也不含这个账号无法开启的。被 Copilot 用“The requested model is not supported.”拒绝的模型会被隐藏 6 小时,之后再试,以防你的套餐已经变了。

-

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · OpenRouter · Claude、ChatGPT 等订阅

+

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · Gemini · Grok · OpenRouter

各个工具的指南:Claude Code 接入其他模型、Codex 接入其他模型、Gemini CLI 接入其他模型、OpenCode 接入其他模型。遇到问题可以在 Discord 提问。

diff --git a/site/public/docs/zh/gemini-cli-models.html b/site/public/docs/zh/gemini-cli-models.html index 0399a48e8..06f40157c 100644 --- a/site/public/docs/zh/gemini-cli-models.html +++ b/site/public/docs/zh/gemini-cli-models.html @@ -235,7 +235,7 @@ magpie gemini model codex/gpt-5.5

路由方式和规则详见 快速上手。

-

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · OpenRouter · GitHub Copilot

+

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · Gemini · Grok · OpenRouter · GitHub Copilot

常见问题

Gemini CLI 能用 Gemini 以外的模型吗?

diff --git a/site/public/docs/zh/gemini.html b/site/public/docs/zh/gemini.html new file mode 100644 index 000000000..62b6d8d97 --- /dev/null +++ b/site/public/docs/zh/gemini.html @@ -0,0 +1,365 @@ + + + + + +Gemini 接入 Claude Code、Codex、Gemini CLI 和 OpenCode · magpie + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+

文档 · 供应商

+

Gemini 接入 Claude Code、Codex、Gemini CLI 和 OpenCode

+

Google 通过两条路提供 Gemini:一是 Gemini Developer API,也就是 AI Studio 的 Key 能用的那个;二是你自己 Google Cloud 项目里的 Vertex AI。任选一个添加到 magpie 一次,Claude Code、Codex、Gemini CLI、OpenCode 以及你接入的其他工具,都能通过 magpie 的本地网关 127.0.0.1:3425 使用 gemini-3.1-pro-preview 等 Gemini 3 模型,每个工具各用各的模型。

+ +

添加 Gemini API Key

+
    +
  1. 拿到 Key在 aistudio.google.com/apikey 创建。
  2. +
  3. 添加供应商在 magpie 的 供应商 页点 + 添加供应商,选 Google Gemini,粘贴 Key 并保存。magpie 会向 Google 查询它提供哪些模型。
  4. +
  5. 给工具选上在 Agent 页点工具那一行的模型,选一个 Gemini 模型,比如 gemini-3.1-pro-preview。
  6. +
+
终端
magpie provider add google AIza…
+magpie provider test google
+

magpie 里的模型 id 是 供应商/模型,所以 Gemini API 的模型写作 google/gemini-3.1-pro-preview:前面是供应商,后面是 Google 自己的 id。Key 保存在 magpie 的设置里,magpie 不会从 shell 里读取它。

+ +

接口地址

+
+ + + +
接口Base URL用途
Chat Completions(OpenAI 兼容)https://generativelanguage.googleapis.com/v1beta/openai模型列表,以及 Claude Code、Codex、OpenCode 等工具的请求
Gemini APIhttps://generativelanguage.googleapis.com/v1betaGemini CLI 的请求、Google 搜索、图像模型
+

预设只会自动填一次 Gemini API 的地址;你清空之后,它就一直空着。不是 Gemini 客户端发来的请求,都走 Chat Completions。

+ +

模型列表

+ + +

在各个工具里用

+

在 Agent 页点工具那一行选模型,或者在终端里切换。每篇指南都写了 magpie 会改工具配置里的哪些内容,以及怎么切回去。

+
终端
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
+ + +

思考

+ + +

思维签名与工具

+ + +

缓存、费用与搜索

+ + +

多个 Key 与限流

+

一个 Google Gemini 供应商可以放多个 Key:在它下面点 添加另一个密钥,也可以一次粘贴好几个。请求先走第一个开着的 Key,它用完或被限流时由下一个接替。也可以把供应商的路由方式改成轮流、按权重或用完一个再换下一个。

+ +
终端
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

+

Google Vertex AI 预设在你自己的 Google Cloud 项目里调用 Gemini,不需要 API Key。填上项目 id 即可,费用记在请求里的这个项目上。

+
终端
gcloud auth application-default login
+magpie provider add google-vertex project=my-project
+magpie claude google-vertex/gemini-3.1-pro-preview
+ + +

Google 登录

+

另有两种 Google 登录不用 Key 也能用 Gemini 模型。它们属于订阅,设置方法见 订阅用于任意 Agent。

+ + +

常见报错

+ + +

常见问题

+

Claude Code 怎么用 Gemini?

+

在 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,工具调用和流式输出都保留。

+

Codex 能用 Gemini 模型吗?

+

能。Codex 只说 Responses API,magpie 会把每个 Codex 请求转换成 Gemini 的 Chat Completions,回复再转回 Responses。运行 magpie codex google/gemini-3.1-pro-preview,或者在 Codex 那一行选模型。

+

Gemini 3 Pro 在 Claude Code 里连续调用工具会出错吗?

+

不会。Gemini 3 会给函数调用签名,下一个请求缺了签名就会被拒。magpie 把每个签名放进交给工具的调用 id 里,发往 Gemini 时再放回去,所以工具循环能一直进行;其他模型发出的调用会按无签名发送。

+

Gemini CLI 和 OpenCode 能通过 magpie 用我的 Gemini Key 吗?

+

能。Gemini CLI 的请求按原样发给 Gemini API,Google 搜索也一样。OpenCode 说 Chat Completions,请求原样发给 Gemini 的 OpenAI 兼容接口。

+

Gemini 为什么返回 429 并提示 “Please retry in 33s”?

+

这是每分钟的限额,不是额度用完。magpie 把它当作限流,让 Key 短暂暂停。运行 magpie provider rpm google 10(换成你自己的限额),magpie 就会把请求压在这个速度以内。

+

不用 API Key,能通过 Vertex AI 用 Gemini 吗?

+

能。用项目 id 添加 Google Vertex AI 预设,比如 magpie provider add google-vertex project=my-project。magpie 用 gcloud 的应用默认凭据或凭据文件签名,费用记在你的项目上。

+

能用 Gemini Code Assist 或 Antigravity 的登录吗?

+

能。两者都是订阅:运行 magpie accounts add gemini 或 magpie accounts add antigravity,然后选 gemini/… 或 antigravity/… 模型。Code Assist 需要有自己 Google Cloud 项目的 Standard 或 Enterprise 账号。

+ +

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · Grok · OpenRouter · GitHub Copilot

+

各个工具的指南:Claude Code 接入其他模型、Codex 接入其他模型、Gemini CLI 接入其他模型、OpenCode 接入其他模型。遇到问题可以在 Discord 提问。

+
+
+ + + + + + + diff --git a/site/public/docs/zh/grok.html b/site/public/docs/zh/grok.html new file mode 100644 index 000000000..aaa77d33f --- /dev/null +++ b/site/public/docs/zh/grok.html @@ -0,0 +1,338 @@ + + + + + +Grok 接入 Claude Code、Codex、Gemini CLI 和 OpenCode · magpie + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+

文档 · 供应商

+

Grok 接入 Claude Code、Codex、Gemini CLI 和 OpenCode

+

xAI 的 Grok 模型同时提供三种接口:OpenAI Chat Completions、OpenAI Responses 和 Anthropic Messages。把 xAI 的 API Key 添加到 magpie 一次,Claude Code、Codex、Gemini CLI、OpenCode 以及你接入的其他工具,都能通过 magpie 的本地网关 127.0.0.1:3425 使用 Grok,每个工具各用各的模型。

+ +

添加 xAI

+
    +
  1. 拿到 Key在 console.x.ai 创建。
  2. +
  3. 添加供应商在 magpie 的 供应商 页点 + 添加供应商,选 xAI,粘贴 Key 并保存。magpie 会向 xAI 查询这个 Key 能用哪些模型。
  4. +
  5. 给工具选上在 Agent 页点工具那一行的模型,选一个 Grok 模型,比如 grok-4.7。
  6. +
+
终端
magpie provider add xai xai-…
+magpie provider test xai
+

magpie 里的模型 id 是 供应商/模型,所以 xAI 的模型写作 xai/grok-4.7:前面是供应商,后面是 xAI 自己的 id。Key 保存在 magpie 的设置里,magpie 不会从 shell 里读取它。

+ +

接口地址

+
+ + + + +
接口Base URL用途
Chat Completionshttps://api.x.ai/v1模型列表、OpenCode 的请求,以及 magpie 转换过的所有请求,Gemini CLI 的请求也在其中
Responseshttps://api.x.ai/v1Codex 的请求,以及由 xAI 自己执行的联网搜索
Anthropic Messageshttps://api.x.aiClaude Code 的请求
+

工具说的接口如果 xAI 提供,请求就直接交给那个接口。需要转换时,magpie 用 Chat Completions:只有 OpenAI 官方的 OpenAI 模型优先走 Responses,只有 Claude 模型优先走 Messages,Grok 两者都不是。

+ +

模型列表

+

magpie 从 xAI 的 https://api.x.ai/v1/models 拉取模型列表,所以工具里看到的就是你这个 Key 能用的模型。模型名称、推理档位和价格来自 models.dev 的 xai 目录。想让工具看到哪些模型,可以在供应商的模型列表里勾选,也可以在终端里设置:

+
终端
magpie provider models xai +grok-4.7
+magpie provider refresh-every xai 1d
+ +

在各个工具里用

+
终端
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
+ +

xAI 自己的命令行工具 Grok Build 也能用 magpie 的模型:magpie 把它们写进 ~/.grok/config.toml,它们就会出现在 /model 的选择列表里。

+ +

magpie 替你修正的请求

+

工具发出的有些内容,xAI 的接口不接受。magpie 会在转发途中改好,原样转发的请求和转换过的请求都一样,工具不会再碰到这些报错:

+ + +

推理

+ + + + + +

缓存、费用与用量

+ + +

多个 Key 与故障切换

+

一个 xAI 供应商可以放多个 Key:在它下面点 添加另一个密钥,也可以一次粘贴好几个。请求先走第一个开着的 Key,它用完或被限流时由下一个接替。

+ +
终端
magpie provider spend-cap xai <key> 20 month
+magpie provider key-balance xai <key> 25
+magpie provider fallback xai deepseek/deepseek-v4-pro
+ +

常见报错

+ + +

常见问题

+

Claude Code 怎么用 Grok?

+

在 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。

+

Codex 能用 Grok 4 吗?

+

能。xAI 提供 Codex 说的 Responses 接口,所以 magpie codex xai/grok-4.7 会把 Codex 的请求原样发到 https://api.x.ai/v1,途中修正 xAI 不接受的内容:工具 schema、没有工具的 tool_choice,以及 Grok 写成 2500.0 的整数。

+

Gemini CLI 和 OpenCode 能用 Grok 吗?

+

能。Gemini CLI 说 Google 的接口,magpie 把它的请求转成 xAI 的 Chat Completions,再把回复转回来。OpenCode 说 Chat Completions,请求原样发给 xAI。运行 magpie gemini model xai/grok-4.7 或 magpie opencode xai/grok-4.7 即可。

+

用 Grok 能联网搜索吗?

+

能。Codex 的联网搜索由 xAI 在自己的 Responses 接口上完成。Claude Code、Gemini CLI 和 OpenCode 则由 magpie 给模型提供自己的搜索工具,由设置里指定的搜索服务回答,或者由 magpie 自己挑一个。

+

Codex 对话中途从 GPT 换到 Grok 为什么报错?

+

xAI 读不了别家加密的推理内容,会回 “Could not decrypt the provided encrypted_content”。magpie 会去掉这些条目重新请求,并在这段对话后面都不再带上。

+

magpie 能显示 xAI 的余额吗?

+

不能。用量页会统计每次 Grok 调用的 token、缓存和费用,按 models.dev 的价格计价,但 magpie 不会从 xAI 读取余额。你可以用 magpie provider key-balance 自己填上余额,用量页会显示它减去 magpie 此后算出的费用。

+ +

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · Gemini · OpenRouter · GitHub Copilot

+

各个工具的指南:Claude Code 接入其他模型、Codex 接入其他模型、Gemini CLI 接入其他模型、OpenCode 接入其他模型。遇到问题可以在 Discord 提问。

+
+
+ + + + + + + diff --git a/site/public/docs/zh/opencode-models.html b/site/public/docs/zh/opencode-models.html index 717617be2..3e1d5880f 100644 --- a/site/public/docs/zh/opencode-models.html +++ b/site/public/docs/zh/opencode-models.html @@ -239,7 +239,7 @@ magpie visible opencode all # 恢复显示全部
终端
magpie opencode default

它会恢复接入 magpie 之前的 model 和 small_model,并把 magpie 供应商从文件里删掉。

-

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · OpenRouter · GitHub Copilot

+

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · Gemini · Grok · OpenRouter · GitHub Copilot

常见问题

OpenCode 怎么用 DeepSeek?

diff --git a/site/public/docs/zh/openrouter.html b/site/public/docs/zh/openrouter.html index 9e9e2c7ba..a4c886f47 100644 --- a/site/public/docs/zh/openrouter.html +++ b/site/public/docs/zh/openrouter.html @@ -288,7 +288,7 @@ magpie group set opus-anywhere stays=session models+=openrouter/anthropic/claude

为什么 magpie 从 /api/v1 拉取 OpenRouter 的模型列表?

在 Anthropic 地址上拉列表,OpenRouter 返回的是挂在 anthropic/ 前缀下的目录,里面的 id 它并不提供服务。magpie 从 Chat Completions 地址 https://openrouter.ai/api/v1 拉列表;只填了 OpenRouter Anthropic 地址的供应商,会提示你补上这个 Chat 地址。

-

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · GitHub Copilot

+

按供应商:DeepSeek · Kimi 与 Kimi Code · GLM 编程套餐 · 通义千问 · MiniMax · Gemini · Grok · GitHub Copilot

各个工具的指南:Claude Code 接入其他模型、Codex 接入其他模型、Gemini CLI 接入其他模型、OpenCode 接入其他模型。遇到问题可以在 Discord 提问。

diff --git a/site/public/llms-full.txt b/site/public/llms-full.txt index 9e6e2d1ec..50ef965e2 100644 --- a/site/public/llms-full.txt +++ b/site/public/llms-full.txt @@ -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 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 ` 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 20 month +magpie provider key-balance xai 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. diff --git a/site/public/llms.txt b/site/public/llms.txt index b31fbbd94..db21a1877 100644 --- a/site/public/llms.txt +++ b/site/public/llms.txt @@ -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. diff --git a/site/public/sitemap.xml b/site/public/sitemap.xml index f1bc8df99..91dbd4f58 100644 --- a/site/public/sitemap.xml +++ b/site/public/sitemap.xml @@ -30,6 +30,8 @@ https://usemagpie.ai/docs/minimax https://usemagpie.ai/docs/openrouter https://usemagpie.ai/docs/copilot +https://usemagpie.ai/docs/gemini +https://usemagpie.ai/docs/grok https://usemagpie.ai/docs/zh/claude-code-models https://usemagpie.ai/docs/zh/codex-models https://usemagpie.ai/docs/zh/contributors @@ -56,6 +58,8 @@ https://usemagpie.ai/docs/zh/minimax https://usemagpie.ai/docs/zh/openrouter https://usemagpie.ai/docs/zh/copilot +https://usemagpie.ai/docs/zh/gemini +https://usemagpie.ai/docs/zh/grok https://usemagpie.ai/docs/ja/claude-code-models https://usemagpie.ai/docs/ja/codex-models https://usemagpie.ai/docs/ja/contributors @@ -81,4 +85,6 @@ https://usemagpie.ai/docs/ja/minimax https://usemagpie.ai/docs/ja/openrouter https://usemagpie.ai/docs/ja/copilot +https://usemagpie.ai/docs/ja/gemini +https://usemagpie.ai/docs/ja/grok