@ai-sdk/google 4.0.0-beta.36 → 4.0.0-beta.38
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 +30 -0
- package/dist/index.js +546 -431
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +11 -3
- package/dist/internal/index.js +325 -296
- package/dist/internal/index.js.map +1 -1
- package/package.json +9 -10
- package/src/convert-to-google-generative-ai-messages.ts +15 -13
- package/src/google-generative-ai-embedding-model.ts +22 -2
- package/src/google-generative-ai-image-model.ts +25 -1
- package/src/google-generative-ai-language-model.ts +20 -3
- package/dist/index.d.mts +0 -427
- package/dist/index.mjs +0 -3439
- package/dist/index.mjs.map +0 -1
- package/dist/internal/index.d.mts +0 -319
- package/dist/internal/index.mjs +0 -2458
- package/dist/internal/index.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.38",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"license": "Apache-2.0",
|
|
5
6
|
"sideEffects": false,
|
|
6
7
|
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.mjs",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/**/*",
|
|
@@ -25,26 +25,25 @@
|
|
|
25
25
|
"./package.json": "./package.json",
|
|
26
26
|
".": {
|
|
27
27
|
"types": "./dist/index.d.ts",
|
|
28
|
-
"import": "./dist/index.
|
|
29
|
-
"
|
|
28
|
+
"import": "./dist/index.js",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
30
|
},
|
|
31
31
|
"./internal": {
|
|
32
32
|
"types": "./dist/internal/index.d.ts",
|
|
33
|
-
"import": "./dist/internal/index.
|
|
34
|
-
"
|
|
35
|
-
"require": "./dist/internal/index.js"
|
|
33
|
+
"import": "./dist/internal/index.js",
|
|
34
|
+
"default": "./dist/internal/index.js"
|
|
36
35
|
}
|
|
37
36
|
},
|
|
38
37
|
"dependencies": {
|
|
39
|
-
"@ai-sdk/provider": "4.0.0-beta.
|
|
40
|
-
"@ai-sdk/provider-utils": "5.0.0-beta.
|
|
38
|
+
"@ai-sdk/provider": "4.0.0-beta.12",
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.0-beta.20"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
43
42
|
"@types/node": "20.17.24",
|
|
44
43
|
"tsup": "^8",
|
|
45
44
|
"typescript": "5.8.3",
|
|
46
45
|
"zod": "3.25.76",
|
|
47
|
-
"@ai-sdk/test-server": "2.0.0-beta.
|
|
46
|
+
"@ai-sdk/test-server": "2.0.0-beta.1",
|
|
48
47
|
"@vercel/ai-tsconfig": "0.0.0"
|
|
49
48
|
},
|
|
50
49
|
"peerDependencies": {
|
|
@@ -71,7 +71,6 @@ function appendToolResultParts(
|
|
|
71
71
|
responseTextParts.push(contentPart.text as string);
|
|
72
72
|
break;
|
|
73
73
|
}
|
|
74
|
-
case 'image-data':
|
|
75
74
|
case 'file-data': {
|
|
76
75
|
functionResponseParts.push({
|
|
77
76
|
inlineData: {
|
|
@@ -81,7 +80,6 @@ function appendToolResultParts(
|
|
|
81
80
|
});
|
|
82
81
|
break;
|
|
83
82
|
}
|
|
84
|
-
case 'image-url':
|
|
85
83
|
case 'file-url': {
|
|
86
84
|
const functionResponsePart = convertUrlToolResultPart(
|
|
87
85
|
contentPart.url as string,
|
|
@@ -144,18 +142,22 @@ function appendLegacyToolResultParts(
|
|
|
144
142
|
},
|
|
145
143
|
});
|
|
146
144
|
break;
|
|
147
|
-
case '
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
145
|
+
case 'file-data':
|
|
146
|
+
if ((contentPart.mediaType as string).startsWith('image/')) {
|
|
147
|
+
parts.push(
|
|
148
|
+
{
|
|
149
|
+
inlineData: {
|
|
150
|
+
mimeType: contentPart.mediaType as string,
|
|
151
|
+
data: contentPart.data as string,
|
|
152
|
+
},
|
|
153
153
|
},
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
{
|
|
155
|
+
text: 'Tool executed successfully and returned this image as a response',
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
} else {
|
|
159
|
+
parts.push({ text: JSON.stringify(contentPart) });
|
|
160
|
+
}
|
|
159
161
|
break;
|
|
160
162
|
default:
|
|
161
163
|
parts.push({ text: JSON.stringify(contentPart) });
|
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
parseProviderOptions,
|
|
11
11
|
postJsonToApi,
|
|
12
12
|
resolve,
|
|
13
|
+
serializeModelOptions,
|
|
14
|
+
WORKFLOW_SERIALIZE,
|
|
15
|
+
WORKFLOW_DESERIALIZE,
|
|
13
16
|
zodSchema,
|
|
14
17
|
} from '@ai-sdk/provider-utils';
|
|
15
18
|
import { z } from 'zod/v4';
|
|
@@ -22,7 +25,7 @@ import {
|
|
|
22
25
|
type GoogleGenerativeAIEmbeddingConfig = {
|
|
23
26
|
provider: string;
|
|
24
27
|
baseURL: string;
|
|
25
|
-
headers
|
|
28
|
+
headers?: () => Record<string, string | undefined>;
|
|
26
29
|
fetch?: FetchFunction;
|
|
27
30
|
};
|
|
28
31
|
|
|
@@ -34,6 +37,23 @@ export class GoogleGenerativeAIEmbeddingModel implements EmbeddingModelV4 {
|
|
|
34
37
|
|
|
35
38
|
private readonly config: GoogleGenerativeAIEmbeddingConfig;
|
|
36
39
|
|
|
40
|
+
static [WORKFLOW_SERIALIZE](model: GoogleGenerativeAIEmbeddingModel) {
|
|
41
|
+
return serializeModelOptions({
|
|
42
|
+
modelId: model.modelId,
|
|
43
|
+
config: model.config,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
48
|
+
modelId: string;
|
|
49
|
+
config: GoogleGenerativeAIEmbeddingConfig;
|
|
50
|
+
}) {
|
|
51
|
+
return new GoogleGenerativeAIEmbeddingModel(
|
|
52
|
+
options.modelId,
|
|
53
|
+
options.config,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
37
57
|
get provider(): string {
|
|
38
58
|
return this.config.provider;
|
|
39
59
|
}
|
|
@@ -70,7 +90,7 @@ export class GoogleGenerativeAIEmbeddingModel implements EmbeddingModelV4 {
|
|
|
70
90
|
}
|
|
71
91
|
|
|
72
92
|
const mergedHeaders = combineHeaders(
|
|
73
|
-
await resolve(this.config.headers),
|
|
93
|
+
this.config.headers ? await resolve(this.config.headers) : undefined,
|
|
74
94
|
headers,
|
|
75
95
|
);
|
|
76
96
|
|
|
@@ -15,6 +15,9 @@ import {
|
|
|
15
15
|
postJsonToApi,
|
|
16
16
|
Resolvable,
|
|
17
17
|
resolve,
|
|
18
|
+
serializeModelOptions,
|
|
19
|
+
WORKFLOW_SERIALIZE,
|
|
20
|
+
WORKFLOW_DESERIALIZE,
|
|
18
21
|
zodSchema,
|
|
19
22
|
} from '@ai-sdk/provider-utils';
|
|
20
23
|
import { z } from 'zod/v4';
|
|
@@ -40,6 +43,24 @@ interface GoogleGenerativeAIImageModelConfig {
|
|
|
40
43
|
export class GoogleGenerativeAIImageModel implements ImageModelV4 {
|
|
41
44
|
readonly specificationVersion = 'v4';
|
|
42
45
|
|
|
46
|
+
static [WORKFLOW_SERIALIZE](model: GoogleGenerativeAIImageModel) {
|
|
47
|
+
return serializeModelOptions({
|
|
48
|
+
modelId: model.modelId,
|
|
49
|
+
config: model.config,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
54
|
+
modelId: string;
|
|
55
|
+
config: GoogleGenerativeAIImageModelConfig;
|
|
56
|
+
}) {
|
|
57
|
+
return new GoogleGenerativeAIImageModel(
|
|
58
|
+
options.modelId,
|
|
59
|
+
{},
|
|
60
|
+
options.config,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
43
64
|
get maxImagesPerCall(): number {
|
|
44
65
|
if (this.settings.maxImagesPerCall != null) {
|
|
45
66
|
return this.settings.maxImagesPerCall;
|
|
@@ -151,7 +172,10 @@ export class GoogleGenerativeAIImageModel implements ImageModelV4 {
|
|
|
151
172
|
predictions: Array<{ bytesBase64Encoded: string }>;
|
|
152
173
|
}>({
|
|
153
174
|
url: `${this.config.baseURL}/models/${this.modelId}:predict`,
|
|
154
|
-
headers: combineHeaders(
|
|
175
|
+
headers: combineHeaders(
|
|
176
|
+
this.config.headers ? await resolve(this.config.headers) : undefined,
|
|
177
|
+
headers,
|
|
178
|
+
),
|
|
155
179
|
body,
|
|
156
180
|
failedResponseHandler: googleFailedResponseHandler,
|
|
157
181
|
successfulResponseHandler: createJsonResponseHandler(
|
|
@@ -27,6 +27,9 @@ import {
|
|
|
27
27
|
postJsonToApi,
|
|
28
28
|
Resolvable,
|
|
29
29
|
resolve,
|
|
30
|
+
serializeModelOptions,
|
|
31
|
+
WORKFLOW_SERIALIZE,
|
|
32
|
+
WORKFLOW_DESERIALIZE,
|
|
30
33
|
zodSchema,
|
|
31
34
|
} from '@ai-sdk/provider-utils';
|
|
32
35
|
import { z } from 'zod/v4';
|
|
@@ -51,7 +54,7 @@ import { mapGoogleGenerativeAIFinishReason } from './map-google-generative-ai-fi
|
|
|
51
54
|
type GoogleGenerativeAIConfig = {
|
|
52
55
|
provider: string;
|
|
53
56
|
baseURL: string;
|
|
54
|
-
headers
|
|
57
|
+
headers?: Resolvable<Record<string, string | undefined>>;
|
|
55
58
|
fetch?: FetchFunction;
|
|
56
59
|
generateId: () => string;
|
|
57
60
|
|
|
@@ -69,6 +72,20 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV4 {
|
|
|
69
72
|
private readonly config: GoogleGenerativeAIConfig;
|
|
70
73
|
private readonly generateId: () => string;
|
|
71
74
|
|
|
75
|
+
static [WORKFLOW_SERIALIZE](model: GoogleGenerativeAILanguageModel) {
|
|
76
|
+
return serializeModelOptions({
|
|
77
|
+
modelId: model.modelId,
|
|
78
|
+
config: model.config,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
83
|
+
modelId: string;
|
|
84
|
+
config: GoogleGenerativeAIConfig;
|
|
85
|
+
}) {
|
|
86
|
+
return new GoogleGenerativeAILanguageModel(options.modelId, options.config);
|
|
87
|
+
}
|
|
88
|
+
|
|
72
89
|
constructor(
|
|
73
90
|
modelId: GoogleGenerativeAIModelId,
|
|
74
91
|
config: GoogleGenerativeAIConfig,
|
|
@@ -273,7 +290,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV4 {
|
|
|
273
290
|
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
274
291
|
|
|
275
292
|
const mergedHeaders = combineHeaders(
|
|
276
|
-
await resolve(this.config.headers),
|
|
293
|
+
this.config.headers ? await resolve(this.config.headers) : undefined,
|
|
277
294
|
options.headers,
|
|
278
295
|
);
|
|
279
296
|
|
|
@@ -492,7 +509,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV4 {
|
|
|
492
509
|
);
|
|
493
510
|
|
|
494
511
|
const headers = combineHeaders(
|
|
495
|
-
await resolve(this.config.headers),
|
|
512
|
+
this.config.headers ? await resolve(this.config.headers) : undefined,
|
|
496
513
|
options.headers,
|
|
497
514
|
);
|
|
498
515
|
|
package/dist/index.d.mts
DELETED
|
@@ -1,427 +0,0 @@
|
|
|
1
|
-
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
2
|
-
import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { ProviderV4, LanguageModelV4, ImageModelV4, EmbeddingModelV4, Experimental_VideoModelV4, FilesV4 } from '@ai-sdk/provider';
|
|
4
|
-
|
|
5
|
-
declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
6
|
-
error: {
|
|
7
|
-
code: number | null;
|
|
8
|
-
message: string;
|
|
9
|
-
status: string;
|
|
10
|
-
};
|
|
11
|
-
}>;
|
|
12
|
-
type GoogleErrorData = InferSchema<typeof googleErrorDataSchema>;
|
|
13
|
-
|
|
14
|
-
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-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 & {});
|
|
15
|
-
declare const googleLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
16
|
-
responseModalities?: ("TEXT" | "IMAGE")[] | undefined;
|
|
17
|
-
thinkingConfig?: {
|
|
18
|
-
thinkingBudget?: number | undefined;
|
|
19
|
-
includeThoughts?: boolean | undefined;
|
|
20
|
-
thinkingLevel?: "minimal" | "low" | "medium" | "high" | undefined;
|
|
21
|
-
} | undefined;
|
|
22
|
-
cachedContent?: string | undefined;
|
|
23
|
-
structuredOutputs?: boolean | undefined;
|
|
24
|
-
safetySettings?: {
|
|
25
|
-
category: "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY";
|
|
26
|
-
threshold: "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF";
|
|
27
|
-
}[] | undefined;
|
|
28
|
-
threshold?: "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF" | undefined;
|
|
29
|
-
audioTimestamp?: boolean | undefined;
|
|
30
|
-
labels?: Record<string, string> | undefined;
|
|
31
|
-
mediaResolution?: "MEDIA_RESOLUTION_UNSPECIFIED" | "MEDIA_RESOLUTION_LOW" | "MEDIA_RESOLUTION_MEDIUM" | "MEDIA_RESOLUTION_HIGH" | undefined;
|
|
32
|
-
imageConfig?: {
|
|
33
|
-
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" | undefined;
|
|
34
|
-
imageSize?: "1K" | "2K" | "4K" | "512" | undefined;
|
|
35
|
-
} | undefined;
|
|
36
|
-
retrievalConfig?: {
|
|
37
|
-
latLng?: {
|
|
38
|
-
latitude: number;
|
|
39
|
-
longitude: number;
|
|
40
|
-
} | undefined;
|
|
41
|
-
} | undefined;
|
|
42
|
-
streamFunctionCallArguments?: boolean | undefined;
|
|
43
|
-
serviceTier?: "standard" | "flex" | "priority" | undefined;
|
|
44
|
-
}>;
|
|
45
|
-
type GoogleLanguageModelOptions = InferSchema<typeof googleLanguageModelOptions>;
|
|
46
|
-
|
|
47
|
-
declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
48
|
-
candidates: {
|
|
49
|
-
content?: Record<string, never> | {
|
|
50
|
-
parts?: ({
|
|
51
|
-
functionCall: {
|
|
52
|
-
name?: string | null | undefined;
|
|
53
|
-
args?: unknown;
|
|
54
|
-
partialArgs?: {
|
|
55
|
-
jsonPath: string;
|
|
56
|
-
stringValue?: string | null | undefined;
|
|
57
|
-
numberValue?: number | null | undefined;
|
|
58
|
-
boolValue?: boolean | null | undefined;
|
|
59
|
-
nullValue?: unknown;
|
|
60
|
-
willContinue?: boolean | null | undefined;
|
|
61
|
-
}[] | null | undefined;
|
|
62
|
-
willContinue?: boolean | null | undefined;
|
|
63
|
-
};
|
|
64
|
-
thoughtSignature?: string | null | undefined;
|
|
65
|
-
} | {
|
|
66
|
-
inlineData: {
|
|
67
|
-
mimeType: string;
|
|
68
|
-
data: string;
|
|
69
|
-
};
|
|
70
|
-
thought?: boolean | null | undefined;
|
|
71
|
-
thoughtSignature?: string | null | undefined;
|
|
72
|
-
} | {
|
|
73
|
-
toolCall: {
|
|
74
|
-
toolType: string;
|
|
75
|
-
id: string;
|
|
76
|
-
args?: unknown;
|
|
77
|
-
};
|
|
78
|
-
thoughtSignature?: string | null | undefined;
|
|
79
|
-
} | {
|
|
80
|
-
toolResponse: {
|
|
81
|
-
toolType: string;
|
|
82
|
-
id: string;
|
|
83
|
-
response?: unknown;
|
|
84
|
-
};
|
|
85
|
-
thoughtSignature?: string | null | undefined;
|
|
86
|
-
} | {
|
|
87
|
-
executableCode?: {
|
|
88
|
-
language: string;
|
|
89
|
-
code: string;
|
|
90
|
-
} | null | undefined;
|
|
91
|
-
codeExecutionResult?: {
|
|
92
|
-
outcome: string;
|
|
93
|
-
output?: string | null | undefined;
|
|
94
|
-
} | null | undefined;
|
|
95
|
-
text?: string | null | undefined;
|
|
96
|
-
thought?: boolean | null | undefined;
|
|
97
|
-
thoughtSignature?: string | null | undefined;
|
|
98
|
-
})[] | null | undefined;
|
|
99
|
-
} | null | undefined;
|
|
100
|
-
finishReason?: string | null | undefined;
|
|
101
|
-
finishMessage?: string | null | undefined;
|
|
102
|
-
safetyRatings?: {
|
|
103
|
-
category?: string | null | undefined;
|
|
104
|
-
probability?: string | null | undefined;
|
|
105
|
-
probabilityScore?: number | null | undefined;
|
|
106
|
-
severity?: string | null | undefined;
|
|
107
|
-
severityScore?: number | null | undefined;
|
|
108
|
-
blocked?: boolean | null | undefined;
|
|
109
|
-
}[] | null | undefined;
|
|
110
|
-
groundingMetadata?: {
|
|
111
|
-
webSearchQueries?: string[] | null | undefined;
|
|
112
|
-
imageSearchQueries?: string[] | null | undefined;
|
|
113
|
-
retrievalQueries?: string[] | null | undefined;
|
|
114
|
-
searchEntryPoint?: {
|
|
115
|
-
renderedContent: string;
|
|
116
|
-
} | null | undefined;
|
|
117
|
-
groundingChunks?: {
|
|
118
|
-
web?: {
|
|
119
|
-
uri: string;
|
|
120
|
-
title?: string | null | undefined;
|
|
121
|
-
} | null | undefined;
|
|
122
|
-
image?: {
|
|
123
|
-
sourceUri: string;
|
|
124
|
-
imageUri: string;
|
|
125
|
-
title?: string | null | undefined;
|
|
126
|
-
domain?: string | null | undefined;
|
|
127
|
-
} | null | undefined;
|
|
128
|
-
retrievedContext?: {
|
|
129
|
-
uri?: string | null | undefined;
|
|
130
|
-
title?: string | null | undefined;
|
|
131
|
-
text?: string | null | undefined;
|
|
132
|
-
fileSearchStore?: string | null | undefined;
|
|
133
|
-
} | null | undefined;
|
|
134
|
-
maps?: {
|
|
135
|
-
uri?: string | null | undefined;
|
|
136
|
-
title?: string | null | undefined;
|
|
137
|
-
text?: string | null | undefined;
|
|
138
|
-
placeId?: string | null | undefined;
|
|
139
|
-
} | null | undefined;
|
|
140
|
-
}[] | null | undefined;
|
|
141
|
-
groundingSupports?: {
|
|
142
|
-
segment?: {
|
|
143
|
-
startIndex?: number | null | undefined;
|
|
144
|
-
endIndex?: number | null | undefined;
|
|
145
|
-
text?: string | null | undefined;
|
|
146
|
-
} | null | undefined;
|
|
147
|
-
segment_text?: string | null | undefined;
|
|
148
|
-
groundingChunkIndices?: number[] | null | undefined;
|
|
149
|
-
supportChunkIndices?: number[] | null | undefined;
|
|
150
|
-
confidenceScores?: number[] | null | undefined;
|
|
151
|
-
confidenceScore?: number[] | null | undefined;
|
|
152
|
-
}[] | null | undefined;
|
|
153
|
-
retrievalMetadata?: Record<string, never> | {
|
|
154
|
-
webDynamicRetrievalScore: number;
|
|
155
|
-
} | null | undefined;
|
|
156
|
-
} | null | undefined;
|
|
157
|
-
urlContextMetadata?: {
|
|
158
|
-
urlMetadata?: {
|
|
159
|
-
retrievedUrl: string;
|
|
160
|
-
urlRetrievalStatus: string;
|
|
161
|
-
}[] | null | undefined;
|
|
162
|
-
} | null | undefined;
|
|
163
|
-
}[];
|
|
164
|
-
usageMetadata?: {
|
|
165
|
-
cachedContentTokenCount?: number | null | undefined;
|
|
166
|
-
thoughtsTokenCount?: number | null | undefined;
|
|
167
|
-
promptTokenCount?: number | null | undefined;
|
|
168
|
-
candidatesTokenCount?: number | null | undefined;
|
|
169
|
-
totalTokenCount?: number | null | undefined;
|
|
170
|
-
trafficType?: string | null | undefined;
|
|
171
|
-
promptTokensDetails?: {
|
|
172
|
-
modality: string;
|
|
173
|
-
tokenCount: number;
|
|
174
|
-
}[] | null | undefined;
|
|
175
|
-
candidatesTokensDetails?: {
|
|
176
|
-
modality: string;
|
|
177
|
-
tokenCount: number;
|
|
178
|
-
}[] | null | undefined;
|
|
179
|
-
} | null | undefined;
|
|
180
|
-
promptFeedback?: {
|
|
181
|
-
blockReason?: string | null | undefined;
|
|
182
|
-
safetyRatings?: {
|
|
183
|
-
category?: string | null | undefined;
|
|
184
|
-
probability?: string | null | undefined;
|
|
185
|
-
probabilityScore?: number | null | undefined;
|
|
186
|
-
severity?: string | null | undefined;
|
|
187
|
-
severityScore?: number | null | undefined;
|
|
188
|
-
blocked?: boolean | null | undefined;
|
|
189
|
-
}[] | null | undefined;
|
|
190
|
-
} | null | undefined;
|
|
191
|
-
serviceTier?: string | null | undefined;
|
|
192
|
-
}>;
|
|
193
|
-
type GroundingMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['groundingMetadata']>;
|
|
194
|
-
type UrlContextMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['urlContextMetadata']>;
|
|
195
|
-
type SafetyRatingSchema = NonNullable<InferSchema<typeof responseSchema>['candidates'][number]['safetyRatings']>[number];
|
|
196
|
-
type PromptFeedbackSchema = NonNullable<InferSchema<typeof responseSchema>['promptFeedback']>;
|
|
197
|
-
type UsageMetadataSchema = NonNullable<InferSchema<typeof responseSchema>['usageMetadata']>;
|
|
198
|
-
|
|
199
|
-
type GoogleGenerativeAIGroundingMetadata = GroundingMetadataSchema;
|
|
200
|
-
type GoogleGenerativeAIUrlContextMetadata = UrlContextMetadataSchema;
|
|
201
|
-
type GoogleGenerativeAISafetyRating = SafetyRatingSchema;
|
|
202
|
-
type GoogleGenerativeAIPromptFeedback = PromptFeedbackSchema;
|
|
203
|
-
type GoogleGenerativeAIUsageMetadata = UsageMetadataSchema;
|
|
204
|
-
interface GoogleGenerativeAIProviderMetadata {
|
|
205
|
-
promptFeedback: GoogleGenerativeAIPromptFeedback | null;
|
|
206
|
-
groundingMetadata: GoogleGenerativeAIGroundingMetadata | null;
|
|
207
|
-
urlContextMetadata: GoogleGenerativeAIUrlContextMetadata | null;
|
|
208
|
-
safetyRatings: GoogleGenerativeAISafetyRating[] | null;
|
|
209
|
-
usageMetadata: GoogleGenerativeAIUsageMetadata | null;
|
|
210
|
-
finishMessage: string | null;
|
|
211
|
-
serviceTier: string | null;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
type GoogleGenerativeAIImageModelId = 'imagen-4.0-generate-001' | 'imagen-4.0-ultra-generate-001' | 'imagen-4.0-fast-generate-001' | 'gemini-2.5-flash-image' | 'gemini-3-pro-image-preview' | 'gemini-3.1-flash-image-preview' | (string & {});
|
|
215
|
-
interface GoogleGenerativeAIImageSettings {
|
|
216
|
-
/**
|
|
217
|
-
* Override the maximum number of images per call (default 4)
|
|
218
|
-
*/
|
|
219
|
-
maxImagesPerCall?: number;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
declare const googleImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
223
|
-
personGeneration?: "dont_allow" | "allow_adult" | "allow_all" | null | undefined;
|
|
224
|
-
aspectRatio?: "1:1" | "3:4" | "4:3" | "9:16" | "16:9" | null | undefined;
|
|
225
|
-
}>;
|
|
226
|
-
type GoogleImageModelOptions = InferSchema<typeof googleImageModelOptionsSchema>;
|
|
227
|
-
|
|
228
|
-
type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | 'gemini-embedding-2-preview' | (string & {});
|
|
229
|
-
declare const googleEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
|
|
230
|
-
outputDimensionality?: number | undefined;
|
|
231
|
-
taskType?: "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "RETRIEVAL_DOCUMENT" | "RETRIEVAL_QUERY" | "QUESTION_ANSWERING" | "FACT_VERIFICATION" | "CODE_RETRIEVAL_QUERY" | undefined;
|
|
232
|
-
content?: (({
|
|
233
|
-
text: string;
|
|
234
|
-
} | {
|
|
235
|
-
inlineData: {
|
|
236
|
-
mimeType: string;
|
|
237
|
-
data: string;
|
|
238
|
-
};
|
|
239
|
-
})[] | null)[] | undefined;
|
|
240
|
-
}>;
|
|
241
|
-
type GoogleEmbeddingModelOptions = InferSchema<typeof googleEmbeddingModelOptions>;
|
|
242
|
-
|
|
243
|
-
type GoogleGenerativeAIVideoModelId = 'veo-3.1-fast-generate-preview' | 'veo-3.1-generate-preview' | 'veo-3.1-generate' | 'veo-3.0-generate-001' | 'veo-3.0-fast-generate-001' | 'veo-2.0-generate-001' | (string & {});
|
|
244
|
-
|
|
245
|
-
type GoogleVideoModelOptions = {
|
|
246
|
-
pollIntervalMs?: number | null;
|
|
247
|
-
pollTimeoutMs?: number | null;
|
|
248
|
-
personGeneration?: 'dont_allow' | 'allow_adult' | 'allow_all' | null;
|
|
249
|
-
negativePrompt?: string | null;
|
|
250
|
-
referenceImages?: Array<{
|
|
251
|
-
bytesBase64Encoded?: string;
|
|
252
|
-
gcsUri?: string;
|
|
253
|
-
}> | null;
|
|
254
|
-
[key: string]: unknown;
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
type GoogleFilesUploadOptions = {
|
|
258
|
-
displayName?: string | null;
|
|
259
|
-
pollIntervalMs?: number | null;
|
|
260
|
-
pollTimeoutMs?: number | null;
|
|
261
|
-
[key: string]: unknown;
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
declare const googleTools: {
|
|
265
|
-
/**
|
|
266
|
-
* Creates a Google search tool that gives Google direct access to real-time web content.
|
|
267
|
-
* Must have name "google_search".
|
|
268
|
-
*/
|
|
269
|
-
googleSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {
|
|
270
|
-
[x: string]: unknown;
|
|
271
|
-
searchTypes?: {
|
|
272
|
-
webSearch?: Record<string, never> | undefined;
|
|
273
|
-
imageSearch?: Record<string, never> | undefined;
|
|
274
|
-
} | undefined;
|
|
275
|
-
timeRangeFilter?: {
|
|
276
|
-
startTime: string;
|
|
277
|
-
endTime: string;
|
|
278
|
-
} | undefined;
|
|
279
|
-
}, {}>;
|
|
280
|
-
/**
|
|
281
|
-
* Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
|
|
282
|
-
* Designed for highly-regulated industries (finance, healthcare, public sector).
|
|
283
|
-
* Does not log customer data and supports VPC service controls.
|
|
284
|
-
* Must have name "enterprise_web_search".
|
|
285
|
-
*
|
|
286
|
-
* @note Only available on Vertex AI. Requires Gemini 2.0 or newer.
|
|
287
|
-
*
|
|
288
|
-
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
|
|
289
|
-
*/
|
|
290
|
-
enterpriseWebSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}, {}>;
|
|
291
|
-
/**
|
|
292
|
-
* Creates a Google Maps grounding tool that gives the model access to Google Maps data.
|
|
293
|
-
* Must have name "google_maps".
|
|
294
|
-
*
|
|
295
|
-
* @see https://ai.google.dev/gemini-api/docs/maps-grounding
|
|
296
|
-
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
297
|
-
*/
|
|
298
|
-
googleMaps: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}, {}>;
|
|
299
|
-
/**
|
|
300
|
-
* Creates a URL context tool that gives Google direct access to real-time web content.
|
|
301
|
-
* Must have name "url_context".
|
|
302
|
-
*/
|
|
303
|
-
urlContext: _ai_sdk_provider_utils.ProviderToolFactory<{}, {}, {}>;
|
|
304
|
-
/**
|
|
305
|
-
* Enables Retrieval Augmented Generation (RAG) via the Gemini File Search tool.
|
|
306
|
-
* Must have name "file_search".
|
|
307
|
-
*
|
|
308
|
-
* @param fileSearchStoreNames - Fully-qualified File Search store resource names.
|
|
309
|
-
* @param metadataFilter - Optional filter expression to restrict the files that can be retrieved.
|
|
310
|
-
* @param topK - Optional result limit for the number of chunks returned from File Search.
|
|
311
|
-
*
|
|
312
|
-
* @see https://ai.google.dev/gemini-api/docs/file-search
|
|
313
|
-
*/
|
|
314
|
-
fileSearch: _ai_sdk_provider_utils.ProviderToolFactory<{}, {
|
|
315
|
-
[x: string]: unknown;
|
|
316
|
-
fileSearchStoreNames: string[];
|
|
317
|
-
topK?: number | undefined;
|
|
318
|
-
metadataFilter?: string | undefined;
|
|
319
|
-
}, {}>;
|
|
320
|
-
/**
|
|
321
|
-
* A tool that enables the model to generate and run Python code.
|
|
322
|
-
* Must have name "code_execution".
|
|
323
|
-
*
|
|
324
|
-
* @note Ensure the selected model supports Code Execution.
|
|
325
|
-
* Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
|
|
326
|
-
*
|
|
327
|
-
* @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
|
|
328
|
-
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
|
|
329
|
-
*/
|
|
330
|
-
codeExecution: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
|
|
331
|
-
language: string;
|
|
332
|
-
code: string;
|
|
333
|
-
}, {
|
|
334
|
-
outcome: string;
|
|
335
|
-
output: string;
|
|
336
|
-
}, {}, {}>;
|
|
337
|
-
/**
|
|
338
|
-
* Creates a Vertex RAG Store tool that enables the model to perform RAG searches against a Vertex RAG Store.
|
|
339
|
-
* Must have name "vertex_rag_store".
|
|
340
|
-
*/
|
|
341
|
-
vertexRagStore: _ai_sdk_provider_utils.ProviderToolFactory<{}, {
|
|
342
|
-
ragCorpus: string;
|
|
343
|
-
topK?: number;
|
|
344
|
-
}, {}>;
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
interface GoogleGenerativeAIProvider extends ProviderV4 {
|
|
348
|
-
(modelId: GoogleGenerativeAIModelId): LanguageModelV4;
|
|
349
|
-
languageModel(modelId: GoogleGenerativeAIModelId): LanguageModelV4;
|
|
350
|
-
chat(modelId: GoogleGenerativeAIModelId): LanguageModelV4;
|
|
351
|
-
/**
|
|
352
|
-
* Creates a model for image generation.
|
|
353
|
-
*/
|
|
354
|
-
image(modelId: GoogleGenerativeAIImageModelId, settings?: GoogleGenerativeAIImageSettings): ImageModelV4;
|
|
355
|
-
/**
|
|
356
|
-
* @deprecated Use `chat()` instead.
|
|
357
|
-
*/
|
|
358
|
-
generativeAI(modelId: GoogleGenerativeAIModelId): LanguageModelV4;
|
|
359
|
-
/**
|
|
360
|
-
* Creates a model for text embeddings.
|
|
361
|
-
*/
|
|
362
|
-
embedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV4;
|
|
363
|
-
/**
|
|
364
|
-
* Creates a model for text embeddings.
|
|
365
|
-
*/
|
|
366
|
-
embeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV4;
|
|
367
|
-
/**
|
|
368
|
-
* @deprecated Use `embedding` instead.
|
|
369
|
-
*/
|
|
370
|
-
textEmbedding(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV4;
|
|
371
|
-
/**
|
|
372
|
-
* @deprecated Use `embeddingModel` instead.
|
|
373
|
-
*/
|
|
374
|
-
textEmbeddingModel(modelId: GoogleGenerativeAIEmbeddingModelId): EmbeddingModelV4;
|
|
375
|
-
/**
|
|
376
|
-
* Creates a model for video generation.
|
|
377
|
-
*/
|
|
378
|
-
video(modelId: GoogleGenerativeAIVideoModelId): Experimental_VideoModelV4;
|
|
379
|
-
/**
|
|
380
|
-
* Creates a model for video generation.
|
|
381
|
-
*/
|
|
382
|
-
videoModel(modelId: GoogleGenerativeAIVideoModelId): Experimental_VideoModelV4;
|
|
383
|
-
files(): FilesV4;
|
|
384
|
-
tools: typeof googleTools;
|
|
385
|
-
}
|
|
386
|
-
interface GoogleGenerativeAIProviderSettings {
|
|
387
|
-
/**
|
|
388
|
-
* Use a different URL prefix for API calls, e.g. to use proxy servers.
|
|
389
|
-
* The default prefix is `https://generativelanguage.googleapis.com/v1beta`.
|
|
390
|
-
*/
|
|
391
|
-
baseURL?: string;
|
|
392
|
-
/**
|
|
393
|
-
* API key that is being send using the `x-goog-api-key` header.
|
|
394
|
-
* It defaults to the `GOOGLE_GENERATIVE_AI_API_KEY` environment variable.
|
|
395
|
-
*/
|
|
396
|
-
apiKey?: string;
|
|
397
|
-
/**
|
|
398
|
-
* Custom headers to include in the requests.
|
|
399
|
-
*/
|
|
400
|
-
headers?: Record<string, string | undefined>;
|
|
401
|
-
/**
|
|
402
|
-
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
403
|
-
* or to provide a custom fetch implementation for e.g. testing.
|
|
404
|
-
*/
|
|
405
|
-
fetch?: FetchFunction;
|
|
406
|
-
/**
|
|
407
|
-
* Optional function to generate a unique ID for each request.
|
|
408
|
-
*/
|
|
409
|
-
generateId?: () => string;
|
|
410
|
-
/**
|
|
411
|
-
* Custom provider name
|
|
412
|
-
* Defaults to 'google.generative-ai'.
|
|
413
|
-
*/
|
|
414
|
-
name?: string;
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Create a Google Generative AI provider instance.
|
|
418
|
-
*/
|
|
419
|
-
declare function createGoogleGenerativeAI(options?: GoogleGenerativeAIProviderSettings): GoogleGenerativeAIProvider;
|
|
420
|
-
/**
|
|
421
|
-
* Default Google Generative AI provider instance.
|
|
422
|
-
*/
|
|
423
|
-
declare const google: GoogleGenerativeAIProvider;
|
|
424
|
-
|
|
425
|
-
declare const VERSION: string;
|
|
426
|
-
|
|
427
|
-
export { type GoogleEmbeddingModelOptions, type GoogleErrorData, type GoogleFilesUploadOptions, type GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions, type GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, type GoogleGenerativeAIVideoModelId, type GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions, type GoogleImageModelOptions, type GoogleLanguageModelOptions, type GoogleVideoModelOptions, VERSION, createGoogleGenerativeAI, google };
|