Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

feat(model-catalog): the OpenCode Go group, after TokenDance and Penguin Go (#786)

Yaowei Zheng8e9cb43614de
diff --git a/changelog/unreleased/2026-09-18-opencode-go.md b/changelog/unreleased/2026-09-18-opencode-go.md
new file mode 100644
index 00000000..183e9d45
--- /dev/null
+++ b/changelog/unreleased/2026-09-18-opencode-go.md
@@ -0,0 +1,22 @@
+# OpenCode Go: a built-in model group, listed after TokenDance and Penguin Go
+
+- **Date:** 2026-09-18
+- **Type:** feature
+- **Scope:** `model-catalog`, `web`, `docs`
+- **PR:** [#786](https://github.com/Prism-Shadow/penguin-harness/pull/786)
+
+[中文版](2026-09-18-opencode-go.zh.md)
+
+The model catalog gained an **OpenCode Go** group (`opencode-go`) holding the 27 models OpenCode lists for its Go subscription. By default the Models page lists it third: TokenDance, Penguin Go, OpenCode Go, DeepSeek, then the other groups in their previous order.
+
+## Details
+
+- Each row pins the protocol OpenCode's endpoint table gives its model. 16 rows use `openai-chat` and 4 use `openai-responses`, all at `https://opencode.ai/zen/go/v1`. The other 7 use `ant-messages` at `https://opencode.ai/zen/go`, because the Anthropic client appends `/v1/messages` itself. A model added to the group by hand gets `openai-chat` and the `/v1` base URL.
+- The key goes on the group. Like every gateway's rows, these do not fall back to `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` when left blank.
+- Prices are the per-token rates on OpenCode's Go page, in USD. Go is a monthly subscription whose usage limits are dollar amounts, so for this group the cost center shows allowance used. `gpt-5.6-luna`, `grok-4.6`, `qwen3.7-plus` and `qwen3.6-plus` store their base tier. The four DeepSeek rows store the peak rate and follow DeepSeek's off-peak schedule. No row carries a promotion.
+- Context windows and image input come from models.dev, the model registry OpenCode maintains. 16 rows accept images and 11 are text only.
+- `muse-spark-1.3-contributor` and `muse-spark-1.2-contributor` answer 403 until the key's OpenCode workspace consents to Meta training on prompts and completions. `deepseek-v4.1-flash`, `deepseek-v4-flash` and `deepseek-v4-pro` answer 403 until it consents to China-hosted serving. From mainland China, `gpt-5.6-luna` and both Muse Spark models answer 403 for the caller's region.
+- Every request to `opencode.ai` names its conversation in `x-opencode-session`, which the gateway requires: a Session's requests carry its id, and a request outside any Session — the Models page's connectivity and speed tests, vision detection — a fresh id of its own. Without it the connectivity test failed with `400 Request is missing x-opencode-session`.
+- The group's glyph is the pixel "G" of OpenCode Go's wordmark.
+- The models docs gained a section on the group, and the configuration docs list its environment variables.
+- Existing Projects pick the group up through "Sync presets" on the Models page. A Project whose groups were dragged into a custom order keeps that order, and the new group comes after the groups it names.
diff --git a/changelog/unreleased/2026-09-18-opencode-go.zh.md b/changelog/unreleased/2026-09-18-opencode-go.zh.md
new file mode 100644
index 00000000..5c7d3ae0
--- /dev/null
+++ b/changelog/unreleased/2026-09-18-opencode-go.zh.md
@@ -0,0 +1,22 @@
+# OpenCode Go:内置模型分组,排在 TokenDance 与 Penguin Go 之后
+
+- **Date:** 2026-09-18
+- **Type:** feature
+- **Scope:** `model-catalog`, `web`, `docs`
+- **PR:** [#786](https://github.com/Prism-Shadow/penguin-harness/pull/786)
+
+[English](2026-09-18-opencode-go.md)
+
+模型目录新增 **OpenCode Go** 分组(`opencode-go`),收录 OpenCode 为 Go 订阅列出的 27 个模型。模型库页面默认把它排在第三位:TokenDance、Penguin Go、OpenCode Go、DeepSeek,其余分组保持原有顺序。
+
+## 细节
+
+- 每个条目按 OpenCode 端点表给出的协议固定:16 条用 `openai-chat`、4 条用 `openai-responses`,都走 `https://opencode.ai/zen/go/v1`;其余 7 条用 `ant-messages`,走 `https://opencode.ai/zen/go`,因为 Anthropic 客户端会自行拼上 `/v1/messages`。手动添加进该分组的模型使用 `openai-chat` 与带 `/v1` 的 base URL。
+- key 设在分组上。与所有网关的条目一样,这些条目在 key 留空时不会回退到 `OPENAI_API_KEY` 或 `ANTHROPIC_API_KEY`。
+- 价格取 OpenCode Go 页面列出的每 Token 美元价。Go 按月订阅、用量上限是美元额度,因此对这个分组而言,成本中心显示的是已用额度。`gpt-5.6-luna`、`grok-4.6`、`qwen3.7-plus` 与 `qwen3.6-plus` 记录基础档;四个 DeepSeek 条目记录高峰价,并沿用 DeepSeek 的空闲时段规则。所有条目都不带促销折扣。
+- 上下文窗口与图像输入能力取自 OpenCode 维护的模型注册表 models.dev:16 个条目支持图像输入,11 个为纯文本。
+- 在 key 所属的 OpenCode 工作区同意 Meta 用提示词和回复训练模型之前,`muse-spark-1.3-contributor` 与 `muse-spark-1.2-contributor` 返回 403;在其同意由中国境内托管的服务提供之前,`deepseek-v4.1-flash`、`deepseek-v4-flash` 与 `deepseek-v4-pro` 返回 403。从中国大陆访问时,`gpt-5.6-luna` 与两个 Muse Spark 模型因调用方所在地区返回 403。
+- 发往 `opencode.ai` 的每个请求都在 `x-opencode-session` 中标明所属对话,这是网关的要求:Session 内的请求带该 Session 的 id,不属于任何 Session 的请求(模型库页面的连通性测试与测速、视觉探测)各自带一个新生成的 id。此前缺少该请求头时,连通性测试会报 `400 Request is missing x-opencode-session`。
+- 分组图标是 OpenCode Go 字标中的像素风「G」。
+- 模型文档新增了介绍该分组的一节,配置文档列出了该分组的环境变量。
+- 已有 Project 经模型库页面的「同步预置」获得该分组。分组被拖动成自定义顺序的 Project 保留原有顺序,新分组排在已排好的分组之后。
diff --git a/packages/core/src/interfaces/llm.ts b/packages/core/src/interfaces/llm.ts
index dba5af98..44e83e55 100644
--- a/packages/core/src/interfaces/llm.ts
+++ b/packages/core/src/interfaces/llm.ts
@@ -74,8 +74,9 @@ export interface GenerativeModelConfig {
/**
* The Session's id, for endpoints whose attribution scheme identifies the conversation
* rather than the app (OpenCode's `x-opencode-session`; see state/model-catalog.ts
- * `attributionHeaders`). Unset: no such header is sent — a placeholder id would file every
- * conversation at the gateway under one session, which is worse than naming none.
+ * `attributionHeaders`). Unset — a request outside any Session: a connectivity test, a
+ * vision probe, a one-off utility completion — attributionHeaders mints a fresh id, which
+ * the instance then keeps for all of its requests, so they are a conversation of their own.
*/
sessionId?: string;
/**
diff --git a/packages/core/src/llm/generative-model.ts b/packages/core/src/llm/generative-model.ts
index b5f02fb9..b92278cb 100644
--- a/packages/core/src/llm/generative-model.ts
+++ b/packages/core/src/llm/generative-model.ts
@@ -985,7 +985,9 @@ export class GenerativeModel implements LLMInterface {
// configured endpoint reads (see attributionHeaders); AgentHub hands it to every request
// the routed client makes, and endpoints with no attribution scheme get no extra headers
// at all. The Session's id rides along for the schemes that name the conversation rather
- // than the app.
+ // than the app; without one, attributionHeaders mints a fresh id. Computed once and kept
+ // in clientOptions, so every request of this instance — across a rotated credential too —
+ // names the same conversation.
const headers = attributionHeaders(config.baseUrl, config.sessionId);
this.clientOptions = {
model: config.modelId,
diff --git a/packages/core/src/state/model-catalog.ts b/packages/core/src/state/model-catalog.ts
index 0922ee86..81392f0e 100644
--- a/packages/core/src/state/model-catalog.ts
+++ b/packages/core/src/state/model-catalog.ts
@@ -18,10 +18,10 @@
* the 2026-09-16 refresh — the direct DeepSeek group down to the two names its pricing page
* lists, TokenDance's deepseek-v4-flash-0731 / deepseek-v4-pro-0813 / kimi-k3 promotions, the
* OpenRouter qwen/qwen3.8-27b row, the Fireworks AI and SiliconFlow additions, and both Qwen
- * groups' line-ups with their peak/off-peak DeepSeek rows: 2026-09-16 — per each provider's
- * docs; and the ModelScope group, whose preset ids were read from public model pages and
- * endpoint listings — their windows, vision flags and prices are NOT verified and say so on the
- * rows themselves: 2026-09-18 and 2026-09-20).
+ * groups' line-ups with their peak/off-peak DeepSeek rows: 2026-09-16; the OpenCode Go group:
+ * 2026-09-18 — per each provider's docs; and the ModelScope group, whose preset ids were read
+ * from public model pages and endpoint listings — their windows, vision flags and prices are
+ * NOT verified and say so on the rows themselves: 2026-09-18 and 2026-09-20).
* Docs: packages/docs/content/models.{zh,en}.md (site path /docs/models) documents the
* provider groups and credential resolution described here.
*
@@ -42,8 +42,8 @@
* (delisted 2026-08-06; the Z.AI direct glm-5.1 remains), the OpenRouter
* inclusionai/ling-3.0-flash:free listing (delisted from OpenRouter, removed 2026-08-18),
* non-chat models (embedding / image generation / TTS), and Bedrock. Direct-vendor ids are
- * auto-routed by AgentHub and leave client_type unset; six gateway groups (OpenRouter,
- * Fireworks AI, SiliconFlow, TokenDance, Qwen Pay-As-You-Go and Qwen Token Plan)
+ * auto-routed by AgentHub and leave client_type unset; seven gateway groups (OpenRouter,
+ * Fireworks AI, SiliconFlow, TokenDance, OpenCode Go, Qwen Pay-As-You-Go and Qwen Token Plan)
* can't be auto-routed, so every gateway row **always pins an explicit client_type** and
* inlines its preset base URL. ModelScope is a mixed-protocol aggregator like Penguin Go:
* each row pins the AgentHub protocol that its upstream model should display and use.
@@ -55,7 +55,7 @@
* against `client_type || model_id` and never looks at base_url, so an unpinned gateway id
* would be routed by its own spelling — `openai/gpt-5.6-sol` would reach the first-party
* GPT-5.6 client aimed at a gateway, and `anthropic/claude-opus-4.8` would throw outright
- * (dotted "4.8" matches neither "4-8" nor "-5"). Three protocols are pinned:
+ * (dotted "4.8" matches neither "4-8" nor "-5"). Four protocols are pinned:
* - `openai-responses` for every OpenRouter row: OpenRouter serves the Responses API for
* every upstream at the same base URL the rows already carry, and the group pins the same
* protocol so a user-added entry inherits it;
@@ -64,7 +64,10 @@
* deprecated upstream alias, see canonicalClientType);
* - `openai-chat-vllm-adapter` for the vLLM group, which is Chat Completions on the wire
* but maps the thinking level onto the served model's own chat template
- * (VLLM_CLIENT_TYPE).
+ * (VLLM_CLIENT_TYPE);
+ * - `ant-messages` for the OpenCode Go rows its endpoint table serves on the Anthropic
+ * Messages API. That group pins row by row, since its models sit on three protocols: the
+ * rest of it is `openai-chat` and `openai-responses` — see its block comment.
* ModelScope's rows follow the same explicit-row rule as Penguin Go even though the endpoint is
* one gateway: its Qwen rows pin the vLLM adapter, while its DeepSeek row pins `deepseek-v4` so
* the frontend shows each model's actual AgentHub protocol instead of flattening the group.
@@ -255,6 +258,10 @@ const MINIMAX_BASE_URL = "https://api.minimax.io/v1";
const DEEPSEEK_BASE_URL = "https://api.deepseek.com";
const MODELSCOPE_BASE_URL = "https://api-inference.modelscope.cn/v1";
export const PENGUIN_GO_BASE_URL = "https://token.penguin.ooo/api";
+/** OpenCode Go's OpenAI-protocol base: the clients append /chat/completions or /responses. */
+const OPENCODE_GO_BASE_URL = "https://opencode.ai/zen/go/v1";
+/** OpenCode Go's Anthropic Messages base: the SDK appends /v1/messages itself, so no /v1 here. */
+const OPENCODE_GO_MESSAGES_BASE_URL = "https://opencode.ai/zen/go";
/** Provider id for the preconfigured Penguin Go relay group. */
export const PENGUIN_GO_PROVIDER_ID = "penguin-go";
@@ -266,23 +273,24 @@ export const MODELSCOPE_PROVIDER_ID = "modelscope";
* Provider list (web model page groups in this order BY DEFAULT — a user's dragged
* arrangement is stored per Project and wins over this sequence; see the web's
* model-group-order.ts). The sequence is a hand-curated display order: TokenDance leads as
- * the recommended group, Penguin Go follows, then DeepSeek as the default model's
- * provider, and custom
+ * the recommended group, Penguin Go follows, then OpenCode Go, then DeepSeek as the default
+ * model's provider, and custom
* (custom OpenAI-protocol models) is always last; in between, gateways and first-party
* vendors are interleaved by expected use rather than sorted by kind. Only this default
* moves when the curation changes: a Project that has ever reordered its groups has every
* key stored already, so it keeps the arrangement its user built.
*
- * The six OpenAI-compatible gateway groups — OpenRouter, Fireworks AI, SiliconFlow, TokenDance,
- * Qwen Pay-As-You-Go and Qwen Token Plan — reach their models through one of AgentHub's generic
- * OpenAI-protocol clients (`openai-responses` for OpenRouter, `openai-chat` for the rest).
- * Those clients read **OPENAI_API_KEY / OPENAI_BASE_URL** when the credential is blank, not
- * the gateway's own variable names, so every such gateway group records the OPENAI_* pair as the
- * fact it is — and that is exactly why a keyless gateway row is refused the fallback (see
- * modelEnvFallback): the variable holds the user's OpenAI key, and a gateway is not OpenAI.
- * ModelScope also records the OPENAI_* pair because its group credential is an api-inference
- * access token even when a row's protocol is model-specific; its rows are refused the fallback
- * on the same terms.
+ * The seven gateway groups — OpenRouter, Fireworks AI, SiliconFlow, TokenDance, OpenCode Go,
+ * Qwen Pay-As-You-Go and Qwen Token Plan — reach their models through AgentHub's generic
+ * protocol clients (`openai-responses` for OpenRouter, `openai-chat` for the rest, and all
+ * three generic clients within OpenCode Go). Those clients read the vendor variables
+ * (**OPENAI_API_KEY / OPENAI_BASE_URL**, and ANTHROPIC_* for OpenCode Go's `ant-messages`
+ * rows) when the credential is blank, not the gateway's own variable names, so every gateway
+ * group records the OPENAI_* pair as the fact it is — and that is exactly why a keyless
+ * gateway row is refused the fallback (see modelEnvFallback): the variable holds the user's
+ * OpenAI (or Anthropic) key, and a gateway is neither. ModelScope also records the OPENAI_*
+ * pair because its group credential is an api-inference access token even when a row's
+ * protocol is model-specific; its rows are refused the fallback on the same terms.
*/
export const MODEL_PROVIDERS: ModelProviderInfo[] = [
{
@@ -312,6 +320,20 @@ export const MODEL_PROVIDERS: ModelProviderInfo[] = [
modelsUrl: "https://token.penguin.ooo/",
bridgeAuth: { flow: "penguin-go" },
},
+ {
+ // One key serves the whole group, but its models sit on three protocols (see the group's
+ // block comment in MODEL_CATALOG), so no group-level pin. The env pair records what its
+ // Chat Completions majority's client reads, and a model added here by hand gets the preset
+ // base URL below with openai-chat. Like every gateway's, a keyless row is refused that
+ // fallback (modelEnvFallback): the key goes on the rows.
+ id: "opencode-go",
+ label: "OpenCode Go",
+ envKey: "OPENAI_API_KEY",
+ envBaseUrlKey: "OPENAI_BASE_URL",
+ apiKeyUrl: "https://opencode.ai/auth",
+ modelsUrl: "https://opencode.ai/docs/go/",
+ gatewayBaseUrl: OPENCODE_GO_BASE_URL,
+ },
{
id: "deepseek",
label: "DeepSeek",
@@ -1833,6 +1855,330 @@ export const MODEL_CATALOG: ModelCatalogEntry[] = [
clientType: "deepseek-v4",
baseUrl: PENGUIN_GO_BASE_URL,
},
+ // -- OpenCode Go (subscription gateway). The lineup, model ids, endpoints and per-token rates
+ // are from opencode.ai/docs/go (read 2026-09-18), which lists these 27 models. Context
+ // windows and input modalities are from the opencode-go provider on models.dev, the model
+ // registry OpenCode maintains (hy3 records its input cap instead; see its row). The gateway's
+ // /models listing also answers ten older ids the docs page does not list and models.dev
+ // marks deprecated (minimax-m2.5, kimi-k2.5, glm-5, deepseek-flash, qwen3.5-plus,
+ // mimo-v2-pro, mimo-v2-omni, hy3-preview, grok-4.5, omen-alpha); they are left out. So is
+ // union-alpha, a limited-time free model the page listed on 2026-09-17 and dropped by
+ // 2026-09-18.
+ //
+ // Protocol: the docs page's endpoint table puts each model on one path, and each row pins
+ // the generic client for it: `openai-chat` for /chat/completions and `openai-responses` for
+ // /responses, both on OPENCODE_GO_BASE_URL, and `ant-messages` for /v1/messages on
+ // OPENCODE_GO_MESSAGES_BASE_URL. The paths are not interchangeable: /chat/completions refuses
+ // grok-4.6 and fails for gpt-5.6-luna. The pins are load-bearing too: unpinned, gpt-5.6-luna,
+ // glm-*, kimi-k3, kimi-k2.6, deepseek-v4* and minimax-m3 would reach their first-party
+ // clients, and the other ids would not route at all. The gateway refuses a request that does
+ // not name its conversation (400 "Request is missing x-opencode-session"), which
+ // attributionHeaders does for this host on every request: a Session's requests carry its id,
+ // and a request outside any Session — a connectivity test, a vision probe — a fresh one.
+ //
+ // Vision: from models.dev, and checked live on 2026-09-17 and 2026-09-18 by sending an image
+ // of a number. Every vision row that could be reached read it back, and the text-only rows
+ // refused the image or answered without seeing it. The rows below that could not be reached
+ // keep models.dev's flag.
+ //
+ // Pricing: Go is a monthly subscription whose usage limits are dollar amounts. Each model has
+ // a monthly allowance, capped at 20% per 5 hours and 50% per week. A request draws the
+ // per-token rates the docs page publishes, and those are what the rows store. So the cost
+ // center shows allowance spent, not an invoice, as with the Qwen Token Plan rows, which store
+ // per-token list prices rather than the plan's fee. Where the page lists no cached-write rate,
+ // cache_write carries the input rate. Four rows are tiered and store their base tier: GPT-5.6
+ // Luna above 272K input tokens, Grok 4.6 above 200K, Qwen 3.7 Plus and Qwen 3.6 Plus above
+ // 256K. The four DeepSeek rows publish a peak and an off-peak rate on DeepSeek's own windows
+ // (peak 01:00-04:00 and 06:00-10:00 UTC on weekdays, i.e. DEEPSEEK_OFF_PEAK), off-peak
+ // exactly half, so they store the peak rate and declare that schedule. DeepSeek V4.1 Flash's
+ // running "4x" offer (ends 2026-09-20) raises its monthly allowance, not its rates, so no
+ // row carries a `discount`.
+ //
+ // Account opt-in and region: five models answer 403 until the key's OpenCode workspace opts
+ // in. The two Muse Spark Contributor models require consent to Meta training on prompts and
+ // completions. deepseek-v4.1-flash, deepseek-v4-flash and deepseek-v4-pro require consent to
+ // China-hosted serving. Some upstreams also refuse a caller's region: from a mainland China
+ // address, gpt-5.6-luna answers 403 unsupported_country_region_territory and both Muse Spark
+ // rows 403 "not available in your country", while gpt-5.6-luna passed every check from
+ // outside it. The rows that could not be reached follow the docs page and the protocol the
+ // other rows on their path proved. --
+ {
+ modelId: "deepseek-v4.1-flash",
+ displayName: "DeepSeek V4.1 Flash",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.006, 0.3, 1.2),
+ offPeakDiscount: DEEPSEEK_OFF_PEAK,
+ supportsVision: true,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "deepseek-v4-flash",
+ displayName: "DeepSeek V4 Flash",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.006, 0.3, 1.2),
+ offPeakDiscount: DEEPSEEK_OFF_PEAK,
+ supportsVision: false,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "deepseek-v4-flash-vision-exp",
+ displayName: "DeepSeek V4 Flash Vision Exp",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.006, 0.3, 1.2),
+ offPeakDiscount: DEEPSEEK_OFF_PEAK,
+ supportsVision: true,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "deepseek-v4-pro",
+ displayName: "DeepSeek V4 Pro",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.044, 1.32, 3.96),
+ offPeakDiscount: DEEPSEEK_OFF_PEAK,
+ supportsVision: false,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "glm-5.3",
+ displayName: "GLM-5.3",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.26, 1.4, 4.4),
+ supportsVision: false,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "glm-5.3-flash",
+ displayName: "GLM-5.3 Flash",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.03, 0.15, 0.5),
+ supportsVision: true,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "glm-5.2",
+ displayName: "GLM-5.2",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.26, 1.4, 4.4),
+ supportsVision: false,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "glm-5.1",
+ displayName: "GLM-5.1",
+ provider: "opencode-go",
+ contextWindow: 202752,
+ pricing: usd(0.26, 1.4, 4.4),
+ supportsVision: false,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "gpt-5.6-luna",
+ displayName: "GPT-5.6 Luna",
+ provider: "opencode-go",
+ contextWindow: 1050000,
+ pricing: usd(0.02, 0.25, 1.2),
+ supportsVision: true,
+ clientType: "openai-responses",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "grok-4.6",
+ displayName: "Grok 4.6",
+ provider: "opencode-go",
+ contextWindow: 500000,
+ pricing: usd(0.5, 2, 6),
+ supportsVision: true,
+ clientType: "openai-responses",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "hy4-preview",
+ displayName: "Hy4 preview",
+ provider: "opencode-go",
+ contextWindow: 1024000,
+ pricing: usd(0.042, 0.834, 2.501),
+ supportsVision: false,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ // models.dev lists a 256,000-token context for Hy3 but caps its input at 192,000. Compaction
+ // derives from this field, so it records the input cap: at 256,000 a Session would keep
+ // sending prompts the upstream refuses until it compacted at ~254K.
+ modelId: "hy3",
+ displayName: "Hy3",
+ provider: "opencode-go",
+ contextWindow: 192000,
+ pricing: usd(0.035, 0.14, 0.58),
+ supportsVision: false,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "kimi-k3",
+ displayName: "Kimi K3",
+ provider: "opencode-go",
+ contextWindow: 1048576,
+ pricing: usd(0.3, 3, 15),
+ supportsVision: true,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "kimi-k2.7-code",
+ displayName: "Kimi K2.7 Code",
+ provider: "opencode-go",
+ contextWindow: 262144,
+ pricing: usd(0.19, 0.95, 4),
+ supportsVision: true,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "kimi-k2.6",
+ displayName: "Kimi K2.6",
+ provider: "opencode-go",
+ contextWindow: 262144,
+ pricing: usd(0.16, 0.95, 4),
+ supportsVision: true,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "longcat-2.0",
+ displayName: "LongCat 2.0",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.006, 0.3, 1.2),
+ supportsVision: false,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "mimo-v2.5",
+ displayName: "MiMo-V2.5",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.0028, 0.14, 0.28),
+ supportsVision: true,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "mimo-v2.5-pro",
+ displayName: "MiMo-V2.5-Pro",
+ provider: "opencode-go",
+ contextWindow: 1048576,
+ pricing: usd(0.003625, 0.435, 0.87),
+ supportsVision: false,
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "minimax-m3",
+ displayName: "MiniMax M3",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.06, 0.3, 1.2),
+ supportsVision: true,
+ clientType: "ant-messages",
+ baseUrl: OPENCODE_GO_MESSAGES_BASE_URL,
+ },
+ {
+ modelId: "minimax-m2.7",
+ displayName: "MiniMax M2.7",
+ provider: "opencode-go",
+ contextWindow: 204800,
+ pricing: usd(0.06, 0.375, 1.2),
+ supportsVision: false,
+ clientType: "ant-messages",
+ baseUrl: OPENCODE_GO_MESSAGES_BASE_URL,
+ },
+ {
+ modelId: "muse-spark-1.3-contributor",
+ displayName: "Muse Spark 1.3 Contributor",
+ provider: "opencode-go",
+ contextWindow: 1048576,
+ pricing: usd(0.002, 0.1, 0.2),
+ supportsVision: true,
+ clientType: "openai-responses",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "muse-spark-1.2-contributor",
+ displayName: "Muse Spark 1.2 Contributor",
+ provider: "opencode-go",
+ contextWindow: 1048576,
+ pricing: usd(0.002, 0.1, 0.2),
+ supportsVision: true,
+ clientType: "openai-responses",
+ baseUrl: OPENCODE_GO_BASE_URL,
+ },
+ {
+ modelId: "qwen3.8-flash",
+ displayName: "Qwen 3.8 Flash",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.016, 0.2, 0.47),
+ supportsVision: true,
+ clientType: "ant-messages",
+ baseUrl: OPENCODE_GO_MESSAGES_BASE_URL,
+ },
+ {
+ modelId: "qwen3.8-max",
+ displayName: "Qwen 3.8 Max",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.25, 2.5, 6),
+ supportsVision: true,
+ clientType: "ant-messages",
+ baseUrl: OPENCODE_GO_MESSAGES_BASE_URL,
+ },
+ {
+ modelId: "qwen3.7-max",
+ displayName: "Qwen 3.7 Max",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.5, 3.125, 7.5),
+ supportsVision: false,
+ clientType: "ant-messages",
+ baseUrl: OPENCODE_GO_MESSAGES_BASE_URL,
+ },
+ {
+ modelId: "qwen3.7-plus",
+ displayName: "Qwen 3.7 Plus",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.04, 0.5, 1.6),
+ supportsVision: true,
+ clientType: "ant-messages",
+ baseUrl: OPENCODE_GO_MESSAGES_BASE_URL,
+ },
+ {
+ modelId: "qwen3.6-plus",
+ displayName: "Qwen 3.6 Plus",
+ provider: "opencode-go",
+ contextWindow: 1000000,
+ pricing: usd(0.05, 0.625, 3),
+ supportsVision: true,
+ clientType: "ant-messages",
+ baseUrl: OPENCODE_GO_MESSAGES_BASE_URL,
+ },
// -- Qwen Token Plan (subscription gateway; vision flags per the plan's supported-model
// table, and for the rows added 2026-09-16 per their model pages' input modalities).
// Pricing and context windows from each model's page at www.qianwenai.com/models/<id>
@@ -3003,9 +3349,10 @@ export function fastModeProtocol(
* config, avoiding duplicate hand-written copies). `provider` and `model_id` are persisted as
* separate fields (`model_id` is the plain upstream id); models whose upstream id can be
* auto-routed by AgentHub leave client_type unset; gateway models (OpenRouter / SiliconFlow)
- * always pin a client_type — openai-responses for the OpenRouter rows, openai-chat for the
- * rest — and inline a preset base_url. The direct MiniMax M3 entry also pins its protocol and
- * endpoint. No secrets are included, so only an API key is needed.
+ * always pin a client_type — openai-responses for the OpenRouter rows, each OpenCode Go row's
+ * own endpoint protocol, openai-chat for the rest — and inline a preset base_url. The direct
+ * MiniMax M3 entry also pins its protocol and endpoint. No secrets are included, so only an
+ * API key is needed.
*
* Pricing is written as the LIST price the catalog records (a scheduled row's PEAK price),
* never a discounted number. What is on disk then stays true whatever promotion is live and
@@ -3157,10 +3504,14 @@ function hostMatches(host: string, domain: string): boolean {
* takes priority over any App URL recorded on the API key — the same key may be in use by
* other tools, so the per-request value is the accurate one.
* - OpenCode (https://opencode.ai): `x-opencode-session` alone, and it names the conversation
- * rather than the app — the gateway keys its backend routing on it, so the value has to hold
- * still across a Session's requests and differ between Sessions. It is therefore sent only
- * when a Session id is at hand: a stand-in constant would file every conversation under one
- * session, which serves the gateway worse than naming none.
+ * rather than the app — the gateway keys its routing and prompt caching on it, so the value
+ * has to hold still across a conversation's requests and differ between conversations. It
+ * is **always** sent: the gateway refuses a request that names none (400 "Request is missing
+ * x-opencode-session"). A Session's requests carry the Session's id; a request with none (a
+ * connectivity test, a vision probe) gets a fresh random id, making it a conversation of its
+ * own — never a shared constant, which would file every such request under one session. A
+ * caller that sends several requests without a Session computes the headers once and
+ * reuses them (GenerativeModel does, per instance), so they share that one id.
*/
export function attributionHeaders(
baseUrl: string | undefined,
@@ -3176,6 +3527,9 @@ export function attributionHeaders(
};
}
if (hostMatches(host, "tokendance.space")) return { "X-App-URL": APP_URL };
- if (hostMatches(host, "opencode.ai") && sessionId) return { "x-opencode-session": sessionId };
+ if (hostMatches(host, "opencode.ai")) {
+ // The global Web Crypto rather than node:crypto: this module is bundled into the web app too.
+ return { "x-opencode-session": sessionId || globalThis.crypto.randomUUID() };
+ }
return undefined;
}
diff --git a/packages/core/test/generative-model-attribution.test.ts b/packages/core/test/generative-model-attribution.test.ts
new file mode 100644
index 00000000..226d1e8d
--- /dev/null
+++ b/packages/core/test/generative-model-attribution.test.ts
@@ -0,0 +1,84 @@
+/**
+ * GenerativeModel's attribution headers: what reaches AgentHub's client as `defaultHeaders`.
+ * OpenCode refuses a request that does not name its conversation in `x-opencode-session`, so
+ * a model built for a Session sends that Session's id, and one built outside any Session (the
+ * connectivity test, the vision probe) sends a fresh id of its own — never nothing, and never
+ * one value shared between instances. The id is fixed per instance, so a rotated credential,
+ * which rebuilds the client, keeps it.
+ */
+import { describe, expect, it, vi } from "vitest";
+
+const captured = vi.hoisted(() => ({ options: [] as Record<string, unknown>[] }));
+
+vi.mock("@prismshadow/agenthub", async (importOriginal) => {
+ const mod = await importOriginal<typeof import("@prismshadow/agenthub")>();
+ class FakeAutoLLMClient {
+ constructor(options: Record<string, unknown>) {
+ captured.options.push(options);
+ }
+ getHistory(): unknown[] {
+ return [];
+ }
+ }
+ return { ...mod, AutoLLMClient: FakeAutoLLMClient };
+});
+
+const { GenerativeModel } = await import("../src/llm/generative-model.js");
+
+const OPENCODE_GO = "https://opencode.ai/zen/go/v1";
+
+/** The `defaultHeaders` of the client the last constructed model built. */
+function lastHeaders(): Record<string, string> | undefined {
+ return captured.options.at(-1)?.defaultHeaders as Record<string, string> | undefined;
+}
+
+const build = (over: { baseUrl?: string; sessionId?: string }) =>
+ new GenerativeModel({
+ modelId: "glm-5.3",
+ apiKey: "sk-test",
+ clientType: "openai-chat",
+ tools: [],
+ ...over,
+ });
+
+describe("GenerativeModel attribution headers", () => {
+ it("names a Session's requests after the Session", () => {
+ build({ baseUrl: OPENCODE_GO, sessionId: "session-2026-09-30-10-00-00-abcd1234" });
+ expect(lastHeaders()).toEqual({
+ "x-opencode-session": "session-2026-09-30-10-00-00-abcd1234",
+ });
+ });
+
+ it("gives a request outside any Session an id of its own, different per instance", () => {
+ build({ baseUrl: OPENCODE_GO });
+ const first = lastHeaders()?.["x-opencode-session"];
+ build({ baseUrl: OPENCODE_GO });
+ const second = lastHeaders()?.["x-opencode-session"];
+ expect(first).toMatch(/^[0-9a-f-]{36}$/);
+ expect(second).toMatch(/^[0-9a-f-]{36}$/);
+ expect(first).not.toBe(second);
+ });
+
+ it("sends nothing extra to an endpoint that reads no such header", () => {
+ build({ baseUrl: "https://api.deepseek.com" });
+ expect(lastHeaders()).toBeUndefined();
+ build({});
+ expect(lastHeaders()).toBeUndefined();
+ });
+
+ it("keeps the id when a rotated credential rebuilds the client", async () => {
+ const keys = ["sk-rotated"];
+ const model = new GenerativeModel({
+ modelId: "glm-5.3",
+ apiKey: "sk-first",
+ resolveApiKey: async () => keys[0],
+ clientType: "openai-chat",
+ baseUrl: OPENCODE_GO,
+ tools: [],
+ });
+ const before = lastHeaders()?.["x-opencode-session"];
+ await (model as unknown as { refreshApiKey(): Promise<void> }).refreshApiKey();
+ expect(captured.options.at(-1)?.apiKey).toBe("sk-rotated");
+ expect(lastHeaders()?.["x-opencode-session"]).toBe(before);
+ });
+});
diff --git a/packages/core/test/model-catalog.test.ts b/packages/core/test/model-catalog.test.ts
index f0730aae..48402994 100644
--- a/packages/core/test/model-catalog.test.ts
+++ b/packages/core/test/model-catalog.test.ts
@@ -47,14 +47,15 @@ describe("model-catalog", () => {
const ids = MODEL_CATALOG.map((m) => m.modelId);
expect(MODEL_CATALOG[0]!.provider).toBe("deepseek");
// Group order is hand-curated, interleaving gateways and first-party vendors: the
- // recommended TokenDance first, the prebuilt Penguin Go group next, DeepSeek after it,
- // and vLLM last
+ // recommended TokenDance first, the prebuilt Penguin Go group next, OpenCode Go third,
+ // DeepSeek after it, and vLLM last
// among the vendors (self-hosted, so nothing in it runs until the user names a server)
// and custom always last. This is the page's DEFAULT only — a Project that has reordered
// its groups stores every key and keeps its own arrangement (web's model-group-order.ts).
expect(MODEL_PROVIDERS.map((p) => p.id)).toEqual([
"tokendance",
"penguin-go",
+ "opencode-go",
"deepseek",
"openrouter",
"fireworks",
@@ -212,6 +213,135 @@ describe("model-catalog", () => {
});
});
+ it("OpenCode Go: each model pins the protocol its endpoint table names, at the Go page's per-token rates", () => {
+ const group = providerInfo("opencode-go")!;
+ expect(group.label).toBe("OpenCode Go");
+ expect(group.apiKeyUrl).toBe("https://opencode.ai/auth");
+ expect(group.modelsUrl).toBe("https://opencode.ai/docs/go/");
+ // A model added by hand gets the Chat Completions base and client, which is what most of
+ // the group speaks; the group pins no protocol, because its models sit on three.
+ expect(group.gatewayBaseUrl).toBe("https://opencode.ai/zen/go/v1");
+ expect(providerClientType("opencode-go")).toBeUndefined();
+ // No per-model pages: every model links to the Go docs page, which lists them all.
+ expect(modelHomepageUrl("opencode-go", "kimi-k3")).toBe("https://opencode.ai/docs/go/");
+
+ const go = MODEL_CATALOG.filter((m) => m.provider === "opencode-go");
+ const CHAT = ["openai-chat", "https://opencode.ai/zen/go/v1"];
+ const RESPONSES = ["openai-responses", "https://opencode.ai/zen/go/v1"];
+ // The Anthropic SDK appends /v1/messages itself, so the Messages base carries no /v1.
+ const MESSAGES = ["ant-messages", "https://opencode.ai/zen/go"];
+ // Dictionary order, newer versions of a series first. Protocols from the docs page's
+ // endpoint table; context windows and modalities from models.dev; vision checked live.
+ expect(
+ go.map((m) => [m.modelId, m.clientType, m.baseUrl, m.contextWindow, m.supportsVision]),
+ ).toEqual([
+ ["deepseek-v4.1-flash", ...CHAT, 1000000, true],
+ ["deepseek-v4-flash", ...CHAT, 1000000, false],
+ ["deepseek-v4-flash-vision-exp", ...CHAT, 1000000, true],
+ ["deepseek-v4-pro", ...CHAT, 1000000, false],
+ ["glm-5.3", ...CHAT, 1000000, false],
+ ["glm-5.3-flash", ...CHAT, 1000000, true],
+ ["glm-5.2", ...CHAT, 1000000, false],
+ ["glm-5.1", ...CHAT, 202752, false],
+ ["gpt-5.6-luna", ...RESPONSES, 1050000, true],
+ ["grok-4.6", ...RESPONSES, 500000, true],
+ ["hy4-preview", ...CHAT, 1024000, false],
+ ["hy3", ...CHAT, 192000, false],
+ ["kimi-k3", ...CHAT, 1048576, true],
+ ["kimi-k2.7-code", ...CHAT, 262144, true],
+ ["kimi-k2.6", ...CHAT, 262144, true],
+ ["longcat-2.0", ...CHAT, 1000000, false],
+ ["mimo-v2.5", ...CHAT, 1000000, true],
+ ["mimo-v2.5-pro", ...CHAT, 1048576, false],
+ ["minimax-m3", ...MESSAGES, 1000000, true],
+ ["minimax-m2.7", ...MESSAGES, 204800, false],
+ ["muse-spark-1.3-contributor", ...RESPONSES, 1048576, true],
+ ["muse-spark-1.2-contributor", ...RESPONSES, 1048576, true],
+ ["qwen3.8-flash", ...MESSAGES, 1000000, true],
+ ["qwen3.8-max", ...MESSAGES, 1000000, true],
+ ["qwen3.7-max", ...MESSAGES, 1000000, false],
+ ["qwen3.7-plus", ...MESSAGES, 1000000, true],
+ ["qwen3.6-plus", ...MESSAGES, 1000000, true],
+ ]);
+
+ // The Go page's rates in the catalog's (cache_read, cache_write, output) order. cache_write
+ // is the published cached-write rate where the page lists one and the input rate where it
+ // does not; tiered rows keep their base tier and the DeepSeek rows their peak rate.
+ expect(
+ Object.fromEntries(
+ go.map((m) => [
+ m.modelId,
+ [m.pricing!.cache_read, m.pricing!.cache_write, m.pricing!.output],
+ ]),
+ ),
+ ).toEqual({
+ "deepseek-v4.1-flash": [0.006, 0.3, 1.2],
+ "deepseek-v4-flash": [0.006, 0.3, 1.2],
+ "deepseek-v4-flash-vision-exp": [0.006, 0.3, 1.2],
+ "deepseek-v4-pro": [0.044, 1.32, 3.96],
+ "glm-5.3": [0.26, 1.4, 4.4],
+ "glm-5.3-flash": [0.03, 0.15, 0.5],
+ "glm-5.2": [0.26, 1.4, 4.4],
+ "glm-5.1": [0.26, 1.4, 4.4],
+ "gpt-5.6-luna": [0.02, 0.25, 1.2],
+ "grok-4.6": [0.5, 2, 6],
+ "hy4-preview": [0.042, 0.834, 2.501],
+ hy3: [0.035, 0.14, 0.58],
+ "kimi-k3": [0.3, 3, 15],
+ "kimi-k2.7-code": [0.19, 0.95, 4],
+ "kimi-k2.6": [0.16, 0.95, 4],
+ "longcat-2.0": [0.006, 0.3, 1.2],
+ "mimo-v2.5": [0.0028, 0.14, 0.28],
+ "mimo-v2.5-pro": [0.003625, 0.435, 0.87],
+ "minimax-m3": [0.06, 0.3, 1.2],
+ "minimax-m2.7": [0.06, 0.375, 1.2],
+ "muse-spark-1.3-contributor": [0.002, 0.1, 0.2],
+ "muse-spark-1.2-contributor": [0.002, 0.1, 0.2],
+ "qwen3.8-flash": [0.016, 0.2, 0.47],
+ "qwen3.8-max": [0.25, 2.5, 6],
+ "qwen3.7-max": [0.5, 3.125, 7.5],
+ "qwen3.7-plus": [0.04, 0.5, 1.6],
+ "qwen3.6-plus": [0.05, 0.625, 3],
+ });
+
+ // The DeepSeek rows are the only ones on a schedule, DeepSeek's own, and off-peak they bill
+ // exactly the Go page's Off-Peak figures. 2026-09-19 is a Saturday: off-peak all day.
+ const scheduled = go.filter((m) => m.offPeakDiscount !== undefined);
+ expect(scheduled.map((m) => m.modelId)).toEqual([
+ "deepseek-v4.1-flash",
+ "deepseek-v4-flash",
+ "deepseek-v4-flash-vision-exp",
+ "deepseek-v4-pro",
+ ]);
+ const saturday = new Date("2026-09-19T10:00:00+08:00");
+ for (const m of scheduled) {
+ expect(m.offPeakDiscount, m.modelId).toBe(DEEPSEEK_OFF_PEAK);
+ const off = effectivePricing(m, saturday)!;
+ expect([off.cache_read, off.cache_write, off.output], m.modelId).toEqual(
+ m.modelId === "deepseek-v4-pro" ? [0.022, 0.66, 1.98] : [0.003, 0.15, 0.6],
+ );
+ }
+ // No promotion is on a rate: the running "4x" offer raises an allowance, not a price.
+ expect(go.filter((m) => m.discount !== undefined)).toEqual([]);
+
+ // A model the catalog already carries elsewhere keeps its display name here.
+ for (const [provider, modelId, goId] of [
+ ["zhipu", "glm-5.3-flash", "glm-5.3-flash"],
+ ["openai", "gpt-5.6-luna", "gpt-5.6-luna"],
+ ["openrouter", "x-ai/grok-4.6", "grok-4.6"],
+ ["moonshot", "kimi-k3", "kimi-k3"],
+ ["fireworks", "accounts/fireworks/models/kimi-k2p7-code", "kimi-k2.7-code"],
+ ["siliconflow", "meituan-longcat/LongCat-2.0", "longcat-2.0"],
+ ["minimax", "MiniMax-M3", "minimax-m3"],
+ ["tokendance", "hy4-preview", "hy4-preview"],
+ ["qwen-pay-as-you-go", "qwen3.8-max", "qwen3.8-max"],
+ ] as const) {
+ expect(catalogEntryFor("opencode-go", goId)!.displayName, goId).toBe(
+ catalogEntryFor(provider, modelId)!.displayName,
+ );
+ }
+ });
+
it("the app URL a minted key is stamped with is the same one attribution headers carry", () => {
expect(APP_URL).toBe("https://penguin.ooo/");
expect(attributionHeaders("https://tokendance.space/gateway/v1")).toEqual({
@@ -810,6 +940,7 @@ describe("model-catalog", () => {
"fireworks",
"siliconflow",
"tokendance",
+ "opencode-go",
"qwen-token-plan",
"qwen-pay-as-you-go",
"modelscope",
@@ -838,6 +969,7 @@ describe("model-catalog", () => {
"fireworks",
"siliconflow",
"tokendance",
+ "opencode-go",
"qwen-token-plan",
"qwen-pay-as-you-go",
"modelscope",
@@ -894,6 +1026,7 @@ describe("model-catalog", () => {
...pinnedDirect,
...customPresets,
...MODEL_CATALOG.filter((m) => m.provider === "penguin-go"),
+ ...MODEL_CATALOG.filter((m) => m.provider === "opencode-go"),
]
// A retired gateway row keeps its pin in the catalog but is not a preset.
.filter((m) => m.retired !== true)
@@ -1159,7 +1292,9 @@ describe("model-catalog", () => {
(m) => m.provider === "moonshot" && m.modelId === "kimi-k3",
)!.pricing!;
expect([cnyOf(k3.cache_read), cnyOf(k3.cache_write), cnyOf(k3.output)]).toEqual([2, 20, 100]);
- const k26 = MODEL_CATALOG.find((m) => m.modelId === "kimi-k2.6")!.pricing!;
+ const k26 = MODEL_CATALOG.find(
+ (m) => m.provider === "moonshot" && m.modelId === "kimi-k2.6",
+ )!.pricing!;
expect([cnyOf(k26.cache_read), cnyOf(k26.cache_write), cnyOf(k26.output)]).toEqual([
1.1, 6.5, 27,
]);
@@ -1410,6 +1545,13 @@ describe("resolveModelEnv (PRN-021: env fallback resolved by AgentHub routing ru
expect(env!.envBaseUrlKey, m.modelId).toBe("ANTHROPIC_BASE_URL");
continue;
}
+ if (m.provider === "opencode-go" && m.clientType === "ant-messages") {
+ // OpenCode Go's group pair is the OPENAI_* one its Chat Completions and Responses rows
+ // read; its Messages rows read the Anthropic client's pair, the same split as custom.
+ expect(env!.envKey, m.modelId).toBe("ANTHROPIC_API_KEY");
+ expect(env!.envBaseUrlKey, m.modelId).toBe("ANTHROPIC_BASE_URL");
+ continue;
+ }
expect(env!.envKey, m.modelId).toBe(provider.envKey);
expect(env!.envBaseUrlKey, m.modelId).toBe(provider.envBaseUrlKey);
}
@@ -1640,7 +1782,7 @@ describe("attributionHeaders (how the harness names itself to the gateways that
});
});
- it("OpenCode gets the session header, and only when there is a session id to put in it", () => {
+ it("OpenCode always gets the session header: the Session's id, or a fresh random one", () => {
const sessionId = "session-2026-09-14-10-30-00-a1b2c3d4";
expect(attributionHeaders("https://opencode.ai/zen/v1", sessionId)).toEqual({
"x-opencode-session": sessionId,
@@ -1649,10 +1791,15 @@ describe("attributionHeaders (how the harness names itself to the gateways that
expect(attributionHeaders("https://api.opencode.ai/v1", sessionId)).toEqual({
"x-opencode-session": sessionId,
});
- // No id, no header. A stand-in constant would file every conversation at the gateway
- // under one session, which serves it worse than naming none.
- expect(attributionHeaders("https://opencode.ai/zen/v1")).toBeUndefined();
- expect(attributionHeaders("https://opencode.ai/zen/v1", "")).toBeUndefined();
+ // No id — a connectivity test, a vision probe — still names a conversation, since the
+ // gateway refuses a request that names none: a fresh random id each time, never one
+ // constant that would file every such request under a single session.
+ const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
+ const first = attributionHeaders("https://opencode.ai/zen/v1")?.["x-opencode-session"];
+ const second = attributionHeaders("https://opencode.ai/zen/v1", "")?.["x-opencode-session"];
+ expect(first).toMatch(uuid);
+ expect(second).toMatch(uuid);
+ expect(first).not.toBe(second);
// A host outside the scheme gets nothing, whatever path it serves: third-party mirrors of
// a gateway are not part of the built-in attribution, and naming one here would put it in
// the repository just as surely as listing it would.
@@ -1685,12 +1832,20 @@ describe("attributionHeaders (how the harness names itself to the gateways that
});
it("catalog invariant: every gateway row whose host runs an attribution scheme carries it", () => {
+ const sessionId = "session-2026-09-17-10-30-00-a1b2c3d4";
for (const m of MODEL_CATALOG) {
const headers = attributionHeaders(m.baseUrl);
if (m.provider === "openrouter") {
expect(headers?.["HTTP-Referer"], m.modelId).toBe("https://penguin.ooo/");
} else if (m.provider === "tokendance") {
expect(headers?.["X-App-URL"], m.modelId).toBe("https://penguin.ooo/");
+ } else if (m.provider === "opencode-go") {
+ // Both OpenCode Go bases, Messages included, name the Session they are serving, and
+ // name a conversation of their own outside one.
+ expect(attributionHeaders(m.baseUrl, sessionId), m.modelId).toEqual({
+ "x-opencode-session": sessionId,
+ });
+ expect(headers?.["x-opencode-session"], m.modelId).toBeTruthy();
} else {
expect(headers, `${m.provider}/${m.modelId}`).toBeUndefined();
}
@@ -1705,9 +1860,9 @@ describe("off-peak schedules", () => {
it("the DeepSeek rows store the peak price and declare the schedule", () => {
// Every direct row, plus the resold rows whose sellers pass DeepSeek's own windows through:
- // two on Penguin Go, two on TokenDance and one on OpenRouter. The retired rows keep the
- // schedule too. A gateway row on the schedule carries no flat `discount` — the two are
- // mutually exclusive, pinned by the last case here.
+ // two on Penguin Go, four on OpenCode Go, two on TokenDance and one on OpenRouter. The
+ // retired rows keep the schedule too. A gateway row on the schedule carries no flat
+ // `discount` — the two are mutually exclusive, pinned by the last case here.
const rows = MODEL_CATALOG.filter((m) => m.offPeakDiscount === S);
expect(rows.map((m) => `${m.provider}/${m.modelId}`)).toEqual([
"deepseek/deepseek-flash",
@@ -1719,6 +1874,10 @@ describe("off-peak schedules", () => {
"tokendance/deepseek-v4.1-flash",
"penguin-go/deepseek-flash",
"penguin-go/deepseek-v4-pro",
+ "opencode-go/deepseek-v4.1-flash",
+ "opencode-go/deepseek-v4-flash",
+ "opencode-go/deepseek-v4-flash-vision-exp",
+ "opencode-go/deepseek-v4-pro",
]);
for (const m of rows) {
// Peak is exactly double the off-peak tier DeepSeek publishes. Compared at 1e-5: both
diff --git a/packages/docs/content/configuration.en.md b/packages/docs/content/configuration.en.md
index bb462720..881be455 100644
--- a/packages/docs/content/configuration.en.md
+++ b/packages/docs/content/configuration.en.md
@@ -72,14 +72,14 @@ When a model entry has no inline `api_key`, it falls back to the provider's envi
| --- | --- | --- |
| deepseek | `DEEPSEEK_API_KEY` | `DEEPSEEK_BASE_URL` |
| anthropic | `ANTHROPIC_API_KEY` | `ANTHROPIC_BASE_URL` |
-| openai, openrouter, fireworks, siliconflow, tokendance, qwen-pay-as-you-go, qwen-token-plan, modelscope, vllm, custom | `OPENAI_API_KEY` | `OPENAI_BASE_URL` |
+| openai, openrouter, fireworks, siliconflow, tokendance, opencode-go, qwen-pay-as-you-go, qwen-token-plan, modelscope, vllm, custom | `OPENAI_API_KEY` | `OPENAI_BASE_URL` |
| penguin-go | `PENGUIN_GO_API_KEY` | `PENGUIN_GO_BASE_URL` |
| minimax | `MINIMAX_API_KEY` | `MINIMAX_BASE_URL` |
| google | `GEMINI_API_KEY` | `GEMINI_BASE_URL` |
| zhipu | `ZAI_API_KEY` | `ZAI_BASE_URL` |
| moonshot | `MOONSHOT_API_KEY` | `MOONSHOT_BASE_URL` |
-The openrouter, fireworks, siliconflow, tokendance, qwen-pay-as-you-go, qwen-token-plan, vllm and custom groups speak an OpenAI-compatible protocol, hence the shared `OPENAI_*` variables — which, by the rule above, their rows do not fall back to: the variable holds your OpenAI key, and a gateway is not OpenAI. ModelScope also shares `OPENAI_*` because its group credential is an api-inference token, even when a preset row pins a model-specific protocol; its rows do not fall back to it either. The Penguin Go relay keeps a pair of its own, so the app never offers a vendor credential for it. The direct MiniMax M3 Responses client uses `MINIMAX_*`, and the built-in MiniMax preset already pins the official endpoint. For provider groups and the built-in model catalog, see [Models & Providers](/models).
+The openrouter, fireworks, siliconflow, tokendance, opencode-go, qwen-pay-as-you-go, qwen-token-plan, vllm and custom groups speak an OpenAI-compatible protocol, hence the shared `OPENAI_*` variables — which, by the rule above, their rows do not fall back to: the variable holds your OpenAI key, and a gateway is not OpenAI. The same holds for the opencode-go models on Anthropic Messages, whose client reads `ANTHROPIC_*`. ModelScope also shares `OPENAI_*` because its group credential is an api-inference token, even when a preset row pins a model-specific protocol; its rows do not fall back to it either. The Penguin Go relay keeps a pair of its own, so the app never offers a vendor credential for it. The direct MiniMax M3 Responses client uses `MINIMAX_*`, and the built-in MiniMax preset already pins the official endpoint. For provider groups and the built-in model catalog, see [Models & Providers](/models).
## Project config
diff --git a/packages/docs/content/configuration.zh.md b/packages/docs/content/configuration.zh.md
index 3ae110fd..da64c042 100644
--- a/packages/docs/content/configuration.zh.md
+++ b/packages/docs/content/configuration.zh.md
@@ -72,14 +72,14 @@ Agent 运行的每条命令,PATH 的第一位都是本安装自带的 `penguin
| --- | --- | --- |
| deepseek | `DEEPSEEK_API_KEY` | `DEEPSEEK_BASE_URL` |
| anthropic | `ANTHROPIC_API_KEY` | `ANTHROPIC_BASE_URL` |
-| openai、openrouter、fireworks、siliconflow、tokendance、qwen-pay-as-you-go、qwen-token-plan、modelscope、vllm、custom | `OPENAI_API_KEY` | `OPENAI_BASE_URL` |
+| openai、openrouter、fireworks、siliconflow、tokendance、opencode-go、qwen-pay-as-you-go、qwen-token-plan、modelscope、vllm、custom | `OPENAI_API_KEY` | `OPENAI_BASE_URL` |
| penguin-go | `PENGUIN_GO_API_KEY` | `PENGUIN_GO_BASE_URL` |
| minimax | `MINIMAX_API_KEY` | `MINIMAX_BASE_URL` |
| google | `GEMINI_API_KEY` | `GEMINI_BASE_URL` |
| zhipu | `ZAI_API_KEY` | `ZAI_BASE_URL` |
| moonshot | `MOONSHOT_API_KEY` | `MOONSHOT_BASE_URL` |
-openrouter、fireworks、siliconflow、tokendance、qwen-pay-as-you-go、qwen-token-plan、vllm 和 custom 这几组供应商使用 OpenAI 兼容协议,因此共用 `OPENAI_*` 变量——按上面的规则,它们的条目并不会回退到这对变量:变量里存的是你的 OpenAI key,而网关不是 OpenAI。ModelScope 也共用 `OPENAI_*`,因为它的分组凭据是 api-inference token,即使某条预置固定了模型专属协议也是如此;它的条目同样不会回退到这对变量。Penguin Go 中转分组单独使用一对自己的变量,应用因此不会为它推荐任何厂商凭证。MiniMax M3 的直连 Responses 客户端使用 `MINIMAX_*`,内置的 MiniMax 预设也已经固定为官方端点。供应商分组和内置模型目录见[模型与供应商](/models)。
+openrouter、fireworks、siliconflow、tokendance、opencode-go、qwen-pay-as-you-go、qwen-token-plan、vllm 和 custom 这几组供应商使用 OpenAI 兼容协议,因此共用 `OPENAI_*` 变量——按上面的规则,它们的条目并不会回退到这对变量:变量里存的是你的 OpenAI key,而网关不是 OpenAI。opencode-go 分组中走 Anthropic Messages 的模型同理,其客户端读取的是 `ANTHROPIC_*`。ModelScope 也共用 `OPENAI_*`,因为它的分组凭据是 api-inference token,即使某条预置固定了模型专属协议也是如此;它的条目同样不会回退到这对变量。Penguin Go 中转分组单独使用一对自己的变量,应用因此不会为它推荐任何厂商凭证。MiniMax M3 的直连 Responses 客户端使用 `MINIMAX_*`,内置的 MiniMax 预设也已经固定为官方端点。供应商分组和内置模型目录见[模型与供应商](/models)。
## Project 配置
diff --git a/packages/docs/content/models.en.md b/packages/docs/content/models.en.md
index 75386c54..d71a44bc 100644
--- a/packages/docs/content/models.en.md
+++ b/packages/docs/content/models.en.md
@@ -405,6 +405,7 @@ The table below lists the built-in groups and the environment variables their mo
| --- | --- | --- |
| tokendance | `OPENAI_API_KEY` | The recommended group. OpenAI-compatible gateway, preset base URL `https://tokendance.space/gateway/v1`; model ids are bare, with no vendor prefix (e.g. `glm-5.3`, `kimi-k3`); pricing is the gateway's own CNY rates, several of them currently discounted |
| penguin-go | `PENGUIN_GO_API_KEY` | Preset relay group, fixed base URL `https://token.penguin.ooo/api`; its header authorizes a key for you or takes one you set by hand. See [The Penguin Go group](#the-penguin-go-group) |
+| opencode-go | `OPENAI_API_KEY` | OpenCode Go subscription gateway. Each model pins its own protocol: Chat Completions or Responses at `https://opencode.ai/zen/go/v1`, Anthropic Messages at `https://opencode.ai/zen/go` (that client's variable is `ANTHROPIC_API_KEY`). See [The OpenCode Go group](#the-opencode-go-group) |
| deepseek | `DEEPSEEK_API_KEY` | Group of the default model |
| openrouter | `OPENAI_API_KEY` | OpenAI-compatible gateway, preset base URL `https://openrouter.ai/api/v1` |
| fireworks | `OPENAI_API_KEY` | Fireworks AI (OpenAI-compatible), preset base URL `https://api.fireworks.ai/inference/v1`; API model ids look like `accounts/fireworks/models/<slug>` |
@@ -427,6 +428,7 @@ The OpenAI-compatible gateway groups (openrouter / fireworks / siliconflow / tok
- The other gateway presets use the Chat Completions client (`client_type = "openai-chat"`).
- ModelScope is an aggregate gateway like Penguin Go: its Qwen presets use `openai-chat-vllm-adapter`, carrying Qwen template thinking controls over Chat Completions, while its DeepSeek preset pins `deepseek-v4` and uses AgentHub's Responses client.
- Those gateway clients read the same `OPENAI_*` variables, so the credential rules are identical either way.
+- The OpenCode Go group is the exception: its models use three protocols, so each one pins its own; see [The OpenCode Go group](#the-opencode-go-group).
The direct MiniMax M3 client reads `MINIMAX_API_KEY`. The built-in MiniMax preset uses `https://api.minimax.io/v1`. `MINIMAX_BASE_URL` is read only for entries without their own `base_url`.
@@ -442,6 +444,15 @@ The group's key comes from its header; see [Authorize a new API key](#authorize-
The platform quotes peak rates in USD per million Tokens. The group's DeepSeek rows follow DeepSeek's current line-up, `deepseek-flash` and `deepseek-v4-pro`, and declare the same off-peak schedule as the direct DeepSeek group, so their cards and cost records use half price outside Beijing weekday 9:00–12:00 and 14:00–18:00.
+### The OpenCode Go group
+
+`opencode-go` holds the 27 models OpenCode lists for its Go subscription. One key serves all of them: set it once with **Set key** on the group header.
+
+- **Protocols.** OpenCode serves each model on one of three endpoints, so each row pins its own `client_type` and base URL. Chat Completions (`openai-chat`) and Responses (`openai-responses`) models use `https://opencode.ai/zen/go/v1`. Anthropic Messages (`ant-messages`) models use `https://opencode.ai/zen/go`, because the client adds `/v1/messages` itself. Like every gateway's rows, none of them falls back to `OPENAI_API_KEY` or `ANTHROPIC_API_KEY`: the key goes on the group. A model you add to the group yourself gets `openai-chat` and the `/v1` base URL.
+- **Prices.** Go is a monthly subscription whose usage limits are dollar amounts per model: a monthly allowance, of which at most 20% can be used in five hours and 50% in a week. The rows record the per-token rates a request draws from that allowance, so for this group the cost center shows how much of it you used, not a bill. `gpt-5.6-luna`, `grok-4.6`, `qwen3.7-plus` and `qwen3.6-plus` record their base tier, which covers up to 272K, 200K, 256K and 256K input tokens respectively. The four DeepSeek models follow DeepSeek's off-peak schedule; see [Prices and promotions](#prices-and-promotions).
+- **Opt-in and regions.** Five models answer with an error until the key's OpenCode workspace opts in to them. `muse-spark-1.3-contributor` and `muse-spark-1.2-contributor` need consent to Meta training on prompts and completions. `deepseek-v4.1-flash`, `deepseek-v4-flash` and `deepseek-v4-pro` need consent to being served from China. Some models also refuse requests from certain regions: from mainland China, `gpt-5.6-luna` and both Muse Spark models answer with an error.
+- **Session header.** Requests to the group name their conversation in `x-opencode-session`; see [App attribution](#app-attribution).
+
### The ModelScope group
`modelscope` is an aggregate gateway group: one ModelScope api-inference endpoint behind the preset base URL `https://api-inference.modelscope.cn/v1`, with each preset row carrying the protocol that AgentHub should use for that upstream model. Model ids are upstream repo names, so they keep their vendor prefix (`deepseek-ai/DeepSeek-V4.1-Flash`, `Qwen/Qwen3.8-27B`). The Qwen rows use `openai-chat-vllm-adapter`, retaining Chat Completions on the wire while mapping thinking controls to the Qwen template; the DeepSeek row pins `deepseek-v4`, matching the direct and Penguin Go DeepSeek V4 rows. A new Project gets these presets right away; a Project created earlier adds them with **Sync presets**.
@@ -471,7 +482,7 @@ The list is not exhaustive.
- **DeepSeek images.** `deepseek-flash` is V4.1 Flash and reads images; `deepseek-v4-pro` is the V4 Pro 0813 release and is text-only. To send an image, use `deepseek-flash`.
- **Retired rows.** DeepSeek still accepts `deepseek-v4-flash` and `deepseek-v4-flash-vision-exp`, and serves both from V4.1 Flash. They are no longer presets, but the catalog keeps them, together with TokenDance's `deepseek-v4-flash-vision-exp`, as retired rows: a Project that still carries one keeps its display name, and **Sync presets** keeps its price current. A retired row is never added to a Project that does not have it, and a new Project never gets one.
- **OpenAI twice.** The whole OpenAI line-up is listed twice: directly (your own OpenAI key, list prices) and on OpenRouter as `openai/<id>` (the gateway's rates, which follow its running promotions).
-- **GLM-5.3 Flash five times.** It appears directly as `glm-5.3-flash`, under the same id on TokenDance, and as OpenRouter's `z-ai/glm-5.3-flash`, Fireworks AI's `accounts/fireworks/models/glm-5p3-flash` and Qwen pay-as-you-go's `ZHIPU/GLM-5.3-Flash`. Every row accepts images: AgentHub's GLM client forwards image parts for this one GLM id, every other GLM id refuses them, and the gateway rows go through the generic OpenAI-compatible clients, which carry images for any id. What the rows do not share is the price: each records what its own seller charges, so they disagree while a promotion runs.
+- **GLM-5.3 Flash six times.** It appears directly as `glm-5.3-flash`, under the same id on TokenDance and OpenCode Go, and as OpenRouter's `z-ai/glm-5.3-flash`, Fireworks AI's `accounts/fireworks/models/glm-5p3-flash` and Qwen pay-as-you-go's `ZHIPU/GLM-5.3-Flash`. Every row accepts images: AgentHub's GLM client forwards image parts for this one GLM id, every other GLM id refuses them, and the gateway rows go through the generic OpenAI-compatible clients, which carry images for any id. What the rows do not share is the price: each records what its own seller charges, so they disagree while a promotion runs.
- **OpenRouter free tier.** The catalog carries the `:free` model variant `nvidia/nemotron-3-ultra-550b-a55b:free` and the `openrouter/free` unified Free Models Router. They cost nothing, but OpenRouter's free-tier rate limits and data policy apply.
### Prices and promotions
@@ -480,7 +491,7 @@ The list is not exhaustive.
- **Rows with no price.** The pricing block can be absent altogether, which records "nobody has looked this vendor's price up" rather than "free": such a row shows no price badge on the **Models** page, and the cost center reports its usage as uncosted. ModelScope's preset rows are the catalog's only ones — ModelScope bills for api-inference, but its model pages are client-rendered and carry no read-able rate. Three zeros would be worse than absent: they would read as the free tier and badge a billed gateway "Free".
- **Base tier only.** Where a vendor's prices step up with input size, the catalog records the base tier. MiniMax M3 records MiniMax's standard pay-as-you-go tier at 512K input tokens or below; above that, every rate doubles, and the priority tier is 1.5x, so long-context and priority usage is underestimated. OpenAI (above 272K) and Gemini 3.1 Pro (above 200K) follow the same convention.
- **DeepSeek off-peak.** The direct DeepSeek rows record the official peak prices and declare DeepSeek's off-peak schedule: outside Beijing time 9:00–12:00 and 14:00–18:00 on weekdays, every bucket is halved. The **Models** page shows a `50% off` tag during those hours, and the cost center bills at that rate.
- - Four resold rows follow the same schedule because their sellers pass DeepSeek's windows through: TokenDance's `deepseek-v4.1-flash`, OpenRouter's `deepseek/deepseek-v4.1-flash`, and Penguin Go's `deepseek-flash` and `deepseek-v4-pro`.
+ - Eight resold rows follow the same schedule because their sellers pass DeepSeek's windows through: TokenDance's `deepseek-v4.1-flash`, OpenRouter's `deepseek/deepseek-v4.1-flash`, Penguin Go's `deepseek-flash` and `deepseek-v4-pro`, and OpenCode Go's `deepseek-v4.1-flash`, `deepseek-v4-flash`, `deepseek-v4-flash-vision-exp` and `deepseek-v4-pro`.
- Qwen bills the DeepSeek models it resells on a schedule of its own, half price from 22:00 to 8:00 Beijing time every day. `deepseek-v4.1-flash` in both Qwen groups, and the Token Plan's `deepseek-v4-pro-0813`, declare that one instead, and the tag's tooltip names the windows of whichever schedule the row follows.
- The stored price is always the peak price, so what is on disk does not depend on the hour a Project was created or synced.
- **Flat promotions.** Nine TokenDance models are discounted today:
@@ -546,9 +557,9 @@ The catalog decides these headers by **endpoint host**, not by the entry's provi
| `openrouter.ai` | `X-OpenRouter-Title` | `PenguinHarness` |
| `openrouter.ai` | `X-OpenRouter-Categories` | `cli-agent,personal-agent` |
| `tokendance.space` | `X-App-URL` | `https://penguin.ooo/` |
-| `opencode.ai` | `x-opencode-session` | The Session id, sent only when a Session id is known |
+| `opencode.ai` | `x-opencode-session` | The Session id; a request outside any Session (a connectivity test, a vision probe) sends a fresh id of its own |
-Every other endpoint, including every direct vendor and every gateway that reads no such header, receives no extra headers. The OpenRouter and TokenDance headers state the app's identity only. The OpenCode header names the conversation, because that gateway routes each conversation by it; no header carries anything about the user or the agent.
+Every other endpoint, including every direct vendor and every gateway that reads no such header, receives no extra headers. The OpenRouter and TokenDance headers state the app's identity only. The OpenCode header names the conversation, because that gateway routes and caches each conversation by it and refuses a request that names none; no header carries anything about the user or the agent.
## How it works
diff --git a/packages/docs/content/models.zh.md b/packages/docs/content/models.zh.md
index a6999bc4..c2afd6e7 100644
--- a/packages/docs/content/models.zh.md
+++ b/packages/docs/content/models.zh.md
@@ -404,6 +404,7 @@ PenguinHarness 升级可能改变内置的预置模型目录。一旦发生,Pr
| --- | --- | --- |
| tokendance | `OPENAI_API_KEY` | 推荐分组。OpenAI 兼容网关,预置 base URL `https://tokendance.space/gateway/v1`;模型 id 为裸名称,不带供应商前缀(如 `glm-5.3`、`kimi-k3`);价格采用网关自己的人民币费率,目前有几项在打折 |
| penguin-go | `PENGUIN_GO_API_KEY` | 预置的中转分组,固定 base URL `https://token.penguin.ooo/api`;分组标题栏可以为你自动授权一把 key,也可以手动设置。见 [Penguin Go 分组](#penguin-go-分组) |
+| opencode-go | `OPENAI_API_KEY` | OpenCode Go 订阅网关。每个模型各自固定协议:Chat Completions 或 Responses 走 `https://opencode.ai/zen/go/v1`,Anthropic Messages 走 `https://opencode.ai/zen/go`(该客户端的变量是 `ANTHROPIC_API_KEY`)。见 [OpenCode Go 分组](#opencode-go-分组) |
| deepseek | `DEEPSEEK_API_KEY` | 默认模型所在的分组 |
| openrouter | `OPENAI_API_KEY` | OpenAI 兼容网关,预置 base URL `https://openrouter.ai/api/v1` |
| fireworks | `OPENAI_API_KEY` | Fireworks AI(OpenAI 兼容),预置 base URL `https://api.fireworks.ai/inference/v1`;API 模型 id 形如 `accounts/fireworks/models/<slug>` |
@@ -426,6 +427,7 @@ OpenAI 兼容网关分组(openrouter / fireworks / siliconflow / tokendance /
- 其他网关的预置模型使用 Chat Completions 客户端(`client_type = "openai-chat"`)。
- ModelScope 像 Penguin Go 一样是聚合网关:Qwen 预置使用 `openai-chat-vllm-adapter`,在 Chat Completions 上按 Qwen 模板传递思考参数;DeepSeek 预置固定为 `deepseek-v4`,运行时走 AgentHub Responses client。
- 这些网关客户端读取相同的 `OPENAI_*` 变量,所以无论哪种方式,凭据规则完全一致。
+- OpenCode Go 分组是例外:它的模型用到三种协议,因此每个模型各自固定协议,见 [OpenCode Go 分组](#opencode-go-分组)。
直连 MiniMax M3 的客户端读取 `MINIMAX_API_KEY`。内置的 MiniMax 预置模型使用 `https://api.minimax.io/v1`。只有条目没有自己的 `base_url` 时,才会读取 `MINIMAX_BASE_URL`。
@@ -441,6 +443,15 @@ OpenAI 兼容网关分组(openrouter / fireworks / siliconflow / tokendance /
平台报的是高峰档费率,单位是每百万 Token 多少美元。分组里的 DeepSeek 条目跟随 DeepSeek 当前的模型阵容,只有 `deepseek-flash` 和 `deepseek-v4-pro`,并声明与直连 DeepSeek 分组相同的空闲时段,因此在北京时间工作日 9:00–12:00、14:00–18:00 之外,卡片和成本记录都按半价计算。
+### OpenCode Go 分组
+
+`opencode-go` 收录 OpenCode 为 Go 订阅列出的 27 个模型。它们共用一把 key:在分组标题栏用**手动设置密钥**设置一次即可。
+
+- **协议。** OpenCode 把每个模型放在三个端点之一上,因此每个条目各自固定 `client_type` 与 base URL。Chat Completions(`openai-chat`)和 Responses(`openai-responses`)模型使用 `https://opencode.ai/zen/go/v1`;Anthropic Messages(`ant-messages`)模型使用 `https://opencode.ai/zen/go`,因为客户端会自行加上 `/v1/messages`。与所有网关的条目一样,它们都不会回退到 `OPENAI_API_KEY` 或 `ANTHROPIC_API_KEY`:key 要设在分组上。你自己添加到该分组的模型使用 `openai-chat` 和带 `/v1` 的 base URL。
+- **价格。** Go 按月订阅,用量上限是按模型计的美元额度:每月一份额度,每 5 小时最多用掉其中 20%,每周最多 50%。条目记录的是每次请求从额度中扣除的每 Token 价格,因此对这个分组而言,成本中心显示的是你用掉了多少额度,而不是一张账单。`gpt-5.6-luna`、`grok-4.6`、`qwen3.7-plus` 和 `qwen3.6-plus` 记录基础档,分别覆盖 272K、200K、256K 和 256K 输入 Token 以内。四个 DeepSeek 模型遵循 DeepSeek 的空闲时段,见[价格与促销](#价格与促销)。
+- **开通与地区。** 在 key 所属的 OpenCode 工作区开通之前,有五个模型会直接报错。`muse-spark-1.3-contributor` 和 `muse-spark-1.2-contributor` 需要同意 Meta 用提示词和回复训练模型。`deepseek-v4.1-flash`、`deepseek-v4-flash` 和 `deepseek-v4-pro` 需要同意由中国境内托管的服务提供。部分模型还会拒绝来自某些地区的请求:从中国大陆访问时,`gpt-5.6-luna` 和两个 Muse Spark 模型都会报错。
+- **会话请求头。** 发往该分组的请求会在 `x-opencode-session` 中标明所属对话,见[应用归因](#应用归因)。
+
### ModelScope 分组
`modelscope` 是聚合网关分组:同一个魔搭 api-inference 端点,预置 base URL `https://api-inference.modelscope.cn/v1`,每条预置各自写明 AgentHub 应该为这个上游模型使用的协议。模型 id 就是上游仓库名,因此保留供应商前缀(`deepseek-ai/DeepSeek-V4.1-Flash`、`Qwen/Qwen3.8-27B`)。Qwen 条目使用 `openai-chat-vllm-adapter`,在线路仍为 Chat Completions 的同时正确控制 Qwen 模板的思考参数;DeepSeek 条目固定为 `deepseek-v4`,与直连 DeepSeek 和 Penguin Go 的 DeepSeek V4 条目保持一致。新建的 Project 立即带上这些预置;更早创建的 Project 用**同步预置**补上。
@@ -470,7 +481,7 @@ OpenAI 兼容网关分组(openrouter / fireworks / siliconflow / tokendance /
- **DeepSeek 图像能力。** `deepseek-flash` 就是 V4.1 Flash,支持读图;`deepseek-v4-pro` 是 V4 Pro 0813 版本,仅支持文本。要发送图像,请使用 `deepseek-flash`。
- **退役条目。** DeepSeek 仍然接受 `deepseek-v4-flash` 和 `deepseek-v4-flash-vision-exp`,并都由 V4.1 Flash 承接。它们不再是预置条目,但目录把它们连同 TokenDance 的 `deepseek-v4-flash-vision-exp` 作为退役条目保留:仍带着其中某条的 Project 照旧显示它的名称,**同步预置**也会继续更新它的价格。退役条目不会被补进没有它的 Project,新建的 Project 也不会拿到。
- **OpenAI 出现两次。** OpenAI 全系模型出现了两遍:一次直连(用你自己的 OpenAI key,官方牌价),一次在 OpenRouter 上以 `openai/<id>` 形式(网关费率,随其当前促销活动浮动)。
-- **GLM-5.3 Flash 出现五次。** 分别是直连的 `glm-5.3-flash`、TokenDance 上的同名条目,以及 OpenRouter 的 `z-ai/glm-5.3-flash`、Fireworks AI 的 `accounts/fireworks/models/glm-5p3-flash` 和 Qwen 按量付费的 `ZHIPU/GLM-5.3-Flash`。每一条都接受图像:AgentHub 的 GLM 客户端只对这一个 GLM id 转发图像内容,其他所有 GLM id 都拒收图像;各网关条目走通用的 OpenAI 兼容客户端,对任何 id 都会携带图像。各条不一致的是价格:每条记录的都是自己卖家收取的价格,所以促销期间彼此不同。
+- **GLM-5.3 Flash 出现六次。** 分别是直连的 `glm-5.3-flash`、TokenDance 与 OpenCode Go 上的同名条目,以及 OpenRouter 的 `z-ai/glm-5.3-flash`、Fireworks AI 的 `accounts/fireworks/models/glm-5p3-flash` 和 Qwen 按量付费的 `ZHIPU/GLM-5.3-Flash`。每一条都接受图像:AgentHub 的 GLM 客户端只对这一个 GLM id 转发图像内容,其他所有 GLM id 都拒收图像;各网关条目走通用的 OpenAI 兼容客户端,对任何 id 都会携带图像。各条不一致的是价格:每条记录的都是自己卖家收取的价格,所以促销期间彼此不同。
- **OpenRouter 免费档。** 目录收录了 `:free` 变体 `nvidia/nemotron-3-ultra-550b-a55b:free`,以及 `openrouter/free` 这个统一的免费模型路由(Free Models Router)。它们不花钱,但 OpenRouter 免费档的限流和数据政策仍然适用。
### 价格与促销
@@ -479,7 +490,7 @@ OpenAI 兼容网关分组(openrouter / fireworks / siliconflow / tokendance /
- **没有价格的条目。** 价格字段可以整体缺席,含义是「没人查过这家的价格」,而不是免费:这类条目在**模型库**页面不显示价格徽标,成本中心把它的用量报为未计价。目录里目前只有 ModelScope 的预置条目是这样——魔搭的 api-inference 是计费的,但它的模型页面是客户端渲染的,读不到费率。写成三个 0 反而更糟:那会被当作免费档,给一个计费网关打上「Free」徽标。
- **仅记录基础档。** 供应商的价格随输入规模上调时,目录只记录基础档。MiniMax M3 记录的是 MiniMax 标准按量付费档在 512K 输入 Token 及以下的价格;超过后每项费率翻倍,priority 档为 1.5 倍,所以长上下文和 priority 用量的成本估算会偏低。OpenAI(272K 以上)和 Gemini 3.1 Pro(200K 以上)遵循同样的约定。
- **DeepSeek 空闲时段。** 直连 DeepSeek 的条目记录官方高峰价格,并声明 DeepSeek 的空闲时段规则:工作日北京时间 9:00–12:00 和 14:00–18:00 以外的时段,三项价格全部减半。**模型库**页面在这些时段显示 `省 50%` 标签,成本中心也按这个费率计费。
- - 四条转售条目遵循同样的时段,因为各自的卖家沿用了 DeepSeek 的时间窗口:TokenDance 的 `deepseek-v4.1-flash`、OpenRouter 的 `deepseek/deepseek-v4.1-flash`,以及 Penguin Go 的 `deepseek-flash` 和 `deepseek-v4-pro`。
+ - 八条转售条目遵循同样的时段,因为各自的卖家沿用了 DeepSeek 的时间窗口:TokenDance 的 `deepseek-v4.1-flash`、OpenRouter 的 `deepseek/deepseek-v4.1-flash`、Penguin Go 的 `deepseek-flash` 和 `deepseek-v4-pro`,以及 OpenCode Go 的 `deepseek-v4.1-flash`、`deepseek-v4-flash`、`deepseek-v4-flash-vision-exp` 和 `deepseek-v4-pro`。
- Qwen 转售的 DeepSeek 模型按它自己的时段计费:北京时间每天 22:00 至次日 8:00 半价。两个 Qwen 分组的 `deepseek-v4.1-flash` 和 Token Plan 的 `deepseek-v4-pro-0813` 声明的是这一套,折扣标签的悬停说明写的也是该条目所遵循时段的窗口。
- 存储的价格始终是高峰价格,所以磁盘上的数值与 Project 创建或同步的时间无关。
- **固定折扣。** 目前有九个 TokenDance 模型在打折:
@@ -545,9 +556,9 @@ api_key = "sk-..."
| `openrouter.ai` | `X-OpenRouter-Title` | `PenguinHarness` |
| `openrouter.ai` | `X-OpenRouter-Categories` | `cli-agent,personal-agent` |
| `tokendance.space` | `X-App-URL` | `https://penguin.ooo/` |
-| `opencode.ai` | `x-opencode-session` | Session id,仅在已知 Session id 时发送 |
+| `opencode.ai` | `x-opencode-session` | Session id;不属于任何 Session 的请求(连通性测试、视觉探测)各自使用一个新生成的 id |
-其他端点,包括所有直连厂商和不读取这类请求头的网关,都不会收到额外的请求头。OpenRouter 和 TokenDance 的请求头只表明应用身份。OpenCode 的请求头标明对话,因为那个网关靠它来路由每段对话;没有任何请求头携带用户或 Agent 的信息。
+其他端点,包括所有直连厂商和不读取这类请求头的网关,都不会收到额外的请求头。OpenRouter 和 TokenDance 的请求头只表明应用身份。OpenCode 的请求头标明对话,因为那个网关靠它来路由和缓存每段对话,并拒绝没有标明对话的请求;没有任何请求头携带用户或 Agent 的信息。
## 工作原理
diff --git a/packages/server/test/models.test.ts b/packages/server/test/models.test.ts
index 1d7bb70f..f67b6eca 100644
--- a/packages/server/test/models.test.ts
+++ b/packages/server/test/models.test.ts
@@ -143,6 +143,25 @@ describe("models preset & catalog enrichment", () => {
expect(mimo.credential?.baseUrl).toBe("https://openrouter.ai/api/v1");
expect(mimo.credential?.apiKeyMasked).toBeUndefined();
+ // OpenCode Go pins each row's protocol and endpoint, so one group holds rows on different
+ // clients: a Messages row sits on the base without /v1, a Chat Completions row on the /v1
+ // base. Like every gateway's rows, neither falls back to its client's environment
+ // variable — that holds the user's vendor key, and the gateway is not the vendor.
+ const messagesRow = pick(body, "opencode-go", "qwen3.8-max");
+ expect(messagesRow).toMatchObject({
+ clientType: "ant-messages",
+ credential: { baseUrl: "https://opencode.ai/zen/go" },
+ vision: true,
+ });
+ expect(messagesRow.envKey).toBeUndefined();
+ const chatRow = pick(body, "opencode-go", "glm-5.3");
+ expect(chatRow).toMatchObject({
+ clientType: "openai-chat",
+ credential: { baseUrl: "https://opencode.ai/zen/go/v1" },
+ vision: false,
+ });
+ expect(chatRow.envKey).toBeUndefined();
+
// A catalog row on a promotion is preset at its LIST price like every other row, and the
// promotion is seeded beside it in web.db: the rows reporting a discount are exactly the
// catalog's flat promotions.
diff --git a/packages/web/src/components/ui/provider-logo.tsx b/packages/web/src/components/ui/provider-logo.tsx
index 9fa0d548..7d600d34 100644
--- a/packages/web/src/components/ui/provider-logo.tsx
+++ b/packages/web/src/components/ui/provider-logo.tsx
@@ -10,8 +10,9 @@
* of the trademark); ModelScope uses its official pixel mark flattened to currentColor; vLLM uses
* its official mark from the
* project's media kit, its two brand colours flattened to currentColor like
- * Qwen's gradient; custom models use a generic cube. All are pure paths, no
- * external image assets.
+ * Qwen's gradient; OpenCode Go uses the pixel "G" of its "go" wordmark, as OpenCode's
+ * own model registry (models.dev) publishes it for the group; custom models use a generic
+ * cube. All are pure paths, no external image assets.
*
* Vendor ids outside the preset table are user-defined groups: instead of all
* sharing the cube (which made same-named models across groups
@@ -136,6 +137,14 @@ const GLYPHS: Record<string, Glyph> = {
</>
),
},
+ "opencode-go": {
+ // The "G" of the pixel-style "go" wordmark on opencode.ai/go, as the 24x24 single-path
+ // provider logo OpenCode publishes for this group. The wordmark's grey inner fill is dropped,
+ // so the glyph is one currentColor shape like the rest of this set.
+ path: (
+ <path d="M19.4004 21H5V3H19.4004V6.59961H8.59961V17.4004H15.7998V13.7998H12.2002V10.2002H19.4004V21Z" />
+ ),
+ },
"qwen-token-plan": QWEN_GLYPH,
"qwen-pay-as-you-go": QWEN_GLYPH,
modelscope: {
diff --git a/packages/web/test/model-grouping.test.ts b/packages/web/test/model-grouping.test.ts
index a3a04d35..ecde63a1 100644
--- a/packages/web/test/model-grouping.test.ts
+++ b/packages/web/test/model-grouping.test.ts
@@ -88,13 +88,13 @@ describe("groupModelRows", () => {
expect(groups[4]!.provider.envKey).toBe("OPENAI_API_KEY");
expect(groups[4]!.rows.map((r) => r.modelId)).toEqual(["weird-model"]);
// Group order matches MODEL_PROVIDERS, whose sequence is hand-curated (gateways and
- // first-party vendors interleaved): the managed Penguin Go group first when present,
- // then TokenDance
- // and DeepSeek, with custom last. This is the page's DEFAULT — the
+ // first-party vendors interleaved): the recommended TokenDance first, then Penguin Go,
+ // OpenCode Go and DeepSeek, with custom last. This is the page's DEFAULT — the
// stored per-Project order applied below overrides it.
expect(MODEL_PROVIDERS.map((p) => p.id)).toEqual([
"tokendance",
"penguin-go",
+ "opencode-go",
"deepseek",
"openrouter",
"fireworks",
diff --git a/packages/web/test/protocol-path.test.ts b/packages/web/test/protocol-path.test.ts
index bbfaa7fd..9e52e6e9 100644
--- a/packages/web/test/protocol-path.test.ts
+++ b/packages/web/test/protocol-path.test.ts
@@ -6,6 +6,7 @@
* /v1beta/models/<id>:…, and every OpenAI-compatible client posts /chat/completions.
*/
import { describe, expect, it } from "vitest";
+import { MODEL_CATALOG } from "@prismshadow/penguin-core/model-catalog";
import { protocolPathForModel } from "../src/features/models/protocol-path";
describe("protocolPathForModel", () => {
@@ -55,6 +56,26 @@ describe("protocolPathForModel", () => {
}
});
+ it("OpenCode Go rows: preset base URL plus the hinted path is the endpoint OpenCode documents", () => {
+ // The group mixes three protocols, and its Messages rows use a base without /v1 because the
+ // Anthropic SDK appends /v1/messages. Joined with the path the dialog shows, every row lands
+ // on one of the three endpoints in the Go docs page's endpoint table.
+ const endpoints = new Set([
+ "https://opencode.ai/zen/go/v1/chat/completions",
+ "https://opencode.ai/zen/go/v1/responses",
+ "https://opencode.ai/zen/go/v1/messages",
+ ]);
+ const rows = MODEL_CATALOG.filter((m) => m.provider === "opencode-go");
+ expect(rows).toHaveLength(27);
+ const hit = new Set<string>();
+ for (const m of rows) {
+ const url = `${m.baseUrl}${protocolPathForModel(m.provider, m.clientType ?? "")}`;
+ expect(endpoints.has(url), `${m.modelId} -> ${url}`).toBe(true);
+ hit.add(url);
+ }
+ expect(hit).toEqual(endpoints);
+ });
+
it("custom and user-defined groups get /chat/completions (with or without the explicit client type)", () => {
expect(protocolPathForModel("custom", "openai-chat")).toBe("/chat/completions");
// The deprecated bare "openai" alias (configs saved before AgentHub 0.4.2) means the same client.