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(model-providers): preserve BYOK speech catalog metadata

JiangJiahao6bfb53aac9c3
diff --git a/apps/desktop/src/main/maker-host/__tests__/modelMetadataLayers.integration.test.ts b/apps/desktop/src/main/maker-host/__tests__/modelMetadataLayers.integration.test.ts
index 9c0725ff22..e31dba8ae7 100644
--- a/apps/desktop/src/main/maker-host/__tests__/modelMetadataLayers.integration.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/modelMetadataLayers.integration.test.ts
@@ -38,9 +38,14 @@ it('isolates excess additions and duplicate tags without discarding valid local
import {
BUNDLED_CATALOG,
buildUserProvider,
+ isAgentSelectableModel,
+ mergeDiscoveredRuntimeModels,
+ parseModelsListResponse,
type Catalog,
+ type CustomProviderConfig,
type ModelRegistry,
} from '@cindy/model-providers';
+import { validateCustomProviderConfig } from '../custom-provider-store.js';
import {
getActiveCatalog,
getActiveLocalModelCatalog,
@@ -108,6 +113,35 @@ afterEach(() => {
setActiveCatalog(BUNDLED_CATALOG);
});
describe('metadata layers through the active catalog', () => {
+ it('keeps BYOK speech metadata through config validation, JSON persistence and active catalog refresh', () => {
+ const discovered = parseModelsListResponse({ data: [{ id: 'gpt-private-voice',
+ mode: 'audio_speech', native_api: 'openai-audio-speech' }] })!;
+ const config: CustomProviderConfig = { id: 'speech-one', name: 'Speech', runtimes: {
+ codex: { baseUrl: 'https://speech.example.test/v1', wireProtocol: 'openai-chat',
+ models: mergeDiscoveredRuntimeModels([], discovered) },
+ } };
+ expect(validateCustomProviderConfig(config)).toEqual({ ok: true });
+ const restored = JSON.parse(JSON.stringify(config)) as CustomProviderConfig;
+ const other: CustomProviderConfig = { ...restored, id: 'speech-two', runtimes: {
+ codex: { ...restored.runtimes.codex!, models: [{ id: 'gpt-private-voice', name: 'Chat', mode: 'chat' }] },
+ } };
+ const publish = () => setCustomProviders([restored, other].map(c =>
+ buildUserProvider(c, { modelRegistry: BUNDLED_CATALOG.modelRegistry })));
+ setActiveCatalog(BUNDLED_CATALOG);
+ publish();
+ for (let refresh = 0; refresh < 2; refresh++) {
+ const active = getActiveCatalog();
+ const speech = active.providers.find(p => p.id === restored.id)!;
+ expect(speech.audioModels?.[0]).toMatchObject({ id: 'gpt-private-voice', mode: 'audio_speech',
+ nativeApi: 'openai-audio-speech', sourceAgent: 'codex' });
+ expect(isAgentSelectableModel(speech.models.codex![0], { userProvider: true })).toBe(false);
+ expect(active.providers.find(p => p.id === other.id)?.audioModels).toBeUndefined();
+ restored.runtimes.codex!.models = mergeDiscoveredRuntimeModels(restored.runtimes.codex!.models,
+ [{ id: 'gpt-private-voice', name: 'Sparse refresh' }]);
+ publish();
+ }
+ });
+
it.each(['absent', 'legacy', 'empty'] as const)(
'applies local overrides after %s registry fallback',
(kind) => {
diff --git a/apps/desktop/src/renderer/__tests__/unifiedModelList.test.ts b/apps/desktop/src/renderer/__tests__/unifiedModelList.test.ts
index a757dcf488..cc44bfa0d7 100644
--- a/apps/desktop/src/renderer/__tests__/unifiedModelList.test.ts
+++ b/apps/desktop/src/renderer/__tests__/unifiedModelList.test.ts
@@ -23,6 +23,7 @@ import {
import { __resetForTest, setModelVisibilityOwner } from '@/state/modelVisibilityPrefs';
import type { CatalogModel, ProviderView } from '@cindy/model-providers';
+import { BUNDLED_CATALOG, buildUserProvider, mergeDiscoveredRuntimeModels, parseModelsListResponse } from '@cindy/model-providers';
function model(id: string, contextWindow = 100_000): CatalogModel {
return { id, name: id, contextWindow, efforts: [], defaultEffort: null } as CatalogModel;
@@ -68,6 +69,25 @@ afterEach(() => {
});
describe('buildUnionRows', () => {
+ it('groups discovered BYOK speech models as TTS and keeps the normal disabled management state', () => {
+ const projected = buildUserProvider({ id: 'speech-byok', name: 'Speech', runtimes: { codex: {
+ baseUrl: 'https://speech.example.test/v1', models: mergeDiscoveredRuntimeModels([], parseModelsListResponse({ data: [
+ { id: 'chat-model', mode: 'chat' },
+ { id: 'speech-model', mode: 'audio_speech', native_api: 'openai-audio-speech' },
+ ] })!),
+ } } }, { modelRegistry: BUNDLED_CATALOG.modelRegistry });
+ const view = { ...projected, connected: true } as ProviderView;
+ const rows = buildUnionRows(view);
+ expect(rows).toHaveLength(2);
+ const speech = rows.find(row => row.id === 'speech-model')!;
+ expect(managementKindsOfRow(speech, true)).toEqual(['tts']);
+ expect(isCapabilityRow(speech, true)).toBe(true);
+ expect(isRowDisabled(speech)).toBe(false);
+ view.models.codex![1].disabled = true;
+ view.audioModels![0].disabled = true;
+ expect(isRowDisabled(buildUnionRows(view).find(row => row.id === 'speech-model')!)).toBe(true);
+ });
+
it('同 id 跨 agent 合并;行序 = 首 agent 目录序 + 后续 agent 独占追加', () => {
const rows = buildUnionRows(provider);
expect(rows.map((r) => r.id)).toEqual(['shared', 'cc-only', 'codex-only']);
diff --git a/apps/desktop/src/renderer/components/settings/ProviderConnectionDialog.tsx b/apps/desktop/src/renderer/components/settings/ProviderConnectionDialog.tsx
index 644b5dda43..b3e7752507 100644
--- a/apps/desktop/src/renderer/components/settings/ProviderConnectionDialog.tsx
+++ b/apps/desktop/src/renderer/components/settings/ProviderConnectionDialog.tsx
@@ -35,6 +35,7 @@ import { SegmentedControl } from '@/components/ui/segmented-control';
import { cn } from '@/lib/utils';
import { toast } from '@/lib/toast';
import { Button } from '@/components/ui/button';
+import { Select } from '@/components/ui/select';
import { FormField } from '@/components/ui/form-field';
import { Tip } from '@/components/ui/tooltip';
import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
@@ -440,6 +441,7 @@ export function ProviderConnectionDialog({
}, [fieldError]);
const [name, setName] = useState(initial?.name ?? '');
const [manualModel, setManualModel] = useState('');
+ const [manualModelMode, setManualModelMode] = useState('inherit');
const [rt, setRt] = useState<Record<DialogAgentKind, RuntimeFields>>(() => initRuntimes(initial));
const [activeTab, setActiveTab] = useState<DialogAgentKind>(
() =>
@@ -1168,6 +1170,7 @@ export function ProviderConnectionDialog({
);
const f = rt[activeTab];
+ const mediaOnly = f.models.some(model => model.id.trim()) && !firstProviderChatModel(f.models);
const boundPreset = presets.find(preset => preset.id === f.catalogPresetId);
const templateBound = Boolean(f.catalogPresetId);
const endpointTemplate = boundPreset?.runtimes[activeTab]?.baseUrl;
@@ -1359,6 +1362,7 @@ export function ProviderConnectionDialog({
id: m.id.trim(),
name: m.name.trim(),
mode: m.mode,
+ nativeApi: m.nativeApi,
modalities: m.modalities,
officialDocs: m.officialDocs,
discoveredMetadata: m.discoveredMetadata,
@@ -1403,6 +1407,7 @@ export function ProviderConnectionDialog({
m.discoveredMetadata ?? { contextWindow: m.contextWindow }),
discoveredCost: m.discoveredCost,
mode: cur?.mode,
+ nativeApi: cur?.nativeApi,
modalities: cur?.modalities,
officialDocs: cur?.officialDocs,
nameExplicit: cur ? (cur.nameExplicit ?? !cur.discoveredMetadata) : undefined,
@@ -1490,6 +1495,7 @@ export function ProviderConnectionDialog({
id: m.id,
name: latest?.name.trim() ? latest.name.trim() : m.name,
mode: latest ? latest.mode : m.mode,
+ nativeApi: latest ? latest.nativeApi : m.nativeApi,
modalities: latest?.modalities ?? m.modalities,
officialDocs: latest?.officialDocs ?? m.officialDocs,
discoveredMetadata: m.discoveredMetadata ?? latest?.discoveredMetadata,
@@ -1517,6 +1523,7 @@ export function ProviderConnectionDialog({
id,
name: m.name.trim() || id,
mode: m.mode,
+ nativeApi: m.nativeApi,
modalities: m.modalities,
officialDocs: m.officialDocs,
discoveredMetadata: m.discoveredMetadata,
@@ -1618,6 +1625,7 @@ export function ProviderConnectionDialog({
id: m.id.trim(),
name: m.name.trim(),
mode: m.mode,
+ nativeApi: m.nativeApi,
modalities: m.modalities,
officialDocs: m.officialDocs,
discoveredMetadata: m.discoveredMetadata,
@@ -2401,13 +2409,33 @@ export function ProviderConnectionDialog({
onChange={setManualModel} />
)}
</FormField>
+ <FormField id={fieldId(`${activeTab}:manualModelMode`)}
+ label={t('settings.providers.custom.fields.modelType')}
+ hint={t('settings.providers.connection.manualModelTypeHint')}>
+ {(control) => (
+ <Select {...control} label={t('settings.providers.custom.fields.modelType')}
+ value={manualModelMode} onValueChange={setManualModelMode}
+ options={[
+ { value: 'inherit', label: t('settings.providers.connection.modelTypeAutomatic') },
+ { value: 'chat', label: t('settings.providers.models.kindFilter.chat') },
+ ...([
+ ['image_generation', 'image'], ['video_generation', 'video'],
+ ['audio_speech', 'tts'], ['audio_transcription', 'stt'],
+ ['audio_generation', 'audio'], ['realtime', 'realtime'], ['embedding', 'embedding'],
+ ] as const).map(([value, category]) => ({ value, label: t(`newChat.modelSelector.category.${category}`) })),
+ ]} />
+ )}
+ </FormField>
<Button variant="secondary" disabled={!manualModel.trim()} onClick={() => {
const ids = [...new Set(manualModel.split(/[,\n]/).map((id) => id.trim()).filter(Boolean))];
patch(activeTab, (runtime) => ({ ...runtime, models: [
- ...runtime.models.filter((model) => model.id.trim()),
- ...ids.filter((id) => !runtime.models.some((model) => model.id === id)).map((id) => ({ id, name: id })),
+ ...runtime.models.filter((model) => model.id.trim()).map(model =>
+ ids.includes(model.id) ? { ...model, mode: manualModelMode === 'inherit' ? undefined : manualModelMode } : model),
+ ...ids.filter((id) => !runtime.models.some((model) => model.id === id))
+ .map((id) => ({ id, name: id, ...(manualModelMode === 'inherit' ? {} : { mode: manualModelMode }) })),
] }));
setManualModel('');
+ setManualModelMode('inherit');
setFieldError(null);
}}>{t('settings.providers.custom.fields.addModel')}</Button>
</div>
@@ -2676,7 +2704,7 @@ export function ProviderConnectionDialog({
用户只补 key。列表已按厂商首字母分组排序(同厂商国内/海外相邻,按构建区域排序)。 */}
{authMode !== 'oauth' && (
<div className="flex min-h-[32px] flex-wrap items-center gap-2.5">
- <Button
+ {!mediaOnly && <Button
variant="secondary"
size="sm"
compact
@@ -2687,7 +2715,7 @@ export function ProviderConnectionDialog({
>
<Plug size={13} />
{t('settings.providers.custom.test.button')}
- </Button>
+ </Button>}
{/* 预设模板(仅新建态、有预设时显示):下拉选择,选中即预填 baseUrl / 模型清单,
用户只补 key。列表已按厂商首字母分组排序(同厂商国内/海外相邻,按构建区域排序)。 */}
<Button
@@ -2703,7 +2731,7 @@ export function ProviderConnectionDialog({
<RefreshCw size={13} />
{t('settings.providers.custom.fetch.button')}
</Button>
- {test[activeTab].status === 'ok' && (
+ {!mediaOnly && test[activeTab].status === 'ok' && (
<span
className="flex items-center gap-1 text-12"
style={{ color: 'var(--remote-status-ready)' }}
@@ -2712,11 +2740,16 @@ export function ProviderConnectionDialog({
{t('settings.providers.custom.test.ok', { ms: test[activeTab].latencyMs ?? 0 })}
</span>
)}
- {test[activeTab].status === 'fail' && (
+ {!mediaOnly && test[activeTab].status === 'fail' && (
<span className="text-12 text-[var(--error-fg)]">
{t(`providerError.${test[activeTab].code ?? 'UNKNOWN'}`)}
</span>
)}
+ {mediaOnly && (
+ <span className="w-full text-12 text-[var(--text-secondary)]">
+ {t('settings.providers.connection.mediaOnlyTestHint')}
+ </span>
+ )}
</div>
)}
</div>
diff --git a/apps/desktop/src/renderer/components/settings/__tests__/CustomProviderDialogAccessibility.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/CustomProviderDialogAccessibility.test.tsx
index c0a9fcee87..3b135402d8 100644
--- a/apps/desktop/src/renderer/components/settings/__tests__/CustomProviderDialogAccessibility.test.tsx
+++ b/apps/desktop/src/renderer/components/settings/__tests__/CustomProviderDialogAccessibility.test.tsx
@@ -2,7 +2,7 @@
import { useRef, useState } from 'react';
import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import type { CustomProviderConfig } from '@cindy/model-providers';
import { ProviderConnectionDialog } from '../ProviderConnectionDialog';
@@ -50,6 +50,88 @@ beforeEach(() => {
afterEach(cleanup);
+describe('BYOK speech catalog settings', () => {
+ const originalScrollIntoView = HTMLElement.prototype.scrollIntoView;
+ beforeAll(() => { HTMLElement.prototype.scrollIntoView = vi.fn(); });
+ afterAll(() => { HTMLElement.prototype.scrollIntoView = originalScrollIntoView; });
+ function speechConnection(models: NonNullable<CustomProviderConfig['runtimes']['codex']>['models']): CustomProviderConfig {
+ return { id: 'speech-only', name: 'Speech account', runtimes: {
+ codex: { baseUrl: 'https://speech.example.test/v1', wireProtocol: 'openai-chat', models },
+ } };
+ }
+
+ it('manually marks an unknown model as speech and preserves that choice and its protocol through refresh and save', async () => {
+ customProviderMocks.readCustomProviderKey.mockResolvedValue(null);
+ window.electronAPI.maker.fetchProviderModels = vi.fn().mockResolvedValue({ ok: true, models: [
+ { id: 'private-voice', name: 'Upstream name', discoveredMetadata: { mode: 'chat', nativeApi: 'openai-responses' } },
+ ] });
+ const user = userEvent.setup();
+ render(<ProviderConnectionDialog initial={speechConnection([
+ { id: 'private-voice', name: 'My Voice', nativeApi: 'openai-audio-speech', defaultEnabled: false },
+ ])} onSaved={vi.fn()} onClose={vi.fn()} />);
+ await waitFor(() => expect(customProviderMocks.readCustomProviderKey).toHaveBeenCalled());
+ await user.type(screen.getByLabelText('settings.providers.connection.manualModel'), 'private-voice');
+ screen.getByRole('combobox', { name: 'settings.providers.custom.fields.modelType' }).focus();
+ await user.keyboard('{ArrowDown}');
+ await user.click(screen.getByRole('option', { name: 'newChat.modelSelector.category.tts' }));
+ await user.click(screen.getByRole('button', { name: 'settings.providers.custom.fields.addModel' }));
+ expect(screen.queryByRole('button', { name: 'settings.providers.custom.test.button' })).toBeNull();
+ expect(screen.getByText('settings.providers.connection.mediaOnlyTestHint')).toBeTruthy();
+ await user.click(screen.getByRole('button', { name: 'settings.providers.custom.fetch.button' }));
+ await screen.findByRole('heading', { name: 'settings.providers.custom.fetch.pickerTitle' });
+ await user.click(screen.getByRole('button', { name: 'settings.providers.custom.fetch.confirm' }));
+ await user.click(screen.getByRole('button', { name: 'settings.providers.custom.save' }));
+ await waitFor(() => expect(customProviderMocks.updateCustomProvider).toHaveBeenCalledOnce());
+ expect(customProviderMocks.updateCustomProvider.mock.calls[0][0].runtimes.codex.models).toEqual([
+ expect.objectContaining({ id: 'private-voice', name: 'My Voice', mode: 'audio_speech',
+ nativeApi: 'openai-audio-speech', defaultEnabled: false,
+ discoveredMetadata: { mode: 'chat', nativeApi: 'openai-responses' } }),
+ ]);
+ expect(window.electronAPI.maker.testProviderConnection).not.toHaveBeenCalled();
+ });
+
+ it('imports speech metadata into a connection with no chat models, without claiming an inference test', async () => {
+ customProviderMocks.readCustomProviderKey.mockResolvedValue(null);
+ window.electronAPI.maker.fetchProviderModels = vi.fn().mockResolvedValue({ ok: true, models: [
+ { id: 'gpt-4o-mini-tts', name: 'Speech', discoveredMetadata: { mode: 'audio_speech', nativeApi: 'openai-audio-speech' } },
+ ] });
+ const user = userEvent.setup();
+ render(<ProviderConnectionDialog initial={speechConnection([
+ { id: 'gpt-4o-mini-tts', name: 'Speech' },
+ ])} onSaved={vi.fn()} onClose={vi.fn()} />);
+ await waitFor(() => expect(customProviderMocks.readCustomProviderKey).toHaveBeenCalled());
+ expect(screen.queryByRole('button', { name: 'settings.providers.custom.test.button' })).toBeNull();
+ await user.click(screen.getByRole('button', { name: 'settings.providers.custom.fetch.button' }));
+ await screen.findByRole('heading', { name: 'settings.providers.custom.fetch.pickerTitle' });
+ await user.click(screen.getByRole('button', { name: 'settings.providers.custom.fetch.confirm' }));
+ await user.click(screen.getByRole('button', { name: 'settings.providers.custom.save' }));
+ await waitFor(() => expect(customProviderMocks.updateCustomProvider).toHaveBeenCalledOnce());
+ const model = customProviderMocks.updateCustomProvider.mock.calls[0][0].runtimes.codex.models[0];
+ expect(model.mode).toBeUndefined();
+ expect(model.discoveredMetadata).toMatchObject({ mode: 'audio_speech', nativeApi: 'openai-audio-speech' });
+ expect(window.electronAPI.maker.testProviderConnection).not.toHaveBeenCalled();
+ expect(screen.queryByText('settings.providers.custom.test.ok')).toBeNull();
+ });
+
+ it('restores inherited model type without dropping other user settings', async () => {
+ customProviderMocks.readCustomProviderKey.mockResolvedValue(null);
+ const user = userEvent.setup();
+ render(<ProviderConnectionDialog initial={speechConnection([
+ { id: 'private-model', name: 'My model', mode: 'audio_speech', defaultEnabled: false,
+ discoveredMetadata: { mode: 'chat' } },
+ ])} onSaved={vi.fn()} onClose={vi.fn()} />);
+ await waitFor(() => expect(customProviderMocks.readCustomProviderKey).toHaveBeenCalled());
+ await user.type(screen.getByLabelText('settings.providers.connection.manualModel'), 'private-model');
+ await user.click(screen.getByRole('button', { name: 'settings.providers.custom.fields.addModel' }));
+ expect(screen.getByRole('button', { name: 'settings.providers.custom.test.button' })).toBeTruthy();
+ await user.click(screen.getByRole('button', { name: 'settings.providers.custom.save' }));
+ await waitFor(() => expect(customProviderMocks.updateCustomProvider).toHaveBeenCalledOnce());
+ const model = customProviderMocks.updateCustomProvider.mock.calls[0][0].runtimes.codex.models[0];
+ expect(model.mode).toBeUndefined();
+ expect(model).toMatchObject({ name: 'My model', defaultEnabled: false, discoveredMetadata: { mode: 'chat' } });
+ });
+});
+
async function waitForInitialDialogFocus(): Promise<void> {
const nameInput = screen.getByPlaceholderText('settings.providers.custom.fields.namePlaceholder');
await waitFor(() => expect(document.activeElement).toBe(nameInput));
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 82019c9eee..82bb68968a 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -3464,7 +3464,10 @@
"connection": {
"modelCount": "{{count}} models configured",
"modelsAutomatic": "Model details are imported automatically. Adjust individual models in the model list.",
- "manualModel": "Model IDs (if discovery is unavailable)"
+ "manualModel": "Model IDs (if discovery is unavailable)",
+ "modelTypeAutomatic": "Detect Automatically",
+ "manualModelTypeHint": "Use the same ID to update its type. Automatic detection restores the catalog type.",
+ "mediaOnlyTestHint": "This connection has only non-chat models. Fetch the model list to check catalog access; model execution is not tested here."
},
"byok": {
"managed": "Managed by your organization",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 06dfced78d..402d1691ce 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -3438,7 +3438,10 @@
"connection": {
"modelCount": "{{count}} 個のモデルを設定済み",
"modelsAutomatic": "モデル情報は自動取得されます。個別の設定はモデル一覧から変更できます。",
- "manualModel": "モデル ID(自動取得できない場合)"
+ "manualModel": "モデル ID(自動取得できない場合)",
+ "modelTypeAutomatic": "自動判別",
+ "manualModelTypeHint": "同じ ID で種類を更新できます。自動判別を選ぶと、カタログの種類に戻ります。",
+ "mediaOnlyTestHint": "この接続にはチャット以外のモデルのみが含まれています。モデル一覧の取得でカタログへのアクセスを確認できます。ここではモデルの実行はテストしません。"
},
"byok": {
"managed": "組織が接続とモデルを管理",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 94bd506dd4..d2b60a0359 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -3438,7 +3438,10 @@
"connection": {
"modelCount": "모델 {{count}}개 설정됨",
"modelsAutomatic": "모델 정보는 자동으로 가져옵니다. 개별 설정은 모델 목록에서 변경하세요.",
- "manualModel": "모델 ID (자동으로 가져올 수 없는 경우)"
+ "manualModel": "모델 ID (자동으로 가져올 수 없는 경우)",
+ "modelTypeAutomatic": "자동 감지",
+ "manualModelTypeHint": "같은 ID로 유형을 변경할 수 있습니다. 자동 감지를 선택하면 카탈로그의 유형으로 돌아갑니다.",
+ "mediaOnlyTestHint": "이 연결에는 채팅 이외의 모델만 있습니다. 모델 목록을 가져와 카탈로그 접근을 확인할 수 있습니다. 여기서는 모델 실행을 테스트하지 않습니다."
},
"byok": {
"managed": "조직에서 연결 및 모델 관리",
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 d87aa77c41..63b0c7d0c3 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -3438,7 +3438,10 @@
"connection": {
"modelCount": "已配置 {{count}} 个模型",
"modelsAutomatic": "模型资料自动获取。单个模型的设置在模型列表中调整。",
- "manualModel": "模型 ID(无法自动获取时填写)"
+ "manualModel": "模型 ID(无法自动获取时填写)",
+ "modelTypeAutomatic": "自动识别",
+ "manualModelTypeHint": "同一 ID 可更新类型;自动识别会恢复目录中的类型。",
+ "mediaOnlyTestHint": "此连接仅含非对话模型。可获取模型列表检查目录访问,此处不验证模型调用。"
},
"byok": {
"managed": "由企业管理连接与模型",
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 97b22b6400..9a14bcf1e7 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -3438,7 +3438,10 @@
"connection": {
"modelCount": "已設定 {{count}} 個模型",
"modelsAutomatic": "模型資料自動取得。個別模型的設定請在模型清單調整。",
- "manualModel": "模型 ID(無法自動取得時填寫)"
+ "manualModel": "模型 ID(無法自動取得時填寫)",
+ "modelTypeAutomatic": "自動辨識",
+ "manualModelTypeHint": "相同 ID 可更新類型;自動辨識會恢復目錄中的類型。",
+ "mediaOnlyTestHint": "此連線僅含非對話模型。可取得模型列表檢查目錄存取,此處不驗證模型呼叫。"
},
"byok": {
"managed": "由企業管理連線與模型",
diff --git a/apps/desktop/src/renderer/lib/__tests__/providerModelFetch.test.ts b/apps/desktop/src/renderer/lib/__tests__/providerModelFetch.test.ts
index 0779676bdc..179d157da0 100644
--- a/apps/desktop/src/renderer/lib/__tests__/providerModelFetch.test.ts
+++ b/apps/desktop/src/renderer/lib/__tests__/providerModelFetch.test.ts
@@ -24,6 +24,15 @@ const fields = {
],
};
+it('excludes exact public speech identities from chat probes without guessing unknown names', () => {
+ const speech = { id: 'gpt-4o-mini-tts' };
+ const unknown = { id: 'private-tts-service' };
+ expect(firstProviderChatModel([speech])).toBeUndefined();
+ expect(firstProviderChatModel([speech, unknown])).toBe(unknown);
+ expect(firstProviderChatModel([{ ...unknown, mode: 'audio_speech' }])).toBeUndefined();
+ expect(firstProviderChatModel([{ ...speech, mode: 'chat' }])?.id).toBe(speech.id);
+});
+
describe('providerModelFetchRequestSignature', () => {
it('invalidates an in-flight result when the auth mode changes', () => {
expect(providerModelFetchRequestSignature(fields, 'apiKey')).not.toBe(
diff --git a/apps/desktop/src/renderer/lib/providerModelFetch.ts b/apps/desktop/src/renderer/lib/providerModelFetch.ts
index 6200ecc1e4..6fba60b01b 100644
--- a/apps/desktop/src/renderer/lib/providerModelFetch.ts
+++ b/apps/desktop/src/renderer/lib/providerModelFetch.ts
@@ -1,5 +1,7 @@
import {
buildUserProvider,
+ BUNDLED_CATALOG,
+ findBaseModel,
type ProviderPreset,
isAgentSelectableModel,
isLoopbackProviderUrl,
@@ -29,7 +31,8 @@ export interface ProviderConnectionTestSignatureFields extends ProviderModelFetc
export function firstProviderChatModel<T extends { id: string; mode?: string; discoveredMetadata?: { mode?: string } }>(models: readonly T[]): T | undefined {
return models.find((model) => model.id.trim().length > 0 && isAgentSelectableModel(
- { id: model.id, group: 'custom', mode: model.mode ?? model.discoveredMetadata?.mode },
+ { id: model.id, group: 'custom', mode: model.mode ?? model.discoveredMetadata?.mode ??
+ findBaseModel(BUNDLED_CATALOG.modelRegistry, model.id.trim())?.defaults.mode },
{ userProvider: true },
));
}
diff --git a/docs/model-registry-v4-media.md b/docs/model-registry-v4-media.md
index 90789d35b9..1d9e68e2a5 100644
--- a/docs/model-registry-v4-media.md
+++ b/docs/model-registry-v4-media.md
@@ -80,6 +80,26 @@
- 自定义型号表单可选择媒体类型或恢复继承;刷新选择器、确认和保存均保留显式类型。
- 统一模型管理页展示上述类型,既有停用偏好同样作用于音频型号。
+### 第三方 API key 连接的语音目录
+
+通用发现保留接口显式返回的 `mode`(含 `model_info.mode`)和已认识的
+`nativeApi` / `native_api`,型号 ID 接受既有字段及 `model_id`。仅返回 ID 时,
+公共资料仍只按精确 ID/唯一 alias 匹配;不因名称含 `tts` 或 `speech` 就把未知私有
+型号改成语音模型。不提供类型的服务可在连接设置中手动指定「语音合成」;同一 ID
+可更新类型,「自动识别」删除类型覆盖,重新使用发现快照/目录资料。
+
+显式媒体类型不套用聊天协议的名称前缀规则(例如 `gpt-*`);语音协议缺失仍保持未知,
+不凭 `audio_speech` 推断具体厂商协议。模型的原生协议资料与连接的聊天 `wireProtocol`
+是两件事,保留资料不会新增语音合成执行器。
+
+纯非对话连接沿用「获取模型列表」检查目录访问并管理型号,不进行聊天探测;手动添加
+后可直接保存,无需先添加虚假的聊天模型。获取目录不代表语音合成、鉴权范围或计费
+调用已经验证。用户类型、名称、开关及协议覆盖刷新后保留,同 ID 的不同连接独立。
+本能力属于客户端的个人 API key/自定义连接,不扩展组织 BYOK 协议、Gateway 成员或权限。
+
+实现与回归:`modelDiscovery.ts`、`modelRegistry.ts`、`user-provider.ts`、
+`speechModelDiscovery.test.ts`、`ProviderConnectionDialog.tsx` 及其组件测试。
+
## 执行与兼容边界
OpenAI 授权登录的图像能力统一显示为 **GPT Image Gen**,由托管 `image_generation` 工具选择底层型号,
diff --git a/packages/model-providers/src/__tests__/speechModelDiscovery.test.ts b/packages/model-providers/src/__tests__/speechModelDiscovery.test.ts
new file mode 100644
index 0000000000..78b1d9eeee
--- /dev/null
+++ b/packages/model-providers/src/__tests__/speechModelDiscovery.test.ts
@@ -0,0 +1,120 @@
+import { describe, expect, it } from 'vitest';
+import { BUNDLED_CATALOG, parseCatalog } from '../catalog.js';
+import { isAgentSelectableModel } from '../classification.js';
+import { parseModelsListResponse } from '../modelDiscovery.js';
+import { mergeDiscoveredRuntimeModels, pickModelMetadata, validModelMetadata } from '../modelMetadataLayers.js';
+import { resolveCatalogModelNativeApi, resolveModelNativeApi } from '../modelRegistry.js';
+import { buildUserProvider } from '../user-provider.js';
+import type { ModelRegistry } from '../modelAccessBean.js';
+import type { ProviderRuntimeModelConfig } from '../types.js';
+
+const registry = BUNDLED_CATALOG.modelRegistry!;
+function provider(models: ProviderRuntimeModelConfig[], id = 'speech-account') {
+ return buildUserProvider({ id, name: id, runtimes: {
+ codex: { baseUrl: 'https://speech.example.test/v1', wireProtocol: 'openai-chat', models },
+ } }, { modelRegistry: registry });
+}
+
+describe('BYOK speech discovery and projection', () => {
+ it.each(['nativeApi', 'native_api'])('retains explicit speech metadata from %s through refresh and catalog parsing', key => {
+ const discovered = parseModelsListResponse({ data: [{ id: 'custom-voice',
+ name: 'Custom Voice', mode: 'audio_speech', [key]: 'openai-audio-speech',
+ }] })!;
+ expect(discovered[0].discoveredMetadata).toMatchObject({ mode: 'audio_speech', nativeApi: 'openai-audio-speech' });
+ const models = mergeDiscoveredRuntimeModels([], discovered);
+ const p = provider(mergeDiscoveredRuntimeModels(models, [{ id: 'custom-voice', name: 'Custom Voice' }]));
+ expect(p.audioModels).toEqual([expect.objectContaining({ id: 'custom-voice',
+ mode: 'audio_speech', nativeApi: 'openai-audio-speech', sourceAgent: 'codex' })]);
+ expect(isAgentSelectableModel(p.models.codex![0], { userProvider: true })).toBe(false);
+ expect(parseCatalog({ ...BUNDLED_CATALOG, providers: [p] }).providers[0].audioModels).toEqual(p.audioModels);
+ });
+
+ it('accepts model_id without inferring a capability or protocol from a vendor name', () => {
+ const result = parseModelsListResponse({ models: [
+ { model_id: 'voice-v1', name: 'Voice', model_info: { mode: 'audio_speech' } },
+ { model_id: 'private-tts-v1', name: 'Unknown model' },
+ ] })!;
+ expect(result.map(m => m.id)).toEqual(['voice-v1', 'private-tts-v1']);
+ const p = provider(mergeDiscoveredRuntimeModels([], result));
+ expect(p.audioModels?.map(m => m.id)).toEqual(['voice-v1']);
+ expect(p.audioModels?.[0].nativeApi).toBeUndefined();
+ expect(isAgentSelectableModel(p.models.codex![1], { userProvider: true })).toBe(true);
+ });
+
+ it('uses exact public identity for ID-only discovery without inventing account members or a speech protocol', () => {
+ const models = mergeDiscoveredRuntimeModels([], parseModelsListResponse({ data: [
+ { id: 'gpt-4o-mini-tts' }, { id: 'gpt-6-astra' },
+ ] })!);
+ const p = provider(models);
+ expect(p.audioModels?.map(m => m.id)).toEqual(['gpt-4o-mini-tts']);
+ expect(p.audioModels?.[0].nativeApi).toBeUndefined();
+ expect(isAgentSelectableModel(p.models.codex![0], { userProvider: true })).toBe(false);
+ expect(isAgentSelectableModel(p.models.codex![1], { userProvider: true })).toBe(true);
+ expect(p.models.codex![1].nativeApi).toBe('openai-responses');
+ expect(provider([]).audioModels).toBeUndefined();
+ });
+
+ it('preserves manual type, name and visibility overrides across conflicting discovery', () => {
+ const original: ProviderRuntimeModelConfig[] = [{ id: 'gpt-private', name: 'My Voice',
+ mode: 'audio_speech', nativeApi: 'openai-audio-speech', defaultEnabled: false }];
+ const merged = mergeDiscoveredRuntimeModels(original, parseModelsListResponse({ data: [
+ { id: 'gpt-private', name: 'Upstream', mode: 'chat', nativeApi: 'openai-responses' },
+ ] })!);
+ expect(merged[0]).toMatchObject(original[0]);
+ const p = provider(merged);
+ expect(p.audioModels?.[0]).toMatchObject({ id: 'gpt-private', name: 'My Voice',
+ mode: 'audio_speech', nativeApi: 'openai-audio-speech' });
+ expect(p.models.codex![0].defaultEnabled).toBe(false);
+ expect(isAgentSelectableModel(p.models.codex![0], { userProvider: true })).toBe(false);
+ const inherited = provider([{ ...merged[0], mode: undefined, nativeApi: undefined }]);
+ expect(inherited.audioModels).toBeUndefined();
+ expect(inherited.models.codex![0].mode).toBe('chat');
+ });
+
+ it('keeps same-ID models scoped to each connection', () => {
+ const speech = provider([{ id: 'same-id', name: 'Speech', mode: 'audio_speech' }], 'speech');
+ const chat = provider([{ id: 'same-id', name: 'Chat', mode: 'chat' }], 'chat');
+ expect(speech.id).not.toBe(chat.id);
+ expect(speech.audioModels?.[0].name).toBe('Speech');
+ expect(chat.audioModels).toBeUndefined();
+ expect(chat.models.codex![0].mode).toBe('chat');
+ });
+});
+
+describe('media native API metadata', () => {
+ it('preserves known media protocols and explicit unknown, and rejects arbitrary protocols', () => {
+ expect(validModelMetadata({ nativeApi: 'openai-audio-speech' })).toBe(true);
+ expect(pickModelMetadata({ nativeApi: null })).toEqual({ nativeApi: null });
+ expect(pickModelMetadata({ nativeApi: 'unimplemented-vendor-protocol' })).toEqual({});
+ });
+
+ it.each(['gpt-4o-mini-tts', 'openai/gpt-4o-mini-tts'])(
+ 'does not assign a chat family protocol to the public speech model %s', id => {
+ expect(resolveCatalogModelNativeApi(registry, id)).toBeUndefined();
+ expect(resolveModelNativeApi(registry, 'xd', id)).toBeUndefined();
+ },
+ );
+
+ it('uses explicit media mode ahead of chat prefix rules, keeping exact declarations authoritative', () => {
+ const r: ModelRegistry = { schemaVersion: 4, updatedAt: '2026-10-12T00:00:00.000Z', models: [],
+ nativeApiRules: [{ providerId: 'xd', modelIdPrefix: 'gpt-', nativeApi: 'openai-responses' }] };
+ expect(resolveCatalogModelNativeApi(r, 'gpt-private', 'audio_speech')).toBeUndefined();
+ expect(resolveModelNativeApi(r, 'xd', 'gpt-private', 'audio_speech')).toBeUndefined();
+ expect(resolveModelNativeApi(r, 'xd', 'gpt-private', 'chat')).toBe('openai-responses');
+ r.models.push({ id: 'gpt-private', name: 'Speech', mode: 'audio_speech', nativeApi: 'openai-audio-speech',
+ routes: [{ providerId: 'xd', modelId: 'gpt-private', agents: [] }] });
+ expect(resolveCatalogModelNativeApi(r, 'gpt-private')).toBe('openai-audio-speech');
+ expect(resolveModelNativeApi(r, 'xd', 'gpt-private')).toBe('openai-audio-speech');
+ r.models[0].nativeApi = null;
+ expect(resolveModelNativeApi(r, 'xd', 'gpt-private')).toBeNull();
+ });
+
+ it('honors a catalog entry type even when it has no Gateway route or public base model', () => {
+ const r: ModelRegistry = { schemaVersion: 4, updatedAt: '2026-10-12T00:00:00.000Z',
+ models: [{ id: 'gpt-private-voice', name: 'Speech', mode: 'audio_speech', routes: [] }],
+ nativeApiRules: [{ providerId: 'xd', modelIdPrefix: 'openai/gpt-', nativeApi: 'openai-responses' }],
+ };
+ expect(resolveCatalogModelNativeApi(r, 'gpt-private-voice')).toBeUndefined();
+ expect(resolveCatalogModelNativeApi(r, 'gpt-private-chat')).toBe('openai-responses');
+ });
+});
diff --git a/packages/model-providers/src/catalog.ts b/packages/model-providers/src/catalog.ts
index 10f91ec16d..f383ef8cae 100644
--- a/packages/model-providers/src/catalog.ts
+++ b/packages/model-providers/src/catalog.ts
@@ -153,7 +153,7 @@ function validateModel(
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}'`);
+ assert(isPiModelApi(m.nativeApi) || validModelMetadata({ nativeApi: m.nativeApi }), `model.nativeApi invalid for '${m.id}'`);
}
if (m.api !== undefined) {
assert(isPiModelApi(m.api), `model.api invalid for '${m.id}'`);
diff --git a/packages/model-providers/src/modelDiscovery.ts b/packages/model-providers/src/modelDiscovery.ts
index 26669ea22f..f1671ecf29 100644
--- a/packages/model-providers/src/modelDiscovery.ts
+++ b/packages/model-providers/src/modelDiscovery.ts
@@ -72,7 +72,9 @@ export function parseModelsListResponse(
? (item as { key: string }).key
: typeof (item as { model_name?: unknown }).model_name === 'string'
? (item as { model_name: string }).model_name
- : google ? google.name.slice('models/'.length) : null
+ : typeof (item as { model_id?: unknown }).model_id === 'string'
+ ? (item as { model_id: string }).model_id
+ : google ? google.name.slice('models/'.length) : null
: null;
if (!id || seen.has(id)) continue;
seen.add(id);
diff --git a/packages/model-providers/src/modelMetadataLayers.ts b/packages/model-providers/src/modelMetadataLayers.ts
index b618ef155b..978d4a7c84 100644
--- a/packages/model-providers/src/modelMetadataLayers.ts
+++ b/packages/model-providers/src/modelMetadataLayers.ts
@@ -1,4 +1,5 @@
import { generationCapabilities, previousModelGenerations } from './modelGeneration.js';
+import { MODEL_NATIVE_APIS } from './modelAccessBean.js';
import type { CatalogModel } from "./types.js";
import type {
ModelRegistry,
@@ -6,7 +7,7 @@ import type {
ModelRegistryRoute,
ModelEffort,
ModelReferencePriceGroup,
- ModelAccessWireProtocol,
+ ModelNativeApi,
} from "./modelAccessBean.js";
// Projection-only provenance; a symbol keeps it out of the public metadata schema
@@ -17,7 +18,7 @@ type ResolvedModelMetadata = ModelMetadata & { [inheritedContextWindow]?: true }
/** Data only. Membership, credentials, routing and billed prices never inherit. */
export interface ModelMetadata {
/** Manufacturer language, independent of the connection's execution protocol. */
- nativeApi?: ModelAccessWireProtocol | null;
+ nativeApi?: ModelNativeApi | null;
mode?: string;
modalities?: { input: string[]; output: string[] };
officialDocs?: string;
@@ -75,7 +76,7 @@ export function validModelMetadata(value: unknown): value is ModelMetadata {
if (!(MODEL_METADATA_FIELDS as readonly string[]).includes(key))
return false;
if (key === 'nativeApi') return v === null ||
- ['anthropic-messages', 'openai-responses', 'openai-completions', 'google-generative-ai'].includes(v as string);
+ (MODEL_NATIVE_APIS as readonly unknown[]).includes(v);
if (key === "mode")
return typeof v === "string" && /^[a-z][a-z0-9_]{0,63}$/.test(v);
if (key === "modalities") {
diff --git a/packages/model-providers/src/modelProtocol.ts b/packages/model-providers/src/modelProtocol.ts
index 506981bad7..f88a9a6cb9 100644
--- a/packages/model-providers/src/modelProtocol.ts
+++ b/packages/model-providers/src/modelProtocol.ts
@@ -1,4 +1,5 @@
import { compatibilityProtocol } from '@cindy/model-compat/protocol';
+import { PI_MODEL_APIS } from './types.js';
import type {
AgentKind,
CatalogModel,
@@ -18,8 +19,8 @@ export function modelProtocolComparison(
) {
// 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);
+ .map((m) => m.nativeApi)
+ .filter((api): api is PiModelApi | null => api === null || PI_MODEL_APIS.some(value => value === api));
const reference: PiModelApi | null = declared.length
? new Set(declared).size === 1
? declared[0]!
diff --git a/packages/model-providers/src/modelRegistry.ts b/packages/model-providers/src/modelRegistry.ts
index 0ff1b89577..af716bb302 100644
--- a/packages/model-providers/src/modelRegistry.ts
+++ b/packages/model-providers/src/modelRegistry.ts
@@ -4,6 +4,7 @@ import {
referencePricesForRoute,
} from "./modelMetadataLayers.js";
import { modelRegistryCanonicalJson } from "./modelRegistryCanonical.js";
+import { MODEL_ACCESS_WIRE_PROTOCOLS } from './modelAccessBean.js';
import type {
ModelAccessV2Agent,
ModelPriceVariant,
@@ -23,6 +24,7 @@ export function resolveModelNativeApi(
registry: ModelRegistry | undefined,
providerId: string,
modelId: string,
+ mode?: string,
): import("./modelAccessBean.js").ModelNativeApi | null | undefined {
if (!registry) return undefined;
const rawId = modelId.replace(/\[1m\]$/, "");
@@ -52,12 +54,18 @@ export function resolveModelNativeApi(
),
];
if (explicit.length) return explicit.length === 1 ? explicit[0] : null;
+ const effectiveMode = mode ?? entries.map(entry => registryEntryDefaults(registry, entry).mode)
+ .find(value => value !== undefined) ?? findBaseModel(registry, id)?.defaults.mode;
+ // Family prefixes describe chat APIs, not every model sharing the name (e.g. gpt-*-tts).
+ // Keep media protocols unknown unless they are declared; mode is not a transport adapter.
return registry.nativeApiRules
?.filter(
(rule) =>
rule.providerId === providerId &&
id.startsWith(rule.modelIdPrefix) &&
- !id.slice(rule.modelIdPrefix.length).includes("/"),
+ !id.slice(rule.modelIdPrefix.length).includes("/") &&
+ (effectiveMode === undefined || effectiveMode === 'chat' || effectiveMode === 'responses' ||
+ !(MODEL_ACCESS_WIRE_PROTOCOLS as readonly string[]).includes(rule.nativeApi)),
)
.sort((a, b) => b.modelIdPrefix.length - a.modelIdPrefix.length)[0]
?.nativeApi;
@@ -71,6 +79,7 @@ export function resolveModelNativeApi(
export function resolveCatalogModelNativeApi(
registry: ModelRegistry | undefined,
modelId: string,
+ mode?: string,
): import("./modelAccessBean.js").ModelNativeApi | null | undefined {
if (!registry) return undefined;
const base = findBaseModel(registry, modelId);
@@ -86,7 +95,8 @@ export function resolveCatalogModelNativeApi(
));
if (declarations.size) return declarations.size === 1 ? [...declarations][0] : null;
const canonicalId = base?.id ?? modelId;
- const declared = resolveModelNativeApi(registry, 'xd', canonicalId);
+ const effectiveMode = mode ?? (target ? registryEntryDefaults(registry, target).mode : base?.defaults.mode);
+ const declared = resolveModelNativeApi(registry, 'xd', canonicalId, effectiveMode);
if (declared !== undefined) return declared;
if (canonicalId.includes('/')) return undefined;
// Direct catalogs may omit the vendor namespace (gemini-*, claude-*, qwen*).
@@ -95,7 +105,7 @@ export function resolveCatalogModelNativeApi(
const slash = rule.modelIdPrefix.lastIndexOf('/');
const prefix = rule.modelIdPrefix.slice(slash + 1);
return rule.providerId === 'xd' && slash >= 0 && prefix && canonicalId.startsWith(prefix)
- ? [{ prefix, nativeApi: resolveModelNativeApi(registry, 'xd', `${rule.modelIdPrefix.slice(0, slash + 1)}${canonicalId}`) }]
+ ? [{ prefix, nativeApi: resolveModelNativeApi(registry, 'xd', `${rule.modelIdPrefix.slice(0, slash + 1)}${canonicalId}`, effectiveMode) }]
: [];
}) ?? [];
const longest = Math.max(0, ...rules.map(rule => rule.prefix.length));
diff --git a/packages/model-providers/src/types.ts b/packages/model-providers/src/types.ts
index 66337c3357..00fb414149 100644
--- a/packages/model-providers/src/types.ts
+++ b/packages/model-providers/src/types.ts
@@ -309,7 +309,7 @@ export interface CatalogModel {
discoveredCost?: ModelCost;
nameExplicit?: boolean;
/** Canonical model API from the accepted Registry; null explicitly means unverified. */
- nativeApi?: PiModelApi | null;
+ nativeApi?: PiModelApi | import('./modelAccessBean.js').ModelNativeApi | 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/user-provider.ts b/packages/model-providers/src/user-provider.ts
index 6fe525cfe9..9026dbc5e6 100644
--- a/packages/model-providers/src/user-provider.ts
+++ b/packages/model-providers/src/user-provider.ts
@@ -612,9 +612,9 @@ export function buildUserProvider(
const registry = options.modelRegistry ?? undefined;
const resolveDeclaration = (source: ModelRegistry | undefined) => {
const baseModel = findBaseModel(source, m.id);
- const routeNativeApi = resolveModelNativeApi(source, config.id, m.id);
+ const routeNativeApi = resolveModelNativeApi(source, config.id, m.id, projected.mode);
return routeNativeApi !== undefined ? routeNativeApi
- : resolveCatalogModelNativeApi(source, baseModel?.id ?? m.id);
+ : resolveCatalogModelNativeApi(source, baseModel?.id ?? m.id, projected.mode);
};
const projected = toCatalogModel(
m,
@@ -631,9 +631,10 @@ export function buildUserProvider(
const declaration = currentDeclaration !== undefined ? currentDeclaration
: projected.nativeApi !== undefined ? projected.nativeApi
: resolveDeclaration(BUNDLED_CATALOG.modelRegistry);
- const nativeApi = declaration === null || declaration === 'anthropic-messages'
- || declaration === 'openai-responses' || declaration === 'openai-completions'
- || declaration === 'google-generative-ai' ? declaration : undefined;
+ // Media declarations are metadata too; dropping them here loses the connection's
+ // speech protocol before audioModels is projected. This does not enable execution.
+ const nativeApi = providerMediaField(projected.mode) && projected.nativeApi !== undefined
+ ? projected.nativeApi : declaration;
return {
...(imported?.cost ? { cost: imported.cost } : {}),
...projected,