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