@tanstack/ai-gemini 0.22.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,24 @@
1
1
  import type { GeminiImageModels } from '../model-meta'
2
2
  import type {
3
+ ContentUnion,
4
+ ImageConfig,
3
5
  ImagePromptLanguage,
4
6
  PersonGeneration,
5
7
  SafetyFilterLevel,
8
+ SafetySetting,
9
+ ThinkingConfig,
6
10
  } from '@google/genai'
7
11
 
8
12
  // Re-export SDK types so users can use them directly
9
- export type { ImagePromptLanguage, PersonGeneration, SafetyFilterLevel }
13
+ export type {
14
+ ContentUnion,
15
+ ImageConfig,
16
+ ImagePromptLanguage,
17
+ PersonGeneration,
18
+ SafetyFilterLevel,
19
+ SafetySetting,
20
+ ThinkingConfig,
21
+ }
10
22
 
11
23
  /**
12
24
  * Gemini Imagen aspect ratio options
@@ -121,11 +133,80 @@ export interface GeminiImageProviderOptions {
121
133
  }
122
134
 
123
135
  /**
124
- * Model-specific provider options mapping
125
- * Currently all Imagen models use the same options structure
136
+ * Provider options for Gemini native image models (Nano Banana and friends).
137
+ *
138
+ * These models are served by `generateContent`, not `generateImages`, so they
139
+ * are configured by @google/genai's `GenerateContentConfig` — a different
140
+ * shape from the Imagen-only {@link GeminiImageProviderOptions} above. Only
141
+ * the `GenerateContentConfig` fields with clear image-generation semantics are
142
+ * surfaced; sampling knobs (`temperature`, `topK`, …) and chat-only plumbing
143
+ * (`tools`, `responseSchema`, …) are deliberately left out.
144
+ *
145
+ * `responseModalities` is intentionally absent: the adapter always requests
146
+ * `['TEXT', 'IMAGE']`, and letting a caller override it would silently disable
147
+ * image output on an image-generation call.
148
+ */
149
+ export interface GeminiNativeImageProviderOptions {
150
+ /**
151
+ * Optional seed for reproducible image generation
152
+ * When the same seed is used with the same prompt and settings,
153
+ * you should get similar (though not identical) results
154
+ */
155
+ seed?: number
156
+
157
+ /**
158
+ * Per-category safety thresholds applied to the request
159
+ * Each entry pairs a HarmCategory with a HarmBlockThreshold
160
+ */
161
+ safetySettings?: Array<SafetySetting>
162
+
163
+ /**
164
+ * Controls the model's internal reasoning before it emits an image
165
+ * Use to raise or disable the thinking budget on models that support it
166
+ */
167
+ thinkingConfig?: ThinkingConfig
168
+
169
+ /**
170
+ * Native image output controls. Merged over the values derived from the
171
+ * portable `size` option, so fields set here win per field while the rest
172
+ * of `size` is preserved.
173
+ *
174
+ * Only `aspectRatio` and `imageSize` are accepted on the Gemini Developer
175
+ * API. Other SDK `ImageConfig` keys throw on this surface.
176
+ */
177
+ imageConfig?: GeminiNativeImageConfig
178
+
179
+ /**
180
+ * System-level instructions that steer the model for the whole request,
181
+ * e.g. a house art direction applied on top of the per-call prompt
182
+ */
183
+ systemInstruction?: ContentUnion
184
+ }
185
+
186
+ /**
187
+ * Every provider-option field this adapter understands, across both API
188
+ * paths. Used as the adapter's base (model-agnostic) option type; the
189
+ * per-model map below is what narrows a given model to the half that
190
+ * actually applies to it.
191
+ */
192
+ export type GeminiAnyImageProviderOptions = GeminiImageProviderOptions &
193
+ GeminiNativeImageProviderOptions
194
+
195
+ /**
196
+ * Model-specific provider options mapping.
197
+ * Gemini native image models go through `generateContent` and take
198
+ * `GenerateContentConfig` fields; Imagen models go through `generateImages`
199
+ * and take `GenerateImagesConfig` fields. Mirrors the native/Imagen split in
200
+ * {@link GeminiImageModelSizeByName} and
201
+ * {@link GeminiImageModelInputModalitiesByName}.
126
202
  */
