@tanstack/ai-gemini 0.23.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.
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,
@@ -946,8 +1039,29 @@ export const GEMINI_COMBINED_TOOLS_AND_SCHEMA_MODELS = new Set<string>([
946
1039
 
947
1040
  export type GeminiModels = (typeof GEMINI_MODELS)[number]
948
1041
 
949
- 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'
950
1051
 
1052
+ export type GeminiImageModels =
1053
+ | Exclude<
1054
+ (typeof GEMINI_IMAGE_MODELS)[number],
1055
+ Gemini31FlashImagePreviewModel | Gemini3ProImagePreviewModel
1056
+ >
1057
+ | Gemini31FlashImagePreviewModel
1058
+ | Gemini3ProImagePreviewModel
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
+ */
951
1065
  export const GEMINI_IMAGE_MODELS = [
952
1066
  GEMINI_3_1_FLASH_IMAGE.name,
953
1067
  GEMINI_3_1_FLASH_LITE_IMAGE.name,
@@ -956,6 +1070,9 @@ export const GEMINI_IMAGE_MODELS = [
956
1070
  IMAGEN_4_GENERATE.name,
957
1071
  IMAGEN_4_GENERATE_FAST.name,
958
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,
959
1076
  ] as const
960
1077
 
961
1078
  /**