Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

provider: ClinePass's Upstream tick pins GLM models to Z.ai too (sdytman on Discord)

yetonedd70c5e6ae58
diff --git a/internal/gateway/cline_pin.go b/internal/gateway/cline_pin.go
index 8c665e169..c78cdc075 100644
--- a/internal/gateway/cline_pin.go
+++ b/internal/gateway/cline_pin.go
@@ -8,8 +8,8 @@ import (
"github.com/yetone/magpie/internal/provider"
)
-// clinePin is body with its DeepSeek model pinned to DeepSeek's own API
-// on the Cline API, when the provider asks it (provider.PinUpstream):
+// clinePin is body with its DeepSeek or GLM model pinned to its maker's
+// own API (DeepSeek's, Z.ai's) on the Cline API, when the provider asks it (provider.PinUpstream):
// providerOptions.gateway.only, which Cline's AI gateway reads to serve
// the model from that host alone, as ClinePass + ProviderPin set it
// (linux.do/t/topic/2918145). A body naming providerOptions itself is
diff --git a/internal/gateway/cline_pin_test.go b/internal/gateway/cline_pin_test.go
index 95b7bb41d..e1a0e4f06 100644
--- a/internal/gateway/cline_pin_test.go
+++ b/internal/gateway/cline_pin_test.go
@@ -15,10 +15,11 @@ import (
// the provider pins them (White Immortal on Discord, as ClinePass +
// ProviderPin does): each request for one carries
// providerOptions.gateway.only ["deepseek"], on Chat and when an Anthropic
-// or Responses request is built into one. Its other models, Cline's free
-// ones, a provider that doesn't pin, and a body naming providerOptions
-// itself go as they were.
-func TestClinePinsDeepSeek(t *testing.T) {
+// or Responses request is built into one. Its GLM models are pinned to
+// Z.ai's the same way, ["zai"] (sdytman on Discord). Its other makers'
+// models, Cline's free ones, a provider that doesn't pin, and a body
+// naming providerOptions itself go as they were.
+func TestClinePinsDeepSeekAndGLM(t *testing.T) {
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
t.Setenv("XDG_CACHE_HOME", t.TempDir())
cline, err := provider.FromPreset("clinepass")
@@ -26,7 +27,7 @@ func TestClinePinsDeepSeek(t *testing.T) {
t.Fatal(err)
}
cline.ID, cline.Key, cline.PinUpstream = "cline", "clp_key", true
- cline.Models = []string{"cline-pass/deepseek-v4-pro", "cline-pass/glm-5.3", "cline-free/deepseek-v4.1-flash"}
+ cline.Models = []string{"cline-pass/deepseek-v4-pro", "cline-pass/glm-5.3", "cline-pass/glm-5.3-flash", "cline-pass/kimi-k3", "cline-pass/qwen3.8-max", "cline-free/deepseek-v4.1-flash", "cline-free/glm-5.3-flash"}
plain := cline
plain.ID, plain.Name, plain.PinUpstream = "cline2", "ClinePass 2", false
for _, p := range []provider.Provider{cline, plain} {
@@ -69,12 +70,25 @@ func TestClinePinsDeepSeek(t *testing.T) {
if got := ask("/v1/responses", `{"model":"cline/cline-pass/deepseek-v4-pro","input":"Say pong","stream":false}`); got != pinned {
t.Errorf("responses: providerOptions %s, want %s", got, pinned)
}
- for _, m := range []string{"cline/cline-pass/glm-5.3", "cline/cline-free/deepseek-v4.1-flash", "cline2/cline-pass/deepseek-v4-pro"} {
+ const zai = `{"gateway":{"only":["zai"]}}`
+ for _, m := range []string{"cline/cline-pass/glm-5.3", "cline/cline-pass/glm-5.3-flash"} {
+ if got := chat(m, ""); got != zai {
+ t.Errorf("%s: providerOptions %s, want %s (sent %s)", m, got, zai, sent)
+ }
+ }
+ if got := ask("/v1/messages", `{"model":"cline/cline-pass/glm-5.3","max_tokens":64,"messages":[{"role":"user","content":"Say pong"}]}`); got != zai {
+ t.Errorf("messages, GLM: providerOptions %s, want %s", got, zai)
+ }
+ for _, m := range []string{"cline/cline-pass/kimi-k3", "cline/cline-pass/qwen3.8-max", "cline/cline-free/deepseek-v4.1-flash", "cline/cline-free/glm-5.3-flash", "cline2/cline-pass/deepseek-v4-pro", "cline2/cline-pass/glm-5.3"} {
if got := chat(m, ""); got != "" {
t.Errorf("%s: providerOptions %s, want none", m, got)
}
}
- if got := chat("cline/cline-pass/deepseek-v4-pro", `,"providerOptions":{"gateway":{"order":["novita"]}}`); got != `{"gateway":{"order":["novita"]}}` {
- t.Errorf("the client's own providerOptions became %s", got)
+ for _, m := range []string{"cline/cline-pass/deepseek-v4-pro", "cline/cline-pass/glm-5.3"} {
+ // a second providerOptions after the client's would be the one a
+ // JSON reader keeps, so the body must hold the client's alone
+ if got := chat(m, `,"providerOptions":{"gateway":{"order":["novita"]}}`); got != `{"gateway":{"order":["novita"]}}` || strings.Count(string(sent), `"providerOptions"`) != 1 {
+ t.Errorf("%s: the client's own providerOptions became %s (sent %s)", m, got, sent)
+ }
}
}
diff --git a/internal/gateway/plugin_cline_pin_test.go b/internal/gateway/plugin_cline_pin_test.go
index e3ebaae35..90c351d27 100644
--- a/internal/gateway/plugin_cline_pin_test.go
+++ b/internal/gateway/plugin_cline_pin_test.go
@@ -12,10 +12,12 @@ import (
// The Cline plugin's provider has ClinePass's Upstream tick too (ARNO on
// Discord): saved on it, a DeepSeek model's request reaches the plugin
-// pinned to DeepSeek's own API, on Chat and Anthropic Messages alike, and
-// its other models' requests go as sent.
-func TestClinePluginPinsDeepSeek(t *testing.T) {
+// pinned to DeepSeek's own API and a GLM model's to Z.ai's (sdytman on
+// Discord), on Chat and Anthropic Messages alike, and its other models'
+// requests go as sent.
+func TestClinePluginPinsDeepSeekAndGLM(t *testing.T) {
t.Setenv("FAKE_DEEPSEEK", "1")
+ t.Setenv("FAKE_GLM", "1")
var mu sync.Mutex
var sent []map[string]any
pid := besideFake(t, "cline", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -37,8 +39,8 @@ func TestClinePluginPinsDeepSeek(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if !p.ClinePinnable() || p.ClinePin("deepseek-v4-pro") != "" {
- t.Fatalf("the Cline plugin's provider: pinnable %v, pinned unasked %q", p.ClinePinnable(), p.ClinePin("deepseek-v4-pro"))
+ if !p.ClinePinnable() || p.ClinePin("deepseek-v4-pro") != "" || p.ClinePin("glm-5.3") != "" {
+ t.Fatalf("the Cline plugin's provider: pinnable %v, pinned unasked %q %q", p.ClinePinnable(), p.ClinePin("deepseek-v4-pro"), p.ClinePin("glm-5.3"))
}
ask := func() []map[string]any {
mu.Lock()
@@ -47,13 +49,15 @@ func TestClinePluginPinsDeepSeek(t *testing.T) {
for _, req := range []struct{ path, body string }{
{"/v1/chat/completions", `{"model":"` + pid + `/deepseek-v4-pro","messages":[{"role":"user","content":"hi"}]}`},
{"/v1/messages", `{"model":"` + pid + `/deepseek-v4-pro","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}`},
+ {"/v1/chat/completions", `{"model":"` + pid + `/glm-5.3","messages":[{"role":"user","content":"hi"}]}`},
+ {"/v1/messages", `{"model":"` + pid + `/glm-5.3","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}`},
{"/v1/chat/completions", `{"model":"` + pid + `/fake-1","messages":[{"role":"user","content":"hi"}]}`},
} {
postProto(t, New(), req.path, req.body)
}
mu.Lock()
defer mu.Unlock()
- if len(sent) != 3 {
+ if len(sent) != 5 {
t.Fatalf("the plugin sent %d requests", len(sent))
}
return append([]map[string]any(nil), sent...)
@@ -73,13 +77,17 @@ func TestClinePluginPinsDeepSeek(t *testing.T) {
t.Fatalf("the tick wasn't kept: %+v, %v", p, err)
}
got := ask()
- for i, q := range got[:2] {
+ for i, q := range got[:4] {
+ want := `{"gateway":{"only":["deepseek"]}}`
+ if i >= 2 {
+ want = `{"gateway":{"only":["zai"]}}`
+ }
po, _ := json.Marshal(q["providerOptions"])
- if string(po) != `{"gateway":{"only":["deepseek"]}}` {
- t.Fatalf("request %d (DeepSeek) reached the plugin with providerOptions %s", i, po)
+ if string(po) != want {
+ t.Fatalf("request %d reached the plugin with providerOptions %s, want %s", i, po, want)
}
}
- if got[2]["providerOptions"] != nil {
- t.Fatalf("fake-1 pinned: %v", got[2]["providerOptions"])
+ if got[4]["providerOptions"] != nil {
+ t.Fatalf("fake-1 pinned: %v", got[4]["providerOptions"])
}
}
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index b69bdea15..2f21b3e0f 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -8994,14 +8994,15 @@ function drawEditor(p, presetID) {
}
// the Cline API serves a model from whichever host its AI gateway picks;
- // pinned, its DeepSeek models are served by DeepSeek's own API alone,
- // which keeps their prompt cache (White Immortal on Discord). ClinePass,
+ // pinned, its DeepSeek models are served by DeepSeek's own API alone and
+ // its GLM models by Z.ai's (sdytman on Discord), which keeps their prompt
+ // cache (White Immortal on Discord). One tick for both makers. ClinePass,
// or the Cline plugin's provider (ARNO on Discord)
const upstreamField = () => {
- const [ptk, pcb] = tick(t("DeepSeek models only from DeepSeek's own API"), !!draft.pinUpstream);
+ const [ptk, pcb] = tick(t("DeepSeek and GLM models only from their makers' own APIs"), !!draft.pinUpstream);
ptk.classList.add("pin-upstream");
pcb.onchange = () => { draft.pinUpstream = pcb.checked; };
- return field(t("Upstream"), ptk, t("Cline serves a model from any host its gateway picks; pinned, a request for a DeepSeek model goes only to DeepSeek, which keeps its prompt cache, and fails when DeepSeek can't take it"));
+ return field(t("Upstream"), ptk, t("Cline serves a model from any host its gateway picks; pinned, a request for a DeepSeek model goes only to DeepSeek and one for a GLM model only to Z.ai, which keeps its prompt cache, and fails when that API can't take it"));
};
// the settings few need — headers, proxy, limits, windows, fallback —
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index 4c89ea749..697981669 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -3360,9 +3360,9 @@ const I18N = {
"User-Agent": "User-Agent",
"Send the agent's own User-Agent": "发送 Agent 自己的 User-Agent",
"For a plan that serves only the coding agents it names: each request goes with the User-Agent the agent sent (pi, OpenCode, Claude Code…), not magpie's. Requests magpie makes itself, and ones the agent sent without one, still go as magpie. A User-Agent set in Headers above always wins.": "给只允许指定编程 Agent 使用的套餐:每个请求带上 Agent 自己发来的 User-Agent(pi、OpenCode、Claude Code…),而不是 magpie 的。magpie 自己发出的请求,以及 Agent 没带 User-Agent 的请求,仍以 magpie 的身份发送。上面请求头里设置的 User-Agent 始终优先。",
- "DeepSeek models only from DeepSeek's own API": "DeepSeek 模型只走 DeepSeek 官方上游",
+ "DeepSeek and GLM models only from their makers' own APIs": "DeepSeek、GLM 模型只走各自官方上游",
"Upstream": "上游",
- "Cline serves a model from any host its gateway picks; pinned, a request for a DeepSeek model goes only to DeepSeek, which keeps its prompt cache, and fails when DeepSeek can't take it": "Cline 的网关会把一个模型发给它挑的任意上游;钉住后,DeepSeek 模型的请求只发给 DeepSeek 官方,缓存能命中;DeepSeek 官方接不了时请求会失败,不会换别家",
+ "Cline serves a model from any host its gateway picks; pinned, a request for a DeepSeek model goes only to DeepSeek and one for a GLM model only to Z.ai, which keeps its prompt cache, and fails when that API can't take it": "Cline 的网关会把一个模型发给它挑的任意上游;钉住后,DeepSeek 模型的请求只发给 DeepSeek 官方,GLM 模型的只发给 Z.ai 官方,缓存能命中;官方接不了时请求会失败,不会换别家",
"For a relay in front of Anthropic's or OpenAI's own API: Claude Code's WebSearch and Codex's web_search go to it as they were sent, not through magpie's search. magpie doesn't automatically search with it for other models, but you can name it as the searcher.": "用于 Anthropic 或 OpenAI 官方 API 前的中转:Claude Code 的 WebSearch 和 Codex 的 web_search 原样发给它,不经 magpie 搜索。不会自动用它为其他模型搜索,但可手动选为代搜供应商。",
"Its models leave the list agents pick from; the routing groups they are in still use them": "它的模型不出现在 Agent 的可选列表里;所在的路由分组仍会使用它们",
"Agents don't see them: only the routing groups they are in use them.": "Agent 看不到这些模型,只有它们所在的路由分组会用到。",
@@ -7055,9 +7055,9 @@ const I18N = {
"User-Agent": "User-Agent",
"Send the agent's own User-Agent": "傳送 Agent 自己的 User-Agent",
"For a plan that serves only the coding agents it names: each request goes with the User-Agent the agent sent (pi, OpenCode, Claude Code…), not magpie's. Requests magpie makes itself, and ones the agent sent without one, still go as magpie. A User-Agent set in Headers above always wins.": "給只允許指定程式設計 Agent 使用的方案:每個請求帶上 Agent 自己送來的 User-Agent(pi、OpenCode、Claude Code…),而不是 magpie 的。magpie 自己發出的請求,以及 Agent 沒帶 User-Agent 的請求,仍以 magpie 的身分傳送。上面請求頭裡設定的 User-Agent 永遠優先。",
- "DeepSeek models only from DeepSeek's own API": "DeepSeek 模型只走 DeepSeek 官方上游",
+ "DeepSeek and GLM models only from their makers' own APIs": "DeepSeek、GLM 模型只走各自官方上游",
"Upstream": "上游",
- "Cline serves a model from any host its gateway picks; pinned, a request for a DeepSeek model goes only to DeepSeek, which keeps its prompt cache, and fails when DeepSeek can't take it": "Cline 的閘道會把一個模型發給它挑的任意上游;釘住後,DeepSeek 模型的請求只發給 DeepSeek 官方,快取能命中;DeepSeek 官方接不了時請求會失敗,不會換別家",
+ "Cline serves a model from any host its gateway picks; pinned, a request for a DeepSeek model goes only to DeepSeek and one for a GLM model only to Z.ai, which keeps its prompt cache, and fails when that API can't take it": "Cline 的閘道會把一個模型發給它挑的任意上游;釘住後,DeepSeek 模型的請求只發給 DeepSeek 官方,GLM 模型的只發給 Z.ai 官方,快取能命中;官方接不了時請求會失敗,不會換別家",
"For a relay in front of Anthropic's or OpenAI's own API: Claude Code's WebSearch and Codex's web_search go to it as they were sent, not through magpie's search. magpie doesn't automatically search with it for other models, but you can name it as the searcher.": "用於 Anthropic 或 OpenAI 官方 API 前的中轉:Claude Code 的 WebSearch 和 Codex 的 web_search 原樣發給它,不經 magpie 搜尋。不會自動用它為其他模型搜尋,但可手動選為代搜供應商。",
"Its models leave the list agents pick from; the routing groups they are in still use them": "它的模型不出現在 Agent 的可選列表裡;所在的路由分組仍會使用它們",
"Agents don't see them: only the routing groups they are in use them.": "Agent 看不到這些模型,只有它們所在的路由分組會用到。",
@@ -10767,9 +10767,9 @@ const I18N = {
"User-Agent": "User-Agent",
"Send the agent's own User-Agent": "エージェント自身の User-Agent を送る",
"For a plan that serves only the coding agents it names: each request goes with the User-Agent the agent sent (pi, OpenCode, Claude Code…), not magpie's. Requests magpie makes itself, and ones the agent sent without one, still go as magpie. A User-Agent set in Headers above always wins.": "指定したコーディングエージェントだけが使えるプラン向け:各リクエストは magpie のものではなく、エージェントが送ってきた User-Agent(pi、OpenCode、Claude Code…)で送られます。magpie 自身のリクエストと、エージェントが User-Agent を付けなかったリクエストは、引き続き magpie として送られます。上のヘッダーで設定した User-Agent が常に優先されます。",
- "DeepSeek models only from DeepSeek's own API": "DeepSeek モデルは DeepSeek 公式 API のみ",
+ "DeepSeek and GLM models only from their makers' own APIs": "DeepSeek・GLM モデルはそれぞれの公式 API のみ",
"Upstream": "上流",
- "Cline serves a model from any host its gateway picks; pinned, a request for a DeepSeek model goes only to DeepSeek, which keeps its prompt cache, and fails when DeepSeek can't take it": "Cline のゲートウェイはモデルを任意の上流に送ります。固定すると DeepSeek モデルへのリクエストは DeepSeek 公式だけに送られ、プロンプトキャッシュが効きます。DeepSeek が受けられないときは失敗します",
+ "Cline serves a model from any host its gateway picks; pinned, a request for a DeepSeek model goes only to DeepSeek and one for a GLM model only to Z.ai, which keeps its prompt cache, and fails when that API can't take it": "Cline のゲートウェイはモデルを任意の上流に送ります。固定すると DeepSeek モデルへのリクエストは DeepSeek 公式だけに、GLM モデルへのリクエストは Z.ai 公式だけに送られ、プロンプトキャッシュが効きます。公式が受けられないときは失敗します",
"For a relay in front of Anthropic's or OpenAI's own API: Claude Code's WebSearch and Codex's web_search go to it as they were sent, not through magpie's search. magpie doesn't automatically search with it for other models, but you can name it as the searcher.": "Anthropic または OpenAI 公式 API の前段にあるリレー向け:Claude Code の WebSearch と Codex の web_search は magpie の検索を通さず、送られたままこのプロバイダに届きます。magpie は他のモデルのためにこれで自動検索はしませんが、検索役として指定することはできます。",
"Its models leave the list agents pick from; the routing groups they are in still use them": "そのモデルはエージェントが選ぶリストから外れます。所属するルーティンググループでは引き続き使われます",
"Agents don't see them: only the routing groups they are in use them.": "エージェントには見えません。所属するルーティンググループだけが使います。",
@@ -14493,9 +14493,9 @@ const I18N = {
"User-Agent": "User-Agent",
"Send the agent's own User-Agent": "Den eigenen User-Agent des Agenten senden",
"For a plan that serves only the coding agents it names: each request goes with the User-Agent the agent sent (pi, OpenCode, Claude Code…), not magpie's. Requests magpie makes itself, and ones the agent sent without one, still go as magpie. A User-Agent set in Headers above always wins.": "Für einen Tarif, der nur die genannten Coding-Agenten zulässt: Jede Anfrage geht mit dem User-Agent, den der Agent gesendet hat (pi, OpenCode, Claude Code…), nicht mit dem von magpie. Anfragen, die magpie selbst stellt, und solche, die der Agent ohne einen gesendet hat, gehen weiter als magpie. Ein oben unter Header gesetzter User-Agent hat immer Vorrang.",
- "DeepSeek models only from DeepSeek's own API": "DeepSeek-Modelle nur über DeepSeeks eigene API",
+ "DeepSeek and GLM models only from their makers' own APIs": "DeepSeek- und GLM-Modelle nur über die eigene API ihres Herstellers",
"Upstream": "Upstream",
- "Cline serves a model from any host its gateway picks; pinned, a request for a DeepSeek model goes only to DeepSeek, which keeps its prompt cache, and fails when DeepSeek can't take it": "Cline lässt ein Modell von einem beliebigen Anbieter seines Gateways bedienen; angeheftet geht eine Anfrage an ein DeepSeek-Modell nur an DeepSeek, das seinen Prompt-Cache behält, und schlägt fehl, wenn DeepSeek sie nicht annimmt",
+ "Cline serves a model from any host its gateway picks; pinned, a request for a DeepSeek model goes only to DeepSeek and one for a GLM model only to Z.ai, which keeps its prompt cache, and fails when that API can't take it": "Cline lässt ein Modell von einem beliebigen Anbieter seines Gateways bedienen; angeheftet geht eine Anfrage an ein DeepSeek-Modell nur an DeepSeek und eine an ein GLM-Modell nur an Z.ai, das jeweils seinen Prompt-Cache behält, und schlägt fehl, wenn dieser Anbieter sie nicht annimmt",
"For a relay in front of Anthropic's or OpenAI's own API: Claude Code's WebSearch and Codex's web_search go to it as they were sent, not through magpie's search. magpie doesn't automatically search with it for other models, but you can name it as the searcher.": "Für ein Relay vor der eigenen API von Anthropic oder OpenAI: WebSearch von Claude Code und web_search von Codex gehen unverändert dorthin, nicht über die Suche von magpie. magpie sucht damit nicht automatisch für andere Modelle, aber Sie können es als Suchdienst festlegen.",
"Its models leave the list agents pick from; the routing groups they are in still use them": "Seine Modelle verschwinden aus der Auswahlliste der Agenten; die Weiterleitungsgruppen, in denen sie sind, nutzen sie weiterhin",
"Agents don't see them: only the routing groups they are in use them.": "Agenten sehen sie nicht: Nur die Weiterleitungsgruppen, in denen sie sind, nutzen sie.",
diff --git a/internal/gui/providers.go b/internal/gui/providers.go
index c6eae0098..93dbe096f 100644
--- a/internal/gui/providers.go
+++ b/internal/gui/providers.go
@@ -91,7 +91,8 @@ type providerJSON struct {
// the vendor searches the web by itself (provider.Searches)
Searches bool `json:"searches"`
// on the Cline API: its DeepSeek models are served by DeepSeek's own
- // API alone (provider.PinUpstream), which only it offers
+ // API alone and its GLM models by Z.ai's (provider.PinUpstream), which
+ // only it offers
Cline bool `json:"cline,omitempty"`
PinUpstream bool `json:"pinUpstream"`
// on this machine or the local network, set to go unmasked by
diff --git a/internal/gui/tests/clinepass-pin.test.cjs b/internal/gui/tests/clinepass-pin.test.cjs
index e7c255ed2..ff3ca4d41 100644
--- a/internal/gui/tests/clinepass-pin.test.cjs
+++ b/internal/gui/tests/clinepass-pin.test.cjs
@@ -1,6 +1,6 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// ClinePass's DeepSeek models pinned to DeepSeek's own API (White Immortal
-// on Discord): the editor of a Cline provider has the tick, as saved; Save
+// on Discord), and its GLM models to Z.ai's (sdytman): the editor of a Cline provider has the tick, as saved; Save
// posts pinUpstream as ticked. The Cline plugin's provider, an account's
// editor, has it too (ARNO on Discord). Another provider's editor has no
// such tick. In English and Chinese.
@@ -54,7 +54,7 @@ function serve(lang, posts) {
};
}
-const words = { en: { tick: "DeepSeek models only from DeepSeek's own API", save: "Save" }, zh: { save: "保存" } };
+const words = { en: { tick: "DeepSeek and GLM models only from their makers' own APIs", save: "Save" }, zh: { save: "保存" } };
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of ["en", "zh"]) {
@@ -70,8 +70,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.route("**/*", serve(lang, posts));
await page.goto("http://magpie.test/?view=providers");
const zh = await page.evaluate(() => [
- "DeepSeek models only from DeepSeek's own API", "Upstream",
- "Cline serves a model from any host its gateway picks; pinned, a request for a DeepSeek model goes only to DeepSeek, which keeps its prompt cache, and fails when DeepSeek can't take it",
+ "DeepSeek and GLM models only from their makers' own APIs", "Upstream",
+ "Cline serves a model from any host its gateway picks; pinned, a request for a DeepSeek model goes only to DeepSeek and one for a GLM model only to Z.ai, which keeps its prompt cache, and fails when that API can't take it",
].map((k) => I18N.zh[k]));
assert(zh.every(Boolean), "every string has its Chinese");
if (lang === "zh") w.tick = zh[0];
diff --git a/internal/plugin/testdata/fake/index.js b/internal/plugin/testdata/fake/index.js
index 60ee44f81..8f7154d09 100644
--- a/internal/plugin/testdata/fake/index.js
+++ b/internal/plugin/testdata/fake/index.js
@@ -87,6 +87,8 @@ export const FakePlugin = async ({ client }) => ({
if (process.env.FAKE_GROK) cfg.provider[ID].models["grok-4.7"] = { name: "Grok 4.7", provider: { npm: "@ai-sdk/openai" }, limit: { context: 4000, output: 400 } }
// $FAKE_DEEPSEEK: a DeepSeek model, as Cline's cline-pass/deepseek-v4-pro
if (process.env.FAKE_DEEPSEEK) cfg.provider[ID].models["deepseek-v4-pro"] = { name: "DeepSeek V4 Pro", limit: { context: 1000, output: 100 } }
+ // $FAKE_GLM: a GLM model, as Cline's cline-pass/glm-5.3
+ if (process.env.FAKE_GLM) cfg.provider[ID].models["glm-5.3"] = { name: "GLM 5.3", limit: { context: 1000, output: 100 } }
// $FAKE_SEARCHES: the provider's upstream searches by itself (#2027),
// as a plugin in front of Claude's API says
if (process.env.FAKE_SEARCHES) cfg.provider[ID].searches = true
diff --git a/internal/provider/cline.go b/internal/provider/cline.go
index bd72719da..38f66043a 100644
--- a/internal/provider/cline.go
+++ b/internal/provider/cline.go
@@ -174,16 +174,28 @@ func (p Provider) ClinePinnable() bool {
return p.IsCline() || p.PluginProvider() == "cline"
}
+// clineMakers maps a model name's start to its maker's own upstream on
+// Cline's AI gateway (Vercel's AI Gateway, whose provider slugs these
+// are: ai-gateway.vercel.sh/v1/models/<model>/endpoints lists "deepseek"
+// for deepseek/deepseek-v4-pro and "zai" for zai/glm-5.3).
+var clineMakers = []struct{ prefix, upstream string }{
+ {"deepseek", "deepseek"},
+ {"glm", "zai"}, // sdytman on Discord: GLM only through Z.ai
+}
+
// ClinePin is the upstream a request for model is pinned to on p
-// (PinUpstream): "deepseek" for a DeepSeek model of the Cline API, ""
-// for anything else. Cline's free models are served where Cline puts
-// them, so they never are.
+// (PinUpstream): "deepseek" for a DeepSeek model of the Cline API, "zai"
+// for a GLM one, "" for anything else. Cline's free models are served
+// where Cline puts them, so they never are.
func (p Provider) ClinePin(model string) string {
if !p.PinUpstream || !p.ClinePinnable() || strings.HasPrefix(model, clineFreePrefix) {
return ""
}
- if name := model[strings.LastIndex(model, "/")+1:]; strings.HasPrefix(strings.ToLower(name), "deepseek") {
- return "deepseek"
+ name := strings.ToLower(model[strings.LastIndex(model, "/")+1:])
+ for _, m := range clineMakers {
+ if strings.HasPrefix(name, m.prefix) {
+ return m.upstream
+ }
}
return ""
}
diff --git a/internal/provider/provider.go b/internal/provider/provider.go
index 4458dd273..5f3882968 100644
--- a/internal/provider/provider.go
+++ b/internal/provider/provider.go
@@ -251,9 +251,10 @@ type Provider struct {
PassUserAgent bool `json:"passUserAgent,omitempty"`
// PinUpstream, on the Cline API, has its DeepSeek models answered only
- // by DeepSeek's own API (White Immortal on Discord): Cline routes a
- // model through an AI gateway that may serve it from any host, and
- // DeepSeek's own keeps its prompt cache. See ClinePin.
+ // by DeepSeek's own API (White Immortal on Discord) and its GLM models
+ // only by Z.ai's (sdytman on Discord): Cline routes a model through an
+ // AI gateway that may serve it from any host, and the maker's own
+ // keeps its prompt cache. See ClinePin.
PinUpstream bool `json:"pinUpstream,omitempty"`
// AuthHeader is which header the key goes in on a third-party