127
203
  export type GeminiImageModelProviderOptionsByName = {
128
- [K in GeminiImageModels]: GeminiImageProviderOptions
204
+ [K in GeminiNativeImageModels]: GeminiNativeImageProviderOptions
205
+ } & {
206
+ [K in Exclude<
207
+ GeminiImageModels,
208
+ GeminiNativeImageModels
209
+ >]: GeminiImageProviderOptions
129
210
  }
130
211
 
131
212
  /**
@@ -145,47 +226,157 @@ export type GeminiImageSize =
145
226
  | '1080x1920'
146
227
 
147
228
  /**
148
- * Aspect ratios supported by Gemini native image models (via generateContent API).
149
- * Matches the SDK's ImageConfig.aspectRatio values.
229
+ * The ten aspect ratios every Gemini native image model accepts.
230
+ *
231
+ * Note `9:21` is deliberately absent: it exists only on Vertex / Cloud and is
232
+ * rejected by the Gemini API (`generateContent`), which is the surface this
233
+ * adapter targets.
234
+ *
235
+ * @see https://ai.google.dev/gemini-api/docs/image-generation
150
236
  */
151
- export type GeminiNativeImageAspectRatio =
237
+ export type GeminiStandardImageAspectRatio =
152
238
  | '1:1'
153
239
  | '2:3'
154
240
  | '3:2'
155
241
  | '3:4'
156
242
  | '4:3'
243
+ | '4:5'
244
+ | '5:4'
157
245
  | '9:16'
158
246
  | '16:9'
159
247
  | '21:9'
160
248
 
161
249
  /**
162
- * Resolution tiers for Gemini native image models.
163
- * Matches the SDK's ImageConfig.imageSize values.
250
+ * The ten standard ratios plus the four extreme banner/strip ratios that only
251
+ * the Gemini 3.1 Flash Image models accept — 14 values, matching the
252
+ * `generateContent` `ImageConfig.aspectRatio` field union.
253
+ *
254
+ * @see https://ai.google.dev/api/generate-content
255
+ */
256
+ export type GeminiExtendedImageAspectRatio =
257
+ | GeminiStandardImageAspectRatio
258
+ | '1:4'
259
+ | '4:1'
260
+ | '1:8'
261
+ | '8:1'
262
+
263
+ /**
264
+ * Sizes for `gemini-3.1-flash-image` (and its shut-down `-preview` alias):
265
+ * all 14 aspect ratios at 512 / 1K / 2K / 4K. `512` is the wire token for the
266
+ * 0.5K tier — not `512px`, and the `K` is case-sensitive (`1k` is rejected).
267
+ */
268
+ export type Gemini31FlashImageSize =
269
+ `${GeminiExtendedImageAspectRatio}_${'512' | '1K' | '2K' | '4K'}`
270
+
271
+ /**
272
+ * Sizes for `gemini-3.1-flash-lite-image`: all 14 aspect ratios, 1K only.
273
+ * 2K and 4K are unsupported on this model.
274
+ *
275
+ * The four banner ratios (`1:4`, `4:1`, `1:8`, `8:1`) come from the Cloud
276
+ * model page. The Gemini API page states a count of 14 but does not list them.
277
+ *
278
+ * @see https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/3-1-flash-lite-image
279
+ * @see https://ai.google.dev/gemini-api/docs/models/gemini-3.1-flash-lite-image
280
+ */
281
+ export type Gemini31FlashLiteImageSize = `${GeminiExtendedImageAspectRatio}_1K`
282
+
283
+ /**
284
+ * Sizes for `gemini-3-pro-image` (and its shut-down `-preview` alias): the ten
285
+ * standard aspect ratios at 1K / 2K / 4K. Pro has no 512 tier and none of the
286
+ * extreme banner ratios on the Gemini API.
287
+ */
288
+ export type Gemini3ProImageSize =
289
+ `${GeminiStandardImageAspectRatio}_${'1K' | '2K' | '4K'}`
290
+
291
+ /**
292
+ * Sizes for `gemini-2.5-flash-image`: a bare aspect ratio with no resolution
293
+ * suffix, e.g. `'16:9'`. Google documents no `image_size` value or default for
294
+ * this model — it emits a single fixed 1024px-class output — so the adapter
295
+ * sends `imageConfig.aspectRatio` and omits `imageSize` entirely rather than
296
+ * guessing a tier the API never documented.
164
297
  */
