@ai-sdk/google 3.0.74 → 3.0.77

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/index.d.mts +55 -12
  3. package/dist/index.d.ts +55 -12
  4. package/dist/index.js +687 -375
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +687 -375
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/internal/index.d.mts +1 -2
  9. package/dist/internal/index.d.ts +1 -2
  10. package/dist/internal/index.js +97 -59
  11. package/dist/internal/index.js.map +1 -1
  12. package/dist/internal/index.mjs +97 -59
  13. package/dist/internal/index.mjs.map +1 -1
  14. package/docs/15-google-generative-ai.mdx +73 -16
  15. package/package.json +1 -1
  16. package/src/google-generative-ai-language-model.ts +104 -56
  17. package/src/google-generative-ai-options.ts +24 -8
  18. package/src/google-provider.ts +9 -4
  19. package/src/interactions/build-google-interactions-stream-transform.ts +285 -154
  20. package/src/interactions/convert-to-google-interactions-input.ts +57 -133
  21. package/src/interactions/extract-google-interactions-sources.ts +3 -3
  22. package/src/interactions/google-interactions-agent.ts +6 -7
  23. package/src/interactions/google-interactions-api.ts +179 -115
  24. package/src/interactions/google-interactions-language-model-options.ts +126 -0
  25. package/src/interactions/google-interactions-language-model.ts +173 -60
  26. package/src/interactions/google-interactions-prompt.ts +239 -114
  27. package/src/interactions/map-google-interactions-finish-reason.ts +3 -5
  28. package/src/interactions/parse-google-interactions-outputs.ts +80 -74
  29. package/src/interactions/prepare-google-interactions-tools.ts +1 -1
  30. package/src/interactions/stream-google-interactions.ts +2 -2
  31. package/src/interactions/synthesize-google-interactions-agent-stream.ts +1 -1
@@ -1066,6 +1066,7 @@ The following Zod features are known to not work with Google Generative AI:
1066
1066
 
1067
1067
  | Model | Image Input | Object Generation | Tool Usage | Tool Streaming | Google Search | URL Context |
1068
1068
  | ------------------------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
1069
+ | `gemini-3.5-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1069
1070
  | `gemini-3.1-pro-preview` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1070
1071
  | `gemini-3.1-flash-image-preview` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1071
1072
  | `gemini-3.1-flash-lite-preview` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
@@ -1179,21 +1180,28 @@ The following optional provider options are available:
1179
1180
  Whether the model returns synthesized thought summaries on reasoning
1180
1181
  parts. Defaults to the API default.
1181
1182
 
1182
- - **imageConfig** _\{ aspectRatio?: string; imageSize?: '1K' | '2K' | '4K' | '512' \}_
1183
+ - **responseFormat** _Array\<\{ type: 'text' | 'image' | 'audio'; mimeType?: string; schema?: unknown; aspectRatio?: string; imageSize?: '1K' \| '2K' \| '4K' \| '512' \}\>_
1183
1184
 
1184
- Image generation configuration when `responseModalities` includes
1185
- `'image'`. `aspectRatio` accepts `1:1`, `2:3`, `3:2`, `3:4`, `4:3`,
1186
- `4:5`, `5:4`, `9:16`, `16:9`, `21:9`, `1:8`, `8:1`, `1:4`, `4:1`.
1185
+ Output-format entries that map directly to the API's `response_format`
1186
+ array. Use this for fine-grained control over image, audio, or non-JSON
1187
+ text outputs (e.g. `aspectRatio` and `imageSize` for image generation).
1188
+ The AI SDK call-level `responseFormat: { type: 'json', schema }` still
1189
+ drives JSON-mode automatically and prepends a matching text entry;
1190
+ entries listed here are appended.
1187
1191
 
1188
- - **mediaResolution** _'low' | 'medium' | 'high' | 'ultra_high'_
1192
+ `aspectRatio` accepts `1:1`, `2:3`, `3:2`, `3:4`, `4:3`, `4:5`, `5:4`,
1193
+ `9:16`, `16:9`, `21:9`, `1:8`, `8:1`, `1:4`, `4:1`.
1189
1194
 
1190
- Media resolution applied to image inputs / outputs.
1195
+ - **imageConfig** _\{ aspectRatio?: string; imageSize?: '1K' | '2K' | '4K' | '512' \}_ (deprecated)
1191
1196
 
1192
- - **responseModalities** _Array\<'text' | 'image' | 'audio' | 'video' | 'document'\>_
1197
+ Use **responseFormat** with a `{ type: 'image', ... }` entry instead.
1198
+ Retained for backwards compatibility; the SDK translates `imageConfig`
1199
+ into a matching `response_format` image entry and emits a warning when
1200
+ set. Ignored when `responseFormat` already supplies an image entry.
1193
1201
 
1194
- The modalities the model may emit. Defaults to text-only. Pass
1195
- `['image']` (or `['text', 'image']`) to enable native image output. See
1196
- [Image output](#image-output-via-interactions).
1202
+ - **mediaResolution** _'low' | 'medium' | 'high' | 'ultra_high'_
1203
+
1204
+ Media resolution applied to image inputs / outputs.
1197
1205
 
1198
1206
  - **serviceTier** _'flex' | 'standard' | 'priority'_
1199
1207
 
@@ -1346,9 +1354,10 @@ const { text, toolCalls } = await generateText({
1346
1354
 
1347
1355
  ### Image output via Interactions
1348
1356
 
1349
- Set `responseModalities: ['image']` on a Gemini image-capable model to get
1350
- images as `LanguageModelV4FilePart` files in the response. No tool wrapping
1351
- is required.
1357
+ Add a `{ type: 'image' }` entry to `responseFormat` on a Gemini
1358
+ image-capable model to get images as `LanguageModelV4FilePart` files in
1359
+ the response. No tool wrapping is required, and the entry doubles as the
1360
+ place to set `aspectRatio`, `imageSize`, and `mimeType`.
1352
1361
 
1353
1362
  ```ts
