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