165
- export type GeminiNativeImageResolution = '1K' | '2K' | '4K'
298
+ export type Gemini25FlashImageSize = GeminiStandardImageAspectRatio
166
299
 
167
300
  /**
168
- * Template literal size type for Gemini native image models: "16:9_4K", "1:1_2K", etc.
301
+ * `imageConfig` fields the Gemini Developer API accepts on `generateContent`.
302
+ * Other `@google/genai` `ImageConfig` keys (`personGeneration`,
303
+ * `outputMimeType`, and more) throw on this surface.
304
+ */
305
+ export type GeminiNativeImageConfig = {
306
+ aspectRatio?: GeminiExtendedImageAspectRatio
307
+ imageSize?: '512' | '1K' | '2K' | '4K'
308
+ }
309
+
310
+ /**
311
+ * Any size accepted by any Gemini native image model. Prefer the per-model
312
+ * narrowing in {@link GeminiImageModelSizeByName} — this union is the widest
313
+ * possible set and accepts combinations no single model supports.
169
314
  */
170
315
  export type GeminiNativeImageSize =
171
- `${GeminiNativeImageAspectRatio}_${GeminiNativeImageResolution}`
316
+ | Gemini31FlashImageSize
317
+ | Gemini31FlashLiteImageSize
318
+ | Gemini3ProImageSize
319
+ | Gemini25FlashImageSize
172
320
 
173
321
  /**
174
322
  * Gemini native image models that use the generateContent API path.
175
- * These models support template literal sizes (aspectRatio_resolution).
323
+ * These models take an aspect-ratio-based size rather than Imagen's
324
+ * WIDTHxHEIGHT pixel strings.
325
+ *
326
+ * This array is the single source of truth for the native/Imagen split: the
327
+ * `GeminiNativeImageModels` union and the per-model option/size/modality maps
328
+ * all derive from it. The `satisfies` clause makes a typo (or a name that
329
+ * is not a known image model) a build error rather than a phantom key on every
330
+ * per-model map.
331
+ *
332
+ * It is also the single source of truth for the adapter's runtime routing
333
+ * — see {@link isGeminiNativeImageModel}. Adding a new `gemini-*` image model
334
+ * means adding it here as well as to `GEMINI_IMAGE_MODELS` in model-meta.
335
+ * Until it is listed here it routes to the Imagen API instead and fails
336
+ * loudly on the first call, rather than silently taking the wrong option
337
+ * shape.
176
338
  */
339
+ export const GEMINI_NATIVE_IMAGE_MODELS = [
340
+ 'gemini-3.1-flash-image',
341
+ 'gemini-3.1-flash-image-preview',
342
+ 'gemini-3.1-flash-lite-image',
343
+ 'gemini-3-pro-image',
344
+ 'gemini-3-pro-image-preview',
345
+ 'gemini-2.5-flash-image',
346
+ ] as const satisfies ReadonlyArray<GeminiImageModels>
347
+
177
348
  export type GeminiNativeImageModels =
178
- | 'gemini-3.1-flash-image-preview'
179
- | 'gemini-3.1-flash-lite-image'
180
- | 'gemini-3-pro-image-preview'
181
- | 'gemini-2.5-flash-image'
349
+ (typeof GEMINI_NATIVE_IMAGE_MODELS)[number]
350
+
351
+ const NATIVE_IMAGE_MODEL_NAMES: ReadonlySet<string> = new Set(
352
+ GEMINI_NATIVE_IMAGE_MODELS,
353
+ )
182
354
 
