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