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

feature-support.ts

325 lines11.5 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 'ollama',
16 'groq',
17 'grok',
18 'bedrock',
19 'bedrock-responses',
20 'openrouter',
21 'openai-compatible',
22 'mistral',
23 'byteplus',
24 ]),
25 'one-shot-text': new Set([
26 'openai',
27 'anthropic',
28 'gemini',
29 'ollama',
30 'groq',
31 'grok',
32 'bedrock',
33 'bedrock-responses',
34 'openrouter',
35 'openai-compatible',
36 'mistral',
37 'byteplus',
38 ]),
39 // BytePlus streams its reasoning trace as `delta.reasoning_content`, which is
40 // exactly the field aimock's OpenAI-compatible chunk builder emits for a
41 // fixture's `reasoning` channel — so the adapter's `extractReasoning`
42 // override is exercised end-to-end against the shared fixture.
43 reasoning: new Set(['openai', 'anthropic', 'gemini', 'mistral', 'byteplus']),
44 'multi-turn': new Set([
45 'openai',
46 'anthropic',
47 'gemini',
48 'ollama',
49 'groq',
50 'grok',
51 'bedrock',
52 'bedrock-responses',
53 'openrouter',
54 'openai-compatible',
55 'mistral',
56 'byteplus',
57 ]),
58 'tool-calling': new Set([
59 'openai',
60 'anthropic',
61 'gemini',
62 'ollama',
63 'groq',
64 'grok',
65 'bedrock',
66 'bedrock-responses',
67 'openrouter',
68 'openrouter-responses',
69 'openai-compatible',
70 'mistral',
71 'byteplus',
72 ]),
73 'parallel-tool-calls': new Set([
74 'openai',
75 'anthropic',
76 'gemini',
77 'groq',
78 'grok',
79 'bedrock',
80 'bedrock-responses',
81 'openrouter',
82 'openai-compatible',
83 'mistral',
84 'byteplus',
85 ]),
86 // Gemini excluded: approval flow timing issues with Gemini's streaming format
87 'tool-approval': new Set([
88 'openai',
89 'anthropic',
90 'ollama',
91 'groq',
92 'grok',
93 'bedrock',
94 'bedrock-responses',
95 'openrouter',
96 'openai-compatible',
97 'mistral',
98 'byteplus',
99 ]),
100 // Ollama excluded: aimock doesn't support content+toolCalls for /api/chat format
101 'text-tool-text': new Set([
102 'openai',
103 'anthropic',
104 'gemini',
105 'groq',
106 'grok',
107 'bedrock',
108 'bedrock-responses',
109 'openrouter',
110 'openai-compatible',
111 'mistral',
112 'byteplus',
113 ]),
114 'structured-output': new Set([
115 'openai',
116 'anthropic',
117 'gemini',
118 'ollama',
119 'groq',
120 'grok',
121 'bedrock',
122 'bedrock-responses',
123 'openrouter',
124 'openai-compatible',
125 'mistral',
126 'byteplus',
127 ]),
128 // Streaming structured output: only providers with native streaming JSON
129 // schema support are listed here. Other providers fall back to the
130 // activity-layer `fallbackStructuredOutputStream` (which wraps the
131 // non-streaming `structuredOutput`) but aren't exercised by E2E yet.
132 'structured-output-stream': new Set([
133 'openai',
134 'groq',
135 'grok',
136 'bedrock',
137 'bedrock-responses',
138 'openrouter',
139 'openai-compatible',
140 'byteplus',
141 ]),
142 // Multi-turn structured output: every turn produces its own typed
143 // `structured-output` part on the assistant message, and historical
144 // turns stay renderable. Works for every provider that supports both
145 // multi-turn and structured-output — non-native-streaming adapters
146 // (anthropic, gemini, ollama) fall back to a single
147 // `structured-output.complete` event per turn, but the per-message
148 // typed part still lands and the round-trip is identical.
149 // Anthropic temporarily excluded — multi-turn structured output regresses
150 // when the engine takes the #605 native-combined path on Claude 4.5+ (the
151 // 2nd turn's rendered structured-output part shows the 1st turn's
152 // content). Other native-combined providers (openai) still pass here,
153 // so the regression appears Anthropic-specific. Likely an interaction
154 // between the assistant message's text-content shape (post-#605) and
155 // either useChat's part rendering or aimock's response routing for the
156 // multi-turn shape. Tracking via follow-up issue; the single-turn
157 // anthropic structured-output and structured-output-stream entries
158 // (where applicable) continue to pass and are sufficient validation
159 // for #605's native combined mode landing.
160 'multi-turn-structured': new Set([
161 'openai',
162 'gemini',
163 'ollama',
164 'groq',
165 'grok',
166 'bedrock',
167 'bedrock-responses',
168 'openrouter',
169 'openai-compatible',
170 'byteplus',
171 ]),
172 'agentic-structured': new Set([
173 'openai',
174 'anthropic',
175 'gemini',
176 'ollama',
177 'groq',
178 'grok',
179 'bedrock',
180 'bedrock-responses',
181 'openrouter',
182 'openai-compatible',
183 'mistral',
184 'byteplus',
185 ]),
186 // Native-combined-mode adapters only. Each provider's default test model
187 // (or per-feature override in `features.ts`) must opt into combined mode
188 // — otherwise the engine takes the legacy finalization path, which makes
189 // an extra request that this feature's fixture doesn't model.
190 'agentic-structured-stream': new Set([
191 'openai',
192 'anthropic',
193 'gemini',
194 'grok',
195 'byteplus',
196 ]),
197 // Bedrock excluded: the default e2e model (openai.gpt-oss-120b) is text-only
198 // (input: ['text'], no vision) — image input isn't supported, so the
199 // multimodal request never carries the image and the description comes back empty.
200 // Mistral excluded: mistral-large-latest is text-only; vision requires pixtral
201 'multimodal-image': new Set([
202 'openai',
203 'anthropic',
204 'gemini',
205 'grok',
206 'openrouter',
207 'byteplus',
208 ]),
209 // Bedrock excluded: same text-only default e2e model as multimodal-image above.
210 'multimodal-structured': new Set([
211 'openai',
212 'anthropic',
213 'gemini',
214 'grok',
215 'openrouter',
216 'byteplus',
217 ]),
218 // byteplus excluded: @tanstack/ai-byteplus ships no summarize adapter —
219 // Ark has no summarization endpoint, and api.summarize.ts builds a
220 // dedicated `create*Summarize` adapter per provider rather than reusing the
221 // chat adapter. Add both entries here if a Seed summarize adapter lands.
222 summarize: new Set([
223 'openai',
224 'anthropic',
225 'gemini',
226 'ollama',
227 'groq',
228 'grok',
229 'bedrock',
230 'bedrock-responses',
231 'openrouter',
232 'mistral',
233 ]),
234 'summarize-stream': new Set([
235 'openai',
236 'anthropic',
237 'gemini',
238 'ollama',
239 'groq',
240 'grok',
241 'bedrock',
242 'bedrock-responses',
243 'openrouter',
244 'mistral',
245 ]),
246 // Embedding (Promise-based `embed()` activity, no streaming). aimock 1.34
247 // natively mocks OpenAI's /v1/embeddings (JSON fixture in
248 // fixtures/embedding/). The other providers run through custom mounts in
249 // global-setup.ts: Gemini because @google/genai posts to
250 // `:batchEmbedContents` (aimock only handles `:embedContent`); Ollama
251 // because aimock's /api/embed handler returns the legacy singular
252 // `embedding` field, not the `embeddings: number[][]` shape the ollama SDK
253 // `embed()` expects; Mistral because its SDK Zod-validates the response and
254 // requires an `id` field aimock's OpenAI-format builder omits.
255 embedding: new Set(['openai', 'gemini', 'ollama', 'mistral']),
256 // Gemini excluded: aimock doesn't mock Gemini's Imagen predict endpoint format
257 'image-gen': new Set(['openai', 'grok', 'byteplus']),
258 // image-to-image (image parts in the generateImage prompt). aimock 1.29
259 // mocks OpenAI's multipart `/v1/images/edits` (matches on the `prompt` form
260 // field, ignores the binary image/mask fields), so the OpenAI route runs
261 // end-to-end. Other providers route to endpoints aimock doesn't mock yet
262 // (Gemini multimodal `generateContent`, xAI's JSON `/v1/images/edits`,
263 // OpenRouter multimodal chat content parts, fal endpoint-specific input
264 // fields) — their mapping is covered by unit tests. Add them here when
265 // aimock support lands.
266 // byteplus excluded: Seedream edits through the same /images/generations
267 // endpoint (reference images ride an `image` array in the JSON body), so
268 // there is no `/v1/images/edits` request for this spec's journal assertion
269 // to find. The reference-image mapping is unit-tested instead.
270 'image-to-image': new Set(['openai']),
271 // byteplus excluded: BytePlus has no music/audio generation product —
272 // Seed Speech is TTS + ASR only.
273 'audio-gen': new Set(['gemini', 'elevenlabs']),
274 // byteplus excluded: no sound-effects endpoint (see audio-gen above).
275 'sound-effects': new Set(['elevenlabs']),
276 tts: new Set(['openai', 'gemini', 'grok', 'elevenlabs', 'byteplus']),
277 transcription: new Set(['openai', 'grok', 'groq', 'elevenlabs', 'byteplus']),
278 // byteplus excluded: this spec asserts named-speaker segments
279 // (`agent`/`customer`), which is OpenAI's `diarized_json` shape. Seed ASR's
280 // nearest equivalent is `enable_speaker_info`, whose response shape is
281 // unverified — it couldn't be probed live without the Seed Speech voice key
282 // — and the adapter reads speaker labels defensively out of an utterance's
283 // `additions` for that reason. Revisit once the shape is confirmed.
284 'transcription-diarization': new Set(['openai']),
285 // Gemini Veo runs through a custom aimock mount (see geminiVeoMount in
286 // global-setup.ts) — aimock 1.29 doesn't model the long-running
287 // `:predictLongRunning` + operations-polling pair natively.
288 // BytePlus Seedance uses its own create→poll task API
289 // (POST/GET /api/v3/contents/generations/tasks), mounted as
290 // byteplusSeedanceMount in global-setup.ts for the same reason.
291 'video-gen': new Set(['openai', 'gemini', 'byteplus']),
292 // image-to-video (image parts in the generateVideo prompt). aimock 1.29's
293 // `/v1/videos` handler parses Sora's multipart upload (the SDK switches to
294 // multipart when `input_reference` carries a File) and matches on the
295 // `prompt` form field, so the OpenAI/Sora route runs end-to-end. fal's
296 // endpoint-specific fields and Gemini Veo's image/lastFrame/referenceImages
297 // routing remain unit-test-only (the spec's journal assertion is tied to
298 // aimock's /v1/videos pipeline, which custom mounts bypass).
299 // byteplus excluded: Seedance takes its opening frame as a `first_frame`
300 // role inside the task body's `content[]`, so the spec's assertion that a
301 // multipart POST /v1/videos carried the prompt can't hold. The role mapping
302 // is unit-tested instead.
303 'image-to-video': new Set(['openai']),
304 // Gemini Omni Flash video generation over the Interactions API. Runs
305 // through a dedicated aimock mount (see geminiOmniVideoMount in
306 // global-setup.ts) — aimock handles synchronous text interactions natively
307 // but not background video jobs (create → poll → inline base64 mp4).
308 // byteplus excluded: Ark has no Interactions-style API — Seedance video is
309 // the task API covered by video-gen above.
310 'interactions-video': new Set(['gemini']),
311 // Only Gemini currently surfaces a first-class stateful conversation API via
312 // the adapter (geminiTextInteractions, behind @tanstack/ai-gemini/experimental).
313 // byteplus excluded for the same reason: Ark's chat endpoint is stateless.
314 'stateful-interactions': new Set(['gemini']),
316​
317export function isSupported(provider: Provider, feature: Feature): boolean {
318 return matrix[feature]?.has(provider) ?? false
320​
321export function getSupportedFeatures(provider: Provider): Feature[] {
322 return (Object.entries(matrix) as Array<[Feature, Set<Provider>]>)
323 .filter(([_, providers]) => providers.has(provider))
324 .map(([feature]) => feature)