183
355
  /**
184
- * Model-specific size options mapping.
185
- * Gemini native image models use template literal sizes, Imagen models use pixel sizes.
356
+ * Runtime counterpart to {@link GeminiNativeImageModels} — decides which of
357
+ * the two Gemini image APIs a model goes to.
358
+ *
359
+ * Membership in {@link GEMINI_NATIVE_IMAGE_MODELS}, not a `gemini-` prefix
360
+ * test, so the runtime route and the type-level split cannot drift apart. An
361
+ * id this package does not know about reaches the Imagen endpoint and fails
362
+ * there, which is the intended signal to add the model here rather than to
363
+ * have it silently take the native path with Imagen-shaped option types.
364
+ */
365
+ export function isGeminiNativeImageModel(model: string): boolean {
366
+ return NATIVE_IMAGE_MODEL_NAMES.has(model)
367
+ }
368
+
369
+ /**
370
+ * Model-specific size options mapping. Each native model gets its own ratio ×
371
+ * resolution set (they genuinely differ); Imagen models use pixel sizes.
186
372
  */
187
373
  export type GeminiImageModelSizeByName = {
188
- [K in GeminiNativeImageModels]: GeminiNativeImageSize
374
+ 'gemini-3.1-flash-image': Gemini31FlashImageSize
375
+ 'gemini-3.1-flash-image-preview': Gemini31FlashImageSize
376
+ 'gemini-3.1-flash-lite-image': Gemini31FlashLiteImageSize
377
+ 'gemini-3-pro-image': Gemini3ProImageSize
378
+ 'gemini-3-pro-image-preview': Gemini3ProImageSize
379
+ 'gemini-2.5-flash-image': Gemini25FlashImageSize
189
380
  } & {
190
381
  [K in Exclude<GeminiImageModels, GeminiNativeImageModels>]: GeminiImageSize
191
382
  }
