@ai-sdk/google 3.0.118 → 3.0.120

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.
@@ -201,18 +201,32 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
201
201
  } | null | undefined;
202
202
  }[] | null | undefined;
203
203
  usageMetadata?: {
204
+ [x: string]: z.core.util.JSONType;
204
205
  cachedContentTokenCount?: number | null | undefined;
205
206
  thoughtsTokenCount?: number | null | undefined;
206
207
  promptTokenCount?: number | null | undefined;
207
208
  candidatesTokenCount?: number | null | undefined;
209
+ toolUsePromptTokenCount?: number | null | undefined;
208
210
  totalTokenCount?: number | null | undefined;
209
211
  trafficType?: string | null | undefined;
210
212
  serviceTier?: string | null | undefined;
211
213
  promptTokensDetails?: {
214
+ [x: string]: z.core.util.JSONType;
215
+ modality: string;
216
+ tokenCount: number;
217
+ }[] | null | undefined;
218
+ cacheTokensDetails?: {
219
+ [x: string]: z.core.util.JSONType;
212
220
  modality: string;
213
221
  tokenCount: number;
214
222
  }[] | null | undefined;
215
223
  candidatesTokensDetails?: {
224
+ [x: string]: z.core.util.JSONType;
225
+ modality: string;
226
+ tokenCount: number;
227
+ }[] | null | undefined;
228
+ toolUsePromptTokensDetails?: {
229
+ [x: string]: z.core.util.JSONType;
216
230
  modality: string;
217
231
  tokenCount: number;
218
232
  }[] | null | undefined;
@@ -201,18 +201,32 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
201
201
  } | null | undefined;
202
202
  }[] | null | undefined;
203
203
  usageMetadata?: {
204
+ [x: string]: z.core.util.JSONType;
204
205
  cachedContentTokenCount?: number | null | undefined;
205
206
  thoughtsTokenCount?: number | null | undefined;
206
207
  promptTokenCount?: number | null | undefined;
207
208
  candidatesTokenCount?: number | null | undefined;
209
+ toolUsePromptTokenCount?: number | null | undefined;
208
210
  totalTokenCount?: number | null | undefined;
209
211
  trafficType?: string | null | undefined;
210
212
  serviceTier?: string | null | undefined;
211
213
  promptTokensDetails?: {
214
+ [x: string]: z.core.util.JSONType;
215
+ modality: string;
216
+ tokenCount: number;
217
+ }[] | null | undefined;
218
+ cacheTokensDetails?: {
219
+ [x: string]: z.core.util.JSONType;
212
220
  modality: string;
213
221
  tokenCount: number;
214
222
  }[] | null | undefined;
215
223
  candidatesTokensDetails?: {
224
+ [x: string]: z.core.util.JSONType;
225
+ modality: string;
226
+ tokenCount: number;
227
+ }[] | null | undefined;
228
+ toolUsePromptTokensDetails?: {
229
+ [x: string]: z.core.util.JSONType;
216
230
  modality: string;
217
231
  tokenCount: number;
218
232
  }[] | null | undefined;
@@ -2525,21 +2525,24 @@ var tokenDetailsSchema = import_v43.z.array(
2525
2525
  import_v43.z.object({
2526
2526
  modality: import_v43.z.string(),
2527
2527
  tokenCount: import_v43.z.number()
2528
- })
2528
+ }).catchall(import_v43.z.json())
2529
2529
  ).nullish();
