Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(models): centralize native API metadata and compatibility defaults

Chris16b3eaede700
diff --git a/apps/desktop/src/main/maker-host/__tests__/activeCatalogDiscovery.test.ts b/apps/desktop/src/main/maker-host/__tests__/activeCatalogDiscovery.test.ts
index 4d85dab9a0..c07c6ea268 100644
--- a/apps/desktop/src/main/maker-host/__tests__/activeCatalogDiscovery.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/activeCatalogDiscovery.test.ts
@@ -128,7 +128,9 @@ describe('active-catalog discovered augment', () => {
const xai = getActiveCatalog().providers.find((provider) => provider.id === 'xai');
expect(xai?.agents).toContain('pi');
expect(xai?.routing.pi?.upstream).toBe('https://api.x.ai/v1');
- expect(xai?.models.pi?.find((model) => model.id === 'grok-4.6')?.piApi).toBe('openai-responses');
+ expect(xai?.models.pi?.find((model) => model.id === 'grok-4.6')?.piApi).toBe(
+ 'openai-responses',
+ );
expect(xai?.models.pi?.map((model) => model.id)).toEqual([
'grok-4.3',
'grok-4.5',
@@ -466,6 +468,7 @@ describe('anthropic 发现条目的 modelRegistry 元数据基线', () => {
['claude-sonnet-4-6', 'Sonnet 4.6'],
['claude-sonnet-4-5', 'Sonnet 4.5'],
['claude-haiku-4-5', 'Haiku 4.5'],
+ ['claude-fable-5-1', 'Fable 5.1'],
]);
expect(anthropicList('codex')).toEqual(
anthropicList('claude-code').map((model) => ({
diff --git a/apps/desktop/src/main/maker-host/__tests__/activeCatalogXdAvailability.test.ts b/apps/desktop/src/main/maker-host/__tests__/activeCatalogXdAvailability.test.ts
index 7f7bbbbbb7..2048a3fbfb 100644
--- a/apps/desktop/src/main/maker-host/__tests__/activeCatalogXdAvailability.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/activeCatalogXdAvailability.test.ts
@@ -74,13 +74,16 @@ describe('XD 网关权威模型清单重建', () => {
expect(getXdGatewayModels()).toEqual([]);
expect(isXdGatewayPaymentRequiredRoute('paid-only-model', 'claude-code')).toBe(true);
- setXdGatewayModels([
- {
- id: 'paid-only-model',
- agents: ['claude-code'],
- availability: 'available',
- },
- ], { authoritative: true });
+ setXdGatewayModels(
+ [
+ {
+ id: 'paid-only-model',
+ agents: ['claude-code'],
+ availability: 'available',
+ },
+ ],
+ { authoritative: true },
+ );
expect(isXdGatewayPaymentRequiredRoute('paid-only-model', 'claude-code')).toBe(false);
});
@@ -168,15 +171,18 @@ describe('XD 网关权威模型清单重建', () => {
catalogXd.embeddingDefaults = { standard: 'voyage/voyage-4' };
setActiveCatalog(catalog);
- setXdGatewayModels([
- {
- id: 'voyage/voyage-4',
- name: 'Voyage 4',
- mode: 'embedding',
- availability: 'requires_payment',
- agents: [],
- },
- ], { authoritative: true });
+ setXdGatewayModels(
+ [
+ {
+ id: 'voyage/voyage-4',
+ name: 'Voyage 4',
+ mode: 'embedding',
+ availability: 'requires_payment',
+ agents: [],
+ },
+ ],
+ { authoritative: true },
+ );
const activeXd = getActiveCatalog().providers.find((provider) => provider.id === 'xd');
expect(activeXd?.embeddingModels).toBeUndefined();
@@ -187,7 +193,9 @@ describe('XD 网关权威模型清单重建', () => {
preservePaymentRequiredRoutes: true,
});
- const afterRefreshFailure = getActiveCatalog().providers.find((provider) => provider.id === 'xd');
+ const afterRefreshFailure = getActiveCatalog().providers.find(
+ (provider) => provider.id === 'xd',
+ );
expect(afterRefreshFailure?.embeddingModels).toBeUndefined();
expect(afterRefreshFailure?.embeddingDefaults).toBeUndefined();
});
@@ -254,14 +262,16 @@ describe('XD 网关权威模型清单重建', () => {
it('服务端显式声明 Codex Responses 路由及其能力覆写', () => {
setActiveCatalog(BUNDLED_CATALOG);
- setXdGatewayModels([{
- id: 'fast-claude-only',
- agents: ['claude-code', 'codex'],
- supportsFastMode: true,
- perAgent: {
- codex: { supportsFastMode: false, wireProtocol: 'openai-responses' },
- },
- }]);
+ setXdGatewayModels([
+ {
+ id: 'fast-claude-only',
+ agents: ['claude-code', 'codex'],
+ supportsFastMode: true,
+ perAgent: {
+ codex: { supportsFastMode: false, wireProtocol: 'openai-responses' },
+ },
+ },
+ ]);
expect(xdModels('claude-code')[0]?.supportsFastMode).toBe(true);
expect(xdModels('codex')[0]).toMatchObject({
supportsFastMode: false,
@@ -287,9 +297,12 @@ describe('XD 网关权威模型清单重建', () => {
const registryEntry = catalog.modelRegistry?.models.find(
(entry) =>
entry.id === 'moonshotai/kimi-k3' ||
- entry.routes.some((route) => route.providerId === 'xd' && route.modelId === 'moonshot/kimi-k3'),
+ entry.routes.some(
+ (route) => route.providerId === 'xd' && route.modelId === 'moonshot/kimi-k3',
+ ),
);
if (!registryEntry) throw new Error('missing Kimi registry fixture');
+ registryEntry.nativeApi = 'anthropic-messages';
registryEntry.routes = [
{ providerId: 'xd', modelId: 'moonshot/kimi-k3', agents: ['claude-code', 'codex'] },
{
@@ -406,9 +419,7 @@ describe('XD 网关权威模型清单重建', () => {
expect(resolveXdPiGatewayApi('claude-opus-5')).toBe('anthropic-messages');
expect(resolveXdPiGatewayApi('google/gemini-3.6-flash')).toBeUndefined();
- expect(xdModels('pi')).toMatchObject([
- { id: 'claude-opus-5', piApi: 'anthropic-messages' },
- ]);
+ expect(xdModels('pi')).toMatchObject([{ id: 'claude-opus-5', piApi: 'anthropic-messages' }]);
});
it('显式登记 efforts=[] 表示不可调,不合成 3 档;fast 显式 false 尊重', () => {
@@ -734,17 +745,77 @@ describe('Anthropic 权威模型清单注入', () => {
});
describe('gateway cross-harness defaults', () => {
+ it('uses canonical APIs for defaults and accepts a later server correction without editing Pi metadata', () => {
+ const id = 'google/gemini-future';
+ setActiveCatalog(BUNDLED_CATALOG);
+ setXdGatewayModels([
+ {
+ id,
+ name: 'Future Gemini',
+ contextWindow: 1_048_576,
+ defaultEnabled: true,
+ agents: ['claude-code', 'codex', 'pi'],
+ perAgent: { pi: { wireProtocol: 'openai-responses' } },
+ },
+ ]);
+ expect(xdModels('claude-code')[0]).toMatchObject({
+ nativeApi: 'google-generative-ai',
+ defaultEnabled: false,
+ });
+ expect(xdModels('codex')[0].defaultEnabled).toBe(false);
+ expect(xdModels('pi')[0]).toMatchObject({
+ piApi: 'google-generative-ai',
+ defaultEnabled: true,
+ });
+ const next = structuredClone(BUNDLED_CATALOG);
+ next.modelRegistry!.updatedAt = '2099-01-01T00:00:00.000Z';
+ next.modelRegistry!.models.push({
+ id: 'future/gemini',
+ name: 'Future Gemini',
+ nativeApi: 'openai-responses',
+ routes: [{ providerId: 'xd', modelId: id, agents: ['claude-code', 'codex'] }],
+ });
+ setActiveCatalog(next, { authorityCatalog: next });
+ expect(xdModels('codex')[0]).toMatchObject({
+ nativeApi: 'openai-responses',
+ defaultEnabled: true,
+ });
+ expect(xdModels('claude-code')[0].defaultEnabled).toBe(false);
+ expect(xdModels('pi')[0].piApi).toBe('openai-responses');
+ // Explicitly unverified native metadata does not disable a declared execution route.
+ next.modelRegistry!.models.at(-1)!.nativeApi = null;
+ setActiveCatalog(next, { authorityCatalog: next });
+ expect(xdModels('pi')[0]).toMatchObject({ nativeApi: null, piApi: 'openai-responses' });
+ // A V3 catalog can explicitly remove family defaults; it is not backfilled from the bundle.
+ next.modelRegistry!.nativeApiRules = [];
+ next.modelRegistry!.models = [];
+ setActiveCatalog(next, { authorityCatalog: next });
+ expect(xdModels('pi')[0].nativeApi).toBeUndefined();
+ expect(xdModels('pi')[0].piApi).toBe('openai-responses');
+ });
+
it('uses explicit per-agent policy before the opt-in fallback', () => {
setActiveCatalog(BUNDLED_CATALOG);
- const entries = ['codex/gpt-6', 'claude-opus-5', 'anthropic-claude/claude-opus-4-8'].map((id) => ({
- id, name: id, contextWindow: 1_000_000, defaultEnabled: true,
- agents: ['claude-code', 'codex', 'pi'] as const,
- }));
+ const entries = ['codex/gpt-6', 'claude-opus-5', 'anthropic-claude/claude-opus-4-8'].map(
+ (id) => ({
+ id,
+ name: id,
+ contextWindow: 1_000_000,
+ defaultEnabled: true,
+ agents: ['claude-code', 'codex', 'pi'] as const,
+ }),
+ );
setXdGatewayModels(entries.map((e) => ({ ...e, agents: [...e.agents] })));
expect(xdModels('claude-code').map((m) => m.defaultEnabled)).toEqual([false, true, true]);
expect(xdModels('codex').map((m) => m.defaultEnabled)).toEqual([true, false, false]);
expect(xdModels('pi').map((m) => m.defaultEnabled)).toEqual([true, true, true]);
- setXdGatewayModels(entries.map((e) => ({ ...e, agents: [...e.agents], perAgent: { 'claude-code': { defaultEnabled: true }, codex: { defaultEnabled: true } } })));
+ setXdGatewayModels(
+ entries.map((e) => ({
+ ...e,
+ agents: [...e.agents],
+ perAgent: { 'claude-code': { defaultEnabled: true }, codex: { defaultEnabled: true } },
+ })),
+ );
expect(xdModels('claude-code').every((m) => m.defaultEnabled)).toBe(true);
expect(xdModels('codex').every((m) => m.defaultEnabled)).toBe(true);
});
diff --git a/apps/desktop/src/main/maker-host/__tests__/piGatewayModelCatalog.test.ts b/apps/desktop/src/main/maker-host/__tests__/piGatewayModelCatalog.test.ts
index d38b785f68..98de7d748d 100644
--- a/apps/desktop/src/main/maker-host/__tests__/piGatewayModelCatalog.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/piGatewayModelCatalog.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
-import type { Catalog } from '@cindy/model-providers';
+import { BUNDLED_CATALOG, type Catalog } from '@cindy/model-providers';
import {
resolveBundledPiGatewayModelProfile,
@@ -130,9 +130,7 @@ describe('Cindy Server Pi Gateway catalog authority', () => {
{ id: 'openrouter', protocol: 'openai-chat', modelId: 'moonshot/kimi-k3' },
],
});
- expect(resolveCatalogPiGatewayModelApi(catalog, 'moonshot/kimi-k3')).toBe(
- 'anthropic-messages',
- );
+ expect(resolveCatalogPiGatewayModelApi(catalog, 'moonshot/kimi-k3')).toBe('anthropic-messages');
});
it('does not borrow an exact namespaced id without a registry provider route', () => {
@@ -167,9 +165,7 @@ describe('Cindy Server Pi Gateway catalog authority', () => {
const catalog = serverCatalog({
gatewayModelId: 'moonshot/kimi-k3',
routes: [{ providerId: 'moonshot-kimi-global', modelId: 'kimi-k3' }],
- presets: [
- { id: 'moonshot-kimi-global', protocol: 'anthropic-messages', modelId: 'kimi-k3' },
- ],
+ presets: [{ id: 'moonshot-kimi-global', protocol: 'anthropic-messages', modelId: 'kimi-k3' }],
});
catalog.modelRegistry!.models[0]!.status = 'retired';
expect(resolveCatalogPiGatewayModelApi(catalog, 'moonshot/kimi-k3')).toBeNull();
@@ -188,7 +184,8 @@ describe('Cindy Server Pi Gateway catalog authority', () => {
describe('Pi Gateway version-matched local supplement catalog', () => {
it.each(['google/gemini-3.8-flash', 'gemini-3.8-flash', 'google/gemini-99-pro-preview[1m]'])(
'keeps new XD Gemini route %s on Google without a per-model registration',
- (id) => expect(resolveBundledPiGatewayModelProfile(id)).toEqual({ api: 'google-generative-ai' }),
+ (id) =>
+ expect(resolveBundledPiGatewayModelProfile(id)).toEqual({ api: 'google-generative-ai' }),
);
it.each(['other/gemini-99-pro', 'google/not-gemini-99', 'google/gemini-99/other'])(
@@ -213,6 +210,23 @@ describe('Pi Gateway version-matched local supplement catalog', () => {
});
});
+ it('does not reuse serializer metadata after an authoritative API correction', () => {
+ const entry = BUNDLED_CATALOG.modelRegistry!.models.find((model) =>
+ model.routes.some(
+ (route) => route.providerId === 'xd' && route.modelId === 'moonshotai/kimi-k3',
+ ),
+ )!;
+ const original = entry.nativeApi;
+ try {
+ entry.nativeApi = 'anthropic-messages';
+ expect(resolveBundledPiGatewayModelProfile('moonshotai/kimi-k3')).toEqual({
+ api: 'anthropic-messages',
+ });
+ } finally {
+ entry.nativeApi = original;
+ }
+ });
+
it.each([
['anthropic/claude-opus-5', 'anthropic-messages'],
['codex/gpt-5.5:auto', 'openai-responses'],
diff --git a/apps/desktop/src/main/maker-host/__tests__/piNativeProviders.test.ts b/apps/desktop/src/main/maker-host/__tests__/piNativeProviders.test.ts
index e88b8c8391..6366d0f768 100644
--- a/apps/desktop/src/main/maker-host/__tests__/piNativeProviders.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/piNativeProviders.test.ts
@@ -101,11 +101,12 @@ describe('resolvePiCindyGatewayModelApi', () => {
},
];
catalog.modelRegistry = {
- schemaVersion: 2,
+ schemaVersion: 3,
updatedAt: '2026-08-29T00:00:00.000Z',
models: [
{
id: 'canonical/kimi-k3',
+ nativeApi: 'anthropic-messages',
name: 'Kimi K3',
routes: [
{ providerId: 'xd', modelId: 'moonshot/kimi-k3', agents: ['claude-code', 'codex'] },
diff --git a/apps/desktop/src/main/maker-host/active-catalog.ts b/apps/desktop/src/main/maker-host/active-catalog.ts
index ec0cd5c186..4e3e5d6042 100644
--- a/apps/desktop/src/main/maker-host/active-catalog.ts
+++ b/apps/desktop/src/main/maker-host/active-catalog.ts
@@ -30,6 +30,7 @@ import {
BUNDLED_CATALOG,
buildUserProvider,
findModelRegistryRoute,
+ resolveModelNativeApi,
type AgentKind,
type Catalog,
type CatalogCapabilityEvidence,
@@ -240,7 +241,15 @@ let localOverrides: ModelCatalogOverrides = EMPTY_MODEL_CATALOG_OVERRIDES;
let lastPlanWarnings: ModelPlaneWarning[] = [];
type Effort = CatalogModel['efforts'][number];
-const EFFORT_RANK: readonly Effort[] = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra'];
+const EFFORT_RANK: readonly Effort[] = [
+ 'minimal',
+ 'low',
+ 'medium',
+ 'high',
+ 'xhigh',
+ 'max',
+ 'ultra',
+];
/**
* 档位集合 → **规范升序**数组(低 → 高)。x.ai discovery 的 payload 是降序,而下游
@@ -343,10 +352,38 @@ function isPiModelApi(value: unknown): value is PiModelApi {
);
}
-function resolveXdPiGatewayServerModelApi(model: XdGatewayModelInfo): PiModelApi | null | undefined {
- return piGatewayAuthorityCatalog
+function resolveXdPiGatewayServerModelApi(
+ model: XdGatewayModelInfo,
+): PiModelApi | null | undefined {
+ if (
+ piGatewayAuthorityCatalog &&
+ isCatalogPiGatewayModelRetired(piGatewayAuthorityCatalog, model.id)
+ )
+ return null;
+ const nativeApi = nativeApiForRoute('xd', model.id);
+ if (nativeApi) return nativeApi;
+ const declared = piGatewayAuthorityCatalog
? resolveCatalogPiGatewayModelApi(piGatewayAuthorityCatalog, model.id)
: undefined;
+ if (declared !== undefined) return declared;
+ // V3 owns explicit unknowns and removed rules. A still-declared execution route remains
+ // usable, but the bundled canonical rule must not be revived as its authority.
+ if ((base?.modelRegistry?.schemaVersion ?? 0) >= 3 || nativeApi === null) {
+ return resolveXdPiGatewayHintModelApi(model);
+ }
+ return undefined;
+}
+
+/** Old Server catalogs cannot express canonical APIs. Only that new metadata falls back;
+ * V3 snapshots own omissions/nulls/removals and never resurrect a bundled protocol rule.
+ */
+function nativeApiForRoute(providerId: string, modelId: string): PiModelApi | null | undefined {
+ const registry = (base ?? BUNDLED_CATALOG).modelRegistry;
+ return resolveModelNativeApi(
+ registry && registry.schemaVersion >= 3 ? registry : BUNDLED_CATALOG.modelRegistry,
+ providerId,
+ modelId,
+ );
}
function resolveXdPiGatewayHintModelApi(model: XdGatewayModelInfo): PiModelApi | null {
@@ -375,7 +412,9 @@ function xdGatewayTargetAgents(model: XdGatewayModelInfo): AgentKind[] {
return (model.agents ?? []).filter((agent) => agent !== 'pi' || !serverRetired);
}
-/** Resolve only Cindy Server's highest-priority protocol declaration. */
+/** Resolve the accepted canonical policy for Pi. Legacy catalogs use the bundled metadata;
+ * V3 removals keep only a still-declared route and suppress older bundled protocol policies.
+ */
export function resolveXdPiGatewayServerApi(modelId: string): PiModelApi | null | undefined {
const normalized = modelId.replace(/\[1m\]$/, '');
const gatewayModel = xdGatewayModels.find((model) => model.id === normalized);
@@ -906,11 +945,7 @@ function projectXdGatewayMediaModels(
delete identity.imageDefaults;
delete identity.videoModels;
delete identity.videoDefaults;
- if (
- options.authoritative ||
- hasEmbeddingEntries ||
- xdGatewayEmbeddingFallbackSuppressed
- ) {
+ if (options.authoritative || hasEmbeddingEntries || xdGatewayEmbeddingFallbackSuppressed) {
delete identity.embeddingModels;
delete identity.embeddingDefaults;
}
@@ -921,9 +956,7 @@ function projectXdGatewayMediaModels(
...(embeddingModels.length > 0 ? { embeddingModels } : {}),
...(imageModels[0] ? { imageDefaults: { standard: imageModels[0].id } } : {}),
...(videoModels[0] ? { videoDefaults: { standard: videoModels[0].id } } : {}),
- ...(embeddingModels[0]
- ? { embeddingDefaults: { standard: embeddingModels[0].id } }
- : {}),
+ ...(embeddingModels[0] ? { embeddingDefaults: { standard: embeddingModels[0].id } } : {}),
};
}
@@ -1254,20 +1287,26 @@ function computeMerged(): Catalog {
const efforts = (ov.efforts ?? gm.efforts ?? []) as Effort[];
const rawDefault = ov.defaultEffort !== undefined ? ov.defaultEffort : gm.defaultEffort;
const defaultEffort = (rawDefault ?? null) as Effort | null;
- // Explicit per-harness policy wins. Without it, GPT in Claude Code and
- // Claude in Codex are opt-in; model-wide defaults still govern native/Pi rows.
- // Namespace spelling is a Gateway route identity, not a different model family
- // (e.g. anthropic-claude/claude-opus-4-8). Keep the wire id intact for execution.
- const familyId = gm.id.slice(gm.id.lastIndexOf('/') + 1);
- const crossHarness =
- (agent === 'claude-code' && /^(?:gpt-|o[134](?:-|$))/i.test(familyId)) ||
- (agent === 'codex' && /^claude-/i.test(familyId));
- const defaultEnabled = ov.defaultEnabled ?? (crossHarness ? false : gm.defaultEnabled);
+ // Canonical Registry API determines native versus compatibility defaults. Explicit
+ // per-harness policy remains an override; user visibility preferences are applied later.
+ const nativeApi = nativeApiForRoute('xd', gm.id);
+ const piApi = agent === 'pi' ? resolveXdPiGatewayModelApi(gm) : undefined;
+ const harnessApi =
+ agent === 'claude-code'
+ ? 'anthropic-messages'
+ : agent === 'codex'
+ ? 'openai-responses'
+ : piApi;
+ const outboundApi = agent === 'pi' ? piApi : (ov.wireProtocol ?? harnessApi);
+ const compatible = Boolean(
+ nativeApi && (harnessApi !== nativeApi || outboundApi !== nativeApi),
+ );
+ const defaultEnabled = ov.defaultEnabled ?? (compatible ? false : gm.defaultEnabled);
const cost = effectiveGatewayModelCost(gm);
const contextWindow = ov.contextWindow ?? gm.contextWindow;
- const piApi = agent === 'pi' ? resolveXdPiGatewayModelApi(gm) : undefined;
const merged: CatalogModel = {
id: gm.id,
+ ...(nativeApi !== undefined ? { nativeApi } : {}),
...(gm.availability ? { availability: gm.availability } : {}),
// name / contextWindow are required by Model Access v3 and therefore never synthesized.
name: gm.name as string,
@@ -1316,7 +1355,18 @@ function computeMerged(): Catalog {
};
});
- if (providers === b.providers) return b; // 无 augment、无 custom → 原样返回
+ providers = providers.map((provider) => ({
+ ...provider,
+ models: Object.fromEntries(
+ Object.entries(provider.models).map(([agent, models]) => [
+ agent,
+ models?.map((model) => {
+ const nativeApi = nativeApiForRoute(provider.id, model.id);
+ return nativeApi !== undefined ? { ...model, nativeApi } : model;
+ }),
+ ]),
+ ),
+ }));
return { ...b, providers }; // spread 保留 presets 等目录顶层字段
}
@@ -1623,9 +1673,7 @@ export function getXdGatewayModelAccessSnapshot(): {
authoritative: xdGatewayModelsAuthoritative,
models: xdGatewayModels,
paymentRequiredModelIds: [...xdGatewayPaymentRequiredRoutes].flatMap((route) =>
- route.startsWith(claudeCodeRoutePrefix)
- ? [route.slice(claudeCodeRoutePrefix.length)]
- : [],
+ route.startsWith(claudeCodeRoutePrefix) ? [route.slice(claudeCodeRoutePrefix.length)] : [],
),
};
}
diff --git a/apps/desktop/src/main/maker-host/pi-gateway-model-catalog.ts b/apps/desktop/src/main/maker-host/pi-gateway-model-catalog.ts
index c64a9d19dd..2b54039544 100644
--- a/apps/desktop/src/main/maker-host/pi-gateway-model-catalog.ts
+++ b/apps/desktop/src/main/maker-host/pi-gateway-model-catalog.ts
@@ -1,3 +1,4 @@
+import { BUNDLED_CATALOG, resolveModelNativeApi } from '@cindy/model-providers';
import type {
Catalog,
PiModelApi,
@@ -23,75 +24,10 @@ const catalog = piModelCatalogJson as unknown as {
};
const rows = Object.values(catalog.providers).flat();
-const gatewayModelIdsByApi: Record<PiModelApi, ReadonlySet<string>> = {
- 'anthropic-messages': new Set([
- 'claude-fable-5',
- 'claude-haiku-4-5',
- 'claude-haiku-4-5-20251001',
- 'claude-opus-4-6',
- 'claude-opus-4-7',
- 'claude-opus-4-8',
- 'claude-opus-5',
- 'claude-sonnet-4-6',
- 'claude-sonnet-5',
- 'anthropic/claude-opus-5',
- ]),
- 'openai-responses': new Set([
- 'gpt-5.4',
- 'gpt-5.4-mini',
- 'gpt-5.4-nano',
- 'gpt-5.5',
- 'gpt-5.6-luna',
- 'gpt-5.6-sol',
- 'gpt-5.6-terra',
- 'codex/gpt-5.4',
- 'codex/gpt-5.4-mini',
- 'codex/gpt-5.5',
- 'codex/gpt-5.5:auto',
- 'codex/gpt-5.6-luna',
- 'codex/gpt-5.6-sol',
- 'codex/gpt-5.6-terra',
- 'meta/muse-spark-1.2',
- 'x-ai-grok/grok-4.6',
- 'x-ai/grok-4.5',
- 'x-ai/grok-4.6',
- ]),
- 'openai-completions': new Set([
- 'deepseek/deepseek-v4-flash',
- 'deepseek/deepseek-v4-flash-vision-exp',
- 'deepseek/deepseek-v4-pro',
- 'moonshot/kimi-k3',
- 'moonshotai/kimi-k2.6',
- 'moonshotai/kimi-k3',
- 'qwen/qwen3.7-max',
- 'qwen/qwen3.8-27b',
- 'qwen/qwen3.8-flash',
- 'qwen/qwen3.8-max',
- 'tencent/hy3',
- 'z-ai/glm-5.1',
- 'z-ai/glm-5.2',
- 'z-ai/glm-5.3',
- 'z-ai/glm-5.3-flash',
- 'z-ai/glm-5.3-highspeed',
- ]),
- 'google-generative-ai': new Set(),
-};
-
function normalizeModelId(modelId: string): string {
return modelId.replace(/\[1m\]$/, '');
}
-/** Cindy's XD Gemini route contract: use Pi's Google adapter, including new releases.
- * This is a routing policy, not inferred model capability. It applies only to XD identities;
- * another aggregator's Gemini-like ID must not acquire Google's protocol or serialization data.
- */
-function googleGatewayIdentity(modelId: string): { provider: string; modelId: string } | undefined {
- const normalized = normalizeModelId(modelId);
- return /^(?:google\/)?gemini-[a-z0-9][a-z0-9._:-]*$/i.test(normalized)
- ? { provider: 'google', modelId: normalized.replace(/^google\//i, '') }
- : undefined;
-}
-
function piApiFromWireProtocol(protocol: ProviderWireProtocol | undefined): PiModelApi | undefined {
switch (protocol) {
case 'anthropic-messages':
@@ -118,11 +54,7 @@ function collapseCatalogApis(apis: readonly PiModelApi[]): PiModelApi | null | u
return distinct.length === 1 ? distinct[0] : null;
}
-function routedCatalogApis(
- catalog: Catalog,
- providerId: string,
- modelId: string,
-): PiModelApi[] {
+function routedCatalogApis(catalog: Catalog, providerId: string, modelId: string): PiModelApi[] {
if (providerId === 'xd') return [];
const apis: PiModelApi[] = [];
const provider = catalog.providers.find((entry) => entry.id === providerId);
@@ -222,24 +154,17 @@ const gatewayCatalogIdentityOverrides = new Map<string, { provider: string; mode
]),
]);
-function authoritativeGatewayApi(modelId: string): PiModelApi | undefined {
- if (googleGatewayIdentity(modelId)) return 'google-generative-ai';
- const normalized = normalizeModelId(modelId);
- for (const [api, ids] of Object.entries(gatewayModelIdsByApi) as Array<
- [PiModelApi, ReadonlySet<string>]
- >) {
- if (ids.has(normalized)) return api;
- }
- return undefined;
-}
-
/** Preferred exact provider/model identity in Pi's complete bundled catalog. */
export function resolveBundledPiGatewayCatalogIdentity(
modelId: string,
): { provider: string; modelId: string } | undefined {
const normalized = normalizeModelId(modelId);
- const google = googleGatewayIdentity(normalized);
- if (google) return google;
+ if (
+ resolveModelNativeApi(BUNDLED_CATALOG.modelRegistry, 'xd', normalized) ===
+ 'google-generative-ai'
+ ) {
+ return { provider: 'google', modelId: normalized.replace(/^google\//, '') };
+ }
const explicit = gatewayCatalogIdentityOverrides.get(normalized);
if (explicit) return explicit;
const direct = rows.find((row) => `${row.provider}/${row.id}` === normalized);
@@ -250,7 +175,7 @@ export function resolveBundledPiGatewayCatalogIdentity(
* Resolve the current Gateway model through Cindy's version-matched Pi table.
*
* Cindy Server's downloaded Catalog is checked before this function. This local table is the
- * second authority: exact identities plus Cindy's XD Gemini routing policy. Gateway metadata
+ * second authority: canonical APIs and route rules in model-registry.json. Gateway metadata
* is a last-resort hint after both higher-priority sources are absent. Unknown identities fail
* closed instead of guessing a provider or protocol.
*/
@@ -261,15 +186,21 @@ export function resolveBundledPiGatewayModelProfile(
const matched = identity
? rows.find((row) => row.provider === identity.provider && row.id === identity.modelId)
: undefined;
- const api = matched?.api ?? authoritativeGatewayApi(modelId);
+ const canonical = resolveModelNativeApi(BUNDLED_CATALOG.modelRegistry, 'xd', modelId);
+ const api = canonical !== undefined ? canonical : matched?.api;
if (!api) return undefined;
+ const compatible = matched?.api === api ? matched : undefined;
// Never borrow compat by bare ID across providers. An allowlisted Gateway identity may still
// use its locally selected API, but provider-specific serialization metadata requires an exact
// canonical provider/model row (or the exact binary probe in pi-host).
return {
api,
- ...(matched?.compat ? { compat: structuredClone(matched.compat) } : {}),
- ...(matched?.samplingParams ? { samplingParams: structuredClone(matched.samplingParams) } : {}),
- ...(matched?.thinkingLevelMap ? { thinkingLevelMap: { ...matched.thinkingLevelMap } } : {}),
+ ...(compatible?.compat ? { compat: structuredClone(compatible.compat) } : {}),
+ ...(compatible?.samplingParams
+ ? { samplingParams: structuredClone(compatible.samplingParams) }
+ : {}),
+ ...(compatible?.thinkingLevelMap
+ ? { thinkingLevelMap: { ...compatible.thinkingLevelMap } }
+ : {}),
};
}
diff --git a/apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx b/apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx
index 7d4ba12cac..a3fd9f42a9 100644
--- a/apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx
+++ b/apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx
@@ -410,7 +410,7 @@ export function ModelAdvancedDrawer({
{primaryModel.name}
</Dialog.Title>
<p className="mt-0.5 truncate text-12 text-[var(--text-tertiary)]">
- {provider.name}
+ {provider.id === 'xd' ? t('settings.providers.xd.title') : provider.name}
</p>
</div>
<Dialog.Close
@@ -436,17 +436,9 @@ export function ModelAdvancedDrawer({
<span className="text-[var(--text-tertiary)]">
{t('settings.providers.models.advanced.protocol.reference')}
</span>
- <Tip
- contentClassName="z-[10002]"
- text={t('settings.providers.models.advanced.protocol.referenceHint')}
- >
- <button
- type="button"
- className="text-[var(--text-secondary)] underline decoration-dotted underline-offset-4"
- >
- {protocolLabel(protocols.reference)}
- </button>
- </Tip>
+ <span className="text-[var(--text-secondary)]">
+ {protocolLabel(protocols.reference)}
+ </span>
</div>
{provider.agents.map((agent) => {
const model = row.byAgent[agent];
@@ -508,28 +500,16 @@ export function ModelAdvancedDrawer({
)}
</div>
{protocol && (
- <Tip
- contentClassName="z-[10002]"
- text={t('settings.providers.models.advanced.protocol.routeHint', {
- harness: protocolLabel(protocol.harness),
- outbound: protocolLabel(protocol.outbound),
- reference: protocolLabel(protocols.reference),
- })}
+ <p
+ id={protocolId}
+ className="mt-0.5 text-11 text-[var(--text-tertiary)]"
>
- <button
- type="button"
- id={protocolId}
- className="mt-0.5 block text-left text-11 text-[var(--text-tertiary)]"
- >
- {protocol.localConversion
- ? `${protocolLabel(protocol.harness)} → ${protocolLabel(protocol.outbound)}`
- : protocolLabel(protocol.outbound)}
- {' · '}
- {t(
- `settings.providers.models.advanced.protocol.${protocol.mode}`,
- )}
- </button>
- </Tip>
+ {protocolLabel(protocol.outbound)}
+ {' · '}
+ {t(
+ `settings.providers.models.advanced.protocol.${protocol.mode}`,
+ )}
+ </p>
)}
</div>
<span
diff --git a/apps/desktop/src/renderer/components/settings/__tests__/ModelAdvancedDrawer.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/ModelAdvancedDrawer.test.tsx
index 098cd283e6..5adf3369bc 100644
--- a/apps/desktop/src/renderer/components/settings/__tests__/ModelAdvancedDrawer.test.tsx
+++ b/apps/desktop/src/renderer/components/settings/__tests__/ModelAdvancedDrawer.test.tsx
@@ -133,7 +133,12 @@ describe('model advanced editor', () => {
});
it('labels both Google compatibility routes and gives Pi the recommendation', () => {
- const primary = { ...model, id: 'google/gemini-future', name: 'Gemini' };
+ const primary = {
+ ...model,
+ id: 'google/gemini-future',
+ name: 'Gemini',
+ nativeApi: 'google-generative-ai' as const,
+ };
const byAgent = {
'claude-code': primary,
codex: primary,
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index df021e5aa3..198fd5a25f 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -1802,7 +1802,7 @@
"contextLimitOverWindow": "Above the provider’s declared window; requests may fail.",
"restoreDefault": "Restore default",
"engines": "Engine support",
- "enginesHint": "Whether this model appears in the model picker under each engine. Turning it off hides it only for that engine.",
+ "enginesHint": "Compatibility mode converts requests. It is off by default and can be enabled when needed.",
"engineUnsupported": "Not supported",
"engineNoFast": "No Fast",
"engineDefaultEffort": "default {{effort}}",
@@ -1839,11 +1839,9 @@
},
"effortMixed": "Effort differs by engine. A selection applies to engines that support that level.",
"protocol": {
- "reference": "Model default protocol",
- "referenceHint": "From this source’s per-model API catalog, using Pi’s protocol configuration as the reference. Missing declarations stay unknown. This is not a list of every native API the manufacturer offers.",
- "routeHint": "Harness request: {{harness}}; Cindy outbound: {{outbound}}; model catalog: {{reference}}. An arrow means local conversion in Cindy; an outbound/catalog mismatch means provider compatibility access. This shows current configuration, not a network trace of an existing task.",
+ "reference": "Native API",
"compatibility": "Compatibility mode",
- "matching": "Same protocol",
+ "matching": "Native support",
"unknown": "Protocol unconfirmed"
}
},
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 2dbe970393..e9c01846a2 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -1801,7 +1801,7 @@
"contextLimitOverWindow": "プロバイダーが宣言した上限を超えています。リクエストが失敗する可能性があります。",
"restoreDefault": "既定に戻す",
"engines": "エンジン対応",
- "enginesHint": "各エンジンでこのモデルをモデル選択に表示するかどうか。オフにしてもそのエンジンでのみ非表示になります。",
+ "enginesHint": "互換モードはリクエストを変換します。初期状態ではオフですが、必要に応じて有効にできます。",
"engineUnsupported": "非対応",
"engineNoFast": "Fast なし",
"engineDefaultEffort": "既定 {{effort}}",
@@ -1838,11 +1838,9 @@
},
"effortMixed": "推論強度はエンジンごとに異なります。選択した強度に対応するエンジンに適用します。",
"protocol": {
- "reference": "モデルの既定プロトコル",
- "referenceHint": "現在のプロバイダーのモデル別 API カタログを参照し、Pi のプロトコル設定を比較基準にします。未宣言の場合は推測しません。メーカーが提供するすべてのネイティブ API の一覧ではありません。",
- "routeHint": "エンジンの要求:{{harness}}、Cindy の送信:{{outbound}}、モデルカタログ:{{reference}}。矢印は Cindy 内の変換を示し、送信とカタログの不一致はプロバイダーの互換接続を示します。現在の設定であり、既存タスクの通信記録ではありません。",
+ "reference": "ネイティブAPI",
"compatibility": "互換モード",
- "matching": "同じプロトコル",
+ "matching": "ネイティブ対応",
"unknown": "プロトコル未確認"
}
},
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 5b05946bc3..caa98fb727 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -1801,7 +1801,7 @@
"contextLimitOverWindow": "공급업체가 명시한 한도를 초과하여 요청이 실패할 수 있습니다.",
"restoreDefault": "기본값 복원",
"engines": "엔진 지원",
- "enginesHint": "각 엔진에서 이 모델을 모델 선택기에 표시할지 여부입니다. 끄면 해당 엔진에서만 숨겨집니다.",
+ "enginesHint": "호환 모드는 요청을 변환합니다. 기본적으로 꺼져 있으며 필요할 때 켤 수 있습니다.",
"engineUnsupported": "지원 안 함",
"engineNoFast": "Fast 없음",
"engineDefaultEffort": "기본 {{effort}}",
@@ -1838,11 +1838,9 @@
},
"effortMixed": "엔진마다 추론 강도가 다릅니다. 선택한 단계를 지원하는 엔진에 적용합니다.",
"protocol": {
- "reference": "모델 기본 프로토콜",
- "referenceHint": "현재 제공자의 모델별 API 카탈로그에서 Pi 프로토콜 설정을 비교 기준으로 사용합니다. 선언이 없으면 추측하지 않습니다. 제조사가 제공하는 모든 네이티브 API 목록은 아닙니다.",
- "routeHint": "엔진 요청: {{harness}}; Cindy 송신: {{outbound}}; 모델 카탈로그: {{reference}}. 화살표는 Cindy 내부 변환을, 송신과 카탈로그의 차이는 제공자 호환 연결을 나타냅니다. 현재 설정이며 기존 작업의 네트워크 기록이 아닙니다.",
+ "reference": "기본 API",
"compatibility": "호환 모드",
- "matching": "동일 프로토콜",
+ "matching": "기본 지원",
"unknown": "프로토콜 미확인"
}
},
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index ea5319b360..6a80c8bd52 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -1801,7 +1801,7 @@
"contextLimitOverWindow": "已超过上游声明的长度,可能导致请求失败。",
"restoreDefault": "恢复默认",
"engines": "引擎支持",
- "enginesHint": "该模型在各引擎下是否出现在模型选择器中。关闭后仅在这个引擎里隐藏,其他引擎不受影响。",
+ "enginesHint": "兼容模式需要转换请求,默认关闭,可按需开启。",
"engineUnsupported": "不支持",
"engineNoFast": "无 Fast",
"engineDefaultEffort": "默认 {{effort}}",
@@ -1838,11 +1838,9 @@
},
"effortMixed": "各引擎的档位不同;选择后应用于支持该档位的引擎。",
"protocol": {
- "reference": "模型默认协议",
- "referenceHint": "来自当前来源的逐模型 API 目录,以 Pi 的协议配置为对照;未声明时不猜测。这不是厂商全部原生接口的清单。",
- "routeHint": "引擎请求:{{harness}};Cindy 出站:{{outbound}};模型目录:{{reference}}。箭头表示 Cindy 本地转换;出站与目录不同表示供应商兼容接入。这里展示当前配置,不是已有任务的网络抓包。",
+ "reference": "原生协议",
"compatibility": "兼容模式",
- "matching": "同协议",
+ "matching": "原生支持",
"unknown": "协议待确认"
}
},
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 7bd93525ac..1cf6b52a58 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -1801,7 +1801,7 @@
"contextLimitOverWindow": "已超過上游宣告的長度,可能導致請求失敗。",
"restoreDefault": "恢復預設",
"engines": "引擎支援",
- "enginesHint": "此模型在各引擎下是否出現在模型選擇器中。關閉後僅在這個引擎裡隱藏,其他引擎不受影響。",
+ "enginesHint": "相容模式需要轉換請求,預設關閉,可依需要開啟。",
"engineUnsupported": "不支援",
"engineNoFast": "無 Fast",
"engineDefaultEffort": "預設 {{effort}}",
@@ -1838,11 +1838,9 @@
},
"effortMixed": "各引擎的檔位不同;選擇後套用至支援該檔位的引擎。",
"protocol": {
- "reference": "模型預設協定",
- "referenceHint": "來自目前來源的逐模型 API 目錄,以 Pi 的協定設定為對照;未宣告時不猜測。這不是廠商全部原生介面的清單。",
- "routeHint": "引擎請求:{{harness}};Cindy 送出:{{outbound}};模型目錄:{{reference}}。箭頭表示 Cindy 本機轉換;送出與目錄不同表示供應商相容接入。這裡顯示目前設定,並非既有任務的網路擷取。",
+ "reference": "原生協定",
"compatibility": "相容模式",
- "matching": "相同協定",
+ "matching": "原生支援",
"unknown": "協定待確認"
}
},
diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.md
index 5df4406937..0316a1125c 100644
--- a/docs/dev-rules/protocol-compatibility.md
+++ b/docs/dev-rules/protocol-compatibility.md
@@ -94,3 +94,13 @@
协议改动按 [`desktop-development.md`](desktop-development.md) 跑相关测试,并与服务端确认
兼容。
+
+
+## Model Registry V3:权威协议与旧端下发
+
+- 权威协议位于 `model-registry.json` 的逐模型 `nativeApi`,与窗口、参考价和输出上限同目录维护。`nativeApiRules` 仅按指定 providerId + modelIdPrefix 覆盖未来家族成员;精确声明优先,显式 null 表示待核实,退役项禁止继承家族规则。跨厂商不根据同名猜测。
+- 新客户端请求 `/api/model-catalog/catalog?registrySchemaVersion=3`。V1/V2 继续可读;旧 Server 忽略查询参数时,新客户端用本地 V3 协议数据兜底。已接受 V3 后,其缺席/撤销含义保持,不从 bundled 补回协议规则。完整目录的 revision、LKG、冲突拒绝仍用既有 updatedAt 策略。
+- Server 支持 V3 后,仅给明确请求 V3 的客户端返回 nativeApi/nativeApiRules;无参数/V1/V2 请求必须返回旧版本并去掉新字段,ETag 按实际响应格式隔离。不得直接把 V3 制品目录原样发送给旧客户端。
+- UI 的 CatalogModel.nativeApi 是主进程按实际 provider/model 投影的结果。Pi 的 piApi 是执行配置,不能反过来当作模型原生协议。界面只展示简短的协议名、原生支持/兼容模式,不展示目录实现与抓包说明。
+- 默认开关按原生协议与 Harness/出站协议比较:兼容路径默认关闭;已有用户显式偏好优先。逐引擎服务端显式 defaultEnabled 保留策展覆盖能力。Google 原生模型推荐 Pi,Messages 推荐 Claude Code,Responses 推荐 Codex,Chat Completions 推荐 Pi;推荐必须在可用候选内。
+- 此客户端改动不代表 Server 已部署 V3。发布目录前须验证旧客户端降级、新客户端 V3、更新/撤销/冲突与相应 ETag 四项;不能只修改 bundled 数据宣布线上生效。
diff --git a/i18n/GLOSSARY.md b/i18n/GLOSSARY.md
index c07f71d3f9..dcf462607c 100644
--- a/i18n/GLOSSARY.md
+++ b/i18n/GLOSSARY.md
@@ -283,6 +283,10 @@ issue #882:模型管理/新对话选择器的分类标签,对应 Gateway mod
用户确认并公开提交 Issue 时展示本轮在 Cindy 中冻结的模型标识。五语暂统一保留技术名称 Model ID,避免与可翻译的模型显示名混淆。
+### Native API
+
+模型目录维护的权威协议;独立于各 Harness 的实际接入配置。设置面板用于简短对比原生支持与兼容模式。
+
### Not signed in
跳过登录后应用内的账号状态名(侧边栏账号胶囊、设置页资料卡、语音服务提示,以及 main 侧不走 locale 的 model-visible 文案——已知 mcp-integrations/ghost.ts 的 GHOST_NOT_FOUND tool result,它会被模型读到并可能回显进对话,#907 review 补上)。**约束范围不限于 locale JSON**:guard 只扫 locale 文件,这类硬编码文案要人工找(见 engineering-conventions §5.1「Slack / IM 侧的文案不在任何 locale 文件里」同类问题)。2026-07-29 产品口径:面向用户只说「未登录」,不再叫「本地模式」——后者听起来像另一种服务端连接方式,实际只是没有登录 Cindy 账号。「本地」仅用于描述数据落在本机(如资料卡副文案「数据仅保存在本机」),不作为状态名。代码内部标识(AuthState mode='local'、authEnterLocal IPC、data owner)不受本条约束,仍用 local。en 侧统一走 not signed in 一种说法(含 settings.userProfile.local 的 exit / exitFailed 两条当前无引用的文案:the not-signed-in state),不与 unauthenticated 混用——PR #907 review 指出过同一状态两种英文说法会让日后启用这些文案时 UI 自相矛盾。status 仍为 proposed:Not signed in 作为状态名尚未与设计侧正式过一遍。
diff --git a/i18n/glossary.json b/i18n/glossary.json
index c1efd4df74..dee5bf839e 100644
--- a/i18n/glossary.json
+++ b/i18n/glossary.json
@@ -1854,6 +1854,18 @@
"ko": "Chat Completions"
},
"note": "模型协议对比中的 OpenAI API 官方名称。保留英文以区别普通消息或回答。"
+ },
+ {
+ "id": "model-native-api",
+ "status": "proposed",
+ "en": "Native API",
+ "translations": {
+ "zh-CN": "原生协议",
+ "zh-TW": "原生協定",
+ "ja": "ネイティブAPI",
+ "ko": "기본 API"
+ },
+ "note": "模型目录维护的权威协议;独立于各 Harness 的实际接入配置。设置面板用于简短对比原生支持与兼容模式。"
}
]
}
diff --git a/packages/model-providers/catalog/model-registry.json b/packages/model-providers/catalog/model-registry.json
index 97251e3951..094f3574b4 100644
--- a/packages/model-providers/catalog/model-registry.json
+++ b/packages/model-providers/catalog/model-registry.json
@@ -1,6 +1,6 @@
{
- "schemaVersion": 1,
- "updatedAt": "2026-08-17T00:00:00.000Z",
+ "schemaVersion": 3,
+ "updatedAt": "2026-09-05T05:29:50.177Z",
"models": [
{
"id": "openai/gpt-5.6-sol",
@@ -401,7 +401,8 @@
"modelId": "claude-fable-5",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "anthropic-messages"
},
{
"id": "anthropic/claude-mythos-5",
@@ -487,7 +488,8 @@
"modelId": "claude-opus-5",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "anthropic-messages"
},
{
"id": "anthropic/claude-opus-4-8",
@@ -541,7 +543,8 @@
"modelId": "claude-opus-4-8",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "anthropic-messages"
},
{
"id": "anthropic/claude-opus-4-7",
@@ -584,7 +587,8 @@
"modelId": "claude-opus-4-7",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "anthropic-messages"
},
{
"id": "anthropic/claude-opus-4-6",
@@ -627,7 +631,8 @@
"modelId": "claude-opus-4-6",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "anthropic-messages"
},
{
"id": "anthropic/claude-opus-4-5",
@@ -670,7 +675,8 @@
"modelId": "claude-opus-4-5",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "anthropic-messages"
},
{
"id": "anthropic/claude-sonnet-5",
@@ -728,7 +734,8 @@
"modelId": "claude-sonnet-5",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "anthropic-messages"
},
{
"id": "anthropic/claude-sonnet-4-6",
@@ -771,7 +778,8 @@
"modelId": "claude-sonnet-4-6",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "anthropic-messages"
},
{
"id": "anthropic/claude-sonnet-4-5",
@@ -813,7 +821,8 @@
"modelId": "claude-sonnet-4-5",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "anthropic-messages"
},
{
"id": "anthropic/claude-haiku-4-5",
@@ -855,7 +864,8 @@
"modelId": "claude-haiku-4-5",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "anthropic-messages"
},
{
"id": "xai/grok-4.6",
@@ -1309,7 +1319,8 @@
"modelId": "codex/gpt-5.6-sol",
"agents": ["claude-code", "codex"]
}
- ]
+ ],
+ "nativeApi": "openai-responses"
},
{
"id": "xd/codex-gpt-5.6-terra",
@@ -1335,7 +1346,8 @@
"modelId": "codex/gpt-5.6-terra",
"agents": ["claude-code", "codex"]
}
- ]
+ ],
+ "nativeApi": "openai-responses"
},
{
"id": "xd/codex-gpt-5.5",
@@ -1359,7 +1371,8 @@
"modelId": "codex/gpt-5.5",
"agents": ["claude-code", "codex"]
}
- ]
+ ],
+ "nativeApi": "openai-responses"
},
{
"id": "xd/codex-gpt-5.4",
@@ -1383,7 +1396,8 @@
"modelId": "codex/gpt-5.4",
"agents": ["claude-code", "codex"]
}
- ]
+ ],
+ "nativeApi": "openai-responses"
},
{
"id": "google/gemini-3.5-flash",
@@ -1401,7 +1415,8 @@
"modelId": "gemini-3.5-flash",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "google-generative-ai"
},
{
"id": "google/gemini-3.1-pro-preview",
@@ -1420,7 +1435,8 @@
"modelId": "gemini-3.1-pro-preview",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "google-generative-ai"
},
{
"id": "google/gemini-3-flash-preview",
@@ -1439,7 +1455,8 @@
"modelId": "gemini-3-flash-preview",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "google-generative-ai"
},
{
"id": "bytedance-seed/seed-2.1-pro",
@@ -1494,7 +1511,8 @@
"modelId": "qwen/qwen3.7-max",
"agents": ["claude-code", "codex"]
}
- ]
+ ],
+ "nativeApi": "openai-completions"
},
{
"id": "moonshotai/kimi-k2.6",
@@ -1512,7 +1530,8 @@
"modelId": "moonshotai/kimi-k2.6",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "openai-completions"
},
{
"id": "z-ai/glm-5.1",
@@ -1530,7 +1549,8 @@
"modelId": "z-ai/glm-5.1",
"agents": ["claude-code"]
}
- ]
+ ],
+ "nativeApi": "openai-completions"
},
{
"id": "z-ai/glm-5.2",
@@ -1554,7 +1574,8 @@
"modelId": "z-ai/glm-5.2",
"agents": ["claude-code", "codex"]
}
- ]
+ ],
+ "nativeApi": "openai-completions"
},
{
"id": "deepseek/deepseek-v4-pro",
@@ -1592,7 +1613,8 @@
}
]
}
- ]
+ ],
+ "nativeApi": "openai-completions"
},
{
"id": "deepseek/deepseek-v4-flash",
@@ -1630,7 +1652,8 @@
}
]
}
- ]
+ ],
+ "nativeApi": "openai-completions"
},
{
"id": "openai/gpt-5.4-nano",
@@ -1670,7 +1693,8 @@
"modelId": "gpt-5.4-nano",
"agents": ["claude-code", "codex"]
}
- ]
+ ],
+ "nativeApi": "openai-responses"
},
{
"id": "xd/codex-gpt-5.4-mini",
@@ -1684,7 +1708,8 @@
"modelId": "codex/gpt-5.4-mini",
"agents": ["claude-code", "codex"]
}
- ]
+ ],
+ "nativeApi": "openai-responses"
},
{
"id": "moonshotai/kimi-k3",
@@ -1700,8 +1725,24 @@
"providerId": "xd",
"modelId": "moonshotai/kimi-k3",
"agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "xd",
+ "modelId": "moonshot/kimi-k3",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "moonshot-kimi-cn",
+ "modelId": "kimi-k3",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "moonshot-kimi-global",
+ "modelId": "kimi-k3",
+ "agents": ["claude-code", "codex"]
}
- ]
+ ],
+ "nativeApi": "openai-completions"
},
{
"id": "qwen/qwen3.6-plus",
@@ -1729,7 +1770,757 @@
"modelId": "codex/gpt-5.5:auto",
"agents": ["claude-code", "codex"]
}
+ ],
+ "nativeApi": "openai-responses"
+ },
+ {
+ "id": "openai/gpt-5.4-pro",
+ "name": "GPT-5.4 Pro",
+ "status": "active",
+ "group": "gpt",
+ "description": "OpenAI GPT-5.4 Pro for demanding reasoning tasks",
+ "contextWindow": 1050000,
+ "maxOutputTokens": 128000,
+ "sortOrder": 23,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "openai",
+ "modelId": "gpt-5.4-pro",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "openai/gpt-5.5-pro",
+ "name": "GPT-5.5 Pro",
+ "status": "active",
+ "group": "gpt",
+ "description": "OpenAI GPT-5.5 Pro for precise, high-quality reasoning",
+ "contextWindow": 1050000,
+ "maxOutputTokens": 128000,
+ "sortOrder": 24,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "openai",
+ "modelId": "gpt-5.5-pro",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "openai/gpt-5.6-cyber",
+ "name": "GPT-5.6 Cyber",
+ "status": "active",
+ "group": "gpt",
+ "description": "OpenAI cyber security reasoning model; access requires approval",
+ "contextWindow": 400000,
+ "maxOutputTokens": 128000,
+ "sortOrder": 25,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "openai",
+ "modelId": "gpt-5.6-cyber",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "openai/gpt-6-astra",
+ "name": "GPT-6 Astra",
+ "status": "active",
+ "group": "gpt",
+ "description": "OpenAI GPT-6 Astra for complex reasoning, coding, computer use, research, and document creation",
+ "contextWindow": 272000,
+ "maxOutputTokens": 128000,
+ "efforts": ["low", "medium", "high", "xhigh", "max"],
+ "defaultEffort": "medium",
+ "perAgent": {
+ "codex": {
+ "efforts": ["low", "medium", "high", "xhigh", "max", "ultra"],
+ "defaultEffort": "medium"
+ }
+ },
+ "routes": [
+ {
+ "providerId": "openai",
+ "modelId": "gpt-6-astra",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "anthropic/claude-fable-5-1",
+ "name": "Fable 5.1",
+ "status": "active",
+ "group": "anthropic",
+ "description": "Claude Fable 5.1 for long-running agentic coding and research",
+ "contextWindow": 1000000,
+ "maxOutputTokens": 128000,
+ "efforts": ["low", "medium", "high", "xhigh", "max"],
+ "defaultEffort": "high",
+ "routes": [
+ {
+ "providerId": "anthropic",
+ "modelId": "claude-fable-5-1",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "xd/codex-gpt-5.6-luna",
+ "name": "GPT-5.6-Luna",
+ "group": "gpt-budget",
+ "sortOrder": 7,
+ "routes": [
+ {
+ "providerId": "xd",
+ "modelId": "codex/gpt-5.6-luna",
+ "agents": ["claude-code", "codex"]
+ }
+ ],
+ "nativeApi": "openai-responses"
+ },
+ {
+ "id": "google/gemini-3.7-flash",
+ "name": "Gemini 3.7 Flash",
+ "status": "active",
+ "group": "google",
+ "description": "Google Gemini 3.7 Flash — agentic workflows and multimodal reasoning",
+ "contextWindow": 1000000,
+ "maxOutputTokens": 65536,
+ "efforts": ["low", "medium", "high"],
+ "defaultEffort": "medium",
+ "sortOrder": 28,
+ "supportsFastMode": false,
+ "routes": [
+ {
+ "providerId": "xd",
+ "modelId": "gemini-3.7-flash",
+ "agents": ["claude-code"],
+ "referencePrices": [
+ {
+ "currency": "USD",
+ "variant": "standard",
+ "inputPerMtok": 0.75,
+ "outputPerMtok": 3.75,
+ "cacheReadPerMtok": 0.075,
+ "cacheWrite1hPerMtok": 0.5,
+ "effectiveFrom": "2026-08-13",
+ "effectiveUntil": "2027-01-01",
+ "source": {
+ "kind": "provider-official",
+ "url": "https://ai.google.dev/gemini-api/docs/pricing",
+ "verifiedAt": "2026-08-13"
+ }
+ },
+ {
+ "currency": "USD",
+ "variant": "standard",
+ "inputPerMtok": 1.5,
+ "outputPerMtok": 7.5,
+ "cacheReadPerMtok": 0.15,
+ "cacheWrite1hPerMtok": 1,
+ "effectiveFrom": "2027-01-01",
+ "source": {
+ "kind": "provider-official",
+ "url": "https://ai.google.dev/gemini-api/docs/pricing",
+ "verifiedAt": "2026-08-13"
+ }
+ }
+ ]
+ }
+ ],
+ "nativeApi": "google-generative-ai"
+ },
+ {
+ "id": "google/gemini-3.6-flash",
+ "name": "Gemini 3.6 Flash",
+ "status": "active",
+ "group": "google",
+ "description": "Google Gemini 3.6 Flash — frontier intelligence optimized for speed and cost",
+ "contextWindow": 1000000,
+ "maxOutputTokens": 65536,
+ "efforts": ["minimal", "low", "medium", "high"],
+ "defaultEffort": "medium",
+ "sortOrder": 29,
+ "supportsFastMode": false,
+ "routes": [
+ {
+ "providerId": "xd",
+ "modelId": "gemini-3.6-flash",
+ "agents": ["claude-code"],
+ "referencePrices": [
+ {
+ "currency": "USD",
+ "variant": "standard",
+ "inputPerMtok": 0.75,
+ "outputPerMtok": 3.75,
+ "cacheReadPerMtok": 0.075,
+ "cacheWrite1hPerMtok": 0.5,
+ "effectiveFrom": "2026-07-21",
+ "effectiveUntil": "2027-01-01",
+ "source": {
+ "kind": "provider-official",
+ "url": "https://ai.google.dev/gemini-api/docs/pricing",
+ "verifiedAt": "2026-08-13"
+ }
+ },
+ {
+ "currency": "USD",
+ "variant": "standard",
+ "inputPerMtok": 1.5,
+ "outputPerMtok": 7.5,
+ "cacheReadPerMtok": 0.15,
+ "cacheWrite1hPerMtok": 1,
+ "effectiveFrom": "2027-01-01",
+ "source": {
+ "kind": "provider-official",
+ "url": "https://ai.google.dev/gemini-api/docs/pricing",
+ "verifiedAt": "2026-08-13"
+ }
+ }
+ ]
+ }
+ ],
+ "nativeApi": "google-generative-ai"
+ },
+ {
+ "id": "google/gemini-3.5-flash-lite",
+ "name": "Gemini 3.5 Flash-Lite",
+ "status": "active",
+ "group": "google",
+ "description": "Google Gemini 3.5 Flash-Lite — cost-efficient multimodal model for high-volume workloads",
+ "contextWindow": 1000000,
+ "maxOutputTokens": 65536,
+ "efforts": ["minimal", "low", "medium", "high"],
+ "defaultEffort": "minimal",
+ "sortOrder": 33,
+ "supportsFastMode": false,
+ "routes": [
+ {
+ "providerId": "xd",
+ "modelId": "gemini-3.5-flash-lite",
+ "agents": ["claude-code"]
+ }
+ ],
+ "nativeApi": "google-generative-ai"
+ },
+ {
+ "id": "google/gemini-3.1-flash-lite",
+ "name": "Gemini 3.1 Flash-Lite",
+ "status": "active",
+ "group": "google",
+ "description": "Google Gemini 3.1 Flash-Lite — efficient multimodal model for large-scale tasks",
+ "contextWindow": 1000000,
+ "maxOutputTokens": 65536,
+ "sortOrder": 34,
+ "supportsFastMode": false,
+ "routes": [
+ {
+ "providerId": "xd",
+ "modelId": "gemini-3.1-flash-lite",
+ "agents": ["claude-code"]
+ }
+ ],
+ "nativeApi": "google-generative-ai"
+ },
+ {
+ "id": "qwen/qwen3.8-max",
+ "name": "Qwen 3.8 Max",
+ "group": "china",
+ "contextWindow": 983616,
+ "maxOutputTokens": 131072,
+ "efforts": ["low", "high", "xhigh"],
+ "defaultEffort": "xhigh",
+ "supportsFastMode": false,
+ "routes": [
+ {
+ "providerId": "xd",
+ "modelId": "qwen/qwen3.8-max",
+ "agents": ["claude-code", "codex"]
+ }
+ ],
+ "nativeApi": "openai-completions"
+ },
+ {
+ "id": "moonshotai/kimi-k2.7-code",
+ "name": "Kimi K2.7 Code",
+ "status": "active",
+ "group": "china",
+ "description": "Moonshot Kimi K2.7 Code agentic coding model",
+ "contextWindow": 262144,
+ "efforts": [],
+ "sortOrder": 107,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "moonshot-kimi-cn",
+ "modelId": "kimi-k2.7-code",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "moonshot-kimi-global",
+ "modelId": "kimi-k2.7-code",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "moonshotai/kimi-k2.7-code-highspeed",
+ "name": "Kimi K2.7 Code Highspeed",
+ "status": "active",
+ "group": "china",
+ "description": "Moonshot Kimi K2.7 Code high-speed API variant",
+ "contextWindow": 262144,
+ "efforts": [],
+ "sortOrder": 108,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "moonshot-kimi-cn",
+ "modelId": "kimi-k2.7-code-highspeed",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "moonshot-kimi-global",
+ "modelId": "kimi-k2.7-code-highspeed",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "z-ai/glm-5.3",
+ "name": "GLM-5.3",
+ "status": "active",
+ "group": "china",
+ "description": "Zhipu GLM-5.3 agentic coding model; 1M context",
+ "contextWindow": 1000000,
+ "maxOutputTokens": 131072,
+ "efforts": ["low", "high", "max"],
+ "defaultEffort": "max",
+ "sortOrder": 44,
+ "supportsFastMode": false,
+ "routes": [
+ {
+ "providerId": "xd",
+ "modelId": "z-ai/glm-5.3",
+ "agents": ["claude-code", "codex"]
+ }
+ ],
+ "nativeApi": "openai-completions"
+ },
+ {
+ "id": "z-ai/glm-5.3-flash",
+ "name": "GLM-5.3-Flash",
+ "status": "active",
+ "group": "china",
+ "description": "Zhipu GLM-5.3-Flash native multimodal coding model; 1M context",
+ "contextWindow": 1000000,
+ "maxOutputTokens": 131072,
+ "routes": [
+ {
+ "providerId": "zhipu-glm-cn",
+ "modelId": "glm-5.3-flash",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "zhipu-glm-global",
+ "modelId": "glm-5.3-flash",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "xd/z-ai-glm-5.3-flash",
+ "name": "GLM-5.3-Flash",
+ "status": "active",
+ "group": "china",
+ "description": "Zhipu GLM-5.3-Flash native multimodal coding model; 1M context",
+ "contextWindow": 1000000,
+ "maxOutputTokens": 131072,
+ "routes": [
+ {
+ "providerId": "xd",
+ "modelId": "z-ai/glm-5.3-flash",
+ "agents": ["claude-code", "codex"]
+ }
+ ],
+ "nativeApi": "openai-completions"
+ },
+ {
+ "id": "minimax/minimax-m3",
+ "name": "MiniMax M3",
+ "status": "active",
+ "group": "china",
+ "contextWindow": 1000000,
+ "sortOrder": 114,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "minimax-cn",
+ "modelId": "MiniMax-M3",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "minimax-global",
+ "modelId": "MiniMax-M3",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "minimax/minimax-m2.7",
+ "name": "MiniMax M2.7",
+ "status": "active",
+ "group": "china",
+ "contextWindow": 204800,
+ "sortOrder": 111,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "minimax-cn",
+ "modelId": "MiniMax-M2.7",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "minimax-global",
+ "modelId": "MiniMax-M2.7",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "minimax/minimax-m2.7-highspeed",
+ "name": "MiniMax M2.7 Highspeed",
+ "status": "active",
+ "group": "china",
+ "contextWindow": 204800,
+ "sortOrder": 112,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "minimax-cn",
+ "modelId": "MiniMax-M2.7-highspeed",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "minimax-global",
+ "modelId": "MiniMax-M2.7-highspeed",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "minimax/minimax-m2.5",
+ "name": "MiniMax M2.5",
+ "status": "active",
+ "group": "china",
+ "contextWindow": 204800,
+ "sortOrder": 116,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "minimax-cn",
+ "modelId": "MiniMax-M2.5",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "minimax-global",
+ "modelId": "MiniMax-M2.5",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "minimax/minimax-m2.5-highspeed",
+ "name": "MiniMax M2.5 Highspeed",
+ "status": "active",
+ "group": "china",
+ "contextWindow": 204800,
+ "sortOrder": 117,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "minimax-cn",
+ "modelId": "MiniMax-M2.5-highspeed",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "minimax-global",
+ "modelId": "MiniMax-M2.5-highspeed",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "minimax/minimax-m2.1",
+ "name": "MiniMax M2.1",
+ "status": "active",
+ "group": "china",
+ "contextWindow": 204800,
+ "sortOrder": 118,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "minimax-cn",
+ "modelId": "MiniMax-M2.1",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "minimax-global",
+ "modelId": "MiniMax-M2.1",
+ "agents": ["claude-code", "codex"]
+ }
]
+ },
+ {
+ "id": "minimax/minimax-m2.1-highspeed",
+ "name": "MiniMax M2.1 Highspeed",
+ "status": "active",
+ "group": "china",
+ "contextWindow": 204800,
+ "sortOrder": 119,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "minimax-cn",
+ "modelId": "MiniMax-M2.1-highspeed",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "minimax-global",
+ "modelId": "MiniMax-M2.1-highspeed",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "minimax/minimax-m2",
+ "name": "MiniMax M2",
+ "status": "active",
+ "group": "china",
+ "contextWindow": 204800,
+ "sortOrder": 120,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "minimax-cn",
+ "modelId": "MiniMax-M2",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "minimax-global",
+ "modelId": "MiniMax-M2",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "qwen/qwen3.6-plus-api",
+ "name": "Qwen 3.6 Plus API",
+ "status": "active",
+ "group": "china",
+ "contextWindow": 991808,
+ "maxOutputTokens": 65536,
+ "sortOrder": 113,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "aliyun-model-studio-cn",
+ "modelId": "qwen3.6-plus",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "aliyun-model-studio-global",
+ "modelId": "qwen3.6-plus",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "qwen/qwen3.7-flash",
+ "name": "Qwen 3.7 Flash",
+ "status": "active",
+ "group": "china",
+ "description": "Alibaba Qwen 3.7 Flash text model with provider-managed thinking",
+ "contextWindow": 991808,
+ "maxOutputTokens": 65536,
+ "efforts": [],
+ "sortOrder": 115,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "aliyun-model-studio-cn",
+ "modelId": "qwen3.7-flash",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "aliyun-model-studio-global",
+ "modelId": "qwen3.7-flash",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "qwen/qwen3.8-flash",
+ "name": "Qwen 3.8 Flash",
+ "status": "active",
+ "group": "china",
+ "description": "Alibaba Qwen 3.8 Flash multimodal model with provider-managed thinking",
+ "contextWindow": 991808,
+ "maxOutputTokens": 131072,
+ "efforts": [],
+ "sortOrder": 121,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "aliyun-model-studio-cn",
+ "modelId": "qwen3.8-flash",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "aliyun-model-studio-global",
+ "modelId": "qwen3.8-flash",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "qwen/qwen3.7-plus",
+ "name": "Qwen 3.7 Plus",
+ "status": "active",
+ "group": "china",
+ "description": "Alibaba Qwen 3.7 Plus text model with provider-managed thinking",
+ "contextWindow": 991808,
+ "maxOutputTokens": 65536,
+ "efforts": [],
+ "sortOrder": 109,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "aliyun-model-studio-cn",
+ "modelId": "qwen3.7-plus",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "aliyun-model-studio-global",
+ "modelId": "qwen3.7-plus",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "qwen/qwen3.6-flash",
+ "name": "Qwen 3.6 Flash",
+ "status": "active",
+ "group": "china",
+ "description": "Alibaba Qwen 3.6 Flash text model with provider-managed thinking",
+ "contextWindow": 991808,
+ "maxOutputTokens": 65536,
+ "efforts": [],
+ "sortOrder": 110,
+ "defaultEnabled": false,
+ "routes": [
+ {
+ "providerId": "aliyun-model-studio-cn",
+ "modelId": "qwen3.6-flash",
+ "agents": ["claude-code", "codex"]
+ },
+ {
+ "providerId": "aliyun-model-studio-global",
+ "modelId": "qwen3.6-flash",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ },
+ {
+ "id": "qwen/qwen3.8-27b",
+ "name": "Qwen3.8 27B",
+ "contextWindow": 991808,
+ "maxOutputTokens": 131072,
+ "efforts": ["low", "medium", "high", "xhigh"],
+ "defaultEffort": "xhigh",
+ "routes": [
+ {
+ "providerId": "xd",
+ "modelId": "qwen/qwen3.8-27b",
+ "agents": ["claude-code", "codex"]
+ }
+ ],
+ "nativeApi": "openai-completions"
+ },
+ {
+ "id": "tencent/hy3",
+ "name": "Hy3",
+ "contextWindow": 262144,
+ "maxOutputTokens": 128000,
+ "efforts": ["low", "medium", "high"],
+ "defaultEffort": "high",
+ "routes": [
+ {
+ "providerId": "xd",
+ "modelId": "tencent/hy3",
+ "agents": ["claude-code", "codex"]
+ }
+ ],
+ "nativeApi": "openai-completions"
+ },
+ {
+ "id": "meta/muse-spark-1.2",
+ "name": "Muse Spark 1.2",
+ "nativeApi": "openai-responses",
+ "routes": [
+ {
+ "providerId": "xd",
+ "modelId": "meta/muse-spark-1.2",
+ "agents": ["claude-code", "codex"]
+ }
+ ]
+ }
+ ],
+ "nativeApiRules": [
+ {
+ "providerId": "xd",
+ "modelIdPrefix": "google/gemini-",
+ "nativeApi": "google-generative-ai"
+ },
+ {
+ "providerId": "xd",
+ "modelIdPrefix": "gemini-",
+ "nativeApi": "google-generative-ai"
+ },
+ {
+ "providerId": "xd",
+ "modelIdPrefix": "claude-",
+ "nativeApi": "anthropic-messages"
+ },
+ {
+ "providerId": "xd",
+ "modelIdPrefix": "anthropic/claude-",
+ "nativeApi": "anthropic-messages"
+ },
+ {
+ "providerId": "xd",
+ "modelIdPrefix": "anthropic-claude/claude-",
+ "nativeApi": "anthropic-messages"
+ },
+ {
+ "providerId": "xd",
+ "modelIdPrefix": "gpt-",
+ "nativeApi": "openai-responses"
+ },
+ {
+ "providerId": "xd",
+ "modelIdPrefix": "codex/gpt-",
+ "nativeApi": "openai-responses"
+ },
+ {
+ "providerId": "xd",
+ "modelIdPrefix": "openai/gpt-",
+ "nativeApi": "openai-responses"
}
]
}
diff --git a/packages/model-providers/src/__tests__/modelAccessValidator.test.ts b/packages/model-providers/src/__tests__/modelAccessValidator.test.ts
index 5cb6cfd71a..877a237079 100644
--- a/packages/model-providers/src/__tests__/modelAccessValidator.test.ts
+++ b/packages/model-providers/src/__tests__/modelAccessValidator.test.ts
@@ -785,7 +785,7 @@ describe('public model registry contract', () => {
});
it('rejects unsupported versions, duplicate canonical ids, and duplicate routes', () => {
- expectRegistryReject({ ...VALID_REGISTRY, schemaVersion: 3 }, 'modelRegistry.schemaVersion');
+ expectRegistryReject({ ...VALID_REGISTRY, schemaVersion: 4 }, 'modelRegistry.schemaVersion');
expectRegistryReject(
{
...VALID_REGISTRY,
diff --git a/packages/model-providers/src/__tests__/modelNativeApi.test.ts b/packages/model-providers/src/__tests__/modelNativeApi.test.ts
new file mode 100644
index 0000000000..a665fc1697
--- /dev/null
+++ b/packages/model-providers/src/__tests__/modelNativeApi.test.ts
@@ -0,0 +1,78 @@
+import { describe, expect, it } from 'vitest';
+import { BUNDLED_CATALOG, type ModelRegistry } from '../index.js';
+import { parseModelRegistry } from '../modelAccessValidator.js';
+import { resolveModelNativeApi } from '../modelRegistry.js';
+
+const registry = (): ModelRegistry => ({
+ schemaVersion: 3,
+ updatedAt: '2026-09-05T00:00:00.000Z',
+ models: [],
+ nativeApiRules: [
+ { providerId: 'xd', modelIdPrefix: 'google/gemini-', nativeApi: 'google-generative-ai' },
+ ],
+});
+
+describe('canonical model APIs in registry v3', () => {
+ it('validates the complete bundled snapshot and keeps legacy versions readable', () => {
+ expect(parseModelRegistry(BUNDLED_CATALOG.modelRegistry).ok).toBe(true);
+ for (const schemaVersion of [1, 2])
+ expect(
+ parseModelRegistry({ schemaVersion, updatedAt: registry().updatedAt, models: [] }).ok,
+ ).toBe(true);
+ expect(parseModelRegistry({ ...registry(), schemaVersion: 2 }).ok).toBe(false);
+ expect(
+ parseModelRegistry({
+ ...registry(),
+ nativeApiRules: [
+ { providerId: 'xd', modelIdPrefix: '', nativeApi: 'google-generative-ai' },
+ ],
+ }).ok,
+ ).toBe(false);
+ expect(
+ parseModelRegistry({
+ ...registry(),
+ nativeApiRules: [...registry().nativeApiRules!, ...registry().nativeApiRules!],
+ }).ok,
+ ).toBe(false);
+ });
+ it('resolves new models by route-scoped rule without inventing other provider identities', () => {
+ expect(resolveModelNativeApi(registry(), 'xd', 'google/gemini-99-pro[1m]')).toBe(
+ 'google-generative-ai',
+ );
+ expect(resolveModelNativeApi(registry(), 'other', 'google/gemini-99-pro')).toBeUndefined();
+ expect(resolveModelNativeApi(registry(), 'xd', 'google/gemini-99/other')).toBeUndefined();
+ });
+ it('honors an exact correction, explicit unknown, and retirement before family defaults', () => {
+ const r = registry();
+ r.models = [
+ {
+ id: 'google/new',
+ name: 'New',
+ nativeApi: 'openai-responses',
+ routes: [{ providerId: 'xd', modelId: 'google/gemini-new', agents: ['codex'] }],
+ },
+ ];
+ expect(parseModelRegistry(r).ok).toBe(true);
+ expect(resolveModelNativeApi(r, 'xd', 'google/gemini-new')).toBe('openai-responses');
+ r.models[0].nativeApi = null;
+ expect(resolveModelNativeApi(r, 'xd', 'google/gemini-new')).toBeNull();
+ delete r.models[0].nativeApi;
+ r.models[0].status = 'retired';
+ expect(resolveModelNativeApi(r, 'xd', 'google/gemini-new')).toBeNull();
+ });
+ it('rejects unrecognized protocol values instead of silently using a compatibility route', () => {
+ const r = registry();
+ expect(
+ parseModelRegistry({
+ ...r,
+ nativeApiRules: [{ ...r.nativeApiRules![0], nativeApi: 'future-api' }],
+ }).ok,
+ ).toBe(false);
+ expect(
+ parseModelRegistry({
+ ...r,
+ models: [{ id: 'm', name: 'M', routes: [], nativeApi: 'future-api' }],
+ }).ok,
+ ).toBe(false);
+ });
+});
diff --git a/packages/model-providers/src/__tests__/modelProtocol.test.ts b/packages/model-providers/src/__tests__/modelProtocol.test.ts
index aa99c4a47e..5130c12f83 100644
--- a/packages/model-providers/src/__tests__/modelProtocol.test.ts
+++ b/packages/model-providers/src/__tests__/modelProtocol.test.ts
@@ -11,10 +11,10 @@ const model: CatalogModel = {
defaultEffort: null,
};
function fixture(api?: PiModelApi) {
- const byAgent = {
+ const byAgent: Record<'claude-code' | 'codex' | 'pi', CatalogModel> = {
'claude-code': { ...model },
codex: { ...model },
- pi: { ...model, ...(api ? { piApi: api } : {}) },
+ pi: { ...model, ...(api ? { piApi: api, nativeApi: api } : {}) },
};
const provider = {
id: 'xd',
@@ -58,14 +58,24 @@ describe('per-model protocol comparison', () => {
it('does not infer a native Google route or recommendation from a Gemini name', () => {
const { provider, byAgent } = fixture('openai-responses');
for (const entry of Object.values(byAgent)) entry.id = 'google/gemini-future';
- expect(pickRecommendedAgent(provider, 'google/gemini-future', provider.agents)).toBe(
- 'claude-code',
- );
+ expect(pickRecommendedAgent(provider, 'google/gemini-future', provider.agents)).toBe('codex');
expect(modelProtocolComparison(provider, byAgent).forAgent('pi')?.outbound).toBe(
'openai-responses',
);
});
+ it('only recommends a native candidate when its effective route also matches', () => {
+ const { provider, byAgent } = fixture('openai-responses');
+ byAgent.codex.route = {
+ baseUrl: 'https://example.invalid',
+ wireProtocol: 'anthropic-messages',
+ };
+ expect(pickRecommendedAgent(provider, model.id, provider.agents)).toBe('pi');
+ byAgent.pi.nativeApi = 'google-generative-ai';
+ expect(modelProtocolComparison(provider, byAgent).forAgent('pi')?.mode).toBe('compatibility');
+ expect(pickRecommendedAgent(provider, model.id, provider.agents)).toBe('claude-code');
+ });
+
it('uses model route overrides for local conversion, ignoring obsolete compatibility annotations', () => {
const { provider, byAgent } = fixture('anthropic-messages');
const codex = {
diff --git a/packages/model-providers/src/__tests__/source-registry.test.ts b/packages/model-providers/src/__tests__/source-registry.test.ts
index bb59ca5b6f..4f44f54717 100644
--- a/packages/model-providers/src/__tests__/source-registry.test.ts
+++ b/packages/model-providers/src/__tests__/source-registry.test.ts
@@ -85,7 +85,7 @@ describe('resolveCatalogUrl', () => {
});
it('builds from baseUrl + public catalog API path', () => {
expect(resolveCatalogUrl({ baseUrl: 'https://model-access.example.com/' })).toBe(
- 'https://model-access.example.com/api/model-catalog/catalog',
+ 'https://model-access.example.com/api/model-catalog/catalog?registrySchemaVersion=3',
);
});
it('builds the migration OSS fallback URL', () => {
@@ -875,7 +875,7 @@ describe('loadCatalog', () => {
);
expect(fetchText).toHaveBeenNthCalledWith(
1,
- 'https://model-access.example.com/api/model-catalog/catalog',
+ 'https://model-access.example.com/api/model-catalog/catalog?registrySchemaVersion=3',
15_000,
);
expect(fetchText).toHaveBeenNthCalledWith(
@@ -931,7 +931,7 @@ describe('loadCatalog', () => {
);
expect(fetchText).toHaveBeenNthCalledWith(
1,
- 'https://model-access.example.com/api/model-catalog/catalog',
+ 'https://model-access.example.com/api/model-catalog/catalog?registrySchemaVersion=3',
15_000,
);
expect(fetchText).toHaveBeenNthCalledWith(
@@ -987,7 +987,7 @@ describe('loadCatalog', () => {
);
expect(fetchText).toHaveBeenNthCalledWith(
1,
- 'https://model-access.example.com/api/model-catalog/catalog',
+ 'https://model-access.example.com/api/model-catalog/catalog?registrySchemaVersion=3',
15_000,
);
expect(fetchText).toHaveBeenNthCalledWith(
@@ -1015,7 +1015,7 @@ describe('loadCatalog', () => {
);
expect(fetchText).toHaveBeenCalledTimes(1);
expect(fetchText).toHaveBeenCalledWith(
- 'https://model-access.example.com/api/model-catalog/catalog',
+ 'https://model-access.example.com/api/model-catalog/catalog?registrySchemaVersion=3',
15_000,
);
expect(cat.version).toBe(BUNDLED_CATALOG.version);
diff --git a/packages/model-providers/src/catalog.ts b/packages/model-providers/src/catalog.ts
index 21364d4189..ff33221f2f 100644
--- a/packages/model-providers/src/catalog.ts
+++ b/packages/model-providers/src/catalog.ts
@@ -147,6 +147,9 @@ function validateModel(
): void {
assert(typeof m.id === 'string' && m.id.length > 0, `model.id missing in provider '${providerId}'`);
assert(typeof m.name === 'string' && m.name.length > 0, `model.name missing for '${m.id}'`);
+ if (m.nativeApi !== undefined && m.nativeApi !== null) {
+ assert(isPiModelApi(m.nativeApi), `model.nativeApi invalid for '${m.id}'`);
+ }
if (m.piApi !== undefined) {
assert(isPiModelApi(m.piApi), `model.piApi invalid for '${m.id}'`);
}
diff --git a/packages/model-providers/src/index.ts b/packages/model-providers/src/index.ts
index b09a6974e3..19b5308ee3 100644
--- a/packages/model-providers/src/index.ts
+++ b/packages/model-providers/src/index.ts
@@ -81,6 +81,7 @@ export {
compareModelRegistryRevisions,
decideModelRegistrySnapshot,
findModelRegistryRoute,
+ resolveModelNativeApi,
resolveModelReferencePrice,
} from './modelRegistry.js';
export { modelRegistryCanonicalJson } from './modelRegistryCanonical.js';
diff --git a/packages/model-providers/src/modelAccessBean.ts b/packages/model-providers/src/modelAccessBean.ts
index 9a644b359a..98baf45321 100644
--- a/packages/model-providers/src/modelAccessBean.ts
+++ b/packages/model-providers/src/modelAccessBean.ts
@@ -51,6 +51,14 @@ export type ModelEffort = (typeof MODEL_ACCESS_EFFORTS)[number];
export const MODEL_REGISTRY_LEGACY_SCHEMA_VERSION = 1 as const;
export const MODEL_REGISTRY_SCHEMA_VERSION = 2 as const;
+export const MODEL_REGISTRY_V3_SCHEMA_VERSION = 3 as const;
+export const MODEL_NATIVE_APIS = [
+ 'anthropic-messages',
+ 'openai-responses',
+ 'openai-completions',
+ 'google-generative-ai',
+] as const;
+export type ModelNativeApi = (typeof MODEL_NATIVE_APIS)[number];
export const MODEL_REGISTRY_STATUSES = ['preview', 'active', 'deprecated', 'retired'] as const;
export type ModelRegistryStatus = (typeof MODEL_REGISTRY_STATUSES)[number];
@@ -117,6 +125,14 @@ export interface ModelRegistryEntryV1 extends ModelRegistryEntryBase {
export interface ModelRegistryEntry extends ModelRegistryEntryBase {
newSessionDefault?: ModelAccessV2Agent[];
+ /** V3: model's canonical API, independent of any harness. Null explicitly means unverified. */
+ nativeApi?: ModelNativeApi | null;
+}
+
+export interface ModelNativeApiRule {
+ providerId: string;
+ modelIdPrefix: string;
+ nativeApi: ModelNativeApi;
}
interface ModelRegistryBase {
@@ -124,8 +140,13 @@ interface ModelRegistryBase {
}
export interface ModelRegistry extends ModelRegistryBase {
- schemaVersion: typeof MODEL_REGISTRY_LEGACY_SCHEMA_VERSION | typeof MODEL_REGISTRY_SCHEMA_VERSION;
+ schemaVersion:
+ | typeof MODEL_REGISTRY_LEGACY_SCHEMA_VERSION
+ | typeof MODEL_REGISTRY_SCHEMA_VERSION
+ | typeof MODEL_REGISTRY_V3_SCHEMA_VERSION;
models: ModelRegistryEntry[];
+ /** V3: route-scoped rules for new members of established model families. */
+ nativeApiRules?: ModelNativeApiRule[];
}
export interface ModelRegistryV1 extends ModelRegistryBase {
diff --git a/packages/model-providers/src/modelAccessValidator.ts b/packages/model-providers/src/modelAccessValidator.ts
index b88e982bc0..c0a5ead4af 100644
--- a/packages/model-providers/src/modelAccessValidator.ts
+++ b/packages/model-providers/src/modelAccessValidator.ts
@@ -12,6 +12,8 @@ import {
MODEL_PRICE_VARIANTS,
MODEL_REGISTRY_LEGACY_SCHEMA_VERSION,
MODEL_REGISTRY_SCHEMA_VERSION,
+ MODEL_REGISTRY_V3_SCHEMA_VERSION,
+ MODEL_NATIVE_APIS,
MODEL_REGISTRY_STATUSES,
type ListModelsResponse,
type ModelAccessParseResult,
@@ -587,11 +589,7 @@ function modelEntryError(
) {
return `${path}.perAgent.pi.wireProtocol must be a non-empty string when present`;
}
- if (
- agent !== 'pi' &&
- isPlainObject(override) &&
- override.wireProtocol !== undefined
- ) {
+ if (agent !== 'pi' && isPlainObject(override) && override.wireProtocol !== undefined) {
if (!isModelAccessWireProtocol(override.wireProtocol)) {
return `${path}.perAgent.${agent}.wireProtocol must be a supported wire protocol`;
}
@@ -715,10 +713,7 @@ export function parseListModelsResponse(
return fail(`response.models[${index}].availability must be available or requires_payment`);
}
const { availability, ...legacyShape } = raw;
- const sanitized = sanitizeModelEntryAgents(
- legacyShape,
- MODEL_ACCESS_CATALOG_SCHEMA_VERSION,
- );
+ const sanitized = sanitizeModelEntryAgents(legacyShape, MODEL_ACCESS_CATALOG_SCHEMA_VERSION);
if (isPlainObject(sanitized) && typeof sanitized.id === 'string') {
if (modelIds.has(sanitized.id)) {
return fail(`response.models[${index}].id must be unique`);
@@ -864,17 +859,26 @@ function registryRouteError(value: unknown, path: string): string | null {
function registryEntryError(
value: unknown,
path: string,
- schemaVersion: typeof MODEL_REGISTRY_LEGACY_SCHEMA_VERSION | typeof MODEL_REGISTRY_SCHEMA_VERSION,
+ schemaVersion: ModelRegistry['schemaVersion'],
): string | null {
if (!isPlainObject(value)) return `${path} must be an object`;
let error = unknownFieldError(
value,
schemaVersion === MODEL_REGISTRY_LEGACY_SCHEMA_VERSION
? MODEL_REGISTRY_ENTRY_V1_FIELDS
- : MODEL_REGISTRY_ENTRY_V2_FIELDS,
+ : schemaVersion === MODEL_REGISTRY_V3_SCHEMA_VERSION
+ ? [...MODEL_REGISTRY_ENTRY_V2_FIELDS, 'nativeApi']
+ : MODEL_REGISTRY_ENTRY_V2_FIELDS,
path,
);
if (error) return error;
+ if (
+ value.nativeApi !== undefined &&
+ value.nativeApi !== null &&
+ !MODEL_NATIVE_APIS.includes(value.nativeApi as never)
+ ) {
+ return `${path}.nativeApi must be a supported API or null`;
+ }
if (typeof value.id !== 'string' || value.id.length === 0 || value.id.length > 256) {
return `${path}.id must be a non-empty string of at most 256 characters`;
}
@@ -954,7 +958,7 @@ function registryEntryError(
if (error) return error;
}
}
- if (schemaVersion === MODEL_REGISTRY_SCHEMA_VERSION) {
+ if (schemaVersion >= MODEL_REGISTRY_SCHEMA_VERSION) {
if (value.status === 'retired' && value.newSessionDefault !== undefined) {
return `${path}.newSessionDefault is not allowed when ${path}.status is retired`;
}
@@ -970,20 +974,48 @@ function registryEntryError(
export function parseModelRegistry(value: unknown): ModelAccessParseResult<ModelRegistry> {
if (!isPlainObject(value)) return fail('modelRegistry must be an object');
- const unknownField = unknownFieldError(value, MODEL_REGISTRY_FIELDS, 'modelRegistry');
+ const unknownField = unknownFieldError(
+ value,
+ value.schemaVersion === MODEL_REGISTRY_V3_SCHEMA_VERSION
+ ? [...MODEL_REGISTRY_FIELDS, 'nativeApiRules']
+ : MODEL_REGISTRY_FIELDS,
+ 'modelRegistry',
+ );
if (unknownField) return fail(unknownField);
if (
value.schemaVersion !== MODEL_REGISTRY_LEGACY_SCHEMA_VERSION &&
- value.schemaVersion !== MODEL_REGISTRY_SCHEMA_VERSION
+ value.schemaVersion !== MODEL_REGISTRY_SCHEMA_VERSION &&
+ value.schemaVersion !== MODEL_REGISTRY_V3_SCHEMA_VERSION
) {
- return fail(
- `modelRegistry.schemaVersion must be ${MODEL_REGISTRY_LEGACY_SCHEMA_VERSION} or ${MODEL_REGISTRY_SCHEMA_VERSION}`,
- );
+ return fail('modelRegistry.schemaVersion must be 1, 2 or 3');
}
if (!isIsoTimestamp(value.updatedAt)) {
return fail('modelRegistry.updatedAt must be an ISO timestamp');
}
if (!Array.isArray(value.models)) return fail('modelRegistry.models must be an array');
+ if (value.nativeApiRules !== undefined) {
+ if (!Array.isArray(value.nativeApiRules))
+ return fail('modelRegistry.nativeApiRules must be an array');
+ const identities = new Set<string>();
+ for (const rule of value.nativeApiRules) {
+ if (
+ !isPlainObject(rule) ||
+ unknownFieldError(rule, ['providerId', 'modelIdPrefix', 'nativeApi'], 'nativeApiRule') ||
+ typeof rule.providerId !== 'string' ||
+ !rule.providerId ||
+ rule.providerId.length > 128 ||
+ typeof rule.modelIdPrefix !== 'string' ||
+ !rule.modelIdPrefix ||
+ rule.modelIdPrefix.length > 256 ||
+ !MODEL_NATIVE_APIS.includes(rule.nativeApi as never)
+ )
+ return fail('modelRegistry.nativeApiRules contains an invalid rule');
+ const key = `${rule.providerId}\u0000${rule.modelIdPrefix}`;
+ if (identities.has(key))
+ return fail('modelRegistry.nativeApiRules must have unique provider/prefix pairs');
+ identities.add(key);
+ }
+ }
const modelIds = new Set<string>();
for (const [index, model] of value.models.entries()) {
if (isPlainObject(model) && typeof model.id === 'string') {
diff --git a/packages/model-providers/src/modelProtocol.ts b/packages/model-providers/src/modelProtocol.ts
index 5650763b37..4338712d44 100644
--- a/packages/model-providers/src/modelProtocol.ts
+++ b/packages/model-providers/src/modelProtocol.ts
@@ -15,16 +15,19 @@ export function modelProtocolComparison(
provider: Pick<Provider, 'id' | 'routing'>,
models: Partial<Record<AgentKind, CatalogModel>>,
) {
- // Pi's per-model API is the catalog's portable protocol reference, not proof of every API
- // offered by the manufacturer. Omission stays unknown; a provider-wide default is not model
- // identity evidence (especially on aggregators). Subscription roots have an explicit contract.
- const reference: PiModelApi | null =
- models.pi?.piApi ??
- (provider.id === 'anthropic' && models['claude-code']
+ // Canonical protocol is model metadata, never reverse-engineered from a harness configuration.
+ const declared = Object.values(models)
+ .filter((m) => m.nativeApi !== undefined)
+ .map((m) => m.nativeApi);
+ const reference: PiModelApi | null = declared.length
+ ? new Set(declared).size === 1
+ ? declared[0]!
+ : null
+ : provider.id === 'anthropic' && models['claude-code']
? 'anthropic-messages'
: provider.id === 'openai' && models.codex
? 'openai-responses'
- : null);
+ : null;
const forAgent = (agent: AgentKind) => {
const model = models[agent];
if (!model) return null;
diff --git a/packages/model-providers/src/modelRegistry.ts b/packages/model-providers/src/modelRegistry.ts
index 838db662d0..1d4bf54ac6 100644
--- a/packages/model-providers/src/modelRegistry.ts
+++ b/packages/model-providers/src/modelRegistry.ts
@@ -15,6 +15,34 @@ export type ModelRegistryRevisionRelation =
| "conflict"
| "invalid-incoming";
+/** Explicit entries win, then the most specific rule for this exact provider route.
+ * Missing data stays unknown; a retired or explicitly unverified entry suppresses family rules.
+ */
+export function resolveModelNativeApi(
+ registry: ModelRegistry | undefined,
+ providerId: string,
+ modelId: string,
+): import('./modelAccessBean.js').ModelNativeApi | null | undefined {
+ if (!registry || registry.schemaVersion < 3) return undefined;
+ const id = modelId.replace(/\[1m\]$/, '');
+ const entries = registry.models.filter((entry) =>
+ entry.routes.some((route) => route.providerId === providerId && route.modelId === id),
+ );
+ if (entries.some((entry) => entry.status === 'retired' || entry.nativeApi === null)) return null;
+ const explicit = [
+ ...new Set(entries.flatMap((entry) => (entry.nativeApi ? [entry.nativeApi] : []))),
+ ];
+ if (explicit.length) return explicit.length === 1 ? explicit[0] : null;
+ return registry.nativeApiRules
+ ?.filter(
+ (rule) =>
+ rule.providerId === providerId &&
+ id.startsWith(rule.modelIdPrefix) &&
+ !id.slice(rule.modelIdPrefix.length).includes('/'),
+ )
+ .sort((a, b) => b.modelIdPrefix.length - a.modelIdPrefix.length)[0]?.nativeApi;
+}
+
export type ModelRegistrySnapshotDecision =
| "accept-incoming"
| "preserve-current"
diff --git a/packages/model-providers/src/source.ts b/packages/model-providers/src/source.ts
index aad6ef8092..a1f7befb4d 100644
--- a/packages/model-providers/src/source.ts
+++ b/packages/model-providers/src/source.ts
@@ -21,7 +21,7 @@ import {
import type { AgentKind, Catalog, Provider, ProviderPreset } from './types.js';
/** 公共模型目录 API 路径。发布版由 model-access-server 匿名提供完整 Catalog。 */
-export const CATALOG_API_PATH = '/api/model-catalog/catalog';
+export const CATALOG_API_PATH = '/api/model-catalog/catalog?registrySchemaVersion=3';
/** 旧客户端目录的 OSS 相对路径。迁移期作为公共 API 失败后的兼容回退。 */
export const CATALOG_CFG_PATH = '/cfg/providers.json';
@@ -112,7 +112,19 @@ function trimTrailingSlashes(s: string): string {
/** 解析主 catalog URL:显式 url 优先,否则 `${baseUrl}${CATALOG_API_PATH}`。 */
export function resolveCatalogUrl(cfg: CatalogSourceConfig): string | null {
- if (cfg.url && cfg.url.trim()) return cfg.url.trim();
+ if (cfg.url && cfg.url.trim()) {
+ const explicit = cfg.url.trim();
+ try {
+ const url = new URL(explicit);
+ if (url.pathname.endsWith('/api/model-catalog/catalog')) {
+ url.searchParams.set('registrySchemaVersion', '3');
+ return url.toString();
+ }
+ } catch {
+ /* Existing fetch/error path reports malformed custom URLs. */
+ }
+ return explicit;
+ }
if (cfg.baseUrl && cfg.baseUrl.trim()) {
return trimTrailingSlashes(cfg.baseUrl.trim()) + CATALOG_API_PATH;
}
diff --git a/packages/model-providers/src/types.ts b/packages/model-providers/src/types.ts
index a158544315..6660fd90d1 100644
--- a/packages/model-providers/src/types.ts
+++ b/packages/model-providers/src/types.ts
@@ -267,6 +267,8 @@ export interface ModelCost {
* 跨 provider(如 gpt-5.5 同时由 openai 与 xd 提供)则必须元数据一致(见 catalog.ts 校验)。
*/
export interface CatalogModel {
+ /** Canonical model API from the accepted Registry; null explicitly means unverified. */
+ nativeApi?: PiModelApi | null;
/** 与 maker-core 现有 model id 一致(如 'claude-opus-4-8' / 'gpt-5.5' / 'codex/gpt-5.5')。 */
id: string;
/** Server entitlement state. Paid-locked models remain present for UI but are never routable. */
diff --git a/packages/model-providers/src/unifiedSelection.ts b/packages/model-providers/src/unifiedSelection.ts
index 1b379cab77..24c416f3ed 100644
--- a/packages/model-providers/src/unifiedSelection.ts
+++ b/packages/model-providers/src/unifiedSelection.ts
@@ -61,8 +61,14 @@ import {
type ProviderView,
} from './registry.js';
import { deriveModelList } from './modelList.js';
+import { modelProtocolComparison } from './modelProtocol.js';
import { effortRank } from './effortResolution.js';
-import { CHATGPT_MODEL_PREFIX, XAI_MODEL_PREFIX, groupOf, isBudgetModel } from './classification.js';
+import {
+ CHATGPT_MODEL_PREFIX,
+ XAI_MODEL_PREFIX,
+ groupOf,
+ isBudgetModel,
+} from './classification.js';
import type { AgentKind, CatalogModel, Effort, Provider } from './types.js';
/**
@@ -259,7 +265,13 @@ export function candidateAgentsForModel(
if (allowed && !allowed.includes(agent)) return false;
// providerId 缺席时没有单一 provider 可查 wire id,逐个可能来源试。
const wireIds = providerId
- ? [resolveWireModelId(providers.find((p) => p.id === providerId), modelId, agent)]
+ ? [
+ resolveWireModelId(
+ providers.find((p) => p.id === providerId),
+ modelId,
+ agent,
+ ),
+ ]
: providers.map((provider) => resolveWireModelId(provider, modelId, agent));
for (const wireId of wireIds) {
if (!wireId) continue;
@@ -335,8 +347,8 @@ export function nativeAgentForProviderModel(
*
* 1. 无候选 → null(没有可推荐的东西,不编);
* 2. 单候选 → 即它(pi 唯一候选时也推荐 pi);
- * 3. Pi 候选明确配置 Google 原生 API → Pi;
- * 4. 原生底座命中候选 → 用它;
+ * 3. 目录声明原生协议且实际路由匹配 → 取该协议首选引擎,其次原生 Pi;
+ * 4. 旧目录缺声明时,保留 Google API Pi 与已有底座的回落规则;
* 5. 回落:候选里按 cc > codex 取第一个;都没有则 pi。
*
* 推荐必须是候选:原生底座不是候选就一定回落。
@@ -348,6 +360,23 @@ export function pickRecommendedAgent(
): AgentKind | null {
if (candidates.length === 0) return null;
if (candidates.length === 1) return candidates[0];
+ const models: Partial<Record<AgentKind, CatalogModel>> = {};
+ for (const agent of candidates) {
+ const model = findCatalogModel(provider, modelId, agent, { exact: true });
+ if (model) models[agent] = model;
+ }
+ const comparison = provider ? modelProtocolComparison(provider, models) : null;
+ const canonical = comparison?.reference;
+ if (canonical) {
+ const preferred =
+ canonical === 'anthropic-messages'
+ ? 'claude-code'
+ : canonical === 'openai-responses'
+ ? 'codex'
+ : 'pi';
+ if (comparison?.forAgent(preferred)?.mode === 'matching') return preferred;
+ if (comparison?.forAgent('pi')?.mode === 'matching') return 'pi';
+ }
// This is an actual per-model route declaration, not a Google brand/name heuristic.
// New models inherit it as soon as the catalog arrives; a Gemini served over Responses
// does not get a fabricated native Google route or a Pi recommendation.
@@ -644,8 +673,7 @@ export function unifiedModelEntries(opts: UnifiedModelEntriesOptions): UnifiedMo
// 再并回一家停用来源只会多出一条点了会改道的影子行。runtime 级 disabled(目录 routing
// 声明该引擎不可路由)不并回:那不是「暂时不可用」而是「从来路由不到」,并回也发不出去。
let keptRail: readonly ProviderView[] | null = null;
- let restrictRejoined: ((model: CatalogModel, provider: ProviderView) => boolean) | null =
- null;
+ let restrictRejoined: ((model: CatalogModel, provider: ProviderView) => boolean) | null = null;
if (keepModel !== undefined && keepModel.agent === agent) {
const connectedIds = new Set(
connectedProvidersForAgent([...providers], agent).map((p) => p.id),