Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

feat(providers): sync API-key services with pi-ai built-ins

vastsa7f380c13452b
diff --git a/docs/adr/0307-pi-ai-api-key-provider-sync.md b/docs/adr/0307-pi-ai-api-key-provider-sync.md
new file mode 100644
index 000000000..89c646cd7
--- /dev/null
+++ b/docs/adr/0307-pi-ai-api-key-provider-sync.md
@@ -0,0 +1,99 @@
+# ADR 0307: Sync the API-key service catalog with pi-ai's built-in providers
+
+- Status: Accepted
+- Date: 2026-09-24
+- Decision owners: PI-Desktop core
+- Related: ADR 0012, ADR 0020, ADR 0116, ADR 0155, D620
+
+## Context
+
+The Model configuration service list has two halves with different sources of
+truth. Vendor accounts are derived at runtime from pi-ai
+(`models.getProviders().filter(p => p.auth.oauth)`), so a subscriptions vendor
+added to the library shows up in the app without a code change. The API-key
+half is hand-maintained in `NAMED_ENDPOINT_PRESETS`
+(`packages/shared/src/provider-presets.ts`), and it had drifted: pi-ai 0.87.1
+ships 41 built-in providers, and fifteen of the ids that take a plain API key
+had no named preset of their own — only `minimax` resolved to the China row
+by alias, and the rest fell to the custom form.
+
+Users could still reach those hosts through the custom endpoint form, but they
+had to know the base URL, the vendor key stayed `custom`, and the models.dev
+catalog binding was lost.
+
+## Decision
+
+Add fifteen named endpoint presets so every pi-ai built-in API-key provider is
+reachable from the Service select:
+
+```text
+id baseUrl apiStyle
+ant-ling https://api.ant-ling.com/v1 chat_completions
+baseten https://inference.baseten.co/v1 chat_completions
+cerebras https://api.cerebras.ai/v1 chat_completions
+huggingface https://router.huggingface.co/v1 chat_completions
+meta https://api.meta.ai/v1 responses
+minimax https://api.minimax.io/anthropic/v1 anthropic_messages
+moonshotai https://api.moonshot.ai/v1 chat_completions
+nvidia https://integrate.api.nvidia.com/v1 chat_completions
+opencode https://opencode.ai/zen/v1 chat_completions
+vercel https://ai-gateway.vercel.sh/v1 chat_completions
+alibaba-token-plan https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1 chat_completions
+alibaba-token-plan-cn https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1 chat_completions
+xiaomi-token-plan-cn https://token-plan-cn.xiaomimimo.com/v1 chat_completions
+xiaomi-token-plan-ams https://token-plan-ams.xiaomimimo.com/v1 chat_completions
+xiaomi-token-plan-sgp https://token-plan-sgp.xiaomimimo.com/v1 chat_completions
+```
+
+Rules that follow from the existing preset contract:
+
+- `id` / `vendorKey` use the models.dev provider key when the snapshot has one,
+ so the catalog binding and the model list work; the pi-ai provider id is kept
+ as an alias when the two differ (`vercel-ai-gateway`, `qwen-token-plan`,
+ `qwen-token-plan-individual`, `qwen-token-plan-cn`, `opencode-zen`, `hf`,
+ `hugging-face`, `nim`).
+- `apiStyle` follows the wire style this app can actually drive with discovery
+ and catalog metadata. Vercel AI Gateway and OpenCode Zen publish several
+ protocols; both are reachable over the OpenAI-compatible face
+ (`chat_completions`), which is also what the models.dev catalog adapter maps
+ to. MiniMax (`anthropic_messages`) and Meta (`responses`) follow the
+ providers' own single protocol.
+- `minimax` (international, `api.minimax.io`) and `minimax-cn`
+ (`api.minimaxi.com`) stay separate rows; `moonshotai` and `moonshotai-cn` too.
+
+Eight built-in providers intentionally stay without a preset. The guard
+`packages/agent-runtime/src/pi-ai-provider-sync.test.ts` records each reason and
+fails when the list goes stale:
+
+- Amazon Bedrock, Azure OpenAI: request signing / per-resource endpoint and
+ deployment id rather than a base URL plus API key.
+- Cloudflare AI Gateway, Cloudflare Workers AI, Google Vertex AI: the base URL
+ embeds an account, gateway, project, or location.
+- GitHub Copilot, OpenAI Codex: offered as vendor-account (OAuth) rows here.
+- Radius: `pi_messages` is an account-only style in this app and the gateway
+ publishes no model list for discovery.
+
+## Consequences
+
+The Service select grows by fifteen API-key rows in the international and
+China groups; each row prefills name, base URL, and format, and
+`vendorKey` binds it to its models.dev catalog entry. Aliases make existing
+rows that stored a pi-ai provider id resolve to the same preset.
+
+The sync guard now fails on a pi-ai upgrade that adds a provider, which turns
+silent drift into a build-time signal. Providers that expose several protocols
+or no protocol at all still need a human decision, and the guard's exception
+list is where that decision is recorded.
+
+No protocol, IPC, storage schema, permission, or default-selection change.
+
+## Alternatives
+
+- **Derive the API-key list from pi-ai at runtime**, as vendor accounts do.
+ Rejected for now: pi-ai providers carry no display ordering, some need
+ account-scoped URLs, and the app's preset table also carries the
+ `apiStyle` and `zhipuCompat` bindings that the library does not express.
+- **Custom endpoint only.** Rejected: it hides the services, loses the
+ models.dev binding, and leaves the drift invisible.
+- **Group providers by library id, ignoring models.dev keys.** Rejected: the
+ catalog lookup and the model list are keyed by `vendorKey`.
diff --git a/docs/adr/README.md b/docs/adr/README.md
index a1729f3fa..a197d17a6 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -336,6 +336,7 @@ Each ADR includes:
| 0304 | [Trust the network endpoints the user enters themselves](0304-user-supplied-endpoint-trust.md) | Accepted for implementation (amends ADR 0243 / 0245 / 0247; follows ADR 0142 / 0257 / 0300) |
| 0305 | [Keep scheduled-task execution settings task-owned](0305-scheduled-task-execution-settings.md) | Accepted for implementation (amends scheduled-desktop-automations) |
| 0306 | [Brazilian Portuguese (pt-BR) shell locale](0306-portuguese-brazil-shell-locale.md) | Accepted (amends ADR 0160 / 0183 / 0185) |
+| 0307 | [Sync the API-key service catalog with pi-ai's built-in providers](0307-pi-ai-api-key-provider-sync.md) | Accepted (amends ADR 0012 / 0020 / 0116 / 0155) |
| turn-process-and-thinking-display | [Turn process and thinking presentation](turn-process-and-thinking-display.md) | Accepted |
| provider-display-order | [Provider display order](provider-display-order.md) | Accepted |
| registry-header-variable-spelling | [Remote header variables accept the registry's `{name}` spelling](registry-header-variable-spelling.md) | Proposed |
diff --git a/docs/spec/03-runtime/12-provider-config-schema.md b/docs/spec/03-runtime/12-provider-config-schema.md
index 13d8be337..ba8d60044 100644
--- a/docs/spec/03-runtime/12-provider-config-schema.md
+++ b/docs/spec/03-runtime/12-provider-config-schema.md
@@ -383,13 +383,33 @@ beside API format. `vendorKey` is the models.dev provider key.
International: OpenAI (`responses`), Anthropic (`anthropic_messages`), Google
Gemini (`google_generative_ai`), OpenRouter, Groq, xAI, Mistral, Together AI,
-Fireworks, OpenCode Go (`opencode_go`), Z.AI / Z.AI Coding Plan.
+Fireworks, OpenCode Go (`opencode_go`), Z.AI / Z.AI Coding Plan, Ant Ling,
+Baseten, Cerebras, Hugging Face (`huggingface`, aliases `hugging-face` / `hf`),
+Meta (`responses`), MiniMax (International) (`anthropic_messages` at
+`https://api.minimax.io/anthropic/v1`), Moonshot AI (International)
+(`moonshotai` at `https://api.moonshot.ai/v1`), NVIDIA (alias `nim`), OpenCode
+Zen (`opencode` at `https://opencode.ai/zen/v1`, alias `opencode-zen`), Vercel
+AI Gateway (`vercel` at `https://ai-gateway.vercel.sh/v1`, alias
+`vercel-ai-gateway`).
+
+`builtinProviders()` from pi-ai is the source for this list: every built-in
+provider is either reachable through one of the presets above or is an
+intentional exception with a recorded reason — Amazon Bedrock, Azure OpenAI,
+Cloudflare AI Gateway, Cloudflare Workers AI, and Google Vertex AI (their URLs
+carry account, region, project, or deployment ids), GitHub Copilot and OpenAI
+Codex (vendor-account rows), and Radius (`pi_messages` is account-only in this
+app). `packages/agent-runtime/src/pi-ai-provider-sync.test.ts` fails when a new
+built-in provider is neither covered nor excepted.
China: DeepSeek, Qwen DashScope (`alibaba-cn`), Moonshot (`moonshotai-cn`),
Zhipu AI / Coding Plan, SiliconFlow (`siliconflow-cn`), Volcengine Ark,
MiniMax (`anthropic_messages` at `https://api.minimaxi.com/anthropic/v1`),
MiniMax (OpenAI) (`chat_completions` at `https://api.minimaxi.com/v1`, aliases
-`minimax-openai` / `minimax-compatible`), Kimi For Coding (`anthropic_messages`).
+`minimax-openai` / `minimax-compatible`), Kimi For Coding (`anthropic_messages`),
+Qwen Token Plan (`alibaba-token-plan`, aliases `qwen-token-plan` /
+`qwen-token-plan-individual`), Qwen Token Plan (China)
+(`alibaba-token-plan-cn`, alias `qwen-token-plan-cn`), Xiaomi Token Plan
+(`xiaomi-token-plan-cn` / `-ams` / `-sgp`).
Zhipu / Z.AI Completions requests still receive `thinkingFormat: "zai"` and
`zaiToolStream: true`. pi-ai `zai-coding-cn` remains an alias of
diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.md
index 23d429bff..c4e1fae42 100644
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@ -305,6 +305,7 @@ Gold source: local Codex electron captures; latest row wins where rows conflict.
| D599 | A development build is its own installation | **Narrow D236 / amend ADR 0094: a development build (unpackaged, or `PI_DESKTOP_DEV=1`) takes `PI-Desktop Dev` as its Electron `userData` — and with it the single-instance lock, renderer `localStorage`, the plugin panel partitions, and browser pane cookies — and reads `~/.pi-desktop-dev`. An explicit `--user-data-dir` still wins, which is how the E2E harnesses point a build at a throwaway profile. A packaged installation keeps `PI-Desktop` and `~/.pi-desktop`, so no existing profile is relocated. `PI_DESKTOP_DATA_DIR` still overrides either profile and is made absolute before it reaches host-core as a child-process environment variable; Electron main publishes the resolved directory back to that variable so the plugin runtime reads one root. No IPC, protocol, schema, or packaged-installation path change. See `03-runtime/07-process-model.md` and E2E-150.** | A packaged app that was already running held the lock, so `pnpm dev` quit on arrival; a development host that won the race instead put a second host-core over the same single-writer `pi.sqlite`, the outbox, and the log tree. |
| D602 | Crash dumps stay in the data directory | **Electron's Crashpad reporter starts local-only (`uploadToServer: false`) before `ready`. Dumps live under `<data_dir>/crash-dumps`, not the default Electron `userData` crashDumps path, so a `PI_DESKTOP_DATA_DIR` profile does not share dumps. The next lock-holding launch writes one `diagnostics` line for dumps newer than `crash-dumps.json`, classified by Crashpad `ptype`: `error` if any new dump is the browser/main process, `warn` for recovered renderer/GPU/utility crashes. Host-core and sidecar crashes stay on the supervisor path. No upload, no IPC, no schema change.** | A crash left a minidump nobody read. Crashpad also records recovered renderer crashes, so a next-launch `error` that said the previous run died was a lie; and dumps outside the data directory escaped `PI_DESKTOP_DATA_DIR` isolation. |
| D619 | A copied formula is its TeX source | **Renderer only: a copy whose selection covers rendered math writes `text/plain` from the MathML `annotation` — `$…$` inline, `$$…$$` on its own lines, the delimiters `lib/latex-math.ts` normalizes `\(…\)` and `\[…\]` to, each run widened past any run inside the formula as a code span's fence is — instead of the two trees KaTeX paints. A cut that lands inside a formula grows to the whole formula. Only the formulas are rewritten: the reduced clone is read back through `Selection.toString()`, the serializer a copy itself runs, so prose, lists, tables and code blocks sharing the selection keep the platform's own reading — `user-select: none` chrome left behind included, which `innerText` would have written out. A selection with no formula in it, and a copy raised where the selection does not live, are left to the platform entirely. One flavour is written, `text/plain`: taking the event over drops the platform's `text/html` too and none is written back, because the reduced clone is app markup that would carry the `user-select: none` chrome the text reading drops, and because carrying the rendering instead would paste every formula twice — KaTeX's stylesheet is the only thing hiding the MathML tree and no stylesheet travels on the clipboard. One document `copy` listener owned by the shell, and the transcript's right-click Copy reads the same selection through the same module.** | A formula pasted as its glyphs, once per rendered tree, so it could not be carried into a LaTeX document or another Markdown editor (issue #414). ADR 0268 removed quoting on the grounds that the OS clipboard was the substitute; the clipboard had to actually carry the source. |
+| D620 | pi-ai built-in API-key services are named presets | **Add fifteen named endpoint presets — Ant Ling, Baseten, Cerebras, Hugging Face, Meta (`responses`), MiniMax (International), Moonshot AI (International), NVIDIA, OpenCode Zen, Vercel AI Gateway, Qwen Token Plan (`alibaba-token-plan`), Qwen Token Plan (China), Xiaomi Token Plan (China / Europe / Singapore) — to `NAMED_ENDPOINT_PRESETS`, each at its published host, with the pi-ai provider id kept as an alias wherever the models.dev key differs. Eight built-in providers remain exceptions with a recorded reason: Amazon Bedrock, Azure OpenAI, Cloudflare AI Gateway, Cloudflare Workers AI, Google Vertex AI (account- or region-scoped URLs), GitHub Copilot and OpenAI Codex (vendor-account rows), and Radius (`pi_messages` is account-only here). `packages/agent-runtime/src/pi-ai-provider-sync.test.ts` fails on a pi-ai upgrade that leaves a provider neither covered nor excepted. No protocol, storage, or IPC change.** | Every other pi-ai capability was already reachable, but the API-key half of the service catalog was hand-maintained and had drifted from the library's own provider list (ADR 0307). |
## M0. Model catalog decisions
diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.md
index f1446cddb..0efbe84e8 100644
--- a/docs/zh-CN/spec/08-meta/decisions-log.md
+++ b/docs/zh-CN/spec/08-meta/decisions-log.md
@@ -309,6 +309,7 @@
| D599 | 开发构建是一个独立安装 | **收窄 D236 / 修订 ADR 0094:开发构建(未打包,或 `PI_DESKTOP_DEV=1`)以 `PI-Desktop Dev` 作为 Electron `userData`(随之独立的单实例锁、渲染层 `localStorage`、插件面板 partition 与浏览器面板 Cookie),数据目录为 `~/.pi-desktop-dev`。显式 `--user-data-dir` 仍然优先,E2E 装置正是用它把构建指向临时 profile。正式安装仍保持 `PI-Desktop` 与 `~/.pi-desktop`,既有 profile 不会被搬迁。`PI_DESKTOP_DATA_DIR` 仍优先于两种 profile,并在作为子进程环境变量传给 host-core 之前被绝对化;Electron 主进程把解析结果回写到该变量,使插件运行时读到同一个根目录。不改 IPC、协议、schema 或正式安装路径。见 `03-runtime/07-process-model.md` 与 E2E-150。** | 已在运行的正式版持有锁,`pnpm dev` 一启动就退出;而抢到锁的开发 host 会把第二个 host-core 压到同一个单写者 `pi.sqlite`、outbox 与日志树上。 |
| D602 | 崩溃转储留在数据目录 | **Electron 的 Crashpad 报告器在 `ready` 之前以本地模式启动(`uploadToServer: false`)。转储放在 `<data_dir>/crash-dumps`,而不是 Electron 默认的 `userData` crashDumps 路径,因此 `PI_DESKTOP_DATA_DIR` profile 不会与其它安装共用转储。下一次持有单实例锁的启动会为新于 `crash-dumps.json` 的转储写一条 `diagnostics` 记录,按 Crashpad `ptype` 分类:任一新转储属于 browser/main 进程则为 `error`,已恢复的 renderer/GPU/utility 崩溃为 `warn`。host-core 与 sidecar 崩溃仍走监督器路径。不上传,不改 IPC,不改 schema。** | 崩溃留下的 minidump 无人读取。Crashpad 也会记录已恢复的渲染进程崩溃,因此下次启动用 `error` 声称上次运行已死是错的;而数据目录之外的转储会逃出 `PI_DESKTOP_DATA_DIR` 隔离。 |
| D619 | 复制公式得到的是它的 TeX 源码 | **仅渲染层:当选区覆盖到渲染出来的公式时,`text/plain` 从 MathML `annotation` 写出——行内 `$…$`,块级 `$$…$$` 独占行,也就是 `lib/latex-math.ts` 把 `\(…\)` 和 `\[…\]` 归一到的那组定界符,且每组定界符都像代码段的围栏那样加长到盖过公式内部出现的最长同字符串——而不是 KaTeX 画的那两棵树。落在公式内部的切口会扩展成整个公式。只有公式被改写:归约后的克隆经由 `Selection.toString()`——复制自己跑的那个序列化器——读回,因此同处一个选区的正文、列表、表格和代码块保留平台自己的读法,包括 `innerText` 会写出、而复制本就会略过的 `user-select: none` 界面零件。不含公式的选区,以及在选区所在位置之外触发的复制,整份交回平台。只写一种 flavour:`text/plain`。接管事件同时丢掉了平台的 `text/html`,且不再写回——归约后的克隆是应用自己的标记,写回去会带上文本读法已略过的 `user-select: none` 界面零件;而改为携带渲染结果则会把每个公式粘贴两遍,因为隐藏 MathML 树的只有 KaTeX 自己的样式表,样式表不会随剪贴板一起走。只有一个由外壳持有的文档级 `copy` 监听器,记录区的右键复制经由同一个模块读取同一个选区。** | 公式粘出来是它的字形,而且每棵渲染树各一份,无法带进 LaTeX 文档或别的 Markdown 编辑器(issue #414)。ADR 0268 当年移除「引用」的理由正是 OS 剪贴板可以替代,那剪贴板就得真的装着源码。 |
+| D620 | pi-ai 内置的 API-key 服务成为命名预设 | **向 `NAMED_ENDPOINT_PRESETS` 新增十五条命名预设——Ant Ling、Baseten、Cerebras、Hugging Face、Meta(`responses`)、MiniMax(国际)、Moonshot AI(国际)、NVIDIA、OpenCode Zen、Vercel AI Gateway、Qwen Token 套餐(`alibaba-token-plan`)、Qwen Token 套餐(中国)、小米 Token 套餐(中国/欧洲/新加坡)——各自使用官方主机名;models.dev 键与 pi-ai 提供方 id 不同的那几条,把 pi-ai id 保留为别名。八个内置提供方仍作例外并写明原因:Amazon Bedrock、Azure OpenAI、Cloudflare AI Gateway、Cloudflare Workers AI、Google Vertex AI(URL 里带账户或区域),GitHub Copilot 与 OpenAI Codex(以厂商账号行提供),以及 Radius(这里的 `pi_messages` 仅限账号)。pi-ai 升级后若某提供方既未被覆盖也不在例外中,`packages/agent-runtime/src/pi-ai-provider-sync.test.ts` 会失败。不改协议、存储或 IPC。** | pi-ai 其他能力本就可达,但服务目录的 API-key 一半靠手工维护,已经跟库自带的提供方列表脱节(ADR 0307)。 |
## M0. 模型目录决策
diff --git a/packages/agent-runtime/src/pi-ai-provider-sync.test.ts b/packages/agent-runtime/src/pi-ai-provider-sync.test.ts
new file mode 100644
index 000000000..72962a604
--- /dev/null
+++ b/packages/agent-runtime/src/pi-ai-provider-sync.test.ts
@@ -0,0 +1,49 @@
+import { matchNamedPreset } from "@pi-desktop/shared";
+import { builtinProviders } from "@earendil-works/pi-ai/providers/all";
+import { describe, expect, it } from "vitest";
+
+/**
+ * pi-ai built-in providers that intentionally have no named API-key preset here.
+ * Every entry must explain why; the guard fails once an entry goes stale.
+ */
+const UNSUPPORTED: Record<string, string> = {
+ "amazon-bedrock":
+ "requires SigV4 request signing plus a region, not a base URL and API key",
+ "azure-openai-responses":
+ "requires a per-resource endpoint and a deployment id",
+ "cloudflare-ai-gateway": "the base URL embeds the account and gateway id",
+ "cloudflare-workers-ai": "the base URL embeds the account id",
+ "github-copilot": "offered as a vendor account (OAuth) service in this app",
+ "google-vertex": "requires a project and location instead of a fixed base URL",
+ "openai-codex":
+ "offered as a vendor account (ChatGPT subscription) service in this app",
+ radius:
+ "pi_messages is an account-only style here and the gateway publishes no model list",
+};
+
+const providers = builtinProviders();
+
+describe("pi-ai built-in provider sync", () => {
+ it("keeps the documented exception list current", () => {
+ const ids = new Set(providers.map((provider) => provider.id));
+ expect(Object.keys(UNSUPPORTED).filter((id) => !ids.has(id))).toEqual([]);
+ for (const [id, reason] of Object.entries(UNSUPPORTED)) {
+ expect(reason.length, id).toBeGreaterThan(20);
+ expect(matchNamedPreset({ vendorKey: id }), id).toBeUndefined();
+ }
+ });
+
+ it("covers every other built-in provider with a named preset", () => {
+ const unmatched = providers
+ .filter((provider) => !(provider.id in UNSUPPORTED))
+ .filter(
+ (provider) =>
+ !matchNamedPreset({
+ vendorKey: provider.id,
+ baseUrl: provider.baseUrl,
+ }),
+ )
+ .map((provider) => provider.id);
+ expect(unmatched).toEqual([]);
+ });
+});
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index f69e044f2..8cae919c6 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -1312,6 +1312,21 @@ sklm: {
"presetMinimaxCn": "MiniMax",
"presetMinimaxCnOpenai": "MiniMax (OpenAI)",
"presetKimiCoding": "Kimi für Codierung",
+ "presetAntLing": "Ant Ling",
+ "presetBaseten": "Baseten",
+ "presetCerebras": "Cerebras",
+ "presetHuggingface": "Hugging Face",
+ "presetNvidia": "NVIDIA",
+ "presetOpenCodeZen": "OpenCode Zen",
+ "presetMeta": "Meta",
+ "presetMinimaxIntl": "MiniMax (International)",
+ "presetMoonshotIntl": "Moonshot AI (International)",
+ "presetVercelGateway": "Vercel AI Gateway",
+ "presetAlibabaTokenPlan": "Qwen Token Plan",
+ "presetAlibabaTokenPlanCn": "Qwen Token Plan (China)",
+ "presetXiaomiTokenPlanCn": "Xiaomi Token Plan (China)",
+ "presetXiaomiTokenPlanAms": "Xiaomi Token Plan (Europe)",
+ "presetXiaomiTokenPlanSgp": "Xiaomi Token Plan (Singapore)",
"presetXiaomi": "Xiaomi",
"apiStyleResponses": "OpenAI-Antworten",
"apiStyleAnthropic": "Anthropic Messages",
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index 2620018d7..93ec3ba15 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -1327,6 +1327,21 @@ sklm: {
presetMinimaxCn: "MiniMax",
presetMinimaxCnOpenai: "MiniMax (OpenAI)",
presetKimiCoding: "Kimi For Coding",
+ presetAntLing: "Ant Ling",
+ presetBaseten: "Baseten",
+ presetCerebras: "Cerebras",
+ presetHuggingface: "Hugging Face",
+ presetNvidia: "NVIDIA",
+ presetOpenCodeZen: "OpenCode Zen",
+ presetMeta: "Meta",
+ presetMinimaxIntl: "MiniMax (International)",
+ presetMoonshotIntl: "Moonshot AI (International)",
+ presetVercelGateway: "Vercel AI Gateway",
+ presetAlibabaTokenPlan: "Qwen Token Plan",
+ presetAlibabaTokenPlanCn: "Qwen Token Plan (China)",
+ presetXiaomiTokenPlanCn: "Xiaomi Token Plan (China)",
+ presetXiaomiTokenPlanAms: "Xiaomi Token Plan (Europe)",
+ presetXiaomiTokenPlanSgp: "Xiaomi Token Plan (Singapore)",
presetXiaomi: "Xiaomi",
apiStyleResponses: "OpenAI Responses",
apiStyleAnthropic: "Anthropic Messages",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index a2ee1d441..a388dfee6 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -1312,6 +1312,21 @@ sklm: {
"presetMinimaxCn": "MiniMax",
"presetMinimaxCnOpenai": "MiniMax (OpenAI)",
"presetKimiCoding": "Kimi para codificación",
+ "presetAntLing": "Ant Ling",
+ "presetBaseten": "Baseten",
+ "presetCerebras": "Cerebras",
+ "presetHuggingface": "Hugging Face",
+ "presetNvidia": "NVIDIA",
+ "presetOpenCodeZen": "OpenCode Zen",
+ "presetMeta": "Meta",
+ "presetMinimaxIntl": "MiniMax (Internacional)",
+ "presetMoonshotIntl": "Moonshot AI (Internacional)",
+ "presetVercelGateway": "Vercel AI Gateway",
+ "presetAlibabaTokenPlan": "Qwen Token Plan",
+ "presetAlibabaTokenPlanCn": "Qwen Token Plan (China)",
+ "presetXiaomiTokenPlanCn": "Xiaomi Token Plan (China)",
+ "presetXiaomiTokenPlanAms": "Xiaomi Token Plan (Europe)",
+ "presetXiaomiTokenPlanSgp": "Xiaomi Token Plan (Singapore)",
"presetXiaomi": "Xiaomi",
"apiStyleResponses": "Respuestas de OpenAI",
"apiStyleAnthropic": "Mensajes antrópicos",
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index 52b1b5de1..261099d49 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -1312,6 +1312,21 @@ sklm: {
"presetMinimaxCn": "MiniMax",
"presetMinimaxCnOpenai": "MiniMax (OpenAI)",
"presetKimiCoding": "Kimi pour le codage",
+ "presetAntLing": "Ant Ling",
+ "presetBaseten": "Baseten",
+ "presetCerebras": "Cerebras",
+ "presetHuggingface": "Hugging Face",
+ "presetNvidia": "NVIDIA",
+ "presetOpenCodeZen": "OpenCode Zen",
+ "presetMeta": "Meta",
+ "presetMinimaxIntl": "MiniMax (International)",
+ "presetMoonshotIntl": "Moonshot AI (International)",
+ "presetVercelGateway": "Vercel AI Gateway",
+ "presetAlibabaTokenPlan": "Qwen Token Plan",
+ "presetAlibabaTokenPlanCn": "Qwen Token Plan (China)",
+ "presetXiaomiTokenPlanCn": "Xiaomi Token Plan (China)",
+ "presetXiaomiTokenPlanAms": "Xiaomi Token Plan (Europe)",
+ "presetXiaomiTokenPlanSgp": "Xiaomi Token Plan (Singapore)",
"presetXiaomi": "Xiaomi",
"apiStyleResponses": "Réponses OpenAI",
"apiStyleAnthropic": "Messages anthropiques",
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index 29337c9f7..a12f85968 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -1325,6 +1325,21 @@ sklm: {
presetMinimaxCn: "MiniMax",
presetMinimaxCnOpenai: "MiniMax (OpenAI)",
presetKimiCoding: "Kimi For Coding",
+ presetAntLing: "Ant Ling",
+ presetBaseten: "Baseten",
+ presetCerebras: "Cerebras",
+ presetHuggingface: "Hugging Face",
+ presetNvidia: "NVIDIA",
+ presetOpenCodeZen: "OpenCode Zen",
+ presetMeta: "Meta",
+ presetMinimaxIntl: "MiniMax (국제)",
+ presetMoonshotIntl: "Moonshot AI (국제)",
+ presetVercelGateway: "Vercel AI Gateway",
+ presetAlibabaTokenPlan: "Qwen Token Plan",
+ presetAlibabaTokenPlanCn: "Qwen Token Plan (China)",
+ presetXiaomiTokenPlanCn: "Xiaomi Token Plan (China)",
+ presetXiaomiTokenPlanAms: "Xiaomi Token Plan (Europe)",
+ presetXiaomiTokenPlanSgp: "Xiaomi Token Plan (Singapore)",
presetXiaomi: "Xiaomi",
apiStyleResponses: "OpenAI Responses",
apiStyleAnthropic: "Anthropic Messages",
diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.ts
index 016e07a15..8795436aa 100644
--- a/packages/i18n/src/locales/pt-BR/index.ts
+++ b/packages/i18n/src/locales/pt-BR/index.ts
@@ -1274,6 +1274,21 @@ export const ptBR = {
presetMinimaxCn: "MiniMax",
presetMinimaxCnOpenai: "MiniMax (OpenAI)",
presetKimiCoding: "Kimi Coding",
+ presetAntLing: "Ant Ling",
+ presetBaseten: "Baseten",
+ presetCerebras: "Cerebras",
+ presetHuggingface: "Hugging Face",
+ presetNvidia: "NVIDIA",
+ presetOpenCodeZen: "OpenCode Zen",
+ presetMeta: "Meta",
+ presetMinimaxIntl: "MiniMax (Internacional)",
+ presetMoonshotIntl: "Moonshot AI (Internacional)",
+ presetVercelGateway: "Vercel AI Gateway",
+ presetAlibabaTokenPlan: "Qwen Token Plan",
+ presetAlibabaTokenPlanCn: "Qwen Token Plan (China)",
+ presetXiaomiTokenPlanCn: "Xiaomi Token Plan (China)",
+ presetXiaomiTokenPlanAms: "Xiaomi Token Plan (Europe)",
+ presetXiaomiTokenPlanSgp: "Xiaomi Token Plan (Singapore)",
presetXiaomi: "Xiaomi",
apiStyleResponses: "OpenAI Responses",
apiStyleAnthropic: "Anthropic Messages",
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index 0b550ae9c..5cf69e8a6 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -1315,6 +1315,21 @@ sklm: {
presetMinimaxCn: "MiniMax",
presetMinimaxCnOpenai: "MiniMax (OpenAI)",
presetKimiCoding: "Kimi For Coding",
+ presetAntLing: "Ant Ling",
+ presetBaseten: "Baseten",
+ presetCerebras: "Cerebras",
+ presetHuggingface: "Hugging Face",
+ presetNvidia: "NVIDIA",
+ presetOpenCodeZen: "OpenCode Zen",
+ presetMeta: "Meta",
+ presetMinimaxIntl: "MiniMax (Uluslararası)",
+ presetMoonshotIntl: "Moonshot AI (Uluslararası)",
+ presetVercelGateway: "Vercel AI Gateway",
+ presetAlibabaTokenPlan: "Qwen Token Plan",
+ presetAlibabaTokenPlanCn: "Qwen Token Plan (China)",
+ presetXiaomiTokenPlanCn: "Xiaomi Token Plan (China)",
+ presetXiaomiTokenPlanAms: "Xiaomi Token Plan (Europe)",
+ presetXiaomiTokenPlanSgp: "Xiaomi Token Plan (Singapore)",
presetXiaomi: "Xiaomi",
apiStyleResponses: "OpenAI Responses",
apiStyleAnthropic: "Anthropic Messages",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index c2d3ddc13..514369d77 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -1299,6 +1299,21 @@ sklm: {
presetMinimaxCn: "MiniMax",
presetMinimaxCnOpenai: "MiniMax(OpenAI)",
presetKimiCoding: "Kimi 编程",
+ presetAntLing: "Ant Ling",
+ presetBaseten: "Baseten",
+ presetCerebras: "Cerebras",
+ presetHuggingface: "Hugging Face",
+ presetNvidia: "NVIDIA",
+ presetOpenCodeZen: "OpenCode Zen",
+ presetMeta: "Meta",
+ presetMinimaxIntl: "MiniMax(国际)",
+ presetMoonshotIntl: "Moonshot AI(国际)",
+ presetVercelGateway: "Vercel AI Gateway",
+ presetAlibabaTokenPlan: "通义 Token 套餐",
+ presetAlibabaTokenPlanCn: "通义 Token 套餐(中国)",
+ presetXiaomiTokenPlanCn: "小米 Token 套餐(中国)",
+ presetXiaomiTokenPlanAms: "小米 Token 套餐(欧洲)",
+ presetXiaomiTokenPlanSgp: "小米 Token 套餐(新加坡)",
presetXiaomi: "小米",
apiStyleResponses: "OpenAI Responses",
apiStyleAnthropic: "Anthropic Messages",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index b7146353c..ef44194dc 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -1299,6 +1299,21 @@ sklm: {
presetMinimaxCn: "MiniMax",
presetMinimaxCnOpenai: "MiniMax(OpenAI)",
presetKimiCoding: "Kimi 程式設計",
+ presetAntLing: "Ant Ling",
+ presetBaseten: "Baseten",
+ presetCerebras: "Cerebras",
+ presetHuggingface: "Hugging Face",
+ presetNvidia: "NVIDIA",
+ presetOpenCodeZen: "OpenCode Zen",
+ presetMeta: "Meta",
+ presetMinimaxIntl: "MiniMax(國際)",
+ presetMoonshotIntl: "Moonshot AI(國際)",
+ presetVercelGateway: "Vercel AI Gateway",
+ presetAlibabaTokenPlan: "通義 Token 套餐",
+ presetAlibabaTokenPlanCn: "通義 Token 套餐(中國)",
+ presetXiaomiTokenPlanCn: "小米 Token 套餐(中國)",
+ presetXiaomiTokenPlanAms: "小米 Token 套餐(歐洲)",
+ presetXiaomiTokenPlanSgp: "小米 Token 套餐(新加坡)",
presetXiaomi: "小米",
apiStyleResponses: "OpenAI Responses",
apiStyleAnthropic: "Anthropic Messages",
diff --git a/packages/shared/src/provider-presets.test.ts b/packages/shared/src/provider-presets.test.ts
index 44f439c9d..e4f57ea77 100644
--- a/packages/shared/src/provider-presets.test.ts
+++ b/packages/shared/src/provider-presets.test.ts
@@ -195,3 +195,79 @@ describe("named endpoint presets", () => {
).toBe("opencode_go");
});
});
+
+describe("pi-ai built-in API-key services", () => {
+ it("resolves newly synced international vendors by key and by URL", () => {
+ const expected = [
+ ["ant-ling", "https://api.ant-ling.com/v1", "chat_completions"],
+ ["baseten", "https://inference.baseten.co/v1", "chat_completions"],
+ ["cerebras", "https://api.cerebras.ai/v1", "chat_completions"],
+ ["huggingface", "https://router.huggingface.co/v1", "chat_completions"],
+ ["nvidia", "https://integrate.api.nvidia.com/v1", "chat_completions"],
+ ["opencode", "https://opencode.ai/zen/v1", "chat_completions"],
+ ["vercel", "https://ai-gateway.vercel.sh/v1", "chat_completions"],
+ ] as const;
+ for (const [id, baseUrl, apiStyle] of expected) {
+ expect(matchNamedPreset({ vendorKey: id })).toMatchObject({
+ id,
+ vendorKey: id,
+ baseUrl,
+ apiStyle,
+ });
+ expect(matchNamedPreset({ baseUrl })).toMatchObject({ id, apiStyle });
+ }
+ });
+
+ it("keeps international and China hosts apart", () => {
+ expect(
+ matchNamedPreset({ baseUrl: "https://api.minimax.io/anthropic/v1" }),
+ ).toMatchObject({ id: "minimax", apiStyle: "anthropic_messages" });
+ expect(
+ matchNamedPreset({ baseUrl: "https://api.minimaxi.com/anthropic/v1" })?.id,
+ ).toBe("minimax-cn");
+ expect(matchNamedPreset({ baseUrl: "https://api.moonshot.ai/v1" })?.id).toBe(
+ "moonshotai",
+ );
+ expect(matchNamedPreset({ baseUrl: "https://api.moonshot.cn/v1" })?.id).toBe(
+ "moonshotai-cn",
+ );
+ });
+
+ it("maps pi-ai gateway and token-plan ids onto catalog keys", () => {
+ expect(matchNamedPreset({ vendorKey: "vercel-ai-gateway" })?.id).toBe("vercel");
+ expect(matchNamedPreset({ vendorKey: "opencode-zen" })?.id).toBe("opencode");
+ expect(matchNamedPreset({ vendorKey: "hf" })?.id).toBe("huggingface");
+ expect(matchNamedPreset({ vendorKey: "qwen-token-plan" })?.id).toBe(
+ "alibaba-token-plan",
+ );
+ expect(
+ matchNamedPreset({ vendorKey: "qwen-token-plan-individual" })?.vendorKey,
+ ).toBe("alibaba-token-plan");
+ expect(matchNamedPreset({ vendorKey: "qwen-token-plan-cn" })?.vendorKey).toBe(
+ "alibaba-token-plan-cn",
+ );
+ });
+
+ it("keeps OpenCode Zen and OpenCode Go as separate services", () => {
+ expect(matchNamedPreset({ baseUrl: "https://opencode.ai/zen/v1" })?.id).toBe(
+ "opencode",
+ );
+ expect(matchNamedPreset({ baseUrl: "https://opencode.ai/zen/go/v1" })?.id).toBe(
+ "opencode_go",
+ );
+ });
+
+ it("exposes Meta and the Xiaomi token plans as named services", () => {
+ expect(matchNamedPreset({ vendorKey: "meta" })).toMatchObject({
+ id: "meta",
+ apiStyle: "responses",
+ });
+ for (const id of [
+ "xiaomi-token-plan-cn",
+ "xiaomi-token-plan-ams",
+ "xiaomi-token-plan-sgp",
+ ]) {
+ expect(matchNamedPreset({ vendorKey: id })?.apiStyle).toBe("chat_completions");
+ }
+ });
+});
diff --git a/packages/shared/src/provider-presets.ts b/packages/shared/src/provider-presets.ts
index 632ef4416..6b0cd9973 100644
--- a/packages/shared/src/provider-presets.ts
+++ b/packages/shared/src/provider-presets.ts
@@ -221,6 +221,132 @@ export const NAMED_ENDPOINT_PRESETS: readonly NamedEndpointPreset[] = [
labelKey: "settings.presetKimiCoding",
aliases: ["kimi-coding", "kimi"],
},
+ {
+ id: "ant-ling",
+ vendorKey: "ant-ling",
+ name: "Ant Ling",
+ baseUrl: "https://api.ant-ling.com/v1",
+ apiStyle: "chat_completions",
+ labelKey: "settings.presetAntLing",
+ },
+ {
+ id: "baseten",
+ vendorKey: "baseten",
+ name: "Baseten",
+ baseUrl: "https://inference.baseten.co/v1",
+ apiStyle: "chat_completions",
+ labelKey: "settings.presetBaseten",
+ },
+ {
+ id: "cerebras",
+ vendorKey: "cerebras",
+ name: "Cerebras",
+ baseUrl: "https://api.cerebras.ai/v1",
+ apiStyle: "chat_completions",
+ labelKey: "settings.presetCerebras",
+ },
+ {
+ id: "huggingface",
+ vendorKey: "huggingface",
+ name: "Hugging Face",
+ baseUrl: "https://router.huggingface.co/v1",
+ apiStyle: "chat_completions",
+ labelKey: "settings.presetHuggingface",
+ aliases: ["hugging-face", "hf"],
+ },
+ {
+ id: "meta",
+ vendorKey: "meta",
+ name: "Meta",
+ baseUrl: "https://api.meta.ai/v1",
+ apiStyle: "responses",
+ labelKey: "settings.presetMeta",
+ },
+ {
+ id: "minimax",
+ vendorKey: "minimax",
+ name: "MiniMax (International)",
+ baseUrl: "https://api.minimax.io/anthropic/v1",
+ apiStyle: "anthropic_messages",
+ labelKey: "settings.presetMinimaxIntl",
+ },
+ {
+ id: "moonshotai",
+ vendorKey: "moonshotai",
+ name: "Moonshot AI (International)",
+ baseUrl: "https://api.moonshot.ai/v1",
+ apiStyle: "chat_completions",
+ labelKey: "settings.presetMoonshotIntl",
+ },
+ {
+ id: "nvidia",
+ vendorKey: "nvidia",
+ name: "NVIDIA",
+ baseUrl: "https://integrate.api.nvidia.com/v1",
+ apiStyle: "chat_completions",
+ labelKey: "settings.presetNvidia",
+ aliases: ["nim"],
+ },
+ {
+ id: "opencode",
+ vendorKey: "opencode",
+ name: "OpenCode Zen",
+ baseUrl: "https://opencode.ai/zen/v1",
+ apiStyle: "chat_completions",
+ labelKey: "settings.presetOpenCodeZen",
+ aliases: ["opencode-zen"],
+ },
+ {
+ id: "vercel",
+ vendorKey: "vercel",
+ name: "Vercel AI Gateway",
+ baseUrl: "https://ai-gateway.vercel.sh/v1",
+ apiStyle: "chat_completions",
+ labelKey: "settings.presetVercelGateway",
+ aliases: ["vercel-ai-gateway"],
+ },
+ {
+ id: "alibaba-token-plan",
+ vendorKey: "alibaba-token-plan",
+ name: "Qwen Token Plan",
+ baseUrl: "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
+ apiStyle: "chat_completions",
+ labelKey: "settings.presetAlibabaTokenPlan",
+ aliases: ["qwen-token-plan", "qwen-token-plan-individual"],
+ },
+ {
+ id: "alibaba-token-plan-cn",
+ vendorKey: "alibaba-token-plan-cn",
+ name: "Qwen Token Plan (China)",
+ baseUrl: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
+ apiStyle: "chat_completions",
+ labelKey: "settings.presetAlibabaTokenPlanCn",
+ aliases: ["qwen-token-plan-cn"],
+ },
+ {
+ id: "xiaomi-token-plan-cn",
+ vendorKey: "xiaomi-token-plan-cn",
+ name: "Xiaomi Token Plan (China)",
+ baseUrl: "https://token-plan-cn.xiaomimimo.com/v1",
+ apiStyle: "chat_completions",
+ labelKey: "settings.presetXiaomiTokenPlanCn",
+ },
+ {
+ id: "xiaomi-token-plan-ams",
+ vendorKey: "xiaomi-token-plan-ams",
+ name: "Xiaomi Token Plan (Europe)",
+ baseUrl: "https://token-plan-ams.xiaomimimo.com/v1",
+ apiStyle: "chat_completions",
+ labelKey: "settings.presetXiaomiTokenPlanAms",
+ },
+ {
+ id: "xiaomi-token-plan-sgp",
+ vendorKey: "xiaomi-token-plan-sgp",
+ name: "Xiaomi Token Plan (Singapore)",
+ baseUrl: "https://token-plan-sgp.xiaomimimo.com/v1",
+ apiStyle: "chat_completions",
+ labelKey: "settings.presetXiaomiTokenPlanSgp",
+ },
];
/** Canonical form of a configured endpoint for preset matching. */