@ai-sdk/google 2.0.66 → 2.0.68

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.
@@ -179,6 +179,14 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
179
179
  candidatesTokenCount?: number | null | undefined;
180
180
  totalTokenCount?: number | null | undefined;
181
181
  trafficType?: string | null | undefined;
182
+ promptTokensDetails?: {
183
+ modality: string;
184
+ tokenCount: number;
185
+ }[] | null | undefined;
186
+ candidatesTokensDetails?: {
187
+ modality: string;
188
+ tokenCount: number;
189
+ }[] | null | undefined;
182
190
  } | null | undefined;
183
191
  promptFeedback?: {
184
192
  blockReason?: string | null | undefined;
@@ -179,6 +179,14 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
179
179
  candidatesTokenCount?: number | null | undefined;
180
180
  totalTokenCount?: number | null | undefined;
181
181
  trafficType?: string | null | undefined;
182
+ promptTokensDetails?: {
183
+ modality: string;
184
+ tokenCount: number;
185
+ }[] | null | undefined;
186
+ candidatesTokensDetails?: {
187
+ modality: string;
188
+ tokenCount: number;
189
+ }[] | null | undefined;
182
190
  } | null | undefined;
183
191
  promptFeedback?: {
184
192
  blockReason?: string | null | undefined;
@@ -513,6 +513,11 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
513
513
  })
514
514
  )
515
515
  );
516
+ var VertexServiceTierMap = {
517
+ standard: "SERVICE_TIER_STANDARD",
518
+ flex: "SERVICE_TIER_FLEX",
519
+ priority: "SERVICE_TIER_PRIORITY"
520
+ };
516
521
 
517
522
  // src/google-prepare-tools.ts
518
523
  var import_provider2 = require("@ai-sdk/provider");
@@ -777,14 +782,19 @@ var GoogleGenerativeAILanguageModel = class {
777
782
  providerOptions,
778
783
  schema: googleGenerativeAIProviderOptions
779
784
  });
785
+ const isVertexProvider = this.config.provider.startsWith("google.vertex.");
780
786
  if ((tools == null ? void 0 : tools.some(
781
787
  (tool) => tool.type === "provider-defined" && tool.id === "google.vertex_rag_store"
782
- )) && !this.config.provider.startsWith("google.vertex.")) {
788
+ )) && !isVertexProvider) {
783
789
  warnings.push({
784
790
  type: "other",
785
791
  message: `The 'vertex_rag_store' tool is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
786
792
  });
787
793
  }
794
+ let sanitizedServiceTier = googleOptions == null ? void 0 : googleOptions.serviceTier;
795
+ if ((googleOptions == null ? void 0 : googleOptions.serviceTier) && isVertexProvider) {
796
+ sanitizedServiceTier = VertexServiceTierMap[googleOptions.serviceTier];
797
+ }
788
798
  const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
789
799
  const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
790
800
  const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(
@@ -841,7 +851,7 @@ var GoogleGenerativeAILanguageModel = class {
841
851
  } : googleToolConfig,
842
852
  cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
843
853
  labels: googleOptions == null ? void 0 : googleOptions.labels,
844
- serviceTier: googleOptions == null ? void 0 : googleOptions.serviceTier
854
+ serviceTier: sanitizedServiceTier
845
855
  },
846
856
  warnings: [...warnings, ...toolWarnings]
847
857
  };
@@ -1429,6 +1439,12 @@ var getSafetyRatingSchema = () => import_v43.z.object({
1429
1439
  severityScore: import_v43.z.number().nullish(),
1430
1440
  blocked: import_v43.z.boolean().nullish()
1431
1441
  });
1442
+ var tokenDetailsSchema = import_v43.z.array(
1443
+ import_v43.z.object({
1444
+ modality: import_v43.z.string(),
1445
+ tokenCount: import_v43.z.number()
1446
+ })
1447
+ ).nullish();
1432
1448
  var usageSchema = import_v43.z.object({
1433
1449
  cachedContentTokenCount: import_v43.z.number().nullish(),
1434
1450
  thoughtsTokenCount: import_v43.z.number().nullish(),
@@ -1436,7 +1452,10 @@ var usageSchema = import_v43.z.object({
1436
1452
  candidatesTokenCount: import_v43.z.number().nullish(),
1437
1453
  totalTokenCount: import_v43.z.number().nullish(),
1438
1454
  // https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
1439
- trafficType: import_v43.z.string().nullish()
1455
+ trafficType: import_v43.z.string().nullish(),
1456
+ // https://ai.google.dev/api/generate-content#Modality
1457
+ promptTokensDetails: tokenDetailsSchema,
1458
+ candidatesTokensDetails: tokenDetailsSchema
1440
1459
  });
1441
1460
  var getUrlContextMetadataSchema = () => import_v43.z.object({
1442
1461
  urlMetadata: import_v43.z.array(