@ai-sdk/google 3.0.57 → 3.0.59

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": "3.0.57",
3
+ "version": "3.0.59",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@ai-sdk/provider": "3.0.8",
40
- "@ai-sdk/provider-utils": "4.0.22"
40
+ "@ai-sdk/provider-utils": "4.0.23"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "20.17.24",
@@ -1,5 +1,10 @@
1
1
  import { LanguageModelV3Usage } from '@ai-sdk/provider';
2
2
 
3
+ export type GoogleGenerativeAITokenDetail = {
4
+ modality: string;
5
+ tokenCount: number;
6
+ };
7
+
3
8
  export type GoogleGenerativeAIUsageMetadata = {
4
9
  promptTokenCount?: number | null;
5
10
  candidatesTokenCount?: number | null;
@@ -7,6 +12,8 @@ export type GoogleGenerativeAIUsageMetadata = {
7
12
  cachedContentTokenCount?: number | null;
8
13
  thoughtsTokenCount?: number | null;
9
14
  trafficType?: string | null;
15
+ promptTokensDetails?: GoogleGenerativeAITokenDetail[] | null;
16
+ candidatesTokensDetails?: GoogleGenerativeAITokenDetail[] | null;
10
17
  };
11
18
 
12
19
  export function convertGoogleGenerativeAIUsage(
@@ -1110,6 +1110,15 @@ const getSafetyRatingSchema = () =>
1110
1110
  blocked: z.boolean().nullish(),
1111
1111
  });
1112
1112
 
1113
+ const tokenDetailsSchema = z
1114
+ .array(
1115
+ z.object({
1116
+ modality: z.string(),
1117
+ tokenCount: z.number(),
1118
+ }),
1119
+ )
1120
+ .nullish();
1121
+
1113
1122
  const usageSchema = z.object({
1114
1123
  cachedContentTokenCount: z.number().nullish(),
1115
1124
  thoughtsTokenCount: z.number().nullish(),
@@ -1118,6 +1127,9 @@ const usageSchema = z.object({
1118
1127
  totalTokenCount: z.number().nullish(),
1119
1128
  // https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
1120
1129
  trafficType: z.string().nullish(),
1130
+ // https://ai.google.dev/api/generate-content#Modality
1131
+ promptTokensDetails: tokenDetailsSchema,
1132
+ candidatesTokensDetails: tokenDetailsSchema,
1121
1133
  });
1122
1134
 
1123
1135
  // https://ai.google.dev/api/generate-content#UrlRetrievalMetadata
@@ -122,7 +122,7 @@ export function prepareTools({
122
122
  type: 'unsupported',
123
123
  feature: `provider-defined tool ${tool.id}`,
124
124
  details:
125
- 'The code execution tools is not supported with other Gemini models than Gemini 2.',
125
+ 'The code execution tool is not supported with other Gemini models than Gemini 2.',
126
126
  });
127
127
  }
128
128
  break;