1354
1363
  import { google } from '@ai-sdk/google';
@@ -1359,7 +1368,7 @@ const result = await generateText({
1359
1368
  prompt: 'Generate an image of a comic cat in a spaceship.',
1360
1369
  providerOptions: {
1361
1370
  google: {
1362
- responseModalities: ['image'],
1371
+ responseFormat: [{ type: 'image' }],
1363
1372
  },
1364
1373
  },
1365
1374
  });
@@ -1371,6 +1380,54 @@ for (const file of result.files) {
1371
1380
  }
1372
1381
  ```
1373
1382
 
1383
+ To control aspect ratio, image size, or output mime type, add those
1384
+ fields to the same image entry:
1385
+
1386
+ ```ts
1387
+ const result = await generateText({
1388
+ model: google.interactions('gemini-3-pro-image-preview'),
1389
+ prompt: 'Generate a high-quality landscape photo of mountains at sunset.',
1390
+ providerOptions: {
1391
+ google: {
1392
+ responseFormat: [
1393
+ {
1394
+ type: 'image',
1395
+ aspectRatio: '16:9',
1396
+ imageSize: '4K',
1397
+ },
1398
+ ],
1399
+ },
1400
+ },
1401
+ });
1402
+ ```
1403
+
1404
+ For multimodal output, list one entry per modality. The model returns
1405
+ text in `result.text` and the accompanying image(s) in `result.files`:
1406
+
1407
+ ```ts
1408
+ import { google } from '@ai-sdk/google';
1409
+ import { generateText } from 'ai';
1410
+
1411
+ const result = await generateText({
1412
+ model: google.interactions('gemini-2.5-flash-image'),
1413
+ prompt:
1414
+ 'Tell me a three sentence bedtime story about a unicorn, accompanied by a suitable illustration.',
1415
+ providerOptions: {
1416
+ google: {
1417
+ responseFormat: [
1418
+ { type: 'text' },
1419
+ { type: 'image', aspectRatio: '16:9' },
1420
+ ],
1421
+ },
1422
+ },
1423
+ });
1424
+
1425
+ console.log(result.text);
1426
+
1427
+ const images = result.files.filter(file => file.mediaType.startsWith('image/'));
1428
+ // images[0].uint8Array | images[0].base64 | images[0].mediaType
1429
+ ```
1430
+
1374
1431
  Iterative image editing pairs naturally with stateful chaining — keep
1375
1432
  `previousInteractionId` set across turns and the model edits its prior
1376
1433
  output:
@@ -1384,7 +1441,7 @@ const model = google.interactions('gemini-3-pro-image-preview');
1384
1441
  const turn1 = await generateText({
1385
1442
  model,
1386
1443
  prompt: 'Generate an image of a comic cat in a spaceship.',
1387
- providerOptions: { google: { responseModalities: ['image'] } },
1444
+ providerOptions: { google: { responseFormat: [{ type: 'image' }] } },
1388
1445
  });
1389
1446
 
1390
1447
  const interactionId = turn1.providerMetadata?.google?.interactionId as
@@ -1396,7 +1453,7 @@ const turn2 = await generateText({
1396
1453
  prompt: 'now make the cat red',
1397
1454
  providerOptions: {
1398
1455
  google: {
1399
- responseModalities: ['image'],
1456
+ responseFormat: [{ type: 'image' }],
1400
1457
  previousInteractionId: interactionId,
1401
1458
  },
1402
1459
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "3.0.74",
3
+ "version": "3.0.77",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,6 @@ import { getModelPath } from './get-model-path';
37
37
  import { googleFailedResponseHandler } from './google-error';
38
38
  import {
39
39
  googleLanguageModelOptions,
40
- VertexServiceTierMap,
41
40
  type GoogleGenerativeAIModelId,
42
41
  } from './google-generative-ai-options';
43
42
  import type {
@@ -155,11 +154,43 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
155
154
  });
156
155
  }
157
156
 
158
- // Vertex API requires another service tier format.
159
- let sanitizedServiceTier: string | undefined = googleOptions?.serviceTier;
160
157
  if (googleOptions?.serviceTier && isVertexProvider) {
161
- sanitizedServiceTier = VertexServiceTierMap[googleOptions.serviceTier];
158
+ warnings.push({
159
+ type: 'other',
160
+ message:
161
+ "'serviceTier' is a Gemini API option and is not supported on Vertex AI. " +
162
+ "Use 'sharedRequestType' (and optionally 'requestType') instead. See " +
163
+ 'https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo',
164
+ });
162
165
  }
166
+ if (
167
+ (googleOptions?.sharedRequestType || googleOptions?.requestType) &&
168
+ !isVertexProvider
169
+ ) {
170
+ warnings.push({
171
+ type: 'other',
172
+ message:
173
+ "'sharedRequestType' and 'requestType' are Vertex AI options and " +
174
+ `are ignored with the current Google provider (${this.config.provider}).`,
175
+ });
176
+ }
177
+
178
+ const vertexPaygoHeaders: Record<string, string> | undefined =
179
+ isVertexProvider &&
180
+ (googleOptions?.sharedRequestType || googleOptions?.requestType)
181
+ ? {
182
+ ...(googleOptions.sharedRequestType && {
183
+ 'X-Vertex-AI-LLM-Shared-Request-Type':
184
+ googleOptions.sharedRequestType,
185
+ }),
186
+ ...(googleOptions.requestType && {
187
+ 'X-Vertex-AI-LLM-Request-Type': googleOptions.requestType,
188
+ }),
189
+ }
190
+ : undefined;
191
+ const bodyServiceTier = isVertexProvider
192
+ ? undefined
193
+ : googleOptions?.serviceTier;
163
194
 
164
195
  const isGemmaModel = this.modelId.toLowerCase().startsWith('gemma-');
165
196
  const supportsFunctionResponseParts = this.modelId.startsWith('gemini-3');
@@ -253,21 +284,24 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
253
284
  toolConfig,
254
285
  cachedContent: googleOptions?.cachedContent,
255
286
  labels: googleOptions?.labels,
256
- serviceTier: sanitizedServiceTier,
287
+ serviceTier: bodyServiceTier,
257
288
  },
258
289
  warnings: [...warnings, ...toolWarnings],
259
290
  providerOptionsName,
291
+ extraHeaders: vertexPaygoHeaders,
260
292
  };
261
293
  }
262
294
 
263
295
  async doGenerate(
264
296
  options: LanguageModelV3CallOptions,
265
297
  ): Promise<LanguageModelV3GenerateResult> {
266
- const { args, warnings, providerOptionsName } = await this.getArgs(options);
298
+ const { args, warnings, providerOptionsName, extraHeaders } =
299
+ await this.getArgs(options);
267
300
 
268
301
  const mergedHeaders = combineHeaders(
269
302
  await resolve(this.config.headers),
270
303
  options.headers,
304
+ extraHeaders,
271
305
  );
272
306
 
273
307
  const {
@@ -464,7 +498,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
464
498
  safetyRatings: candidate.safetyRatings ?? null,
465
499
  usageMetadata: usageMetadata ?? null,
466
500
  finishMessage: candidate.finishMessage ?? null,
467
- serviceTier: response.serviceTier ?? null,
501
+ serviceTier: responseHeaders?.['x-gemini-service-tier'] ?? null,
468
502
  } satisfies GoogleGenerativeAIProviderMetadata,
469
503
  },
470
504
  request: { body: args },
@@ -479,14 +513,13 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
479
513
  async doStream(
480
514
  options: LanguageModelV3CallOptions,
481
515
  ): Promise<LanguageModelV3StreamResult> {
482
- const { args, warnings, providerOptionsName } = await this.getArgs(
483
- options,
484
- { isStreaming: true },
485
- );
516
+ const { args, warnings, providerOptionsName, extraHeaders } =
517
+ await this.getArgs(options, { isStreaming: true });
486
518
 
487
519
  const headers = combineHeaders(
488
520
  await resolve(this.config.headers),
489
521
  options.headers,
522
+ extraHeaders,
490
523
  );
491
524
 
492
525
  const { responseHeaders, value: response } = await postJsonToApi({
@@ -509,7 +542,8 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
509
542
  let providerMetadata: SharedV3ProviderMetadata | undefined = undefined;
510
543
  let lastGroundingMetadata: GroundingMetadataSchema | null = null;
511
544
  let lastUrlContextMetadata: UrlContextMetadataSchema | null = null;
512
- let serviceTier: string | null = null;
545
+ const serviceTier: string | null =
546
+ responseHeaders?.['x-gemini-service-tier'] ?? null;
513
547
 
514
548
  const generateId = this.config.generateId;
515
549
  let hasToolCalls = false;
@@ -533,6 +567,42 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
533
567
  providerMetadata?: SharedV3ProviderMetadata;
534
568
  }> = [];
535
569
 
570
+ const finishActiveStreamingToolCall = (
571
+ controller: TransformStreamDefaultController<LanguageModelV3StreamPart>,
572
+ ) => {
573
+ const active = activeStreamingToolCalls.pop();
574
+ if (active == null) {
575
+ return;
576
+ }
577
+
578
+ const { finalJSON, closingDelta } = active.accumulator.finalize();
579
+
580
+ if (closingDelta.length > 0) {
581
+ controller.enqueue({
582
+ type: 'tool-input-delta',
583
+ id: active.toolCallId,
584
+ delta: closingDelta,
585
+ providerMetadata: active.providerMetadata,
586
+ });
587
+ }
588
+
589
+ controller.enqueue({
590
+ type: 'tool-input-end',
591
+ id: active.toolCallId,
592
+ providerMetadata: active.providerMetadata,
593
+ });
594
+
595
+ controller.enqueue({
596
+ type: 'tool-call',
597
+ toolCallId: active.toolCallId,
598
+ toolName: active.toolName,
599
+ input: finalJSON,
600
+ providerMetadata: active.providerMetadata,
601
+ });
602
+
603
+ hasToolCalls = true;
604
+ };
605
+
536
606
  return {
537
607
  stream: response.pipeThrough(
538
608
  new TransformStream<
@@ -561,10 +631,6 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
561
631
  usage = usageMetadata;
562
632
  }
563
633
 
564
- if (value.serviceTier != null) {
565
- serviceTier = value.serviceTier;
566
- }
567
-
568
634
  const candidate = value.candidates?.[0];
569
635
 
570
636
  // sometimes the API returns an empty candidates array
@@ -824,10 +890,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
824
890
  part.functionCall.willContinue !== true;
825
891
 
826
892
  if (isStreamingChunk) {
827
- if (
828
- part.functionCall.name != null &&
829
- part.functionCall.willContinue === true
830
- ) {
893
+ if (part.functionCall.name != null) {
831
894
  const toolCallId = part.functionCall.id ?? generateId();
832
895
  const accumulator = new GoogleJSONAccumulator();
833
896
  activeStreamingToolCalls.push({
@@ -845,9 +908,10 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
845
908
  });
846
909
 
847
910
  if (part.functionCall.partialArgs != null) {
848
- const { textDelta } = accumulator.processPartialArgs(
849
- part.functionCall.partialArgs as PartialArg[],
850
- );
911
+ const partialArgs = part.functionCall
912
+ .partialArgs as PartialArg[];
913
+ const { textDelta } =
914
+ accumulator.processPartialArgs(partialArgs);
851
915
  if (textDelta.length > 0) {
852
916
  controller.enqueue({
853
917
  type: 'tool-input-delta',
@@ -856,6 +920,12 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
856
920
  providerMetadata: providerMeta,
857
921
  });
858
922
  }
923
+ if (
924
+ part.functionCall.willContinue !== true &&
925
+ partialArgs.every(arg => arg.willContinue !== true)
926
+ ) {
927
+ finishActiveStreamingToolCall(controller);
928
+ }
859
929
  }
860
930
  } else if (
861
931
  part.functionCall.partialArgs != null &&
@@ -865,9 +935,10 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
865
935
  activeStreamingToolCalls[
866
936
  activeStreamingToolCalls.length - 1
867
937
  ];
868
- const { textDelta } = active.accumulator.processPartialArgs(
869
- part.functionCall.partialArgs as PartialArg[],
870
- );
938
+ const partialArgs = part.functionCall
939
+ .partialArgs as PartialArg[];
940
+ const { textDelta } =
941
+ active.accumulator.processPartialArgs(partialArgs);
871
942
  if (textDelta.length > 0) {
872
943
  controller.enqueue({
873
944
  type: 'tool-input-delta',
@@ -876,39 +947,18 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
876
947
  providerMetadata: providerMeta,
877
948
  });
878
949
  }
950
+ if (
951
+ part.functionCall.willContinue !== true &&
952
+ partialArgs.every(arg => arg.willContinue !== true)
953
+ ) {
954
+ finishActiveStreamingToolCall(controller);
955
+ }
879
956
  }
880
957
  } else if (
881
958
  isTerminalChunk &&
882
959
  activeStreamingToolCalls.length > 0
883
960
  ) {
884
- const active = activeStreamingToolCalls.pop()!;
885
- const { finalJSON, closingDelta } =
886
- active.accumulator.finalize();
887
-
888
- if (closingDelta.length > 0) {
889
- controller.enqueue({
890
- type: 'tool-input-delta',
891
- id: active.toolCallId,
892
- delta: closingDelta,
893
- providerMetadata: active.providerMetadata,
894
- });
895
- }
896
-
897
- controller.enqueue({
898
- type: 'tool-input-end',
899
- id: active.toolCallId,
900
- providerMetadata: active.providerMetadata,
901
- });
902
-
903
- controller.enqueue({
904
- type: 'tool-call',
905
- toolCallId: active.toolCallId,
906
- toolName: active.toolName,
907
- input: finalJSON,
908
- providerMetadata: active.providerMetadata,
909
- });
910
-
911
- hasToolCalls = true;
961
+ finishActiveStreamingToolCall(controller);
912
962
  } else if (isCompleteCall) {
913
963
  const toolCallId = part.functionCall.id ?? generateId();
914
964
  const toolName = part.functionCall.name!;
@@ -1377,7 +1427,6 @@ const responseSchema = lazySchema(() =>
1377
1427
  safetyRatings: z.array(getSafetyRatingSchema()).nullish(),
1378
1428
  })
1379
1429
  .nullish(),
1380
- serviceTier: z.string().nullish(),
1381
1430
  }),
1382
1431
  ),
1383
1432
  );
@@ -1433,7 +1482,6 @@ const chunkSchema = lazySchema(() =>
1433
1482
  safetyRatings: z.array(getSafetyRatingSchema()).nullish(),
1434
1483
  })
1435
1484
  .nullish(),
1436
- serviceTier: z.string().nullish(),
1437
1485
  }),
1438
1486
  ),
1439
1487
  );
@@ -30,6 +30,7 @@ export type GoogleGenerativeAIModelId =
30
30
  | 'gemini-3.1-flash-image-preview'
31
31
  | 'gemini-3.1-flash-lite-preview'
32
32
  | 'gemini-3.1-flash-tts-preview'
33
+ | 'gemini-3.5-flash'
33
34
  // latest version
34
35
  // https://ai.google.dev/gemini-api/docs/models#latest
35
36
  | 'gemini-pro-latest'
@@ -206,9 +207,31 @@ export const googleLanguageModelOptions = lazySchema(() =>
206
207
  streamFunctionCallArguments: z.boolean().optional(),
207
208
 
208
209
  /**
209
- * Optional. The service tier to use for the request.
210
+ * Optional. The service tier to use for the request. Sent as the
211
+ * `serviceTier` body field. Gemini API only.
210
212
  */
211
213
  serviceTier: z.enum(['standard', 'flex', 'priority']).optional(),
214
+
215
+ /**
216
+ * Optional. Vertex AI only. Sent as the
217
+ * `X-Vertex-AI-LLM-Shared-Request-Type` request header to select a
218
+ * shared (PayGo) tier. With Provisioned Throughput allocated and
219
+ * `requestType` unset, the request falls back to this tier only if
220
+ * PT capacity is exhausted.
221
+ *
222
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
223
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/flex-paygo
224
+ */
225
+ sharedRequestType: z.enum(['priority', 'flex', 'standard']).optional(),
226
+
227
+ /**
228
+ * Optional. Vertex AI only. Sent as the `X-Vertex-AI-LLM-Request-Type`
229
+ * request header. Set to `'shared'` together with `sharedRequestType`
230
+ * to bypass Provisioned Throughput entirely.
231
+ *
232
+ * https://docs.cloud.google.com/vertex-ai/generative-ai/docs/priority-paygo
233
+ */
234
+ requestType: z.enum(['shared']).optional(),
212
235
  }),
213
236
  ),
214
237
  );
@@ -216,10 +239,3 @@ export const googleLanguageModelOptions = lazySchema(() =>
216
239
  export type GoogleLanguageModelOptions = InferSchema<
217
240
  typeof googleLanguageModelOptions
218
241
  >;
219
-
220
- // Vertex API requires another service tier format.
221
- export const VertexServiceTierMap = {
222
- standard: 'SERVICE_TIER_STANDARD',
223
- flex: 'SERVICE_TIER_FLEX',
224
- priority: 'SERVICE_TIER_PRIORITY',
225
- } as const;
@@ -89,13 +89,17 @@ export interface GoogleGenerativeAIProvider extends ProviderV3 {
89
89
 
90
90
  /**
91
91
  * Creates a language model targeting the Gemini Interactions API
92
- * (`POST /v1beta/interactions`). Pass either a model ID (string) or
93
- * `{ agent: <name> }` to use a Gemini agent preset.
92
+ * (`POST /v1beta/interactions`). Pass:
93
+ * - a model ID (string),
94
+ * - `{ agent: <name> }` to use a known Gemini agent preset, or
95
+ * - `{ managedAgent: <name> }` to use a user-defined agent created via
96
+ * the `/v1beta/agents` endpoint.
94
97
  */
95
98
  interactions(
96
99
  modelIdOrAgent:
97
100
  | GoogleInteractionsModelId
98
- | { agent: GoogleInteractionsAgentName },
101
+ | { agent: GoogleInteractionsAgentName }
102
+ | { managedAgent: string },
99
103
  ): LanguageModelV3;
100
104
 
101
105
  tools: typeof googleTools;
@@ -214,7 +218,8 @@ export function createGoogleGenerativeAI(
214
218
  const createInteractionsModel = (
215
219
  modelIdOrAgent:
216
220
  | GoogleInteractionsModelId
217
- | { agent: GoogleInteractionsAgentName },
221
+ | { agent: GoogleInteractionsAgentName }
222
+ | { managedAgent: string },
218
223
  ) =>
219
224
  new GoogleInteractionsLanguageModel(
220
225
  modelIdOrAgent as GoogleInteractionsModelInput,