Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

feature-support.ts

500 lines15.8 KB

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