2530
2530
  var usageSchema = import_v43.z.object({
2531
2531
  cachedContentTokenCount: import_v43.z.number().nullish(),
2532
2532
  thoughtsTokenCount: import_v43.z.number().nullish(),
2533
2533
  promptTokenCount: import_v43.z.number().nullish(),
2534
2534
  candidatesTokenCount: import_v43.z.number().nullish(),
2535
+ toolUsePromptTokenCount: import_v43.z.number().nullish(),
2535
2536
  totalTokenCount: import_v43.z.number().nullish(),
2536
2537
  // https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
2537
2538
  trafficType: import_v43.z.string().nullish(),
2538
2539
  serviceTier: import_v43.z.string().nullish(),
2539
2540
  // https://ai.google.dev/api/generate-content#Modality
2540
2541
  promptTokensDetails: tokenDetailsSchema,
2541
- candidatesTokensDetails: tokenDetailsSchema
2542
- });
2542
+ cacheTokensDetails: tokenDetailsSchema,
2543
+ candidatesTokensDetails: tokenDetailsSchema,
2544
+ toolUsePromptTokensDetails: tokenDetailsSchema
2545
+ }).catchall(import_v43.z.json());
2543
2546
  var getUrlContextMetadataSchema = () => import_v43.z.object({
2544
2547
  urlMetadata: import_v43.z.array(
2545
2548
  import_v43.z.object({
@@ -4276,8 +4279,8 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils14.lazySch
4276
4279
  thinkingSummaries: import_v412.z.enum(["auto", "none"]).nullish(),
4277
4280
  /**
4278
4281
  * Output-format entries that map directly to the API's `response_format`
4279
- * array. Use this to request image, audio, or non-JSON text outputs
4280
- * with full control over `mime_type`, `aspect_ratio`, and `image_size`.
4282
+ * array. Use this to request image, audio, video, or non-JSON text
4283
+ * outputs with modality-specific controls.
4281
4284
  *
4282
4285
  * Entries are sent in order. The AI SDK call-level `responseFormat: {
4283
4286
  * type: 'json', schema }` still drives JSON-mode and adds a matching
@@ -4314,6 +4317,14 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils14.lazySch
4314
4317
  import_v412.z.object({
4315
4318
  type: import_v412.z.literal("audio"),
4316
4319
  mimeType: import_v412.z.string().nullish()
4320
+ }).loose(),
4321
+ import_v412.z.object({
4322
+ type: import_v412.z.literal("video"),
4323
+ aspectRatio: import_v412.z.enum(["16:9", "9:16"]).nullish(),
4324
+ resolution: import_v412.z.enum(["360p", "720p", "1080p", "4k"]).nullish(),
4325
+ duration: import_v412.z.string().nullish(),
4326
+ delivery: import_v412.z.enum(["inline", "uri"]).nullish(),
4327
+ gcsUri: import_v412.z.string().nullish()
4317
4328
  }).loose()
4318
4329
  ])
4319
4330
  ).nullish(),
@@ -5200,7 +5211,7 @@ var GoogleInteractionsLanguageModel = class {
5200
5211
  };
5201
5212
  }
5202
5213
  async getArgs(options) {
5203
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
5214
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
5204
5215
  const warnings = [];
5205
5216
  const opts = await (0, import_provider_utils18.parseProviderOptions)({
5206
5217
  provider: "google",
@@ -5276,6 +5287,17 @@ var GoogleInteractionsLanguageModel = class {
5276
5287
  mime_type: (_g = entry.mimeType) != null ? _g : void 0
5277
5288
  })
5278
5289
  );
5290
+ } else if (entry.type === "video") {
5291
+ responseFormatEntries.push(
5292
+ pruneUndefined({
5293
+ type: "video",
5294
+ aspect_ratio: (_h = entry.aspectRatio) != null ? _h : void 0,
5295
+ resolution: (_i = entry.resolution) != null ? _i : void 0,
5296
+ duration: (_j = entry.duration) != null ? _j : void 0,
5297
+ delivery: (_k = entry.delivery) != null ? _k : void 0,
5298
+ gcs_uri: (_l = entry.gcsUri) != null ? _l : void 0
5299
+ })
5300
+ );
5279
5301
  }
5280
5302
  }
5281
5303
  }
@@ -5285,13 +5307,13 @@ var GoogleInteractionsLanguageModel = class {
5285
5307
  warnings: convWarnings
5286
5308
  } = convertToGoogleInteractionsInput({
5287
5309
  prompt: options.prompt,
5288
- previousInteractionId: (_h = opts == null ? void 0 : opts.previousInteractionId) != null ? _h : void 0,
5289
- store: (_i = opts == null ? void 0 : opts.store) != null ? _i : void 0,
5290
- mediaResolution: (_j = opts == null ? void 0 : opts.mediaResolution) != null ? _j : void 0
5310
+ previousInteractionId: (_m = opts == null ? void 0 : opts.previousInteractionId) != null ? _m : void 0,
5311
+ store: (_n = opts == null ? void 0 : opts.store) != null ? _n : void 0,
5312
+ mediaResolution: (_o = opts == null ? void 0 : opts.mediaResolution) != null ? _o : void 0
5291
5313
  });
5292
5314
  warnings.push(...convWarnings);
5293
5315
  let systemInstruction = convertedSystemInstruction;
5294
- const optionSystemInstruction = (_k = opts == null ? void 0 : opts.systemInstruction) != null ? _k : void 0;
5316
+ const optionSystemInstruction = (_p = opts == null ? void 0 : opts.systemInstruction) != null ? _p : void 0;
5295
5317
  if (systemInstruction != null && optionSystemInstruction != null) {
5296
5318
  warnings.push({
5297
5319
  type: "other",
@@ -5330,14 +5352,14 @@ var GoogleInteractionsLanguageModel = class {
5330
5352
  generationConfig = void 0;
5331
5353
  } else {
5332
5354
  generationConfig = pruneUndefined({
5333
- temperature: (_l = options.temperature) != null ? _l : void 0,
5334
- top_p: (_m = options.topP) != null ? _m : void 0,
5335
- top_k: (_n = options.topK) != null ? _n : void 0,
5336
- seed: (_o = options.seed) != null ? _o : void 0,
5355
+ temperature: (_q = options.temperature) != null ? _q : void 0,
5356
+ top_p: (_r = options.topP) != null ? _r : void 0,
5357
+ top_k: (_s = options.topK) != null ? _s : void 0,
5358
+ seed: (_t = options.seed) != null ? _t : void 0,
5337
5359
  stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
5338
- max_output_tokens: (_p = options.maxOutputTokens) != null ? _p : void 0,
5339
- thinking_level: (_q = opts == null ? void 0 : opts.thinkingLevel) != null ? _q : void 0,
5340
- thinking_summaries: (_r = opts == null ? void 0 : opts.thinkingSummaries) != null ? _r : void 0,
5360
+ max_output_tokens: (_u = options.maxOutputTokens) != null ? _u : void 0,
5361
+ thinking_level: (_v = opts == null ? void 0 : opts.thinkingLevel) != null ? _v : void 0,
5362
+ thinking_summaries: (_w = opts == null ? void 0 : opts.thinkingSummaries) != null ? _w : void 0,
5341
5363
  tool_choice: toolChoiceForBody
5342
5364
  });
5343
5365
  if ((opts == null ? void 0 : opts.imageConfig) != null) {
@@ -5364,9 +5386,9 @@ var GoogleInteractionsLanguageModel = class {
5364
5386
  if (ac.type === "deep-research") {
5365
5387
  agentConfig = pruneUndefined({
5366
5388
  type: "deep-research",
5367
- thinking_summaries: (_s = ac.thinkingSummaries) != null ? _s : void 0,
5368
- visualization: (_t = ac.visualization) != null ? _t : void 0,
5369
- collaborative_planning: (_u = ac.collaborativePlanning) != null ? _u : void 0
5389
+ thinking_summaries: (_x = ac.thinkingSummaries) != null ? _x : void 0,
5390
+ visualization: (_y = ac.visualization) != null ? _y : void 0,
5391
+ collaborative_planning: (_z = ac.collaborativePlanning) != null ? _z : void 0
5370
5392
  });
5371
5393
  } else if (ac.type === "dynamic") {
5372
5394
  agentConfig = { type: "dynamic" };
@@ -5383,7 +5405,7 @@ var GoogleInteractionsLanguageModel = class {
5383
5405
  environment = opts.environment;
5384
5406
  } else {
5385
5407
  const env = opts.environment;
5386
- const sources = (_v = env.sources) == null ? void 0 : _v.map((s) => {
5408
+ const sources = (_A = env.sources) == null ? void 0 : _A.map((s) => {
5387
5409
  var _a2;
5388
5410
  if (s.type === "inline") {
5389
5411
  return {
@@ -5428,20 +5450,20 @@ var GoogleInteractionsLanguageModel = class {
5428
5450
  tools: toolsForBody,
5429
5451
  response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
5430
5452
  response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
5431
- previous_interaction_id: (_w = opts == null ? void 0 : opts.previousInteractionId) != null ? _w : void 0,
5432
- service_tier: (_x = opts == null ? void 0 : opts.serviceTier) != null ? _x : void 0,
5433
- store: (_y = opts == null ? void 0 : opts.store) != null ? _y : void 0,
5453
+ previous_interaction_id: (_B = opts == null ? void 0 : opts.previousInteractionId) != null ? _B : void 0,
5454
+ service_tier: (_C = opts == null ? void 0 : opts.serviceTier) != null ? _C : void 0,
5455
+ store: (_D = opts == null ? void 0 : opts.store) != null ? _D : void 0,
5434
5456
  generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
5435
5457
  agent_config: agentConfig,
5436
5458
  environment,
5437
- background: (_z = opts == null ? void 0 : opts.background) != null ? _z : void 0
5459
+ background: (_E = opts == null ? void 0 : opts.background) != null ? _E : void 0
5438
5460
  });
5439
5461
  return {
5440
5462
  args,
5441
5463
  warnings,
5442
5464
  isAgent,
5443
5465
  isBackground: (opts == null ? void 0 : opts.background) === true,
5444
- pollingTimeoutMs: (_A = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _A : void 0
5466
+ pollingTimeoutMs: (_F = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _F : void 0
5445
5467
  };
5446
5468
  }
5447
5469
  async doGenerate(options) {