diff --git a/site/public/docs/ja/openrouter.html b/site/public/docs/ja/openrouter.html index 5d40c238e..b52a1874f 100644 --- a/site/public/docs/ja/openrouter.html +++ b/site/public/docs/ja/openrouter.html @@ -297,6 +297,8 @@ magpie group set opus-anywhere stays=session models+=openrouter/anthropic/claude

Vercel AI Gateway を Claude Code・Codex などのエージェントで使う

+

API 中継サービスを Claude Code・Codex などのエージェントで使う

+

よくある質問

Claude Code で OpenRouter を使うには?

magpie に OpenRouter のキーを追加し(プロバイダ、プロバイダを追加、OpenRouter)、Claude Code の行で anthropic/claude-opus-5.5 などのモデルを選ぶか、magpie claude openrouter/anthropic/claude-opus-5.5 を実行します。magpie が Claude Code の settings.json を書き、リクエストはそのまま OpenRouter の Anthropic エンドポイントに渡されます。

diff --git a/site/public/docs/ja/relay.html b/site/public/docs/ja/relay.html new file mode 100644 index 000000000..2dea5483b --- /dev/null +++ b/site/public/docs/ja/relay.html @@ -0,0 +1,277 @@ + + + + + +API 中継サービスを Claude Code・Codex などで使う:価格・モデル名・キャッシュ · magpie + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+

ドキュメント · ガイド

+

API 中継サービスを Claude Code・Codex などのエージェントで使う

+

中継サービスは 1 つのキーで多くのベンダーのモデルを売り、価格もモデル名も独自のことがよくあります。magpie は中継を 1 つのプロバイダーとして扱い、エージェントは 中継/モデル で使えます。価格・名前・コンテキスト長は中継の実際に合わせて設定できます。

+

中継を追加する

+
    +
  1. プリセットの中継。AiHubMix・PipeLLM・302.AI・CherryIN・鱼鱼连线はプリセットで、APIキー を入れるだけです。鱼鱼连线は Auto・Global・China Mainland の回線も選べます。
  2. +
  3. そのほかの中継。アドレスを指定します。url= は OpenAI 互換、anthropic= は Anthropic 互換で、両方あれば両方、Responses に別アドレスがあれば responses= も加えます。
  4. +
+
ターミナル
magpie presets
+magpie provider add aihubmix sk-…
+magpie provider add "My Relay" url=https://relay.example.com/v1 anthropic=https://relay.example.com key=sk-…
+magpie provider test "My Relay"
+

magpie provider test は API ごとに小さなリクエストを 1 つ送り、レイテンシを表示します。

+

Claude モデルのキャッシュ

+

