@ai-sdk/google 4.0.16 → 4.0.18

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.
@@ -498,7 +498,7 @@ The response will contain the tool calls and results from the code execution.
498
498
  With [Google Search grounding](https://ai.google.dev/gemini-api/docs/google-search),
499
499
  the model has access to the latest information using Google Search.
500
500
 
501
- ```ts highlight="8,17-20"
501
+ ```ts highlight="8,17-19"
502
502
  import { google } from '@ai-sdk/google';
503
503
  import { GoogleProviderMetadata } from '@ai-sdk/google';
504
504
  import { generateText } from 'ai';
@@ -657,7 +657,7 @@ Google provides a provider-defined URL context tool.
657
657
 
658
658
  The URL context tool allows you to provide specific URLs that you want the model to analyze directly in from the prompt.
659
659
 
660
- ```ts highlight="9,13-17"
660
+ ```ts highlight="9,13-15"
661
661
  import { google } from '@ai-sdk/google';
662
662
  import { generateText } from 'ai';
663
663
 
@@ -818,7 +818,7 @@ This enables the model to provide answers based on your specific data sources an
818
818
  Google provider (`@ai-sdk/google`) to use this feature.
819
819
  </Note>
820
820
 
821
- ```ts highlight="8,17-20"
821
+ ```ts highlight="5-8,13-17,25-27"
822
822
  import { createGoogleVertex } from '@ai-sdk/google-vertex';
823
823
  import { GoogleProviderMetadata } from '@ai-sdk/google';
824
824
  import { generateText } from 'ai';
@@ -2024,7 +2024,7 @@ spoken text, so `instructions: 'Say cheerfully'` with `text: 'Hello'` speaks `Sa
2024
2024
  For multi-speaker dialogue, pass a `multiSpeakerVoiceConfig` through `providerOptions`. Each speaker
2025
2025
  name must match a name used in the input text. When set, it overrides the top-level `voice`.
2026
2026
 
2027
- ```ts highlight="8-23"
2027
+ ```ts highlight="7-22"
2028
2028
  import { generateSpeech } from 'ai';
2029
2029
  import { google, type GoogleSpeechModelOptions } from '@ai-sdk/google';
2030
2030
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "4.0.16",
3
+ "version": "4.0.18",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@ai-sdk/provider": "4.0.3",
39
- "@ai-sdk/provider-utils": "5.0.10"
39
+ "@ai-sdk/provider-utils": "5.0.11"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "22.19.19",
@@ -176,6 +176,46 @@ export const googleLanguageModelOptions = lazySchema(() =>
176
176
  ])
177
177
  .optional(),
178
178
  imageSize: z.enum(['1K', '2K', '4K', '512']).optional(),
179
+
180
+ /**
181
+ * Optional. Controls the generation of people in images.
182
+ * Vertex AI only.
183
+ */
184
+ personGeneration: z
185
+ .enum([
186
+ 'PERSON_GENERATION_UNSPECIFIED',
187
+ 'ALLOW_ALL',
188
+ 'ALLOW_ADULT',
189
+ 'ALLOW_NONE',
190
+ ])
191
+ .optional(),
192
+
193
+ /**
194
+ * Optional. Controls whether generation of prominent people
195
+ * (celebrities) is allowed. When set together with
196
+ * `personGeneration`, `personGeneration` takes precedence.
197
+ * Vertex AI only.
198
+ *
199
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerationConfig
200
+ */
201
+ prominentPeople: z
202
+ .enum([
203
+ 'PROMINENT_PEOPLE_UNSPECIFIED',
204
+ 'ALLOW_PROMINENT_PEOPLE',
205
+ 'BLOCK_PROMINENT_PEOPLE',
206
+ ])
207
+ .optional(),
208
+
209
+ /**
210
+ * Optional. The image output format for generated images.
211
+ * Vertex AI only.
212
+ */
213
+ imageOutputOptions: z
214
+ .object({
215
+ mimeType: z.enum(['image/jpeg', 'image/png']).optional(),
216
+ compressionQuality: z.number().optional(),
217
+ })
218
+ .optional(),
179
219
  })
180
220
  .optional(),
181
221
 
@@ -227,6 +227,35 @@ export class GoogleLanguageModel implements LanguageModelV4 {
227
227
  ? undefined
228
228
  : googleOptions?.serviceTier;
229
229
 
230
+ // personGeneration, prominentPeople and imageOutputOptions are only
231
+ // supported by the Vertex AI API, the Gemini API rejects them.
232
+ let imageConfig = googleOptions?.imageConfig;
233
+ if (imageConfig != null && !isVertexProvider) {
234
+ const {
235
+ personGeneration,
236
+ prominentPeople,
237
+ imageOutputOptions,
238
+ ...geminiApiImageConfig
239
+ } = imageConfig;
240
+ const droppedImageConfigFields = Object.entries({
241
+ personGeneration,
242
+ prominentPeople,
243
+ imageOutputOptions,
244
+ })
245
+ .filter(([, value]) => value != null)
246
+ .map(([key]) => `'imageConfig.${key}'`);
247
+ if (droppedImageConfigFields.length > 0) {
248
+ warnings.push({
249
+ type: 'other',
250
+ message:
251
+ `${droppedImageConfigFields.join(', ')} ` +
252
+ `${droppedImageConfigFields.length === 1 ? 'is a Vertex AI option and is' : 'are Vertex AI options and are'} ` +
253
+ `ignored with the current Google provider (${this.config.provider}).`,
254
+ });
255
+ imageConfig = geminiApiImageConfig;
256
+ }
257
+ }
258
+
230
259
  const isGemmaModel = this.modelId.toLowerCase().startsWith('gemma-');
231
260
  const isGemini3Model = /^gemini-3[.-]/.test(this.modelId);
232
261
  const supportsFunctionResponseParts = isGemini3Model;
@@ -328,9 +357,7 @@ export class GoogleLanguageModel implements LanguageModelV4 {
328
357
  ...(googleOptions?.mediaResolution && {
329
358
  mediaResolution: googleOptions.mediaResolution,
330
359
  }),
331
- ...(googleOptions?.imageConfig && {
332
- imageConfig: googleOptions.imageConfig,
333
- }),
360
+ ...(imageConfig && { imageConfig }),
334
361
  },
335
362
  contents,
336
363
  systemInstruction: isGemmaModel ? undefined : systemInstruction,