Open History to see the last commit
1import type { Provider, Feature } from '@/lib/types'
2
3/**
4 * Single source of truth for provider × feature support.
5 *
6 * This matrix is imported by `tests/test-matrix.ts` (Playwright specs) and
7 * by the dev routes under `src/routes/` to decide which provider/feature
8 * combinations to render and test. Update this file only — do not fork.
9 */
10export const matrix: Record<Feature, Set<Provider>> = {
11 chat: new Set([
12 'openai',
13 'anthropic',
14 'gemini',
15 'vertex',
16 'vertex-grok',
17 'vertex-mistral',
18 'ollama',
19 'groq',
20 'grok',
21 'bedrock',
22 'bedrock-responses',
23 'openrouter',
24 'vercel-gateway',
25 'lovable',
26 'openai-compatible',
27 'mistral',
28 'byteplus',
29 'llmgateway',
30 'cloudflare',
31 ]),
32 'one-shot-text': new Set([
33 'openai',
34 'anthropic',
35 'gemini',
36 'vertex',
37 'vertex-grok',
38 'vertex-mistral',
39 'ollama',
40 'groq',
41 'grok',
42 'bedrock',
43 'bedrock-responses',
44 'openrouter',
45 'vercel-gateway',
46 'lovable',
47 'openai-compatible',
48 'mistral',
49 'byteplus',
50 'llmgateway',
51 'cloudflare',
52 ]),
53 // BytePlus and LLM Gateway both stream their reasoning trace as
54 // `delta.reasoning_content`, which is exactly the field aimock's
55 // OpenAI-compatible chunk builder emits for a fixture's `reasoning` channel —
56 // so each adapter's `extractReasoning` override is exercised end-to-end
57 // against the shared fixture.
58 // `openai-compatible-legacy` re-keys aimock's reasoning frames to the
59 // pre-July-2025 `response.reasoning.delta` event name that OpenAI-compatible
60 // endpoints frozen on the older spec still emit (see providers.ts), pinning
61 // openai-base's legacy-event mapping end-to-end. Reasoning-only on purpose.
62 reasoning: new Set([
63 'openai',
64 'anthropic',
65 'gemini',
66 'vertex',
67 'mistral',
68 'byteplus',
69 'llmgateway',
70 'cloudflare',
71 'openai-compatible-legacy',
72 ]),
73 'multi-turn': new Set([
74 'openai',
75 'anthropic',
76 'gemini',
77 'vertex',
78 'vertex-grok',
79 'vertex-mistral',
80 'ollama',
81 'groq',
82 'grok',
83 'bedrock',
84 'bedrock-responses',
85 'openrouter',
86 'vercel-gateway',
87 'lovable',
88 'openai-compatible',
89 'mistral',
90 'byteplus',
91 'llmgateway',
92 'cloudflare',
93 ]),
94 'tool-calling': new Set([
95 'openai',
96 'anthropic',
97 'gemini',
98 'vertex',
99 'vertex-grok',
100 'vertex-mistral',
101 'ollama',
102 'groq',
103 'grok',
104 'bedrock',
105 'bedrock-responses',
106 'openrouter',
107 'openrouter-responses',
108 'vercel-gateway',
109 'vercel-gateway-responses',
110 'lovable',
111 'lovable-responses',
112 'openai-compatible',
113 'mistral',
114 'byteplus',
115 'llmgateway',
116 'cloudflare',
117 ]),
118 // OpenAI only: aimock's journal keeps `tool_choice` for Responses requests,
119 // but stores Anthropic requests in OpenAI shape without it. Anthropic is
120 // covered by `/api/tool-choice-wire`, which captures the request body.
121 'tool-choice': new Set(['openai']),
122 'parallel-tool-calls': new Set([
123 'openai',
124 'anthropic',
125 'gemini',
126 'vertex',
127 'vertex-grok',
128 'vertex-mistral',
129 'groq',
130 'grok',
131 'bedrock',
132 'bedrock-responses',
133 'openrouter',
134 'vercel-gateway',
135 'lovable',
136 'openai-compatible',
137 'mistral',
138 'byteplus',
139 'llmgateway',
140 'cloudflare',
141 ]),
142 // Gemini excluded: approval flow timing issues with Gemini's streaming format
143 // Vertex uses the same Gemini stream, so it is excluded for the same reason.
144 'tool-approval': new Set([
145 'openai',
146 'anthropic',
147 'ollama',
148 'groq',
149 'grok',
150 'vertex-grok',
151 'vertex-mistral',
152 'bedrock',
153 'bedrock-responses',
154 'openrouter',
155 'vercel-gateway',
156 'lovable',
157 'openai-compatible',
158 'mistral',
159 'byteplus',
160 'llmgateway',
161 'cloudflare',
162 ]),
163 // Ollama excluded: aimock doesn't support content+toolCalls for /api/chat format
164 'text-tool-text': new Set([
165 'openai',
166 'anthropic',
167 'gemini',
168 'vertex',
169 'vertex-grok',
170 'vertex-mistral',
171 'groq',
172 'grok',
173 'bedrock',
174 'bedrock-responses',
175 'openrouter',
176 'vercel-gateway',
177 'lovable',
178 'openai-compatible',
179 'mistral',
180 'byteplus',
181 'llmgateway',
182 'cloudflare',
183 ]),
184 'structured-output': new Set([
185 'openai',
186 'anthropic',
187 'gemini',
188 'vertex',
189 'vertex-grok',
190 'vertex-mistral',
191 'ollama',
192 'groq',
193 'grok',
194 'bedrock',
195 'bedrock-responses',
196 'openrouter',
197 'vercel-gateway',
198 'lovable',
199 'openai-compatible',
200 'mistral',
201 'byteplus',
202 'llmgateway',
203 'cloudflare',
204 ]),
205 // Streaming structured output: only providers with native streaming JSON
206 // schema support are listed here. Other providers fall back to the
207 // activity-layer `fallbackStructuredOutputStream` (which wraps the
208 // non-streaming `structuredOutput`) but aren't exercised by E2E yet.
209 'structured-output-stream': new Set([
210 'openai',
211 'gemini',
212 'groq',
213 'grok',
214 'vertex-grok',
215 'bedrock',
216 'bedrock-responses',
217 'openrouter',
218 'vercel-gateway',
219 'lovable',
220 'openai-compatible',
221 'byteplus',
222 'llmgateway',
223 'cloudflare',
224 ]),
225 // Multi-turn structured output: every turn produces its own typed
226 // `structured-output` part on the assistant message, and historical
227 // turns stay renderable. Works for every provider that supports both
228 // multi-turn and structured-output — non-native-streaming adapters
229 // (gemini, ollama) fall back to a single `structured-output.complete`
230 // event per turn, but the per-message typed part still lands and the
231 // round-trip is identical.
232 // Anthropic is the one provider that breaks visibly when the structured
233 // part stops round-tripping into assistant content (#613), so it stays in
234 // this set; `tests/anthropic-multi-turn-structured-wire.spec.ts` pins the
235 // wire shape behind it.
236 'multi-turn-structured': new Set([
237 'openai',
238 'anthropic',
239 'gemini',
240 'vertex',
241 'vertex-grok',
242 'ollama',
243 'groq',
244 'grok',
245 'bedrock',
246 'bedrock-responses',
247 'openrouter',
248 'vercel-gateway',
249 'lovable',
250 'openai-compatible',
251 'byteplus',
252 'llmgateway',
253 'cloudflare',
254 ]),
255 'agentic-structured': new Set([
256 'openai',
257 'anthropic',
258 'gemini',
259 'vertex',
260 'vertex-grok',
261 'vertex-mistral',
262 'ollama',
263 'groq',
264 'grok',
265 'bedrock',
266 'bedrock-responses',
267 'openrouter',
268 'vercel-gateway',
269 'lovable',
270 'openai-compatible',
271 'mistral',
272 'byteplus',
273 'llmgateway',
274 'cloudflare',
275 ]),
276 // Native-combined-mode adapters only. Each provider's default test model
277 // (or per-feature override in `features.ts`) must opt into combined mode
278 // — otherwise the engine takes the legacy finalization path, which makes
279 // an extra request that this feature's fixture doesn't model.
280 // openrouter and openrouter-responses both default to openai/gpt-4o,
281 // which is in OPENROUTER_COMBINED_TOOLS_AND_SCHEMA_MODELS.
282 'agentic-structured-stream': new Set([
283 'openai',
284 'anthropic',
285 'gemini',
286 'vertex',
287 'grok',
288 'vertex-grok',
289 'openrouter',
290 'openrouter-responses',
291 'byteplus',
292 ]),
293 // Bedrock excluded: the default e2e model (openai.gpt-oss-120b) is text-only
294 // (input: ['text'], no vision) — image input isn't supported, so the
295 // multimodal request never carries the image and the description comes back empty.
296 // Mistral API default e2e model (mistral-large-latest) is text-only.
297 // vertex-mistral uses mistral-medium-3, which accepts image input.
298 'multimodal-image': new Set([
299 'openai',
300 'anthropic',
301 'gemini',
302 'vertex',
303 'grok',
304 'vertex-grok',
305 'vertex-mistral',
306 'openrouter',
307 'byteplus',
308 'llmgateway',
309 'cloudflare',
310 ]),
311 // OpenAI only: this feature exercises the Responses adapter's PDF
312 // `input_file` conversion (base64 `file_data` + filename).
313 'multimodal-document': new Set(['openai']),
314 // Bedrock excluded: same text-only default e2e model as multimodal-image above.
315 'multimodal-structured': new Set([
316 'openai',
317 'anthropic',
318 'gemini',
319 'vertex',
320 'grok',
321 'vertex-grok',
322 'vertex-mistral',
323 'openrouter',
324 'byteplus',
325 'llmgateway',
326 'cloudflare',
327 ]),
328 // byteplus excluded: @tanstack/ai-byteplus ships no summarize adapter —
329 // Ark has no summarization endpoint, and api.summarize.ts builds a
330 // dedicated `create*Summarize` adapter per provider rather than reusing the
331 // chat adapter. Add both entries here if a Seed summarize adapter lands.
332 summarize: new Set([
333 'openai',
334 'anthropic',
335 'gemini',
336 'vertex',
337 'vertex-grok',
338 'vertex-mistral',
339 'ollama',
340 'groq',
341 'grok',
342 'bedrock',
343 'bedrock-responses',
344 'openrouter',
345 'vercel-gateway',
346 'lovable',
347 'mistral',
348 'llmgateway',
349 'cloudflare',
350 ]),
351 'summarize-stream': new Set([
352 'openai',
353 'anthropic',
354 'gemini',
355 'vertex',
356 'vertex-grok',
357 'vertex-mistral',
358 'ollama',
359 'groq',
360 'grok',
361 'bedrock',
362 'bedrock-responses',
363 'openrouter',
364 'vercel-gateway',
365 'lovable',
366 'mistral',
367 'llmgateway',
368 'cloudflare',
369 ]),
370 // Embedding (Promise-based `embed()` activity, no streaming). aimock 1.34
371 // natively mocks OpenAI's /v1/embeddings (JSON fixture in
372 // fixtures/embedding/). The other providers run through custom mounts in
373 // global-setup.ts: Gemini because @google/genai posts to
374 // `:batchEmbedContents` (aimock only handles `:embedContent`); Ollama
375 // because aimock's /api/embed handler returns the legacy singular
376 // `embedding` field, not the `embeddings: number[][]` shape the ollama SDK
377 // `embed()` expects; Mistral because its SDK Zod-validates the response and
378 // requires an `id` field aimock's OpenAI-format builder omits.
379 // Vertex excluded: aimock's Vertex handler only covers
380 // generateContent / streamGenerateContent. Vertex embed uses a
381 // different path (`:predict` / `:batchEmbedContents` under
382 // /v1/projects/…), so it cannot reuse the Gemini /v1beta mount.
383 embedding: new Set([
384 'openai',
385 'gemini',
386 'ollama',
387 'mistral',
388 'vercel-gateway',
389 'lovable',
390 ]),
391 // Gemini excluded: aimock doesn't mock Gemini's Imagen predict endpoint format
392 // vercel-gateway uses POST /v1/images/generations, the same path aimock
393 // already mocks for openai. Drop this entry if the first run has no fixture.
394 'image-gen': new Set([
395 'openai',
396 'grok',
397 'byteplus',
398 'vercel-gateway',
399 'lovable',
400 ]),
401 // image-to-image (image parts in the generateImage prompt). aimock 1.29
402 // mocks OpenAI's multipart `/v1/images/edits` (matches on the `prompt` form
403 // field, ignores the binary image/mask fields), so the OpenAI route runs
404 // end-to-end. Other providers route to endpoints aimock doesn't mock yet
405 // (Gemini multimodal `generateContent`, xAI's JSON `/v1/images/edits`,
406 // OpenRouter multimodal chat content parts, fal endpoint-specific input
407 // fields) — their mapping is covered by unit tests. Add them here when
408 // aimock support lands.
409 // byteplus excluded: Seedream edits through the same /images/generations
410 // endpoint (reference images ride an `image` array in the JSON body), so
411 // there is no `/v1/images/edits` request for this spec's journal assertion
412 // to find. The reference-image mapping is unit-tested instead.
413 'image-to-image': new Set(['openai', 'lovable']),
414 // byteplus excluded: BytePlus has no music/audio generation product —
415 // Seed Speech is TTS + ASR only.
416 // Vertex excluded for the same media-path reason as embedding: the
417 // Gemini TTS / Veo / Lyria / Interactions mounts live under /v1beta.
418 // Vertex posts those activities to /v1/projects/… instead.
419 'audio-gen': new Set(['gemini', 'elevenlabs']),
420 // byteplus excluded: no sound-effects endpoint (see audio-gen above).
421 'sound-effects': new Set(['elevenlabs']),
422 tts: new Set([
423 'openai',
424 'gemini',
425 'grok',
426 'elevenlabs',
427 'byteplus',
428 'lovable',
429 ]),
430 // ElevenLabs is the only adapted provider with a voice-creation API.
431 // xAI's POST /v1/custom-voices and fal's clone endpoints are the obvious
432 // next two — add them here when their adapters implement generateVoice.
433 // aimock has no /v1/text-to-voice routes, so this runs against
434 // `elevenlabsVoiceMount` in global-setup.ts.
435 'voice-design': new Set(['elevenlabs']),
436 transcription: new Set([
437 'openai',
438 'grok',
439 'groq',
440 'elevenlabs',
441 'byteplus',
442 'lovable',
443 ]),
444 // byteplus excluded: this spec asserts named-speaker segments
445 // (`agent`/`customer`), which is OpenAI's `diarized_json` shape. Seed ASR's
446 // nearest equivalent is `enable_speaker_info`, whose response shape is
447 // unverified — it couldn't be probed live without the Seed Speech voice key
448 // — and the adapter reads speaker labels defensively out of an utterance's
449 // `additions` for that reason. Revisit once the shape is confirmed.
450 'transcription-diarization': new Set(['openai']),
451 // Gemini Veo runs through a custom aimock mount (see geminiVeoMount in
452 // global-setup.ts) — aimock 1.29 doesn't model the long-running
453 // `:predictLongRunning` + operations-polling pair natively.
454 // BytePlus Seedance uses its own create→poll task API
455 // (POST/GET /api/v3/contents/generations/tasks), mounted as
456 // byteplusSeedanceMount in global-setup.ts for the same reason.
457 // OpenRouter excluded: aimock mocks its async video API since 1.38, but
458 // answers `POST /api/v1/videos` with 200 and the official SDK accepts
459 // only 202, so job creation fails
460 // (https://github.com/CopilotKit/aimock/issues/491). The adapter's
461 // submit/poll/download lifecycle is covered by unit tests
462 // (packages/ai-openrouter/tests/video-adapter.test.ts). When that is
463 // fixed, bump aimock and add it here.
464 'video-gen': new Set(['openai', 'gemini', 'byteplus', 'lovable']),
465 // image-to-video (image parts in the generateVideo prompt). aimock 1.29's
466 // `/v1/videos` handler parses Sora's multipart upload (the SDK switches to
467 // multipart when `input_reference` carries a File) and matches on the
468 // `prompt` form field, so the OpenAI/Sora route runs end-to-end. fal's
469 // endpoint-specific fields, Gemini Veo's image/lastFrame/referenceImages
470 // routing, and OpenRouter's `frame_images` / `input_references` mapping
471 // remain unit-test-only (the spec's journal assertion is tied to aimock's
472 // /v1/videos pipeline, which custom mounts bypass).
473 // byteplus excluded: Seedance takes its opening frame as a `first_frame`
474 // role inside the task body's `content[]`, so the spec's assertion that a
475 // multipart POST /v1/videos carried the prompt can't hold. The role mapping
476 // is unit-tested instead.
477 'image-to-video': new Set(['openai', 'lovable']),
478 // Gemini Omni Flash video generation over the Interactions API. Runs
479 // through a dedicated aimock mount (see geminiOmniVideoMount in
480 // global-setup.ts) — aimock handles synchronous text interactions natively
481 // but not background video jobs (create → poll → inline base64 mp4).
482 // byteplus excluded: Ark has no Interactions-style API — Seedance video is
483 // the task API covered by video-gen above.
484 'interactions-video': new Set(['gemini']),
485 // Only Gemini currently surfaces a first-class stateful conversation API via
486 // the adapter (geminiTextInteractions, behind @tanstack/ai-gemini/experimental).
487 // byteplus excluded for the same reason: Ark's chat endpoint is stateless.
488 'stateful-interactions': new Set(['gemini']),
489 // Gemini-only. Agentic video understanding: a video content part with
490 // metadata.processing: 'agentic' makes geminiText route through the
491 // Interactions API (aimock serves synchronous text interactions natively;
492 // it extracts the text prompt and ignores the video block when matching).
493 'video-understanding': new Set(['gemini']),
494}
495
496export function isSupported(provider: Provider, feature: Feature): boolean {
497 return matrix[feature]?.has(provider) ?? false
498}
499
500export function getSupportedFeatures(provider: Provider): Feature[] {
501 return (Object.entries(matrix) as Array<[Feature, Set<Provider>]>)
502 .filter(([_, providers]) => providers.has(provider))
503 .map(([feature]) => feature)
504}