中継に OpenAI と Anthropic の両方のアドレスがあるとき、Claude モデルはエージェントの API にかかわらず Anthropic の Messages に送ります。多くの中継は Chat で cache_control を落とし、毎ターンがキャッシュなしで課金され、思考も失われていました(#997)。Anthropic のアドレスがあれば指定してください。

+

中継の価格で数える

+

初期状態では、呼び出しはモデル提供元の定価で数えます。割引や倍率で売る中継ではこの数字は正しくないので、中継の実際の価格を指定すれば、使用量の明細とセッション合計がそれを使います。

+
ターミナル
magpie model price relay-a/gpt-5.5 0.12,0.60,0.01,0.15
+magpie model price relay-a/gpt-5.5
+magpie model prices
+

4 つの数は入力・出力・キャッシュ読み込み・キャッシュ書き込みで、100 万トークンあたりの米ドルです。4 つとも必要で、0 は無料のモデルです。kimi-k3 を moonshot-kimi-k3 として売る中継は kimi-k3 として答えるので、価格のない改名モデルは同じ中継の kimi-k3 の価格で数えます。

+

モデル名とコンテキスト長

+

中継はモデル ID に独自の接頭辞や日付を付けることがよくあります。magpie model wire で中継に送る名前を指定し、* はモデル自身を表します。models.dev にないモデルや、サイズが違うモデルには magpie model context と magpie model output でコンテキスト長と応答の上限を指定します。

+
ターミナル
magpie model wire 'relay-b/*' 'vendor-c/*'
+magpie model wire relay-b/model-2 --reset
+magpie model context "relay-a/*" 200000
+magpie model output relay-a/gpt-5.5 131072
+

zsh では * を含む引数を引用符で囲んでください。囲まないと no matches found になります。コンテキスト長と上限は、このモデル → このプロバイダーの * → プロバイダー自身の一覧 → models.dev の順に探します。

+

モデル一覧

+

中継は新しいモデルをすぐに載せます。ゲートウェイに一覧を定期的に取り直させ、パターンに合う新モデルを自動で公開できます。

+
ターミナル
magpie provider refresh-every relay 6h
+magpie provider auto-include relay 'gpt-*' 're:claude-.*'
+

補足

+ + +

よくある質問

+

magpie で API 中継サービスを使えますか?

+

使えます。AiHubMix・PipeLLM・302.AI・CherryIN・鱼鱼连线はキーを入れるだけのプリセットで、ほかの中継は magpie provider add で OpenAI 互換と Anthropic 互換のアドレスを指定します。

+

中継経由の Claude モデルでキャッシュが効かないのはなぜ?

+

多くの中継は Chat で cache_control を落とします。中継の Anthropic アドレスを指定すれば、magpie は Claude モデルを Messages に送り、キャッシュと思考が保たれます。

+

中継が割引価格のとき、費用を正しく数えるには?

+

magpie model price 中継/モデル で入力・出力・キャッシュ読み込み・書き込みの価格(100 万トークンあたり米ドル)を指定すれば、使用量とセッション合計がそれを使います。

+

中継のモデル名に接頭辞が付いているときは?

+

magpie model wire で中継に送る名前を指定します。'relay-b/*' 'vendor-c/*' なら各モデルに vendor-c/ を付けて送ります。

+ +

関連ページ:OpenRouter を Claude Code・Codex・Gemini CLI・OpenCode で使う、アカウント・キー・プロバイダーのローテーションとフェイルオーバー。エラーが出たら よくあるエラーの直し方:401・429・502・504 など を見るか、Discord で質問してください。

+
+
+ + + + + + + diff --git a/site/public/docs/openrouter.html b/site/public/docs/openrouter.html index 962f19653..08a92d672 100644 --- a/site/public/docs/openrouter.html +++ b/site/public/docs/openrouter.html @@ -297,6 +297,8 @@ magpie group set opus-anywhere stays=session models+=openrouter/anthropic/claude

Vercel AI Gateway in Claude Code, Codex and other agents

+

API relays in Claude Code, Codex and other agents

+

FAQ

How do I use OpenRouter in Claude Code?

Add your OpenRouter key in magpie (Providers, Add provider, OpenRouter), then pick a model such as anthropic/claude-opus-5.5 on Claude Code’s row, or run magpie claude openrouter/anthropic/claude-opus-5.5. magpie writes Claude Code’s settings.json and passes its requests on to OpenRouter’s Anthropic endpoint as they are.

diff --git a/site/public/docs/relay.html b/site/public/docs/relay.html new file mode 100644 index 000000000..e9e044d93 --- /dev/null +++ b/site/public/docs/relay.html @@ -0,0 +1,277 @@ + + + + + +API relays in Claude Code, Codex and other agents: prices, model names, caching · magpie + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+

Docs · Guide

+

API relays in Claude Code, Codex and other agents

+

A relay sells many vendors' models on one key, often at its own prices and under its own model names. magpie treats a relay as a provider: an agent asks for relay/model, and prices, names and windows can be set to what the relay really does.

+

Add a relay

+
    +
  1. A preset relay.AiHubMix, PipeLLM, 302.AI, CherryIN and 鱼鱼连线 are presets: give an API key. 鱼鱼连线 also takes an Auto, Global or China Mainland line.
  2. +
  3. Any other relay.Give its addresses: url= for an OpenAI-compatible base, anthropic= for an Anthropic-compatible one, both when it has both, and responses= when Responses has an address of its own.
  4. +
+
Terminal
magpie presets
+magpie provider add aihubmix sk-…
+magpie provider add "My Relay" url=https://relay.example.com/v1 anthropic=https://relay.example.com key=sk-…
+magpie provider test "My Relay"
+

magpie provider test sends one tiny request per API, with latency.

+

Caching for Claude models

+

When a relay has both an OpenAI and an Anthropic address, a Claude model goes to Anthropic's Messages whatever API the agent spoke: many relays drop cache_control on Chat, so every turn was billed uncached, and thinking went with it (#997). If the relay has an Anthropic address, give it.

+

Count the relay's prices

+

Out of the box a call is counted at the model maker's list price, the wrong number for a relay that sells at a discount or a multiplier. Say what the relay charges, and the usage ledger and session totals use it:

+
Terminal
magpie model price relay-a/gpt-5.5 0.12,0.60,0.01,0.15
+magpie model price relay-a/gpt-5.5
+magpie model prices
+

The four numbers are input, output, cache read and cache write, in USD per million tokens, and all four are asked for; 0 is a model served at no cost. A relay that sells kimi-k3 as moonshot-kimi-k3 answers as kimi-k3, so a renamed model with no price of its own is counted at kimi-k3's price at the same relay.

+

Model names and windows

+

Relays often add a prefix or a date to a model's id. magpie model wire sets the name the relay is asked for, * standing for the model; for a model models.dev doesn't list or lists at the wrong size, magpie model context and magpie model output set the window and the reply limit:

+
Terminal
magpie model wire 'relay-b/*' 'vendor-c/*'
+magpie model wire relay-b/model-2 --reset
+magpie model context "relay-a/*" 200000
+magpie model output relay-a/gpt-5.5 131072
+

Quote arguments with a * in zsh, or it answers no matches found. Windows and limits are looked for in this order: this model → this provider's * → the provider's own list → models.dev.

+

The model list

+

Relays list new models fast. Have the gateway fetch the list on a schedule, and expose new models that match a pattern:

+
Terminal
magpie provider refresh-every relay 6h
+magpie provider auto-include relay 'gpt-*' 're:claude-.*'
+

Notes

+ + +

FAQ

+

Can magpie use an API relay?

+

Yes. AiHubMix, PipeLLM, 302.AI, CherryIN and 鱼鱼连线 are presets that take a key; any other relay is added with magpie provider add and its OpenAI- and Anthropic-compatible addresses.

+

Why does caching miss for Claude models through a relay?

+

Many relays drop cache_control on Chat. Give the relay's Anthropic address, and magpie sends Claude models to Messages, keeping caching and thinking.

+

The relay sells at a discount. How do I count the right cost?

+

Run magpie model price relay/model with the input, output, cache read and cache write prices in USD per million tokens; usage and session totals use them.

+

The relay's model names have a prefix. What now?

+

magpie model wire sets the name the relay is asked for: 'relay-b/*' 'vendor-c/*' sends every model with a vendor-c/ prefix.

+ +

Related: OpenRouter in Claude Code, Codex, Gemini CLI and OpenCode, Round robin and failover across accounts, keys and providers. If something fails, see Fixing common errors: 401, 429, 502, 504 and more or ask on Discord.

+
+
+ + + + + + + diff --git a/site/public/docs/zh/openrouter.html b/site/public/docs/zh/openrouter.html index c38362edc..5a02ab82c 100644 --- a/site/public/docs/zh/openrouter.html +++ b/site/public/docs/zh/openrouter.html @@ -297,6 +297,8 @@ magpie group set opus-anywhere stays=session models+=openrouter/anthropic/claude

Vercel AI Gateway 接入 Claude Code、Codex 等 Agent

+

中转站 API 接入 Claude Code、Codex 等 Agent

+

常见问题

Claude Code 怎么用 OpenRouter?

在 magpie 里添加 OpenRouter 的 Key(供应商页,添加供应商,选 OpenRouter),然后在 Claude Code 那一行选一个模型,比如 anthropic/claude-opus-5.5,或者运行 magpie claude openrouter/anthropic/claude-opus-5.5。magpie 会写好 Claude Code 的 settings.json,请求原样转给 OpenRouter 的 Anthropic 接口。

diff --git a/site/public/docs/zh/relay.html b/site/public/docs/zh/relay.html new file mode 100644 index 000000000..5347dd9d3 --- /dev/null +++ b/site/public/docs/zh/relay.html @@ -0,0 +1,277 @@ + + + + + +中转站 API 接入 Claude Code、Codex 等 Agent:价格、模型名与缓存 · magpie + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+

文档 · 指南

+

中转站 API 接入 Claude Code、Codex 等 Agent

+

中转站用一把 Key 卖很多家的模型,价格常常和官方不一样,模型名也常常带着自己的前缀。magpie 把中转站当成一个供应商:Agent 里写 中转站/模型 就能用,价格、模型名和窗口都可以按中转站的实际情况改。

+

添加中转站

+
    +
  1. 内置的中转站。AiHubMix、PipeLLM、302.AI、CherryIN、鱼鱼连线已经是预设,填一把 API 密钥 就行。鱼鱼连线还可以选 Auto、Global 或 China Mainland 线路。
  2. +
  3. 其他中转站。填它的地址:url= 是 OpenAI 兼容的地址,anthropic= 是 Anthropic 兼容的地址,两个都有就都填;另有单独 Responses 地址的再加 responses=。
  4. +
+
终端
magpie presets
+magpie provider add aihubmix sk-…
+magpie provider add "My Relay" url=https://relay.example.com/v1 anthropic=https://relay.example.com key=sk-…
+magpie provider test "My Relay"
+

magpie provider test 对每种 API 各发一个很小的请求,并给出延迟。

+

Claude 模型的缓存

+

中转站同时有 OpenAI 和 Anthropic 两种地址时,Claude 模型不管 Agent 说的是哪种协议,都发到 Anthropic 的 Messages:不少中转站在 Chat 接口上会丢掉 cache_control,每一轮都按没缓存计费,思考也一起丢了(#997)。所以中转站有 Anthropic 地址,就把它填上。

+

按中转站的价格记账

+

magpie 默认按模型厂商的官方价格算一次调用的花费。中转站打折或者加倍率时,这个数就不对,把中转站的实际价格告诉 magpie,用量明细和会话合计就按它算:

+
终端
magpie model price relay-a/gpt-5.5 0.12,0.60,0.01,0.15
+magpie model price relay-a/gpt-5.5
+magpie model prices
+

四个数依次是输入、输出、缓存读、缓存写,单位是美元每百万 token,四个都要填;0 表示这个模型不花钱。中转站把 kimi-k3 改名成 moonshot-kimi-k3 卖时,回答里写的是 kimi-k3,没有价格的改名模型就按 kimi-k3 在同一个中转站的价格算。

+

模型名和窗口

+

中转站常给模型加自己的前缀或日期。magpie model wire 指定发给中转站的模型名,* 代表模型本身;models.dev 没收录或收录错了的模型,用 magpie model context 和 magpie model output 补上窗口和回复上限:

+
终端
magpie model wire 'relay-b/*' 'vendor-c/*'
+magpie model wire relay-b/model-2 --reset
+magpie model context "relay-a/*" 200000
+magpie model output relay-a/gpt-5.5 131072
+

在 zsh 里带 * 的参数要加引号,否则会报 no matches found。窗口和上限按这个顺序找:这个模型 → 这个供应商的 * → 供应商自己的列表 → models.dev。

+

模型列表

+

中转站上新模型很快。让网关定时去取列表,再用规则把新模型自动放进选择器:

+
终端
magpie provider refresh-every relay 6h
+magpie provider auto-include relay 'gpt-*' 're:claude-.*'
+

几点说明

+ + +

常见问题

+

magpie 能接 API 中转站吗?

+

能。AiHubMix、PipeLLM、302.AI、CherryIN、鱼鱼连线是预设,填 Key 即可;其他中转站用 magpie provider add 填 OpenAI 兼容地址和 Anthropic 兼容地址。

+

通过中转站用 Claude 模型,缓存为什么不命中?

+

很多中转站在 Chat 接口上会丢掉 cache_control。填上中转站的 Anthropic 地址,magpie 就把 Claude 模型都发到 Messages,缓存和思考都能保住。

+

中转站打折,花费怎么算才对?

+

用 magpie model price 中转站/模型 填上输入、输出、缓存读、缓存写四个价格(美元每百万 token),用量和会话合计就按它算。

+

中转站的模型名带前缀怎么办?

+

用 magpie model wire 指定发给中转站的名字,比如 'relay-b/*' 'vendor-c/*' 会把每个模型都加上 vendor-c/ 前缀再发出去。

+ +

相关页面:OpenRouter 接入 Claude Code、Codex、Gemini CLI 和 OpenCode、多个账号、Key 和供应商轮询与故障切换。遇到错误请看 常见错误排查:401、429、502、504 等,或者到 Discord 提问。

+
+
+ + + + + + + diff --git a/site/public/llms-full.txt b/site/public/llms-full.txt index e0cd8139a..0a565ca1d 100644 --- a/site/public/llms-full.txt +++ b/site/public/llms-full.txt @@ -2360,6 +2360,8 @@ magpie group set opus-anywhere stays=session models+=openrouter/anthropic/claude [Vercel AI Gateway in Claude Code, Codex and other agents](https://usemagpie.ai/docs/vercel) +[API relays in Claude Code, Codex and other agents](https://usemagpie.ai/docs/relay) + ## FAQ ### How do I use OpenRouter in Claude Code? @@ -9838,6 +9840,92 @@ Related: [ModelScope in Claude Code and Codex](https://usemagpie.ai/docs/modelsc --- +Source: https://usemagpie.ai/docs/relay + +# API relays in Claude Code, Codex and other agents + +A relay sells many vendors' models on one key, often at its own prices and under its own model names. magpie treats a relay as a provider: an agent asks for `relay/model`, and prices, names and windows can be set to what the relay really does. + +## Add a relay + +1. **A preset relay..** AiHubMix, PipeLLM, 302.AI, CherryIN and 鱼鱼连线 are presets: give an API key. 鱼鱼连线 also takes an Auto, Global or China Mainland line. +2. **Any other relay..** Give its addresses: `url=` for an OpenAI-compatible base, `anthropic=` for an Anthropic-compatible one, both when it has both, and `responses=` when Responses has an address of its own. + +``` +magpie presets +magpie provider add aihubmix sk-… +magpie provider add "My Relay" url=https://relay.example.com/v1 anthropic=https://relay.example.com key=sk-… +magpie provider test "My Relay" +``` + +`magpie provider test` sends one tiny request per API, with latency. + +## Caching for Claude models + +When a relay has both an OpenAI and an Anthropic address, a Claude model goes to Anthropic's Messages whatever API the agent spoke: many relays drop `cache_control` on Chat, so every turn was billed uncached, and thinking went with it (#997). If the relay has an Anthropic address, give it. + +## Count the relay's prices + +Out of the box a call is counted at the model maker's list price, the wrong number for a relay that sells at a discount or a multiplier. Say what the relay charges, and the usage ledger and session totals use it: + +``` +magpie model price relay-a/gpt-5.5 0.12,0.60,0.01,0.15 +magpie model price relay-a/gpt-5.5 +magpie model prices +``` + +The four numbers are input, output, cache read and cache write, in USD per million tokens, and all four are asked for; `0` is a model served at no cost. A relay that sells `kimi-k3` as `moonshot-kimi-k3` answers as `kimi-k3`, so a renamed model with no price of its own is counted at `kimi-k3`'s price at the same relay. + +## Model names and windows + +Relays often add a prefix or a date to a model's id. `magpie model wire` sets the name the relay is asked for, `*` standing for the model; for a model models.dev doesn't list or lists at the wrong size, `magpie model context` and `magpie model output` set the window and the reply limit: + +``` +magpie model wire 'relay-b/*' 'vendor-c/*' +magpie model wire relay-b/model-2 --reset +magpie model context "relay-a/*" 200000 +magpie model output relay-a/gpt-5.5 131072 +``` + +Quote arguments with a `*` in zsh, or it answers `no matches found`. Windows and limits are looked for in this order: this model → this provider's `*` → the provider's own list → models.dev. + +## The model list + +Relays list new models fast. Have the gateway fetch the list on a schedule, and expose new models that match a pattern: + +``` +magpie provider refresh-every relay 6h +magpie provider auto-include relay 'gpt-*' 're:claude-.*' +``` + +## Notes + +- Agents only ever reach magpie; they never hold the relay's key or its address. +- Several relays can share a routing group: when one fails, the group's next member answers. +- When a reply says another model answered, usage marks it and counts the model that answered. + +## FAQ + +### Can magpie use an API relay? + +Yes. AiHubMix, PipeLLM, 302.AI, CherryIN and 鱼鱼连线 are presets that take a key; any other relay is added with magpie provider add and its OpenAI- and Anthropic-compatible addresses. + +### Why does caching miss for Claude models through a relay? + +Many relays drop cache_control on Chat. Give the relay's Anthropic address, and magpie sends Claude models to Messages, keeping caching and thinking. + +### The relay sells at a discount. How do I count the right cost? + +Run magpie model price relay/model with the input, output, cache read and cache write prices in USD per million tokens; usage and session totals use them. + +### The relay's model names have a prefix. What now? + +magpie model wire sets the name the relay is asked for: 'relay-b/*' 'vendor-c/*' sends every model with a vendor-c/ prefix. + +Related: [OpenRouter in Claude Code, Codex, Gemini CLI and OpenCode](https://usemagpie.ai/docs/openrouter), [Round robin and failover across accounts, keys and providers](https://usemagpie.ai/docs/routing-groups). If something fails, see [Fixing common errors: 401, 429, 502, 504 and more](https://usemagpie.ai/docs/troubleshooting) or ask on [Discord](https://discord.gg/vGSnD3ZKQF). + +--- + Source: https://usemagpie.ai/docs/library # Library diff --git a/site/public/llms.txt b/site/public/llms.txt index 1f70fb343..c8ce6fc0f 100644 --- a/site/public/llms.txt +++ b/site/public/llms.txt @@ -148,6 +148,7 @@ DeepSeek, Kimi (Moonshot), GLM (Zhipu), Qwen, MiniMax, Anthropic (Claude), OpenA - [Groq in Claude Code, Codex and other agents](https://usemagpie.ai/docs/groq): the groq preset with one key, Claude Code translated to Chat with the cache counted, per-model rate limits, overflows that make the agent compact, Whisper and speech. - [Vercel AI Gateway in Claude Code, Codex and other agents](https://usemagpie.ai/docs/vercel): the vercel preset with Chat, Responses and Anthropic Messages set, Claude models kept on Messages for the cache, and the model list sorted by Vercel's own types. - [NVIDIA NIM in Claude Code, Codex and other agents](https://usemagpie.ai/docs/nvidia): the nvidia preset on Chat Completions at integrate.api.nvidia.com, Claude Code and Codex translated, free models marked in the pickers, imported keys folded into one provider. +- [API relays in Claude Code, Codex and other agents](https://usemagpie.ai/docs/relay): preset relays (AiHubMix, PipeLLM, 302.AI, CherryIN, 鱼鱼连线) and any OpenAI- or Anthropic-compatible address, Claude models on Messages for caching, model price, model wire, context and output limits, scheduled list refresh. - [Library](https://usemagpie.ai/docs/library): instructions, MCP servers, skills, hooks and subagents for each agent. - [MCP router](https://usemagpie.ai/docs/mcp-router): one magpie MCP server per agent. - [Remote magpie](https://usemagpie.ai/docs/remote): use one magpie from several computers. diff --git a/site/public/sitemap.xml b/site/public/sitemap.xml index 966b8f3a0..9482f5aad 100644 --- a/site/public/sitemap.xml +++ b/site/public/sitemap.xml @@ -100,6 +100,7 @@ https://usemagpie.ai/docs/groq https://usemagpie.ai/docs/vercel https://usemagpie.ai/docs/nvidia +https://usemagpie.ai/docs/relay https://usemagpie.ai/docs/local-models https://usemagpie.ai/docs/opencode-models https://usemagpie.ai/docs/alternatives @@ -221,6 +222,7 @@ https://usemagpie.ai/docs/zh/groq https://usemagpie.ai/docs/zh/vercel https://usemagpie.ai/docs/zh/nvidia +https://usemagpie.ai/docs/zh/relay https://usemagpie.ai/docs/zh/local-models https://usemagpie.ai/docs/zh/opencode-models https://usemagpie.ai/docs/zh/alternatives @@ -341,6 +343,7 @@ https://usemagpie.ai/docs/ja/groq https://usemagpie.ai/docs/ja/vercel https://usemagpie.ai/docs/ja/nvidia +https://usemagpie.ai/docs/ja/relay https://usemagpie.ai/docs/ja/local-models https://usemagpie.ai/docs/ja/opencode-models https://usemagpie.ai/docs/ja/alternatives