@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 3.0.120
4
+
5
+ ### Patch Changes
6
+
7
+ - daaa769: fix(google): support video response formats in Gemini Interactions
8
+
9
+ ## 3.0.119
10
+
11
+ ### Patch Changes
12
+
13
+ - 1912e88: Preserve complete Google Generative Language usage metadata in raw usage results.
14
+ - Updated dependencies [cc23556]
15
+ - @ai-sdk/provider-utils@4.0.50
16
+
3
17
  ## 3.0.118
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
2
  import { InferSchema, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
3
- import { TranscriptionModelV3, ProviderV3, LanguageModelV3, ImageModelV3, EmbeddingModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
4
3
  import { z } from 'zod/v4';
4
+ import { TranscriptionModelV3, ProviderV3, LanguageModelV3, ImageModelV3, EmbeddingModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
5
5
 
6
6
  declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
7
7
  error: {
@@ -174,18 +174,32 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
174
174
  } | null | undefined;
175
175
  }[] | null | undefined;
176
176
  usageMetadata?: {
177
+ [x: string]: z.core.util.JSONType;
177
178
  cachedContentTokenCount?: number | null | undefined;
178
179
  thoughtsTokenCount?: number | null | undefined;
179
180
  promptTokenCount?: number | null | undefined;
180
181
  candidatesTokenCount?: number | null | undefined;
182
+ toolUsePromptTokenCount?: number | null | undefined;
181
183
  totalTokenCount?: number | null | undefined;
182
184
  trafficType?: string | null | undefined;
183
185
  serviceTier?: string | null | undefined;
184
186
  promptTokensDetails?: {
187
+ [x: string]: z.core.util.JSONType;
188
+ modality: string;
189
+ tokenCount: number;
190
+ }[] | null | undefined;
191
+ cacheTokensDetails?: {
192
+ [x: string]: z.core.util.JSONType;
185
193
  modality: string;
186
194
  tokenCount: number;
187
195
  }[] | null | undefined;
188
196
  candidatesTokensDetails?: {
197
+ [x: string]: z.core.util.JSONType;
198
+ modality: string;
199
+ tokenCount: number;
200
+ }[] | null | undefined;
201
+ toolUsePromptTokensDetails?: {
202
+ [x: string]: z.core.util.JSONType;
189
203
  modality: string;
190
204
  tokenCount: number;
191
205
  }[] | null | undefined;
@@ -330,6 +344,14 @@ declare const googleInteractionsLanguageModelOptions: _ai_sdk_provider_utils.Laz
330
344
  [x: string]: unknown;
331
345
  type: "audio";
332
346
  mimeType?: string | null | undefined;
347
+ } | {
348
+ [x: string]: unknown;
349
+ type: "video";
350
+ aspectRatio?: "9:16" | "16:9" | null | undefined;
351
+ resolution?: "720p" | "1080p" | "4k" | "360p" | null | undefined;
352
+ duration?: string | null | undefined;
353
+ delivery?: "uri" | "inline" | null | undefined;
354
+ gcsUri?: string | null | undefined;
333
355
  })[] | null | undefined;
334
356
  imageConfig?: {
335
357
  aspectRatio?: "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9" | "1:8" | "8:1" | "1:4" | "4:1" | null | undefined;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
2
  import { InferSchema, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
3
- import { TranscriptionModelV3, ProviderV3, LanguageModelV3, ImageModelV3, EmbeddingModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
4
3
  import { z } from 'zod/v4';
4
+ import { TranscriptionModelV3, ProviderV3, LanguageModelV3, ImageModelV3, EmbeddingModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
5
5
 
6
6
  declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
7
7
  error: {
@@ -174,18 +174,32 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
174
174
  } | null | undefined;
175
175
  }[] | null | undefined;
176
176
  usageMetadata?: {
177
+ [x: string]: z.core.util.JSONType;
177
178
  cachedContentTokenCount?: number | null | undefined;
178
179
  thoughtsTokenCount?: number | null | undefined;
179
180
  promptTokenCount?: number | null | undefined;
180
181
  candidatesTokenCount?: number | null | undefined;
182
+ toolUsePromptTokenCount?: number | null | undefined;
181
183
  totalTokenCount?: number | null | undefined;
182
184
  trafficType?: string | null | undefined;
183
185
  serviceTier?: string | null | undefined;
184
186
  promptTokensDetails?: {
187
+ [x: string]: z.core.util.JSONType;
188
+ modality: string;
189
+ tokenCount: number;
190
+ }[] | null | undefined;
191
+ cacheTokensDetails?: {
192
+ [x: string]: z.core.util.JSONType;
185
193
  modality: string;
186
194
  tokenCount: number;
187
195
  }[] | null | undefined;
188
196
  candidatesTokensDetails?: {
197
+ [x: string]: z.core.util.JSONType;
198
+ modality: string;
199
+ tokenCount: number;
200
+ }[] | null | undefined;
201
+ toolUsePromptTokensDetails?: {
202
+ [x: string]: z.core.util.JSONType;
189
203
  modality: string;
190
204
  tokenCount: number;
191
205
  }[] | null | undefined;
@@ -330,6 +344,14 @@ declare const googleInteractionsLanguageModelOptions: _ai_sdk_provider_utils.Laz
330
344
  [x: string]: unknown;
331
345
  type: "audio";
332
346
  mimeType?: string | null | undefined;
347
+ } | {
348
+ [x: string]: unknown;
349
+ type: "video";
350
+ aspectRatio?: "9:16" | "16:9" | null | undefined;
351
+ resolution?: "720p" | "1080p" | "4k" | "360p" | null | undefined;
352
+ duration?: string | null | undefined;
353
+ delivery?: "uri" | "inline" | null | undefined;
354
+ gcsUri?: string | null | undefined;
333
355
  })[] | null | undefined;
334
356
  imageConfig?: {
335
357
  aspectRatio?: "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9" | "1:8" | "8:1" | "1:4" | "4:1" | null | undefined;
package/dist/index.js CHANGED
@@ -235,7 +235,7 @@ var googleInteractionsTranscriptionResponseSchema = import_v43.z.object({
235
235
  var import_provider_utils24 = require("@ai-sdk/provider-utils");
236
236
 
237
237
  // src/version.ts
238
- var VERSION = true ? "3.0.118" : "0.0.0-test";
238
+ var VERSION = true ? "3.0.120" : "0.0.0-test";
239
239
 
240
240
  // src/google-generative-ai-embedding-model.ts
241
241
  var import_provider2 = require("@ai-sdk/provider");
@@ -2907,21 +2907,24 @@ var tokenDetailsSchema = import_v47.z.array(
2907
2907
  import_v47.z.object({
2908
2908
  modality: import_v47.z.string(),
2909
2909
  tokenCount: import_v47.z.number()
2910
- })
2910
+ }).catchall(import_v47.z.json())
2911
2911
  ).nullish();
2912
2912
  var usageSchema = import_v47.z.object({
2913
2913
  cachedContentTokenCount: import_v47.z.number().nullish(),
2914
2914
  thoughtsTokenCount: import_v47.z.number().nullish(),
2915
2915
  promptTokenCount: import_v47.z.number().nullish(),
2916
2916
  candidatesTokenCount: import_v47.z.number().nullish(),
2917
+ toolUsePromptTokenCount: import_v47.z.number().nullish(),
2917
2918
  totalTokenCount: import_v47.z.number().nullish(),
2918
2919
  // https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
2919
2920
  trafficType: import_v47.z.string().nullish(),
2920
2921
  serviceTier: import_v47.z.string().nullish(),
2921
2922
  // https://ai.google.dev/api/generate-content#Modality
2922
2923
  promptTokensDetails: tokenDetailsSchema,
2923
- candidatesTokensDetails: tokenDetailsSchema
2924
- });
2924
+ cacheTokensDetails: tokenDetailsSchema,
2925
+ candidatesTokensDetails: tokenDetailsSchema,
2926
+ toolUsePromptTokensDetails: tokenDetailsSchema
2927
+ }).catchall(import_v47.z.json());
2925
2928
  var getUrlContextMetadataSchema = () => import_v47.z.object({
2926
2929
  urlMetadata: import_v47.z.array(
2927
2930
  import_v47.z.object({
@@ -5238,8 +5241,8 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils19.lazySch
5238
5241
  thinkingSummaries: import_v418.z.enum(["auto", "none"]).nullish(),
5239
5242
  /**
5240
5243
  * Output-format entries that map directly to the API's `response_format`
5241
- * array. Use this to request image, audio, or non-JSON text outputs
5242
- * with full control over `mime_type`, `aspect_ratio`, and `image_size`.
5244
+ * array. Use this to request image, audio, video, or non-JSON text
5245
+ * outputs with modality-specific controls.
5243
5246
  *
5244
5247
  * Entries are sent in order. The AI SDK call-level `responseFormat: {
5245
5248
  * type: 'json', schema }` still drives JSON-mode and adds a matching
@@ -5276,6 +5279,14 @@ var googleInteractionsLanguageModelOptions = (0, import_provider_utils19.lazySch
5276
5279
  import_v418.z.object({
5277
5280
  type: import_v418.z.literal("audio"),
5278
5281
  mimeType: import_v418.z.string().nullish()
5282
+ }).loose(),
5283
+ import_v418.z.object({
5284
+ type: import_v418.z.literal("video"),
5285
+ aspectRatio: import_v418.z.enum(["16:9", "9:16"]).nullish(),
5286
+ resolution: import_v418.z.enum(["360p", "720p", "1080p", "4k"]).nullish(),
5287
+ duration: import_v418.z.string().nullish(),
5288
+ delivery: import_v418.z.enum(["inline", "uri"]).nullish(),
5289
+ gcsUri: import_v418.z.string().nullish()
5279
5290
  }).loose()
5280
5291
  ])
5281
5292
  ).nullish(),
@@ -6162,7 +6173,7 @@ var GoogleInteractionsLanguageModel = class {
6162
6173
  };
6163
6174
  }
6164
6175
  async getArgs(options) {
6165
- 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;
6176
+ 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;
6166
6177
  const warnings = [];
6167
6178
  const opts = await (0, import_provider_utils23.parseProviderOptions)({
6168
6179
  provider: "google",
@@ -6238,6 +6249,17 @@ var GoogleInteractionsLanguageModel = class {
6238
6249
  mime_type: (_g = entry.mimeType) != null ? _g : void 0
6239
6250
  })
6240
6251
  );
6252
+ } else if (entry.type === "video") {
6253
+ responseFormatEntries.push(
6254
+ pruneUndefined({
6255
+ type: "video",
6256
+ aspect_ratio: (_h = entry.aspectRatio) != null ? _h : void 0,
6257
+ resolution: (_i = entry.resolution) != null ? _i : void 0,
6258
+ duration: (_j = entry.duration) != null ? _j : void 0,
6259
+ delivery: (_k = entry.delivery) != null ? _k : void 0,
6260
+ gcs_uri: (_l = entry.gcsUri) != null ? _l : void 0
6261
+ })
6262
+ );
6241
6263
  }
6242
6264
  }
6243
6265
  }
@@ -6247,13 +6269,13 @@ var GoogleInteractionsLanguageModel = class {
6247
6269
  warnings: convWarnings
6248
6270
  } = convertToGoogleInteractionsInput({
6249
6271
  prompt: options.prompt,
6250
- previousInteractionId: (_h = opts == null ? void 0 : opts.previousInteractionId) != null ? _h : void 0,
6251
- store: (_i = opts == null ? void 0 : opts.store) != null ? _i : void 0,
6252
- mediaResolution: (_j = opts == null ? void 0 : opts.mediaResolution) != null ? _j : void 0
6272
+ previousInteractionId: (_m = opts == null ? void 0 : opts.previousInteractionId) != null ? _m : void 0,
6273
+ store: (_n = opts == null ? void 0 : opts.store) != null ? _n : void 0,
6274
+ mediaResolution: (_o = opts == null ? void 0 : opts.mediaResolution) != null ? _o : void 0
6253
6275
  });
6254
6276
  warnings.push(...convWarnings);
6255
6277
  let systemInstruction = convertedSystemInstruction;
6256
- const optionSystemInstruction = (_k = opts == null ? void 0 : opts.systemInstruction) != null ? _k : void 0;
6278
+ const optionSystemInstruction = (_p = opts == null ? void 0 : opts.systemInstruction) != null ? _p : void 0;
6257
6279
  if (systemInstruction != null && optionSystemInstruction != null) {
6258
6280
  warnings.push({
6259
6281
  type: "other",
@@ -6292,14 +6314,14 @@ var GoogleInteractionsLanguageModel = class {
6292
6314
  generationConfig = void 0;
6293
6315
  } else {
6294
6316
  generationConfig = pruneUndefined({
6295
- temperature: (_l = options.temperature) != null ? _l : void 0,
6296
- top_p: (_m = options.topP) != null ? _m : void 0,
6297
- top_k: (_n = options.topK) != null ? _n : void 0,
6298
- seed: (_o = options.seed) != null ? _o : void 0,
6317
+ temperature: (_q = options.temperature) != null ? _q : void 0,
6318
+ top_p: (_r = options.topP) != null ? _r : void 0,
6319
+ top_k: (_s = options.topK) != null ? _s : void 0,
6320
+ seed: (_t = options.seed) != null ? _t : void 0,
6299
6321
  stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
6300
- max_output_tokens: (_p = options.maxOutputTokens) != null ? _p : void 0,
6301
- thinking_level: (_q = opts == null ? void 0 : opts.thinkingLevel) != null ? _q : void 0,
6302
- thinking_summaries: (_r = opts == null ? void 0 : opts.thinkingSummaries) != null ? _r : void 0,
6322
+ max_output_tokens: (_u = options.maxOutputTokens) != null ? _u : void 0,
6323
+ thinking_level: (_v = opts == null ? void 0 : opts.thinkingLevel) != null ? _v : void 0,
6324
+ thinking_summaries: (_w = opts == null ? void 0 : opts.thinkingSummaries) != null ? _w : void 0,
6303
6325
  tool_choice: toolChoiceForBody
6304
6326
  });
6305
6327
  if ((opts == null ? void 0 : opts.imageConfig) != null) {
@@ -6326,9 +6348,9 @@ var GoogleInteractionsLanguageModel = class {
6326
6348
  if (ac.type === "deep-research") {
6327
6349
  agentConfig = pruneUndefined({
6328
6350
  type: "deep-research",
6329
- thinking_summaries: (_s = ac.thinkingSummaries) != null ? _s : void 0,
6330
- visualization: (_t = ac.visualization) != null ? _t : void 0,
6331
- collaborative_planning: (_u = ac.collaborativePlanning) != null ? _u : void 0
6351
+ thinking_summaries: (_x = ac.thinkingSummaries) != null ? _x : void 0,
6352
+ visualization: (_y = ac.visualization) != null ? _y : void 0,
6353
+ collaborative_planning: (_z = ac.collaborativePlanning) != null ? _z : void 0
6332
6354
  });
6333
6355
  } else if (ac.type === "dynamic") {
6334
6356
  agentConfig = { type: "dynamic" };
@@ -6345,7 +6367,7 @@ var GoogleInteractionsLanguageModel = class {
6345
6367
  environment = opts.environment;
6346
6368
  } else {
6347
6369
  const env = opts.environment;
6348
- const sources = (_v = env.sources) == null ? void 0 : _v.map((s) => {
6370
+ const sources = (_A = env.sources) == null ? void 0 : _A.map((s) => {
6349
6371
  var _a2;
6350
6372
  if (s.type === "inline") {
6351
6373
  return {
@@ -6390,20 +6412,20 @@ var GoogleInteractionsLanguageModel = class {
6390
6412
  tools: toolsForBody,
6391
6413
  response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
6392
6414
  response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
6393
- previous_interaction_id: (_w = opts == null ? void 0 : opts.previousInteractionId) != null ? _w : void 0,
6394
- service_tier: (_x = opts == null ? void 0 : opts.serviceTier) != null ? _x : void 0,
6395
- store: (_y = opts == null ? void 0 : opts.store) != null ? _y : void 0,
6415
+ previous_interaction_id: (_B = opts == null ? void 0 : opts.previousInteractionId) != null ? _B : void 0,
6416
+ service_tier: (_C = opts == null ? void 0 : opts.serviceTier) != null ? _C : void 0,
6417
+ store: (_D = opts == null ? void 0 : opts.store) != null ? _D : void 0,
6396
6418
  generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
6397
6419
  agent_config: agentConfig,
6398
6420
  environment,
6399
- background: (_z = opts == null ? void 0 : opts.background) != null ? _z : void 0
6421
+ background: (_E = opts == null ? void 0 : opts.background) != null ? _E : void 0
6400
6422
  });
6401
6423
  return {
6402
6424
  args,
6403
6425
  warnings,
6404
6426
  isAgent,
6405
6427
  isBackground: (opts == null ? void 0 : opts.background) === true,
6406
- pollingTimeoutMs: (_A = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _A : void 0
6428
+ pollingTimeoutMs: (_F = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _F : void 0
6407
6429
  };
6408
6430
  }
6409
6431
  async doGenerate(options) {