@@ -309,13 +500,23 @@ export function validatePrompt(options: {
309
500
 
310
501
  /**
311
502
  * Parses a Gemini native image size string into its components.
312
- * Format: "aspectRatio_resolution" e.g. "16:9_4K" → { aspectRatio: "16:9", resolution: "4K" }
503
+ *
504
+ * Format: `"aspectRatio_resolution"`, e.g. `"16:9_4K"` →
505
+ * `{ aspectRatio: "16:9", resolution: "4K" }`.
506
+ *
507
+ * The resolution suffix is optional: `gemini-2.5-flash-image` takes a bare
508
+ * aspect ratio (`"16:9"` → `{ aspectRatio: "16:9" }`) because Google documents
509
+ * no `image_size` for it, and the caller must then omit `imageSize` from the
510
+ * request rather than substituting a default.
313
511
  */
314
512
  export function parseNativeImageSize(
315
513
  size: string,
316
- ): { aspectRatio: string; resolution: string } | undefined {
317
- const match = size.match(/^(\d+:\d+)_(.+)$/)
514
+ ): { aspectRatio: string; resolution?: string } | undefined {
515
+ const match = size.match(/^(\d+:\d+)(?:_(.+))?$/)
318
516
  const [, aspectRatio, resolution] = match ?? []
319
- if (aspectRatio === undefined || resolution === undefined) return undefined
320
- return { aspectRatio, resolution }
517
+ if (aspectRatio === undefined) return undefined
518
+ return {
519
+ aspectRatio,
520
+ ...(resolution !== undefined && { resolution }),
521
+ }
321
522
  }
package/src/index.ts CHANGED
@@ -28,13 +28,37 @@ export {
28
28
  } from './adapters/image'
29
29
  export type {
30
30
  GeminiImageProviderOptions,
31
+ GeminiNativeImageConfig,
32
+ GeminiNativeImageProviderOptions,
33
+ GeminiAnyImageProviderOptions,
31
34
  GeminiImageModelProviderOptionsByName,
32
35
  GeminiAspectRatio,
36
+ // Per-model size narrowing. `GeminiImageModelSizeByName` is the map
37
+ // `generateImage()` applies at the call site; the per-model aliases let you
38
+ // name a single model's set directly. `GeminiNativeImageSize` is the widest
39
+ // union across all native models — prefer the narrower types above it.
40
+ GeminiImageModelSizeByName,
41
+ GeminiStandardImageAspectRatio,
42
+ GeminiExtendedImageAspectRatio,
43
+ Gemini31FlashImageSize,
44
+ Gemini31FlashLiteImageSize,
45
+ Gemini3ProImageSize,
46
+ Gemini25FlashImageSize,
47
+ GeminiNativeImageSize,
33
48
  // Re-export SDK types for convenience
34
49
  PersonGeneration,
35
50
  SafetyFilterLevel,
36
51
  ImagePromptLanguage,
52
+ SafetySetting,
53
+ ThinkingConfig,
54
+ ImageConfig,
55
+ ContentUnion,
37
56
  } from './image/image-provider-options'
57
+ // `SafetySetting` is built from two SDK enums, and enums are values — they
58
+ // cannot travel through `export type`. Re-exported here so `safetySettings`
59
+ // is usable with only `@tanstack/ai-gemini` installed, without the consumer
60
+ // having to add `@google/genai` to their own dependencies.
61
+ export { HarmBlockThreshold, HarmCategory } from '@google/genai'
38
62
 
39
63
  // Embedding adapter - for embedding vectors
40
64
  export {
@@ -104,6 +128,10 @@ export {
104
128
  } from './model-meta'
105
129
  export { GEMINI_MODELS as GeminiTextModels } from './model-meta'
106
130
  export { GEMINI_IMAGE_MODELS as GeminiImageModels } from './model-meta'
131
+ export {
132
+ GEMINI_NATIVE_IMAGE_MODELS,
133
+ isGeminiNativeImageModel,
134
+ } from './image/image-provider-options'
107
135
  export { GEMINI_TTS_MODELS as GeminiTTSModels } from './model-meta'
108
136
  export { GEMINI_TTS_VOICES as GeminiTTSVoices } from './model-meta'
109
137
  export { GEMINI_AUDIO_MODELS as GeminiAudioModels } from './model-meta'
package/src/model-meta.ts CHANGED
@@ -118,7 +118,46 @@ const GEMINI_3_FLASH = {
118
118
  GeminiThinkingOptions
119
119
  >
120
120
 
121
+ /**
122
+ * Gemini 3 Pro Image ("Nano Banana Pro") — GA. Accepts the ten standard
123
+ * aspect ratios at 1K / 2K / 4K.
124
+ * @see https://ai.google.dev/gemini-api/docs/models/gemini-3-pro-image
125
+ */
121
126
  const GEMINI_3_PRO_IMAGE = {
127
+ name: 'gemini-3-pro-image',
128
+ max_input_tokens: 65_536,
129
+ max_output_tokens: 32_768,
130
+ knowledge_cutoff: '2025-01-01',
131
+ supports: {
132
+ input: ['text', 'image'],
133
+ output: ['text', 'image'],
134
+ capabilities: ['batch_api', 'structured_output', 'thinking'],
135
+ tools: ['google_search'],
136
+ },
137
+ pricing: {
138
+ input: {
139
+ normal: 2,
140
+ },
141
+ output: {
142
+ normal: 0.134,
143
+ },
144
+ },
145
+ } as const satisfies ModelMeta<
146
+ GeminiToolConfigOptions &
147
+ GeminiSafetyOptions &
148
+ GeminiCommonConfigOptions &
149
+ GeminiCachedContentOptions &
150
+ GeminiStructuredOutputOptions &
151
+ GeminiThinkingOptions
152
+ >
153
+
154
+ /**
155
+ * @deprecated `gemini-3-pro-image-preview` was shut down on 2026-06-25. Use
156
+ * the GA id `gemini-3-pro-image` instead — the preview id now 404s.
157
+ * Kept in the model union so existing code still compiles.
158
+ * @see https://ai.google.dev/gemini-api/docs/deprecations
159
+ */
160
+ const GEMINI_3_PRO_IMAGE_PREVIEW = {
122
161
  name: 'gemini-3-pro-image-preview',
123
162
  max_input_tokens: 65_536,
124
163
  max_output_tokens: 32_768,
@@ -146,7 +185,46 @@ const GEMINI_3_PRO_IMAGE = {
146
185
  GeminiThinkingOptions
147
186
  >
148
187
 
188
+ /**
189
+ * Gemini 3.1 Flash Image ("Nano Banana 2") — GA. The only native image model
190
+ * that accepts the four extreme banner ratios (1:4, 4:1, 1:8, 8:1) and the
191
+ * 512 (0.5K) resolution tier.
192
+ * @see https://ai.google.dev/gemini-api/docs/models/gemini-3.1-flash-image
193
+ */
149
194
  const GEMINI_3_1_FLASH_IMAGE = {
195
+ name: 'gemini-3.1-flash-image',
196
+ max_input_tokens: 131_072,
197
+ max_output_tokens: 32_768,
198
+ knowledge_cutoff: '2025-01-01',
199
+ supports: {
200
+ input: ['text', 'image'],
201
+ output: ['text', 'image'],
202
+ capabilities: ['batch_api', 'thinking'],
203
+ tools: ['google_search'],
204
+ },
205
+ pricing: {
206
+ input: {
207
+ normal: 0.5,
208
+ },
209
+ output: {
210
+ normal: 3,
211
+ },
212
+ },
213
+ } as const satisfies ModelMeta<
214
+ GeminiToolConfigOptions &
215
+ GeminiSafetyOptions &
216
+ GeminiCommonConfigOptions &
217
+ GeminiCachedContentOptions &
218
+ GeminiThinkingOptions
219
+ >
220
+
221
+ /**
222
+ * @deprecated `gemini-3.1-flash-image-preview` was shut down on 2026-06-25.
223
+ * Use the GA id `gemini-3.1-flash-image` instead — the preview id now 404s.
224
+ * Kept in the model union so existing code still compiles.
225
+ * @see https://ai.google.dev/gemini-api/docs/deprecations
226
+ */
227
+ const GEMINI_3_1_FLASH_IMAGE_PREVIEW = {
150
228
  name: 'gemini-3.1-flash-image-preview',
151
229
  max_input_tokens: 65_536,
152
230
  max_output_tokens: 65_536,
@@ -174,6 +252,10 @@ const GEMINI_3_1_FLASH_IMAGE = {
174
252
  GeminiThinkingOptions
175
253
  >
176
254
 
255
+ /**
256
+ * Gemini 3.1 Flash Lite Image ("Nano Banana 2 Lite") — GA. 1K output only.
257
+ * @see https://ai.google.dev/gemini-api/docs/models/gemini-3.1-flash-lite-image
258
+ */
177
259
  const GEMINI_3_1_FLASH_LITE_IMAGE = {
178
260
  name: 'gemini-3.1-flash-lite-image',
179
261
  max_input_tokens: 65_536,
@@ -375,6 +457,17 @@ const GEMINI_2_5_FLASH = {
375
457
  GeminiThinkingOptions
376
458
  >
377
459
 
460
+ /**
461
+ * Gemini 2.5 Flash Image ("Nano Banana") — still GA, but documented as the
462
+ * legacy member of the family. Google publishes no `image_size` value for it,
463
+ * so its size type is a bare aspect ratio and the adapter sends no
464
+ * `imageConfig.imageSize`.
465
+ * @deprecated `gemini-2.5-flash-image` shuts down on 2026-10-02. Migrate to
466
+ * `gemini-3.1-flash-lite-image` (cheapest successor) or
467
+ * `gemini-3.1-flash-image`. Google's deprecations table still names the
468
+ * already-dead `gemini-3.1-flash-image-preview` as the replacement.
469
+ * @see https://ai.google.dev/gemini-api/docs/deprecations
470
+ */
378
471
  const GEMINI_2_5_FLASH_IMAGE = {
379
472
  name: 'gemini-2.5-flash-image',
380
473
  max_input_tokens: 1_048_576,
@@ -744,6 +837,50 @@ const GEMINI_OMNI_FLASH_PREVIEW = {
744
837
  GeminiCachedContentOptions
745
838
  >
746
839
 
840
+ const GEMINI_3_7_FLASH = {
841
+ name: 'gemini-3.7-flash',
842
+ max_input_tokens: 1_048_576,
843
+ max_output_tokens: 65_536,
844
+ knowledge_cutoff: '2026-03-01',
845
+ supports: {
846
+ input: ['text', 'image', 'video', 'audio', 'document'],
847
+ output: ['text'],
848
+ capabilities: [
849
+ 'batch_api',
850
+ 'caching',
851
+ 'function_calling',
852
+ 'structured_output',
853
+ 'thinking',
854
+ ],
855
+ tools: [
856
+ 'code_execution',
857
+ 'file_search',
858
+ 'google_search',
859
+ 'google_maps',
860
+ 'url_context',
861
+ 'computer_use',
862
+ ],
863
+ },
864
+ // Currently 50% off through the end of 2026.
865
+ // https://ai.google.dev/gemini-api/docs/pricing#gemini-3.7-flash
866
+ pricing: {
867
+ input: {
868
+ normal: 0.75,
869
+ cached: 0.075,
870
+ },
871
+ output: {
872
+ normal: 3.75,
873
+ },
874
+ },
875
+ } as const satisfies ModelMeta<
876
+ GeminiToolConfigOptions &
877
+ GeminiSafetyOptions &
878
+ GeminiCommonConfigOptions &
879
+ GeminiCachedContentOptions &
880
+ GeminiStructuredOutputOptions &
881
+ GeminiThinkingOptions
882
+ >
883
+
747
884
  const GEMINI_3_6_FLASH = {
748
885
  name: 'gemini-3.6-flash',
749
886
  max_input_tokens: 1_048_576,
@@ -869,6 +1006,7 @@ const GEMINI_3_5_FLASH_LITE = {
869
1006
  >
870
1007
 
871
1008
  export const GEMINI_MODELS = [
1009
+ GEMINI_3_7_FLASH.name,
872
1010
  GEMINI_3_6_FLASH.name,
873
1011
  GEMINI_3_5_FLASH.name,
874
1012
  GEMINI_3_5_FLASH_LITE.name,
@@ -889,6 +1027,7 @@ export const GEMINI_MODELS = [
889
1027
  * brittle and keeps the engine's legacy finalization fallback.
890
1028
  */
891
1029
  export const GEMINI_COMBINED_TOOLS_AND_SCHEMA_MODELS = new Set<string>([
1030
+ GEMINI_3_7_FLASH.name,
892
1031
  GEMINI_3_6_FLASH.name,
893
1032
  GEMINI_3_5_FLASH.name,
894
1033
  GEMINI_3_5_FLASH_LITE.name,
@@ -900,8 +1039,29 @@ export const GEMINI_COMBINED_TOOLS_AND_SCHEMA_MODELS = new Set<string>([
900
1039
 
901
1040
  export type GeminiModels = (typeof GEMINI_MODELS)[number]
902
1041
 
903
- export type GeminiImageModels = (typeof GEMINI_IMAGE_MODELS)[number]
1042
+ /**
1043
+ * @deprecated Shut down 2026-06-25. Use `gemini-3.1-flash-image`.
1044
+ */
1045
+ type Gemini31FlashImagePreviewModel = 'gemini-3.1-flash-image-preview'
1046
+
1047
+ /**
1048
+ * @deprecated Shut down 2026-06-25. Use `gemini-3-pro-image`.
1049
+ */
1050
+ type Gemini3ProImagePreviewModel = 'gemini-3-pro-image-preview'
1051
+
1052
+ export type GeminiImageModels =
1053
+ | Exclude<
1054
+ (typeof GEMINI_IMAGE_MODELS)[number],
1055
+ Gemini31FlashImagePreviewModel | Gemini3ProImagePreviewModel
1056
+ >
1057
+ | Gemini31FlashImagePreviewModel
1058
+ | Gemini3ProImagePreviewModel
904
1059
 
1060
+ /**
1061
+ * Image generation models. GA ids come first; the trailing `-preview` ids are
1062
+ * shut-down aliases kept only so existing code keeps compiling — new code
1063
+ * should use the GA id above its alias.
1064
+ */
905
1065
  export const GEMINI_IMAGE_MODELS = [
906
1066
  GEMINI_3_1_FLASH_IMAGE.name,
907
1067
  GEMINI_3_1_FLASH_LITE_IMAGE.name,
@@ -910,6 +1070,9 @@ export const GEMINI_IMAGE_MODELS = [
910
1070
  IMAGEN_4_GENERATE.name,
911
1071
  IMAGEN_4_GENERATE_FAST.name,
912
1072
  IMAGEN_4_GENERATE_ULTRA.name,
1073
+ // Deprecated aliases — shut down 2026-06-25.
1074
+ GEMINI_3_1_FLASH_IMAGE_PREVIEW.name,
1075
+ GEMINI_3_PRO_IMAGE_PREVIEW.name,
913
1076
  ] as const
914
1077
 
915
1078
  /**
@@ -1017,6 +1180,12 @@ export type GeminiEmbeddingModelInputModalitiesByName = {
1017
1180
  // Manual type map for per-model provider options
1018
1181
  export type GeminiChatModelProviderOptionsByName = {
1019
1182
  // Models with thinking and structured output support
1183
+ [GEMINI_3_7_FLASH.name]: GeminiToolConfigOptions &
1184
+ GeminiSafetyOptions &
1185
+ GeminiCommonConfigOptions &
1186
+ GeminiCachedContentOptions &
1187
+ GeminiStructuredOutputOptions &
1188
+ GeminiThinkingOptions
1020
1189
  [GEMINI_3_6_FLASH.name]: GeminiToolConfigOptions &
1021
1190
  GeminiSafetyOptions &
1022
1191
  GeminiCommonConfigOptions &
@@ -1084,6 +1253,7 @@ export type GeminiChatModelProviderOptionsByName = {
1084
1253
  * Based on the 'supports.tools' arrays defined for each model.
1085
1254
  */
1086
1255
  export type GeminiChatModelToolCapabilitiesByName = {
1256
+ [GEMINI_3_7_FLASH.name]: typeof GEMINI_3_7_FLASH.supports.tools
1087
1257
  [GEMINI_3_6_FLASH.name]: typeof GEMINI_3_6_FLASH.supports.tools
1088
1258
  [GEMINI_3_5_FLASH.name]: typeof GEMINI_3_5_FLASH.supports.tools
1089
1259
  [GEMINI_3_5_FLASH_LITE.name]: typeof GEMINI_3_5_FLASH_LITE.supports.tools
@@ -1111,6 +1281,7 @@ export type GeminiChatModelToolCapabilitiesByName = {
1111
1281
  */
1112
1282
  export type GeminiModelInputModalitiesByName = {
1113
1283
  // Models with full multimodal support (text, image, audio, video, document)
1284
+ [GEMINI_3_7_FLASH.name]: typeof GEMINI_3_7_FLASH.supports.input
1114
1285
  [GEMINI_3_6_FLASH.name]: typeof GEMINI_3_6_FLASH.supports.input
1115
1286
  [GEMINI_3_5_FLASH.name]: typeof GEMINI_3_5_FLASH.supports.input
1116
1287
  [GEMINI_3_5_FLASH_LITE.name]: typeof GEMINI_3_5_FLASH_LITE.supports.input