@ai-sdk/google 4.0.0-beta.4 → 4.0.0-beta.41

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.
@@ -1,32 +1,40 @@
1
1
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
- import { Resolvable, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
3
- import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from '@ai-sdk/provider';
2
+ import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, Resolvable, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
3
+ import { LanguageModelV4, JSONObject, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult } from '@ai-sdk/provider';
4
4
  import { z } from 'zod/v4';
5
5
 
6
- type GoogleGenerativeAIModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-exp-image-generation' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
6
+ type GoogleGenerativeAIModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
7
7
 
8
8
  type GoogleGenerativeAIConfig = {
9
9
  provider: string;
10
10
  baseURL: string;
11
- headers: Resolvable<Record<string, string | undefined>>;
11
+ headers?: Resolvable<Record<string, string | undefined>>;
12
12
  fetch?: FetchFunction;
13
13
  generateId: () => string;
14
14
  /**
15
15
  * The supported URLs for the model.
16
16
  */
17
- supportedUrls?: () => LanguageModelV3['supportedUrls'];
17
+ supportedUrls?: () => LanguageModelV4['supportedUrls'];
18
18
  };
19
- declare class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
20
- readonly specificationVersion = "v3";
19
+ declare class GoogleGenerativeAILanguageModel implements LanguageModelV4 {
20
+ readonly specificationVersion = "v4";
21
21
  readonly modelId: GoogleGenerativeAIModelId;
22
22
  private readonly config;
23
23
  private readonly generateId;
24
+ static [WORKFLOW_SERIALIZE](model: GoogleGenerativeAILanguageModel): {
25
+ modelId: string;
26
+ config: JSONObject;
27
+ };
28
+ static [WORKFLOW_DESERIALIZE](options: {
29
+ modelId: string;
30
+ config: GoogleGenerativeAIConfig;
31
+ }): GoogleGenerativeAILanguageModel;
24
32
  constructor(modelId: GoogleGenerativeAIModelId, config: GoogleGenerativeAIConfig);
25
33
  get provider(): string;
26
34
  get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
27
35
  private getArgs;
28
- doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
29
- doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
36
+ doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
37
+ doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
30
38
  }
31
39
  declare const getGroundingMetadataSchema: () => z.ZodObject<{
32
40
  webSearchQueries: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
@@ -86,8 +94,17 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
86
94
  content?: Record<string, never> | {
87
95
  parts?: ({
88
96
  functionCall: {
89
- name: string;
90
- args: unknown;
97
+ name?: string | null | undefined;
98
+ args?: unknown;
99
+ partialArgs?: {
100
+ jsonPath: string;
101
+ stringValue?: string | null | undefined;
102
+ numberValue?: number | null | undefined;
103
+ boolValue?: boolean | null | undefined;
104
+ nullValue?: unknown;
105
+ willContinue?: boolean | null | undefined;
106
+ }[] | null | undefined;
107
+ willContinue?: boolean | null | undefined;
91
108
  };
92
109
  thoughtSignature?: string | null | undefined;
93
110
  } | {
@@ -97,6 +114,20 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
97
114
  };
98
115
  thought?: boolean | null | undefined;
99
116
  thoughtSignature?: string | null | undefined;
117
+ } | {
118
+ toolCall: {
119
+ toolType: string;
120
+ id: string;
121
+ args?: unknown;
122
+ };
123
+ thoughtSignature?: string | null | undefined;
124
+ } | {
125
+ toolResponse: {
126
+ toolType: string;
127
+ id: string;
128
+ response?: unknown;
129
+ };
130
+ thoughtSignature?: string | null | undefined;
100
131
  } | {
101
132
  executableCode?: {
102
133
  language: string;
@@ -112,6 +143,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
112
143
  })[] | null | undefined;
113
144
  } | null | undefined;
114
145
  finishReason?: string | null | undefined;
146
+ finishMessage?: string | null | undefined;
115
147
  safetyRatings?: {
116
148
  category?: string | null | undefined;
117
149
  probability?: string | null | undefined;
@@ -181,6 +213,14 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
181
213
  candidatesTokenCount?: number | null | undefined;
182
214
  totalTokenCount?: number | null | undefined;
183
215
  trafficType?: string | null | undefined;
216
+ promptTokensDetails?: {
217
+ modality: string;
218
+ tokenCount: number;
219
+ }[] | null | undefined;
220
+ candidatesTokensDetails?: {
221
+ modality: string;
222
+ tokenCount: number;
223
+ }[] | null | undefined;
184
224
  } | null | undefined;
185
225
  promptFeedback?: {
186
226
  blockReason?: string | null | undefined;
@@ -193,10 +233,13 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
193
233
  blocked?: boolean | null | undefined;
194
234
  }[] | null | undefined;
195
235
  } | null | undefined;
236
+ serviceTier?: string | null | undefined;
196
237
  }>;
