@ai-sdk/google 4.0.15 → 4.0.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "4.0.15",
3
+ "version": "4.0.17",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -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,
@@ -78,7 +78,7 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV4 {
78
78
 
79
79
  /**
80
80
  * Optional agent name. When provided, the request body sends `agent:` instead
81
- * of `model:` and rejects `tools` / `generation_config` (warned, not thrown).
81
+ * of `model:` and rejects `generation_config` (warned, not thrown).
82
82
  */
83
83
  readonly agent: string | undefined;
84
84
 
@@ -158,13 +158,7 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV4 {
158
158
  let toolsForBody: Array<GoogleInteractionsTool> | undefined;
159
159
  let toolChoiceForBody: GoogleInteractionsToolChoice | undefined;
160
160
 
161
- if (hasTools && isAgent) {
162
- warnings.push({
163
- type: 'other',
164
- message:
165
- 'google.interactions: tools are not supported when an agent is set; tools will be omitted from the request body.',
166
- });
167
- } else if (hasTools) {
161
+ if (hasTools) {
168
162
  const prepared = prepareGoogleInteractionsTools({
169
163
  tools: options.tools,
170
164
  toolChoice: options.toolChoice,