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

vertex-catalog.test.ts

168 lines5.6 KB

1import { describe, expect, it } from 'vitest'
2​
3import {
4 parseCard,
5 parseLocationModels,
6 parseThinking,
7 vertexActivity,
8 vertexEndpoint,
9} from './vertex-catalog.ts'
10​
11const LOCATIONS = `
12<h2 id="google-models" data-text="Google model endpoint locations">Google model endpoint locations</h2>
13<a href="/gemini-enterprise-agent-platform/models/gemini/3-1-pro">Gemini 3.1 Pro</a>
14<code>(gemini-3.1-pro-preview)</code>
15<a href="/gemini-enterprise-agent-platform/models/gemini/3-5-transcribe">Transcribe</a>
16<code>(['gemini-3.5-transcribe', 'gemini-3.5-transcribe-live'])</code>
17<code>(chirp_3)</code>
18<a href="/speech-to-text/docs/models/chirp-3">Chirp</a>
19<h2 id="genai-partner-models">Google Cloud partner model endpoint locations</h2>
20<a href="/gemini-enterprise-agent-platform/models/partner-models/claude">Claude</a>
21<code>(claude-sonnet-4-5)</code>
23​
24const CARD = `
25<h1 class="devsite-page-title">
26 Gemini 3.1 Pro<devsite-actions hidden data-nosnippet>
27 <span slot="popout-heading">Stay organized with collections</span>
28 <span slot="popout-contents">Save and categorize content based on your preferences.</span>
29 </devsite-actions>
30</h1>
31<p>Model ID</p>
32<p>gemini-3.1-pro-preview</p>
33<p>Modalities</p>
34<p>description</p><p>Text</p><p>Input and output</p>
35<p>photo</p><p>Image</p><p>Input only</p>
36<p>mic</p><p>Audio</p><p>Not supported</p>
37<p>Token limits</p>
38<p>Context window</p><p>1,048,576</p>
39<p>Maximum output tokens</p><p>65,536</p>
40<p>Capabilities</p>
41<p>Thinking</p><p>Supported</p>
42<p>Structured output</p><p>Supported</p>
43<p>URL context</p><p>Supported</p>
44<p>Tools</p>
45<p>Grounding</p>
46<p>Google Search, Parallel Web Search</p>
47<p>Supported</p>
48<p>Code execution</p><p>Supported</p>
49<p>Function calling</p><p>Supported</p>
50<p>Computer use</p><p>preview</p><p>Preview feature</p><p>Not supported</p>
51<p>Consumption options</p>
52<p>Temperature: 0.0-2.0 (default 1.0)</p>
53<p>topP: 0.0-1.0 (default 0.95)</p>
54<p>topK: 64 (fixed)</p>
55<p>Versions</p>
56<p>gemini-3.1-pro-preview</p>
57<p>Launch stage: Public preview</p>
58<p>Release date: February 19, 2026</p>
59<p>gemini-3.1-pro-preview-customtools*</p>
60<p>Launch stage: Public preview</p>
61<p>Release date: February 23, 2026</p>
62<p>Send feedback</p>
64​
65const THINKING = `
66<table>
67<tr><th>Model</th><th>Supported thinking_level values</th><th>Default</th></tr>
68<tr><td>Gemini 3.1 Pro preview</td><td>LOW , MEDIUM , HIGH</td><td>HIGH</td></tr>
69<tr><td>Gemini 3 Pro Image</td><td>HIGH</td><td>HIGH</td></tr>
70</table>
71<table>
72<tr><th>Model</th><th>Minimum tokens</th><th>Maximum tokens</th></tr>
73<tr><td>Gemini 2.5 Flash</td><td>1</td><td>24,576</td></tr>
74<tr><td>Gemini 2.5 Pro</td><td>128</td><td>32,768</td></tr>
75</table>
76<p>You can turn off thinking for Gemini 2.5 Flash and Gemini 2.5 Flash-Lite by setting thinking_budget to 0.</p>
77<p>You can't turn off thinking for Gemini 2.5 Pro.</p>
79​
80describe('vertex locations', () => {
81 it('reads Google model ids and drops Chirp and partner models', () => {
82 expect(parseLocationModels(LOCATIONS)).toEqual([
83 {
84 rawId: 'gemini-3.1-pro-preview',
85 cardPath: '/gemini-enterprise-agent-platform/models/gemini/3-1-pro',
86 },
87 {
88 rawId: 'gemini-3.5-transcribe',
89 cardPath:
90 '/gemini-enterprise-agent-platform/models/gemini/3-5-transcribe',
91 },
92 {
93 rawId: 'gemini-3.5-transcribe-live',
94 cardPath:
95 '/gemini-enterprise-agent-platform/models/gemini/3-5-transcribe',
96 },
97 ])
98 })
99})
100​
101describe('vertex model card', () => {
102 it('reads limits, modalities, tools, and version dates', () => {
103 const card = parseCard(CARD)
104 expect(card.title).toBe('Gemini 3.1 Pro')
105 expect(card.modelId).toBe('gemini-3.1-pro-preview')
106 expect(card.contextWindow).toBe(1_048_576)
107 expect(card.maxOutput).toBe(65_536)
108 expect(card.modalities).toEqual({
109 input: ['text', 'image'],
110 output: ['text'],
111 })
112 expect(card.capabilities).toEqual([
113 'structured_outputs',
114 'tools',
115 'temperature',
116 'top_p',
117 'top_k',
118 ])
119 expect(card.serverTools).toEqual([
120 'googleSearch',
121 'codeExecution',
122 'urlContext',
123 ])
124 expect(card.thinkingSupported).toBe(true)
125 expect(card.versions).toEqual([
126 {
127 rawId: 'gemini-3.1-pro-preview',
128 releasedAt: Date.UTC(2026, 1, 19) / 1000,
129 deprecated: false,
130 },
131 {
132 rawId: 'gemini-3.1-pro-preview-customtools',
133 releasedAt: Date.UTC(2026, 1, 23) / 1000,
134 deprecated: false,
135 },
136 ])
137 })
138})
139​
140describe('vertex thinking', () => {
141 it('maps thinking_level and which 2.5 models can disable a budget', () => {
142 const thinking = parseThinking(THINKING)
143 expect(thinking.effort.get('gemini 3 1 pro')).toEqual([
144 'LOW',
145 'MEDIUM',
146 'HIGH',
147 ])
148 expect(thinking.effort.get('gemini 3 pro image')).toEqual(['HIGH'])
149 expect(thinking.budgetOff.has('gemini 2 5 flash')).toBe(true)
150 expect(thinking.budgetOff.has('gemini 2 5 flash lite')).toBe(true)
151 expect(thinking.budgetOn.has('gemini 2 5 pro')).toBe(true)
152 })
153})
154​
155describe('vertex routes', () => {
156 it('binds generation, predict, and embed by id', () => {
157 expect(vertexActivity('gemini-3.1-pro-preview')).toBe('chat')
158 expect(vertexActivity('gemini-3-pro-image')).toBe('image')
159 expect(vertexActivity('veo-3.1-generate-001')).toBe('video')
160 expect(vertexActivity('gemini-embedding-001')).toBe('embeddings')
161 expect(vertexActivity('gemini-2.5-flash-tts')).toBe('audio')
162 expect(vertexEndpoint('virtual-try-on-001')).toContain(':predict')
163 expect(vertexEndpoint('veo-3.1-generate-001')).toContain(
164 ':predictLongRunning',
165 )
166 expect(vertexEndpoint('gemini-3-pro-image')).toContain(':generateContent')
167 })
168})