197
238
  type GroundingMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['groundingMetadata']>;
198
239
  type UrlContextMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['urlContextMetadata']>;
199
240
  type SafetyRatingSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['safetyRatings']>[number];
241
+ type PromptFeedbackSchema = NonNullable<InferSchema<typeof responseSchema>['promptFeedback']>;
242
+ type UsageMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['usageMetadata']>;
200
243
 
201
244
  declare const googleTools: {
202
245
  /**
@@ -213,7 +256,7 @@ declare const googleTools: {
213
256
  startTime: string;
214
257
  endTime: string;
215
258
  } | undefined;
216
- }>;
259
+ }, {}>;
217
260
  /**
218
261
  * Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
219
262
  * Designed for highly-regulated industries (finance, healthcare, public sector).
@@ -224,7 +267,7 @@ declare const googleTools: {
224
267
  *
225
268
  * @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
226
269
  */
227
- enterpriseWebSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
270
+ enterpriseWebSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}, {}>;
228
271
  /**
229
272
  * Creates a Google Maps grounding tool that gives the model access to Google Maps data.
230
273
  * Must have name "google_maps".
@@ -232,12 +275,12 @@ declare const googleTools: {
232
275
  * @see https://ai.google.dev/gemini-api/docs/maps-grounding
233
276
  * @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
234
277
  */
235
- googleMaps: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
278
+ googleMaps: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}, {}>;
236
279
  /**
237
280
  * Creates a URL context tool that gives Google direct access to real-time web content.
238
281
  * Must have name "url_context".
239
282
  */
240
- urlContext: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}>;
283
+ urlContext: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}, {}>;
241
284
  /**
242
285
  * Enables Retrieval Augmented Generation (RAG) via the Gemini File Search tool.
243
286
  * Must have name "file_search".
@@ -253,7 +296,7 @@ declare const googleTools: {
253
296
  fileSearchStoreNames: string[];
254
297
  topK?: number | undefined;
255
298
  metadataFilter?: string | undefined;
256
- }>;
299
+ }, {}>;
257
300
  /**
258
301
  * A tool that enables the model to generate and run Python code.
259
302
  * Must have name "code_execution".
@@ -270,7 +313,7 @@ declare const googleTools: {
270
313
  }, {
271
314
  outcome: string;
272
315
  output: string;
273
- }, {}>;
316
+ }, {}, {}>;
274
317
  /**
275
318
  * Creates a Vertex RAG Store tool that enables the model to perform RAG searches against a Vertex RAG Store.
276
319
  * Must have name "vertex_rag_store".
@@ -278,7 +321,7 @@ declare const googleTools: {
278
321
  vertexRagStore: _ai_sdk_provider_utils.ProviderToolFactory<{}, {
279
322
  ragCorpus: string;
280
323
  topK?: number;
281
- }>;
324
+ }, {}>;
282
325
  };
283
326
 
284
- export { GoogleGenerativeAILanguageModel, type GoogleGenerativeAIModelId, type GroundingMetadataSchema, type SafetyRatingSchema, type UrlContextMetadataSchema, getGroundingMetadataSchema, getUrlContextMetadataSchema, googleTools };
327
+ export { GoogleGenerativeAILanguageModel, type GoogleGenerativeAIModelId, type GroundingMetadataSchema, type PromptFeedbackSchema, type SafetyRatingSchema, type UrlContextMetadataSchema, type UsageMetadataSchema, getGroundingMetadataSchema, getUrlContextMetadataSchema, googleTools };