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

model-features.test.ts

807 lines29.7 KB

1import { describe, expect, it } from 'vitest'
2​
3import {
4 anthropicReasoning,
5 anthropicSampling,
6 anthropicServerTools,
7 parseThinkingTable,
8} from './anthropic-features.ts'
9import {
10 GEMINI_MODELS_INDEX_URL,
11 GEMINI_THINKING_URL,
12 familyOf,
13 geminiModelFeatures,
14 parseModelIndexDocs,
15 parsePageModalities,
16 parsePageSections,
17 parsePageThinking,
18 parsePageTools,
19 parseThinkingBudgets,
20 parseThinkingPage,
21} from './gemini-features.ts'
22import { GEMINI_LIVE_GUIDE_URL } from './gemini-live-thinking.ts'
23import { grokReasoningGap, parseGrokReasoning } from './grok.ts'
24​
25describe('anthropic features (issue #77)', () => {
26 const table = `| Model | Thinking types | Default | Rejected with 400 |
27| --------------------- | -------------------------------- | --------- | -------------------------- |
28| Claude Fable 5.1 | Adaptive only | Always on | \`"enabled"\`, \`"disabled"\` |
29| Claude Opus 5 | Adaptive only | On | \`"enabled"\`, \`"disabled"\`2 |
30| Claude Sonnet 4.5 | Extended only | Off | \`"adaptive"\` |`
31​
32 it('reads "Always on" as thinking that cannot be turned off', () => {
33 expect([...parseThinkingTable(table)]).toEqual([
34 ['claude fable 5.1', true],
35 ['claude opus 5', false],
36 ['claude sonnet 4.5', false],
37 ])
38 })
39​
40 it('prefers adaptive, falls back to budget, lists supported efforts', () => {
41 const effort = {
42 supported: true,
43 low: { supported: true },
44 max: { supported: false },
45 }
46 expect(
47 anthropicReasoning(
48 {
49 thinking: {
50 supported: true,
51 types: {
52 enabled: { supported: true },
53 adaptive: { supported: true },
54 },
55 },
56 effort,
57 },
58 true,
59 ),
60 ).toEqual({ mode: 'adaptive', mandatory: true, efforts: ['low'] })
61 expect(
62 anthropicReasoning(
63 {
64 thinking: {
65 supported: true,
66 types: {
67 enabled: { supported: true },
68 adaptive: { supported: false },
69 },
70 },
71 },
72 false,
73 ),
74 ).toEqual({ mode: 'budget', mandatory: false })
75 expect(anthropicReasoning({ thinking: { supported: false } }, false)).toBe(
76 null,
77 )
78 })
79​
80 it('gives every model the unrestricted tools, listed models the rest', () => {
81 const opus = anthropicServerTools('claude-opus-5-5')
82 expect(opus.serverTools).toContain('web_search_20250305')
83 expect(opus.serverTools).toContain('computer_toolset_20260801')
84 expect(opus.serverTools).not.toContain('computer_20251124')
85 expect(opus.sources.web_search_20250305?.sourceUrl).toMatch(
86 /web-search-tool$/,
87 )
88 const unknown = anthropicServerTools('claude-new-model')
89 expect(unknown.serverTools).toContain('bash_20250124')
90 expect(unknown.serverTools).not.toContain('code_execution_20250825')
91 })
92​
93 it('states sampling support for the ids the migration guides name', () => {
94 for (const id of [
95 'claude-sonnet-5-5',
96 'claude-opus-5-5',
97 'claude-fable-5-1',
98 ]) {
99 expect(anthropicSampling(id).unsupported).toContain('temperature')
100 expect(anthropicSampling(id).supported).toEqual([])
101 }
102 for (const id of [
103 'claude-sonnet-4-5-20250929',
104 'claude-haiku-4-5-20251001',
105 ]) {
106 expect(anthropicSampling(id).supported).toEqual([
107 'temperature',
108 'top_p',
109 'top_k',
110 ])
111 }
112 expect(
113 anthropicSampling('claude-haiku-4-5-20251001').sources.temperature
114 ?.sourceUrl,
115 ).toMatch(/haiku-5-5\/migration-guide$/)
116 const none = anthropicSampling('claude-new-model')
117 expect([none.supported, none.unsupported, none.sources]).toEqual([
118 [],
119 [],
120 {},
121 ])
122 })
123})
124​
125describe('gemini features (issue #77)', () => {
126 const thinking = `You cannot disable thinking for Gemini 3.1 Pro. Gemini 3 Flash and Flash-Lite also do not support full thinking-off.
127​
128| Thinking Level | Gemini 3.8 \\& 3.7 Flash | Gemini 3.1 Pro | Description |
129|---|---|---|---|
130| **\`minimal\`** | Not supported (error) | Not supported | x |
131| **\`low\`** | Supported | Supported | x |
132| **\`high\`** | Supported (Dynamic) | Supported (Default, Dynamic) | x |
133​
134| Model | Default setting (Thinking budget is not set) | Range | Disable thinking | Turn on dynamic thinking |
135|---|---|---|---|---|
136| **2.5 Pro** | Dynamic thinking | \`128\` to \`32768\` | N/A: Cannot disable thinking | \`thinkingBudget = -1\` (Default) |
137| **2.5 Flash** | Dynamic thinking | \`0\` to \`24576\` | \`thinkingBudget = 0\` | \`thinkingBudget = -1\` (Default) |
138| **Robotics-ER 1.6 Preview** | Dynamic thinking | \`0\` to \`24576\` | \`thinkingBudget = 0\` | \`thinkingBudget = -1\` (Default) |
139| **2.5 Flash Live Native Audio Preview (09-2025)** | Dynamic thinking | \`0\` to \`24576\` | \`thinkingBudget = 0\` | \`thinkingBudget = -1\` (Default) |`
140​
141 it('keys levels by family column and budgets by family row', () => {
142 const parsed = parseThinkingPage(thinking)
143 expect(parsed.get('gemini-3.7-flash')).toEqual({
144 mode: 'effort',
145 mandatory: null,
146 efforts: ['low', 'high'],
147 })
148 expect(parsed.get('gemini-3.8-flash')).toEqual({
149 mode: 'effort',
150 mandatory: null,
151 efforts: ['low', 'high'],
152 })
153 expect(parsed.get('gemini-3.1-pro')).toEqual({
154 mode: 'effort',
155 mandatory: true,
156 efforts: ['low', 'high'],
157 })
158 expect(parsed.get('gemini-2.5-pro')).toEqual({
159 mode: 'budget',
160 mandatory: true,
161 })
162 expect(parsed.get('gemini-2.5-flash')).toEqual({
163 mode: 'budget',
164 mandatory: false,
165 })
166 expect(parsed.get('gemini-2.5-flash-native-audio-preview-09-2025')).toEqual(
167 { mode: 'budget', mandatory: false },
168 )
169 expect(parsed.get('gemini-2.5-flash-native-audio-latest')).toBeUndefined()
170 expect(
171 parsed.get('gemini-2.5-flash-live-native-audio-preview'),
172 ).toBeUndefined()
173 expect(parsed.get('gemini-robotics-er-1.6-preview')).toBeUndefined()
174 expect(
175 parseThinkingBudgets(thinking).get(
176 'gemini-2.5-flash-native-audio-preview-09-2025',
177 ),
178 ).toEqual({ on: -1, off: 0 })
179 expect(parseThinkingBudgets(thinking).get('gemini-2.5-pro')).toEqual({
180 on: -1,
181 off: null,
182 })
183 expect(parseThinkingBudgets(thinking).get('gemini-2.5-flash')).toEqual({
184 on: -1,
185 off: 0,
186 })
187 })
188​
189 it('sets mandatory only for families the prose says cannot turn thinking off', () => {
190 const page = `You cannot disable thinking for Gemini 3.1 Pro. Gemini 3 Flash and Flash-Lite also do not support full thinking-off.
191​
192| Thinking Level | Gemini 3 Flash | Gemini 3.1 Flash-Lite | Gemini 3.6 \\& 3.5 Flash | Gemini Robotics ER 2 | Description |
193|---|---|---|---|---|---|
194| **\`minimal\`** | Supported | Supported | Supported | Supported | x |
195| **\`low\`** | Supported | Supported | Supported | Supported | x |
196| **\`medium\`** | Supported | Supported | Supported | Supported | x |
197| **\`high\`** | Supported | Supported | Supported | Supported | x |`
198 const parsed = parseThinkingPage(page)
199 const efforts = ['minimal', 'low', 'medium', 'high']
200 expect(parsed.get('gemini-3-flash')).toEqual({
201 mode: 'effort',
202 mandatory: true,
203 efforts,
204 })
205 expect(parsed.get('gemini-3.1-flash-lite')).toEqual({
206 mode: 'effort',
207 mandatory: true,
208 efforts,
209 })
210 for (const id of [
211 'gemini-3.6-flash',
212 'gemini-3.5-flash',
213 'gemini-robotics-er-2',
214 ]) {
215 expect(parsed.get(id)).toEqual({
216 mode: 'effort',
217 mandatory: null,
218 efforts,
219 })
220 }
221 })
222​
223 it('resolves ids to the longest family they version, never a sibling', () => {
224 const families = ['gemini-2.5-flash', 'gemini-2.5-flash-lite']
225 expect(familyOf('gemini-2.5-flash-lite-preview-09-2025', families)).toBe(
226 'gemini-2.5-flash-lite',
227 )
228 expect(familyOf('gemini-2.5-flash-001', families)).toBe('gemini-2.5-flash')
229 expect(familyOf('gemini-2.5-flash-image', families)).toBeNull()
230 })
231​
232 it('does not invent a mode when the thinking tables omit the id', () => {
233 const parsed = parseThinkingPage(thinking)
234 expect(
235 familyOf('gemini-2.5-computer-use-preview-10-2025', parsed.keys()),
236 ).toBeNull()
237 expect(familyOf('deep-research-preview-04-2026', parsed.keys())).toBeNull()
238 })
239​
240 it('reads the Supported data types row, or nothing', () => {
241 const row = (cells: string) => `x\n| Supported data types | ${cells} |\n`
242 expect(
243 parsePageModalities(
244 row('**Inputs** Audio, images, video, text, and PDF **Output** Text'),
245 ),
246 ).toEqual({
247 input: ['text', 'image', 'audio', 'video', 'file'],
248 output: ['text'],
249 })
250 expect(
251 parsePageModalities(
252 row(
253 '**Inputs** Audio (speech) **Output** Audio (translated speech) and Text (transcript)',
254 ),
255 ),
256 ).toEqual({ input: ['audio'], output: ['text', 'audio'] })
257 // A word that is not a medium leaves the whole fact unknown.
258 expect(
259 parsePageModalities(row('**Input** Text **Output** Text embeddings')),
260 ).toBeNull()
261 expect(
262 parsePageModalities(
263 row('**Input** Text, Image **Output** Video with audio'),
264 ),
265 ).toBeNull()
266 expect(parsePageModalities('| Capabilities | x |')).toBeNull()
267 // A parenthetical is dropped as a qualifier unless it names a medium.
268 expect(
269 parsePageModalities(
270 row(
271 '**Input** Text, Image, Video (up to 10s for editing) **Output** Audio (MP3), Text (Lyrics)',
272 ),
273 ),
274 ).toEqual({ input: ['text', 'image', 'video'], output: ['text', 'audio'] })
275 expect(
276 parsePageModalities(
277 row('**Inputs** Text (and Image, Audio) **Output** Text'),
278 ),
279 ).toBeNull()
280 expect(
281 parsePageModalities(row('**Inputs** Text **Output** Text (or images)')),
282 ).toBeNull()
283 expect(
284 parsePageModalities(
285 row('**Inputs** Text (short videos) **Output** Text'),
286 ),
287 ).toBeNull()
288 // Timestamp metadata is not a medium. The other words still count.
289 expect(
290 parsePageModalities(
291 row(
292 '**Inputs** Audio (up to 1 hour) **Output** Text, Word annotations',
293 ),
294 ),
295 ).toEqual({ input: ['audio'], output: ['text'] })
296 expect(
297 parsePageModalities(row('**Inputs** Audio **Output** Word annotations')),
298 ).toBeNull()
299 })
300​
301 describe('model pages', () => {
302 const INDEX = 'https://aistudio.google.com/docs/models'
303 const page = (types: string) =>
304 `| Supported data types | ${types} |\n| Capabilities | **[Search grounding](u)** Supported |\n`
305 const withPages = async <T>(
306 pages: Record<string, string | null>,
307 run: () => Promise<T>,
308 options?: {
309 index?: string
310 thinking?: string
311 extras?: Record<string, string | null | 404>
312 },
313 ): Promise<T> => {
314 const original = globalThis.fetch
315 const indexBody =
316 options?.index ??
317 Object.keys(pages)
318 .map((name) => `${INDEX}/${name}`)
319 .join('\n')
320 const thinkingBody = options?.thinking ?? thinking
321 const extras = options?.extras ?? {}
322 globalThis.fetch = ((url: string) => {
323 const href = String(url)
324 const slug = href.match(/\/models\/([^/]+)\.md$/)?.[1]
325 const extra = Object.keys(extras).find((key) => href.endsWith(key))
326 const body = href.endsWith('/thinking.md?generate-content=true')
327 ? thinkingBody
328 : slug && Object.hasOwn(pages, slug)
329 ? pages[slug]
330 : extra
331 ? extras[extra]
332 : indexBody
333 return Promise.resolve(
334 typeof body === 'string'
335 ? new Response(body)
336 : body === 404
337 ? new Response('not found', { status: 404 })
338 : new Response('upstream down', { status: 503 }),
339 )
340 }) as typeof fetch
341 try {
342 return await run()
343 } finally {
344 globalThis.fetch = original
345 }
346 }
347​
348 it('keeps stored facts, and records the failure, when a page fails to load', async () => {
349 const { features, docsFailures } = await withPages(
350 {
351 'gemini-2.5-flash': page('**Inputs** Text, images **Output** Text'),
352 'gemini-2.5-flash-lite': null,
353 },
354 () =>
355 geminiModelFeatures([
356 'gemini-2.5-flash',
357 'gemini-2.5-flash-lite',
358 'gemma-4-31b-it',
359 ]),
360 )
361 expect(features('gemini-2.5-flash', false)).toMatchObject({
362 modalities: { input: ['text', 'image'], output: ['text'] },
363 serverTools: ['googleSearch'],
364 factSources: {
365 modalities: {
366 derivation: 'docs-derived',
367 sourceUrl: `${INDEX}/gemini-2.5-flash.md`,
368 path: 'Supported data types',
369 },
370 },
371 })
372 expect(features('gemini-2.5-flash', false).absent).toBeUndefined()
373 // The page that failed: the poll keeps what is stored, and the row is
374 // not handed to the `gemini-2.5-flash` page that did load.
375 expect(features('gemini-2.5-flash-lite', false)).toMatchObject({
376 modalities: null,
377 serverTools: null,
378 absent: { modalities: 'unavailable', serverTools: 'unavailable' },
379 })
380 expect(docsFailures.failed).toBe(1)
381 expect(docsFailures.first[0]?.source).toBe(
382 `${INDEX}/gemini-2.5-flash-lite.md`,
383 )
384 // No page at all is a plain unknown.
385 expect(features('gemma-4-31b-it', false).absent).toBeUndefined()
386 })
387​
388 it('keeps stored page facts when the models index parses no slugs (#567)', async () => {
389 const { features, docsFailures } = await withPages(
390 { 'gemini-2.5-flash': page('**Inputs** Text **Output** Text') },
391 () => geminiModelFeatures(['gemini-2.5-flash']),
392 { index: 'The docs moved.' },
393 )
394 expect(features('gemini-2.5-flash', true)).toMatchObject({
395 modalities: null,
396 serverTools: null,
397 absent: { modalities: 'unavailable', serverTools: 'unavailable' },
398 })
399 expect(
400 features('gemini-2.5-flash', true).absent?.reasoning,
401 ).toBeUndefined()
402 expect(docsFailures.first).toEqual([
403 expect.objectContaining({
404 source: GEMINI_MODELS_INDEX_URL,
405 error: 'gemini models index: 0 slugs',
406 }),
407 ])
408 })
409​
410 it('keeps stored native audio reasoning when the live guide fails (#568)', async () => {
411 const id = 'gemini-2.5-flash-native-audio-preview-12-2025'
412 const { features, docsFailures } = await withPages(
413 { [id]: page('**Inputs** Text, audio **Output** Text, audio') },
414 () => geminiModelFeatures([id]),
415 { extras: { '/live-api/capabilities.md': null } },
416 )
417 expect(features(id, true)).toMatchObject({
418 modalities: { input: ['text', 'audio'], output: ['text', 'audio'] },
419 reasoning: null,
420 absent: { reasoning: 'unavailable' },
421 })
422 expect(docsFailures.first).toEqual([
423 expect.objectContaining({ source: GEMINI_LIVE_GUIDE_URL }),
424 ])
425 })
426​
427 it('keeps stored reasoning when the thinking page parses nothing (#567)', async () => {
428 const { features, docsFailures, thinkingLoaded } = await withPages(
429 { 'gemini-2.5-flash': page('**Inputs** Text **Output** Text') },
430 () => geminiModelFeatures(['gemini-2.5-flash']),
431 { thinking: '' },
432 )
433 expect(thinkingLoaded).toBe(false)
434 expect(features('gemini-2.5-flash', true)).toMatchObject({
435 modalities: { input: ['text'], output: ['text'] },
436 serverTools: ['googleSearch'],
437 reasoning: null,
438 absent: { reasoning: 'unavailable' },
439 })
440 expect(features('gemini-2.5-flash', false).absent).toBeUndefined()
441 expect(docsFailures.first).toEqual([
442 expect.objectContaining({
443 source: GEMINI_THINKING_URL,
444 error: 'gemini thinking page: parsed 0 model rows',
445 }),
446 ])
447 })
448​
449 it('refuses a poll in which no page that loaded states modalities', async () => {
450 await expect(
451 withPages(
452 {
453 'gemini-2.5-flash': '| Supported modalities | Text |',
454 'gemini-2.5-pro': '| Supported modalities | Text |',
455 },
456 () => geminiModelFeatures(['gemini-2.5-flash', 'gemini-2.5-pro']),
457 ),
458 ).rejects.toThrow('gemini model pages: 0 of 2 state modalities')
459 })
460​
461 it('reads a model page the index does not link, by its own id (#409)', async () => {
462 const own = (code: string) =>
463 `## ${code}\n\n| Model code | \`${code}\` |\n${page('**Inputs** Text **Output** Text')}`
464 const { features, docsFailures } = await withPages(
465 { 'gemini-2.5-flash': page('**Inputs** Text **Output** Text') },
466 () =>
467 geminiModelFeatures([
468 'gemini-2.5-flash',
469 'gemini-3.5-flash',
470 'gemini-3.7-flash',
471 'gemini-flash-latest',
472 ]),
473 {
474 extras: {
475 '/models/gemini-3.5-flash.md': own('gemini-3.5-flash'),
476 // A page that names another model binds nothing to this id.
477 '/models/gemini-3.7-flash.md': own('gemini-9-flash'),
478 '/models/gemini-flash-latest.md': 404,
479 },
480 },
481 )
482 expect(features('gemini-3.5-flash', false)).toMatchObject({
483 serverTools: ['googleSearch'],
484 factSources: {
485 serverTools: {
486 googleSearch: {
487 sourceUrl: `${INDEX}/gemini-3.5-flash.md`,
488 path: 'Capabilities',
489 },
490 },
491 },
492 })
493 expect(features('gemini-3.7-flash', false).serverTools).toBeNull()
494 expect(features('gemini-flash-latest', false)).toMatchObject({
495 serverTools: null,
496 modalities: null,
497 })
498 expect(docsFailures.failed).toBe(0)
499 })
500​
501 it('maps Supported capabilities to generateContent tool fields', () => {
502 const row =
503 '| Capabilities | **[Code execution](u)** Supported **[Computer use](u)** Supported (Preview) **[File search](u)** Not supported **[Search grounding](u)** Supported **[Thinking](u)** Supported |'
504 expect(parsePageTools(`x\n${row}\n`)).toEqual([
505 'codeExecution',
506 'computerUse',
507 'googleSearch',
508 ])
509 })
510​
511 it('leaves tools empty when the page marks none supported', () => {
512 const row =
513 '| Capabilities | **[Code execution](u)** Not supported **[Search grounding](u)** Not supported |'
514 expect(parsePageTools(`x\n${row}\n`)).toEqual([])
515 })
516​
517 it('reads backtick thinking levels and drops a level the same paragraph rejects', () => {
518 expect(
519 parsePageThinking(
520 'Configurable Thinking levels (`minimal`, `medium` default, and `high`).',
521 ),
522 ).toEqual({
523 mode: 'effort',
524 mandatory: null,
525 efforts: ['minimal', 'medium', 'high'],
526 })
527 expect(
528 parsePageThinking(
529 'Configure background reasoning using `thinking_config` (`thinking_level`: `low`, `medium`, or `high`). Note that `MINIMAL` is not supported.',
530 ),
531 ).toEqual({
532 mode: 'effort',
533 mandatory: null,
534 efforts: ['low', 'medium', 'high'],
535 })
536 expect(
537 parsePageThinking(
538 'Thinking levels (`low`, `high`). You cannot disable thinking for this model.',
539 )?.mandatory,
540 ).toBe(true)
541 expect(
542 parsePageThinking('generation_config.thinking_level: "high"'),
543 ).toBeNull()
544 expect(
545 parsePageThinking(
546 'Thinking levels (`low`).\n\nThinking levels (`high`).',
547 ),
548 ).toBeNull()
549 })
550​
551 it('binds endpoint ids on the models index and version ids on the page', () => {
552 const index = [
553 '| [Gemini Omni Flash](https://aistudio.google.com/docs/models/gemini-omni-flash) | ``` gemini-omni-1.1-flash ``` |',
554 '| [Gemini 3.1 Pro](https://aistudio.google.com/docs/models/gemini-3.1-pro-preview) | ``` gemini-3.1-pro-preview ``` |',
555 '| [Gemini Robotics ER 2](https://aistudio.google.com/docs/robotics-overview) | ``` gemini-robotics-er-2-preview ``` |',
556 'https://aistudio.google.com/docs/models/gemini-2.5-flash',
557 ].join('\n')
558 const docs = parseModelIndexDocs(index)
559 expect(docs).toEqual([
560 {
561 url: 'https://aistudio.google.com/docs/models/gemini-omni-flash',
562 ids: ['gemini-omni-1.1-flash'],
563 },
564 {
565 url: 'https://aistudio.google.com/docs/models/gemini-3.1-pro-preview',
566 ids: ['gemini-3.1-pro-preview'],
567 },
568 {
569 url: 'https://aistudio.google.com/docs/robotics-overview',
570 ids: ['gemini-robotics-er-2-preview'],
571 },
572 {
573 url: 'https://aistudio.google.com/docs/models/gemini-2.5-flash',
574 ids: [],
575 },
576 ])
577 const omni = `## gemini-omni-1.1-flash\n| Model code | **Gemini API** \`gemini-omni-1.1-flash\` |\n| Supported data types | **Input** Text, Image, Video (up to 10s for editing and extension) **Output** Video |\n| Versions | - Stable: \`gemini-omni-1.1-flash\` - Preview: \`gemini-omni-flash-preview\` |`
578 const pro = `## gemini-3.1-pro-preview\n| Model code | \`gemini-3.1-pro-preview\` |\n| Supported data types | **Inputs** Text **Output** Text |\n| Versions | - Preview: \`gemini-3.1-pro-preview\` - Preview: \`gemini-3.1-pro-preview-customtools\` |`
579 const overview = [
580 '### Gemini Robotics ER 2 Preview',
581 '| Model code | `gemini-robotics-er-2-preview` |',
582 '| Supported data types | **Inputs** Text, images, video, audio **Output** Text |',
583 'generation_config={"thinking_level": "high"}',
584 '### Gemini Robotics ER 2 Streaming Preview',
585 '| Model code | `gemini-robotics-er-2-streaming-preview` |',
586 '| Supported data types | **Inputs** Audio **Output** Text |',
587 ].join('\n')
588 const sections = parsePageSections(overview)
589 expect(sections.map((section) => section.ids)).toEqual([
590 ['gemini-robotics-er-2-preview'],
591 ['gemini-robotics-er-2-streaming-preview'],
592 ])
593 expect(parsePageThinking(overview)).toBeNull()
594 return withPages(
595 {
596 'gemini-omni-flash': omni,
597 'gemini-3.1-pro-preview': pro,
598 'gemini-2.5-flash':
599 '| Supported data types | **Inputs** Text **Output** Text |',
600 },
601 async () => {
602 const { features } = await geminiModelFeatures([
603 'gemini-omni-1.1-flash',
604 'gemini-omni-flash-preview',
605 'gemini-3.1-pro-preview',
606 'gemini-3.1-pro-preview-customtools',
607 'gemini-robotics-er-2-preview',
608 'gemini-robotics-er-2-streaming-preview',
609 ])
610 expect(features('gemini-omni-1.1-flash', false).modalities).toEqual({
611 input: ['text', 'image', 'video'],
612 output: ['video'],
613 })
614 expect(
615 features('gemini-omni-flash-preview', false).modalities?.output,
616 ).toEqual(['video'])
617 expect(
618 features('gemini-3.1-pro-preview-customtools', false).modalities,
619 ).toEqual({ input: ['text'], output: ['text'] })
620 expect(
621 features('gemini-robotics-er-2-preview', false).modalities?.input,
622 ).toEqual(['text', 'image', 'audio', 'video'])
623 expect(
624 features('gemini-robotics-er-2-streaming-preview', false)
625 .modalities,
626 ).toEqual({ input: ['audio'], output: ['text'] })
627 expect(
628 features('gemini-robotics-er-2-streaming-preview', true).reasoning,
629 ).toBeNull()
630 },
631 {
632 index,
633 extras: { '/robotics-overview.md': overview },
634 },
635 )
636 })
637​
638 it('uses native page thinking levels even when listing omits its flag', () => {
639 const body = [
640 '- Configurable Thinking levels (`minimal`, `medium` default, and `high`).',
641 '## gemini-nano-banana-2.1',
642 '| Model code | `gemini-nano-banana-2.1` |',
643 '| Supported data types | **Inputs** Text, Image **Output** Image and Text |',
644 ].join('\n')
645 return withPages({ 'gemini-nano-banana-2.1': body }, async () => {
646 const { features } = await geminiModelFeatures([
647 'gemini-nano-banana-2.1',
648 ])
649 expect(features('gemini-nano-banana-2.1', true)).toMatchObject({
650 reasoning: {
651 mode: 'effort',
652 mandatory: null,
653 efforts: ['minimal', 'medium', 'high'],
654 },
655 factSources: {
656 reasoning: {
657 path: 'thinking level',
658 sourceUrl: `${INDEX}/gemini-nano-banana-2.1.md`,
659 },
660 },
661 })
662 expect(features('gemini-nano-banana-2.1', undefined).reasoning).toEqual(
663 features('gemini-nano-banana-2.1', true).reasoning,
664 )
665 })
666 })
667​
668 it('keeps the dedicated model-code page when a versions row repeats the id', async () => {
669 const index = [
670 '| [Gemini 3.5 Flash](https://aistudio.google.com/docs/models/gemini-3.5-flash) | ``` gemini-3.5-flash ``` |',
671 '| [Gemini 3 Flash](https://aistudio.google.com/docs/models/gemini-3-flash-preview) | ``` gemini-3-flash-preview ``` |',
672 ].join('\n')
673 const flash35 = [
674 '## gemini-3.5-flash',
675 '| Model code | `gemini-3.5-flash` |',
676 '| Versions | - Stable: `gemini-3.5-flash` - Preview: `gemini-3-flash-preview` |',
677 '| Supported data types | **Inputs** Audio **Output** Text |',
678 ].join('\n')
679 const flash3 = [
680 '## gemini-3-flash-preview',
681 '| Model code | `gemini-3-flash-preview` |',
682 '| Supported data types | **Inputs** Text **Output** Text |',
683 ].join('\n')
684 const { features } = await withPages(
685 {
686 'gemini-3.5-flash': flash35,
687 'gemini-3-flash-preview': flash3,
688 },
689 () =>
690 geminiModelFeatures(['gemini-3.5-flash', 'gemini-3-flash-preview']),
691 { index },
692 )
693 expect(features('gemini-3-flash-preview', false).modalities).toEqual({
694 input: ['text'],
695 output: ['text'],
696 })
697 expect(features('gemini-3.5-flash', false).modalities).toEqual({
698 input: ['audio'],
699 output: ['text'],
700 })
701 })
702​
703 it('lets a looked-up page repeat a sibling another page states', async () => {
704 const index = [
705 '| [Gemini Robotics ER 2](https://aistudio.google.com/docs/robotics-overview) | ``` gemini-robotics-er-2-preview ``` |',
706 `${INDEX}/gemini-2.5-flash`,
707 ].join('\n')
708 const section = (id: string, types: string) =>
709 `### ${id}\n| Model code | \`${id}\` |\n| Supported data types | ${types} |\n`
710 const overview = section(
711 'gemini-robotics-er-2-preview',
712 '**Inputs** Text, images **Output** Text',
713 )
714 // Google's family page repeats the sibling's table above its own.
715 const streaming = [
716 section(
717 'gemini-robotics-er-2-preview',
718 '**Inputs** Text, images **Output** Text',
719 ),
720 section(
721 'gemini-robotics-er-2-streaming-preview',
722 '**Inputs** Audio **Output** Text',
723 ),
724 section(
725 'gemini-robotics-er-1.6-preview',
726 '**Inputs** Video **Output** Text',
727 ),
728 ].join('\n')
729 const { features } = await withPages(
730 {},
731 () =>
732 geminiModelFeatures([
733 'gemini-robotics-er-2-preview',
734 'gemini-robotics-er-2-streaming-preview',
735 'gemini-robotics-er-1.6-preview',
736 ]),
737 {
738 index,
739 extras: {
740 '/robotics-overview.md': overview,
741 '/models/gemini-robotics-er-2-streaming-preview.md': streaming,
742 '/models/gemini-robotics-er-1.6-preview.md': 404,
743 },
744 },
745 )
746 expect(features('gemini-robotics-er-2-preview', false)).toMatchObject({
747 modalities: { input: ['text', 'image'], output: ['text'] },
748 factSources: {
749 modalities: {
750 sourceUrl: 'https://aistudio.google.com/docs/robotics-overview.md',
751 },
752 },
753 })
754 expect(
755 features('gemini-robotics-er-2-streaming-preview', false).modalities,
756 ).toEqual({ input: ['audio'], output: ['text'] })
757 // A sibling no other page states still binds from the repeat.
758 expect(
759 features('gemini-robotics-er-1.6-preview', false).modalities,
760 ).toEqual({ input: ['video'], output: ['text'] })
761 })
762​
763 it('refuses a model id that two pages both document', async () => {
764 const documented = (id: string) =>
765 `## ${id}\n| Model code | \`${id}\` |\n| Supported data types | **Inputs** Text **Output** Text |\n`
766 await expect(
767 withPages(
768 {
769 'gemini-a': documented('shared-id'),
770 'gemini-b': documented('shared-id'),
771 },
772 () => geminiModelFeatures(['gemini-a', 'gemini-b']),
773 ),
774 ).rejects.toThrow('gemini model pages: shared-id is documented twice')
775 })
776 })
777})
778​
779describe('grok reasoning (issue #77)', () => {
780 const page = (lines: string) =>
781 `# Grok\n\n## Capabilities\n\n${lines}\n\n## Pricing\n`
782 it('reads efforts; none means reasoning can be turned off', () => {
783 expect(
784 parseGrokReasoning(
785 page(
786 '- **Reasoning:** Yes\n- **Reasoning efforts (supported):** `low`, `high`',
787 ),
788 ),
789 ).toEqual({ mode: 'effort', mandatory: true, efforts: ['low', 'high'] })
790 expect(
791 parseGrokReasoning(
792 page(
793 '- **Reasoning:** Yes\n- **Reasoning efforts (supported):** `none`, `low`',
794 ),
795 )?.mandatory,
796 ).toBe(false)
797 })
798​
799 it('stays null without a documented knob or without reasoning', () => {
800 const yes = page('- **Reasoning:** Yes')
801 expect(parseGrokReasoning(yes)).toBeNull()
802 expect(grokReasoningGap(yes)).toBe('silent')
803 const no = page('- **Reasoning:** No')
804 expect(parseGrokReasoning(no)).toBeNull()
805 expect(grokReasoningGap(no)).toBeNull()
806 })
807})