@google/genai 0.5.0 → 0.6.1
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/dist/genai.d.ts +3474 -0
- package/dist/index.js +7096 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +7062 -0
- package/dist/index.mjs.map +1 -0
- package/dist/node/index.js +7401 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/node.d.ts +3486 -0
- package/dist/web/index.mjs +7082 -0
- package/dist/web/index.mjs.map +1 -0
- package/dist/web/web.d.ts +3479 -0
- package/package.json +2 -1
package/dist/genai.d.ts
ADDED
|
@@ -0,0 +1,3474 @@
|
|
|
1
|
+
import { GoogleAuthOptions } from 'google-auth-library';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The ApiClient class is used to send requests to the Gemini API or Vertex AI
|
|
5
|
+
* endpoints.
|
|
6
|
+
*/
|
|
7
|
+
declare class ApiClient {
|
|
8
|
+
readonly clientOptions: ApiClientInitOptions;
|
|
9
|
+
constructor(opts: ApiClientInitOptions);
|
|
10
|
+
isVertexAI(): boolean;
|
|
11
|
+
getProject(): string | undefined;
|
|
12
|
+
getLocation(): string | undefined;
|
|
13
|
+
getApiVersion(): string;
|
|
14
|
+
getBaseUrl(): string;
|
|
15
|
+
getRequestUrl(): string;
|
|
16
|
+
getHeaders(): Record<string, string>;
|
|
17
|
+
private getRequestUrlInternal;
|
|
18
|
+
getBaseResourcePath(): string;
|
|
19
|
+
getApiKey(): string | undefined;
|
|
20
|
+
getWebsocketBaseUrl(): string;
|
|
21
|
+
setBaseUrl(url: string): void;
|
|
22
|
+
private constructUrl;
|
|
23
|
+
request(request: HttpRequest): Promise<HttpResponse>;
|
|
24
|
+
private patchHttpOptions;
|
|
25
|
+
requestStream(request: HttpRequest): Promise<any>;
|
|
26
|
+
private includeExtraHttpOptionsToRequestInit;
|
|
27
|
+
private unaryApiCall;
|
|
28
|
+
private streamApiCall;
|
|
29
|
+
processStreamResponse(response: Response): AsyncGenerator<any>;
|
|
30
|
+
private apiCall;
|
|
31
|
+
getDefaultHeaders(): Record<string, string>;
|
|
32
|
+
private getHeadersInternal;
|
|
33
|
+
/**
|
|
34
|
+
* Uploads a file asynchronously using Gemini API only, this is not supported
|
|
35
|
+
* in Vertex AI.
|
|
36
|
+
*
|
|
37
|
+
* @param file The string path to the file to be uploaded or a Blob object.
|
|
38
|
+
* @param config Optional parameters specified in the `UploadFileConfig`
|
|
39
|
+
* interface. @see {@link UploadFileConfig}
|
|
40
|
+
* @return A promise that resolves to a `File` object.
|
|
41
|
+
* @throws An error if called on a Vertex AI client.
|
|
42
|
+
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
43
|
+
*/
|
|
44
|
+
uploadFile(file: string | Blob, config?: UploadFileConfig): Promise<File_2>;
|
|
45
|
+
private fetchUploadUrl;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Options for initializing the ApiClient. The ApiClient uses the parameters
|
|
50
|
+
* for authentication purposes as well as to infer if SDK should send the
|
|
51
|
+
* request to Vertex AI or Gemini API.
|
|
52
|
+
*/
|
|
53
|
+
declare interface ApiClientInitOptions {
|
|
54
|
+
/**
|
|
55
|
+
* The object used for adding authentication headers to API requests.
|
|
56
|
+
*/
|
|
57
|
+
auth: Auth;
|
|
58
|
+
/**
|
|
59
|
+
* The uploader to use for uploading files. This field is required for
|
|
60
|
+
* creating a client, will be set through the Node_client or Web_client.
|
|
61
|
+
*/
|
|
62
|
+
uploader: Uploader;
|
|
63
|
+
/**
|
|
64
|
+
* Optional. The Google Cloud project ID for Vertex AI users.
|
|
65
|
+
* It is not the numeric project name.
|
|
66
|
+
* If not provided, SDK will try to resolve it from runtime environment.
|
|
67
|
+
*/
|
|
68
|
+
project?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Optional. The Google Cloud project location for Vertex AI users.
|
|
71
|
+
* If not provided, SDK will try to resolve it from runtime environment.
|
|
72
|
+
*/
|
|
73
|
+
location?: string;
|
|
74
|
+
/**
|
|
75
|
+
* The API Key. This is required for Gemini API users.
|
|
76
|
+
*/
|
|
77
|
+
apiKey?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Optional. Set to true if you intend to call Vertex AI endpoints.
|
|
80
|
+
* If unset, default SDK behavior is to call Gemini API.
|
|
81
|
+
*/
|
|
82
|
+
vertexai?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Optional. The API version for the endpoint.
|
|
85
|
+
* If unset, SDK will choose a default api version.
|
|
86
|
+
*/
|
|
87
|
+
apiVersion?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Optional. A set of customizable configuration for HTTP requests.
|
|
90
|
+
*/
|
|
91
|
+
httpOptions?: HttpOptions;
|
|
92
|
+
/**
|
|
93
|
+
* Optional. An extra string to append at the end of the User-Agent header.
|
|
94
|
+
*
|
|
95
|
+
* This can be used to e.g specify the runtime and its version.
|
|
96
|
+
*/
|
|
97
|
+
userAgentExtra?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @license
|
|
102
|
+
* Copyright 2025 Google LLC
|
|
103
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
104
|
+
*/
|
|
105
|
+
/**
|
|
106
|
+
* The Auth interface is used to authenticate with the API service.
|
|
107
|
+
*/
|
|
108
|
+
declare interface Auth {
|
|
109
|
+
/**
|
|
110
|
+
* Sets the headers needed to authenticate with the API service.
|
|
111
|
+
*
|
|
112
|
+
* @param headers - The Headers object that will be updated with the authentication headers.
|
|
113
|
+
*/
|
|
114
|
+
addAuthHeaders(headers: Headers): Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
declare class BaseModule {
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Content blob. */
|
|
121
|
+
declare interface Blob_2 {
|
|
122
|
+
/** Required. Raw bytes. */
|
|
123
|
+
data?: string;
|
|
124
|
+
/** Required. The IANA standard MIME type of the source data. */
|
|
125
|
+
mimeType?: string;
|
|
126
|
+
}
|
|
127
|
+
export { Blob_2 as Blob }
|
|
128
|
+
|
|
129
|
+
export declare enum BlockedReason {
|
|
130
|
+
BLOCKED_REASON_UNSPECIFIED = "BLOCKED_REASON_UNSPECIFIED",
|
|
131
|
+
SAFETY = "SAFETY",
|
|
132
|
+
OTHER = "OTHER",
|
|
133
|
+
BLOCKLIST = "BLOCKLIST",
|
|
134
|
+
PROHIBITED_CONTENT = "PROHIBITED_CONTENT"
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** A resource used in LLM queries for users to explicitly specify what to cache. */
|
|
138
|
+
export declare interface CachedContent {
|
|
139
|
+
/** The server-generated resource name of the cached content. */
|
|
140
|
+
name?: string;
|
|
141
|
+
/** The user-generated meaningful display name of the cached content. */
|
|
142
|
+
displayName?: string;
|
|
143
|
+
/** The name of the publisher model to use for cached content. */
|
|
144
|
+
model?: string;
|
|
145
|
+
/** Creation time of the cache entry. */
|
|
146
|
+
createTime?: string;
|
|
147
|
+
/** When the cache entry was last updated in UTC time. */
|
|
148
|
+
updateTime?: string;
|
|
149
|
+
/** Expiration time of the cached content. */
|
|
150
|
+
expireTime?: string;
|
|
151
|
+
/** Metadata on the usage of the cached content. */
|
|
152
|
+
usageMetadata?: CachedContentUsageMetadata;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Metadata on the usage of the cached content. */
|
|
156
|
+
export declare interface CachedContentUsageMetadata {
|
|
157
|
+
/** Duration of audio in seconds. */
|
|
158
|
+
audioDurationSeconds?: number;
|
|
159
|
+
/** Number of images. */
|
|
160
|
+
imageCount?: number;
|
|
161
|
+
/** Number of text characters. */
|
|
162
|
+
textCount?: number;
|
|
163
|
+
/** Total number of tokens that the cached content consumes. */
|
|
164
|
+
totalTokenCount?: number;
|
|
165
|
+
/** Duration of video in seconds. */
|
|
166
|
+
videoDurationSeconds?: number;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export declare class Caches extends BaseModule {
|
|
170
|
+
private readonly apiClient;
|
|
171
|
+
constructor(apiClient: ApiClient);
|
|
172
|
+
/**
|
|
173
|
+
* Lists cached content configurations.
|
|
174
|
+
*
|
|
175
|
+
* @param params - The parameters for the list request.
|
|
176
|
+
* @return The paginated results of the list of cached contents.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* const cachedContents = await ai.caches.list({config: {'pageSize': 2}});
|
|
181
|
+
* for (const cachedContent of cachedContents) {
|
|
182
|
+
* console.log(cachedContent);
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
list: (params?: types.ListCachedContentsParameters) => Promise<Pager<types.CachedContent>>;
|
|
187
|
+
/**
|
|
188
|
+
* Creates a cached contents resource.
|
|
189
|
+
*
|
|
190
|
+
* @param params - The parameters for the create request.
|
|
191
|
+
* @return The created cached content.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const contents = ...; // Initialize the content to cache.
|
|
196
|
+
* const response = await ai.caches.create({
|
|
197
|
+
* model: 'gemini-2.0-flash',
|
|
198
|
+
* config: {
|
|
199
|
+
* 'contents': contents,
|
|
200
|
+
* 'displayName': 'test cache',
|
|
201
|
+
* 'systemInstruction': 'What is the sum of the two pdfs?',
|
|
202
|
+
* 'ttl': '86400s',
|
|
203
|
+
* }
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
create(params: types.CreateCachedContentParameters): Promise<types.CachedContent>;
|
|
208
|
+
/**
|
|
209
|
+
* Gets cached content configurations.
|
|
210
|
+
*
|
|
211
|
+
* @param params - The parameters for the get request.
|
|
212
|
+
* @return The cached content.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```ts
|
|
216
|
+
* await ai.caches.get({name: 'gemini-1.5-flash'});
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
get(params: types.GetCachedContentParameters): Promise<types.CachedContent>;
|
|
220
|
+
/**
|
|
221
|
+
* Deletes cached content.
|
|
222
|
+
*
|
|
223
|
+
* @param params - The parameters for the delete request.
|
|
224
|
+
* @return The empty response returned by the API.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* await ai.caches.delete({name: 'gemini-1.5-flash'});
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
delete(params: types.DeleteCachedContentParameters): Promise<types.DeleteCachedContentResponse>;
|
|
232
|
+
/**
|
|
233
|
+
* Updates cached content configurations.
|
|
234
|
+
*
|
|
235
|
+
* @param params - The parameters for the update request.
|
|
236
|
+
* @return The updated cached content.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```ts
|
|
240
|
+
* const response = await ai.caches.update({
|
|
241
|
+
* name: 'gemini-1.5-flash',
|
|
242
|
+
* config: {'ttl': '7600s'}
|
|
243
|
+
* });
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
update(params: types.UpdateCachedContentParameters): Promise<types.CachedContent>;
|
|
247
|
+
private listInternal;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** A response candidate generated from the model. */
|
|
251
|
+
export declare interface Candidate {
|
|
252
|
+
/** Contains the multi-part content of the response.
|
|
253
|
+
*/
|
|
254
|
+
content?: Content;
|
|
255
|
+
/** Source attribution of the generated content.
|
|
256
|
+
*/
|
|
257
|
+
citationMetadata?: CitationMetadata;
|
|
258
|
+
/** Describes the reason the model stopped generating tokens.
|
|
259
|
+
*/
|
|
260
|
+
finishMessage?: string;
|
|
261
|
+
/** Number of tokens for this candidate.
|
|
262
|
+
*/
|
|
263
|
+
tokenCount?: number;
|
|
264
|
+
/** The reason why the model stopped generating tokens.
|
|
265
|
+
If empty, the model has not stopped generating the tokens.
|
|
266
|
+
*/
|
|
267
|
+
finishReason?: FinishReason;
|
|
268
|
+
/** Output only. Average log probability score of the candidate. */
|
|
269
|
+
avgLogprobs?: number;
|
|
270
|
+
/** Output only. Metadata specifies sources used to ground generated content. */
|
|
271
|
+
groundingMetadata?: GroundingMetadata;
|
|
272
|
+
/** Output only. Index of the candidate. */
|
|
273
|
+
index?: number;
|
|
274
|
+
/** Output only. Log-likelihood scores for the response tokens and top tokens */
|
|
275
|
+
logprobsResult?: LogprobsResult;
|
|
276
|
+
/** Output only. List of ratings for the safety of a response candidate. There is at most one rating per category. */
|
|
277
|
+
safetyRatings?: SafetyRating[];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Chat session that enables sending messages to the model with previous
|
|
282
|
+
* conversation context.
|
|
283
|
+
*
|
|
284
|
+
* @remarks
|
|
285
|
+
* The session maintains all the turns between user and model.
|
|
286
|
+
*/
|
|
287
|
+
export declare class Chat {
|
|
288
|
+
private readonly apiClient;
|
|
289
|
+
private readonly modelsModule;
|
|
290
|
+
private readonly model;
|
|
291
|
+
private readonly config;
|
|
292
|
+
private history;
|
|
293
|
+
private sendPromise;
|
|
294
|
+
constructor(apiClient: ApiClient, modelsModule: Models, model: string, config?: types.GenerateContentConfig, history?: types.Content[]);
|
|
295
|
+
/**
|
|
296
|
+
* Sends a message to the model and returns the response.
|
|
297
|
+
*
|
|
298
|
+
* @remarks
|
|
299
|
+
* This method will wait for the previous message to be processed before
|
|
300
|
+
* sending the next message.
|
|
301
|
+
*
|
|
302
|
+
* @see {@link Chat#sendMessageStream} for streaming method.
|
|
303
|
+
* @param params - parameters for sending messages within a chat session.
|
|
304
|
+
* @returns The model's response.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```ts
|
|
308
|
+
* const chat = ai.chats.create({model: 'gemini-2.0-flash'});
|
|
309
|
+
* const response = await chat.sendMessage({
|
|
310
|
+
* message: 'Why is the sky blue?'
|
|
311
|
+
* });
|
|
312
|
+
* console.log(response.text);
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
sendMessage(params: types.SendMessageParameters): Promise<types.GenerateContentResponse>;
|
|
316
|
+
/**
|
|
317
|
+
* Sends a message to the model and returns the response in chunks.
|
|
318
|
+
*
|
|
319
|
+
* @remarks
|
|
320
|
+
* This method will wait for the previous message to be processed before
|
|
321
|
+
* sending the next message.
|
|
322
|
+
*
|
|
323
|
+
* @see {@link Chat#sendMessage} for non-streaming method.
|
|
324
|
+
* @param params - parameters for sending the message.
|
|
325
|
+
* @return The model's response.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```ts
|
|
329
|
+
* const chat = ai.chats.create({model: 'gemini-2.0-flash'});
|
|
330
|
+
* const response = await chat.sendMessageStream({
|
|
331
|
+
* message: 'Why is the sky blue?'
|
|
332
|
+
* });
|
|
333
|
+
* for await (const chunk of response) {
|
|
334
|
+
* console.log(chunk.text);
|
|
335
|
+
* }
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
sendMessageStream(params: types.SendMessageParameters): Promise<AsyncGenerator<types.GenerateContentResponse>>;
|
|
339
|
+
/**
|
|
340
|
+
* Returns the chat history.
|
|
341
|
+
*
|
|
342
|
+
* @remarks
|
|
343
|
+
* The history is a list of contents alternating between user and model.
|
|
344
|
+
*
|
|
345
|
+
* There are two types of history:
|
|
346
|
+
* - The `curated history` contains only the valid turns between user and
|
|
347
|
+
* model, which will be included in the subsequent requests sent to the model.
|
|
348
|
+
* - The `comprehensive history` contains all turns, including invalid or
|
|
349
|
+
* empty model outputs, providing a complete record of the history.
|
|
350
|
+
*
|
|
351
|
+
* The history is updated after receiving the response from the model,
|
|
352
|
+
* for streaming response, it means receiving the last chunk of the response.
|
|
353
|
+
*
|
|
354
|
+
* The `comprehensive history` is returned by default. To get the `curated
|
|
355
|
+
* history`, set the `curated` parameter to `true`.
|
|
356
|
+
*
|
|
357
|
+
* @param curated - whether to return the curated history or the comprehensive
|
|
358
|
+
* history.
|
|
359
|
+
* @return History contents alternating between user and model for the entire
|
|
360
|
+
* chat session.
|
|
361
|
+
*/
|
|
362
|
+
getHistory(curated?: boolean): types.Content[];
|
|
363
|
+
private processStreamResponse;
|
|
364
|
+
private recordHistory;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* A utility class to create a chat session.
|
|
369
|
+
*/
|
|
370
|
+
export declare class Chats {
|
|
371
|
+
private readonly modelsModule;
|
|
372
|
+
private readonly apiClient;
|
|
373
|
+
constructor(modelsModule: Models, apiClient: ApiClient);
|
|
374
|
+
/**
|
|
375
|
+
* Creates a new chat session.
|
|
376
|
+
*
|
|
377
|
+
* @remarks
|
|
378
|
+
* The config in the params will be used for all requests within the chat
|
|
379
|
+
* session unless overridden by a per-request `config` in
|
|
380
|
+
* @see {@link types.SendMessageParameters#config}.
|
|
381
|
+
*
|
|
382
|
+
* @param params - Parameters for creating a chat session.
|
|
383
|
+
* @returns A new chat session.
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```ts
|
|
387
|
+
* const chat = ai.chats.create({
|
|
388
|
+
* model: 'gemini-2.0-flash'
|
|
389
|
+
* config: {
|
|
390
|
+
* temperature: 0.5,
|
|
391
|
+
* maxOutputTokens: 1024,
|
|
392
|
+
* }
|
|
393
|
+
* });
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
create(params: types.CreateChatParameters): Chat;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** Source attributions for content. */
|
|
400
|
+
export declare interface Citation {
|
|
401
|
+
/** Output only. End index into the content. */
|
|
402
|
+
endIndex?: number;
|
|
403
|
+
/** Output only. License of the attribution. */
|
|
404
|
+
license?: string;
|
|
405
|
+
/** Output only. Publication date of the attribution. */
|
|
406
|
+
publicationDate?: GoogleTypeDate;
|
|
407
|
+
/** Output only. Start index into the content. */
|
|
408
|
+
startIndex?: number;
|
|
409
|
+
/** Output only. Title of the attribution. */
|
|
410
|
+
title?: string;
|
|
411
|
+
/** Output only. Url reference of the attribution. */
|
|
412
|
+
uri?: string;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/** Citation information when the model quotes another source. */
|
|
416
|
+
export declare interface CitationMetadata {
|
|
417
|
+
/** Contains citation information when the model directly quotes, at
|
|
418
|
+
length, from another source. Can include traditional websites and code
|
|
419
|
+
repositories.
|
|
420
|
+
*/
|
|
421
|
+
citations?: Citation[];
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/** Result of executing the [ExecutableCode]. Always follows a `part` containing the [ExecutableCode]. */
|
|
425
|
+
export declare interface CodeExecutionResult {
|
|
426
|
+
/** Required. Outcome of the code execution. */
|
|
427
|
+
outcome?: Outcome;
|
|
428
|
+
/** Optional. Contains stdout when code execution is successful, stderr or other description otherwise. */
|
|
429
|
+
output?: string;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
declare namespace common {
|
|
433
|
+
export {
|
|
434
|
+
formatMap,
|
|
435
|
+
setValueByPath,
|
|
436
|
+
getValueByPath,
|
|
437
|
+
BaseModule,
|
|
438
|
+
UploadFileParameters
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/** Optional parameters for computing tokens. */
|
|
443
|
+
export declare interface ComputeTokensConfig {
|
|
444
|
+
/** Used to override HTTP request options. */
|
|
445
|
+
httpOptions?: HttpOptions;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** Parameters for computing tokens. */
|
|
449
|
+
export declare interface ComputeTokensParameters {
|
|
450
|
+
/** ID of the model to use. For a list of models, see `Google models
|
|
451
|
+
<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
|
|
452
|
+
model: string;
|
|
453
|
+
/** Input content. */
|
|
454
|
+
contents: ContentListUnion;
|
|
455
|
+
/** Optional parameters for the request.
|
|
456
|
+
*/
|
|
457
|
+
config?: ComputeTokensConfig;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/** Response for computing tokens. */
|
|
461
|
+
export declare class ComputeTokensResponse {
|
|
462
|
+
/** Lists of tokens info from the input. A ComputeTokensRequest could have multiple instances with a prompt in each instance. We also need to return lists of tokens info for the request with multiple instances. */
|
|
463
|
+
tokensInfo?: TokensInfo[];
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/** Contains the multi-part content of a message. */
|
|
467
|
+
export declare interface Content {
|
|
468
|
+
/** List of parts that constitute a single message. Each part may have
|
|
469
|
+
a different IANA MIME type. */
|
|
470
|
+
parts?: Part[];
|
|
471
|
+
/** Optional. The producer of the content. Must be either 'user' or
|
|
472
|
+
'model'. Useful to set for multi-turn conversations, otherwise can be
|
|
473
|
+
left blank or unset. If role is not specified, SDK will determine the role. */
|
|
474
|
+
role?: string;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/** The embedding generated from an input content. */
|
|
478
|
+
export declare interface ContentEmbedding {
|
|
479
|
+
/** A list of floats representing an embedding.
|
|
480
|
+
*/
|
|
481
|
+
values?: number[];
|
|
482
|
+
/** Vertex API only. Statistics of the input text associated with this
|
|
483
|
+
embedding.
|
|
484
|
+
*/
|
|
485
|
+
statistics?: ContentEmbeddingStatistics;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/** Statistics of the input text associated with the result of content embedding. */
|
|
489
|
+
export declare interface ContentEmbeddingStatistics {
|
|
490
|
+
/** Vertex API only. If the input text was truncated due to having
|
|
491
|
+
a length longer than the allowed maximum input.
|
|
492
|
+
*/
|
|
493
|
+
truncated?: boolean;
|
|
494
|
+
/** Vertex API only. Number of tokens of the input text.
|
|
495
|
+
*/
|
|
496
|
+
tokenCount?: number;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
export declare type ContentListUnion = ContentUnion[] | ContentUnion;
|
|
500
|
+
|
|
501
|
+
export declare type ContentUnion = Content | PartUnion[] | PartUnion;
|
|
502
|
+
|
|
503
|
+
/** Configuration for a Control reference image. */
|
|
504
|
+
export declare interface ControlReferenceConfig {
|
|
505
|
+
/** The type of control reference image to use. */
|
|
506
|
+
controlType?: ControlReferenceType;
|
|
507
|
+
/** Defaults to False. When set to True, the control image will be
|
|
508
|
+
computed by the model based on the control type. When set to False,
|
|
509
|
+
the control image must be provided by the user. */
|
|
510
|
+
enableControlImageComputation?: boolean;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/** A control reference image.
|
|
514
|
+
|
|
515
|
+
The image of the control reference image is either a control image provided
|
|
516
|
+
by the user, or a regular image which the backend will use to generate a
|
|
517
|
+
control image of. In the case of the latter, the
|
|
518
|
+
enable_control_image_computation field in the config should be set to True.
|
|
519
|
+
|
|
520
|
+
A control image is an image that represents a sketch image of areas for the
|
|
521
|
+
model to fill in based on the prompt.
|
|
522
|
+
*/
|
|
523
|
+
export declare interface ControlReferenceImage {
|
|
524
|
+
/** The reference image for the editing operation. */
|
|
525
|
+
referenceImage?: Image_2;
|
|
526
|
+
/** The id of the reference image. */
|
|
527
|
+
referenceId?: number;
|
|
528
|
+
/** The type of the reference image. Only set by the SDK. */
|
|
529
|
+
referenceType?: string;
|
|
530
|
+
/** Configuration for the control reference image. */
|
|
531
|
+
config?: ControlReferenceConfig;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
export declare enum ControlReferenceType {
|
|
535
|
+
CONTROL_TYPE_DEFAULT = "CONTROL_TYPE_DEFAULT",
|
|
536
|
+
CONTROL_TYPE_CANNY = "CONTROL_TYPE_CANNY",
|
|
537
|
+
CONTROL_TYPE_SCRIBBLE = "CONTROL_TYPE_SCRIBBLE",
|
|
538
|
+
CONTROL_TYPE_FACE_MESH = "CONTROL_TYPE_FACE_MESH"
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/** Config for the count_tokens method. */
|
|
542
|
+
export declare interface CountTokensConfig {
|
|
543
|
+
/** Used to override HTTP request options. */
|
|
544
|
+
httpOptions?: HttpOptions;
|
|
545
|
+
/** Instructions for the model to steer it toward better performance.
|
|
546
|
+
*/
|
|
547
|
+
systemInstruction?: ContentUnion;
|
|
548
|
+
/** Code that enables the system to interact with external systems to
|
|
549
|
+
perform an action outside of the knowledge and scope of the model.
|
|
550
|
+
*/
|
|
551
|
+
tools?: Tool[];
|
|
552
|
+
/** Configuration that the model uses to generate the response. Not
|
|
553
|
+
supported by the Gemini Developer API.
|
|
554
|
+
*/
|
|
555
|
+
generationConfig?: GenerationConfig;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/** Parameters for counting tokens. */
|
|
559
|
+
export declare interface CountTokensParameters {
|
|
560
|
+
/** ID of the model to use. For a list of models, see `Google models
|
|
561
|
+
<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
|
|
562
|
+
model: string;
|
|
563
|
+
/** Input content. */
|
|
564
|
+
contents: ContentListUnion;
|
|
565
|
+
/** Configuration for counting tokens. */
|
|
566
|
+
config?: CountTokensConfig;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/** Response for counting tokens. */
|
|
570
|
+
export declare class CountTokensResponse {
|
|
571
|
+
/** Total number of tokens. */
|
|
572
|
+
totalTokens?: number;
|
|
573
|
+
/** Number of tokens in the cached part of the prompt (the cached content). */
|
|
574
|
+
cachedContentTokenCount?: number;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/** Optional configuration for cached content creation. */
|
|
578
|
+
export declare interface CreateCachedContentConfig {
|
|
579
|
+
/** Used to override HTTP request options. */
|
|
580
|
+
httpOptions?: HttpOptions;
|
|
581
|
+
/** The TTL for this resource. The expiration time is computed: now + TTL. */
|
|
582
|
+
ttl?: string;
|
|
583
|
+
/** Timestamp of when this resource is considered expired. */
|
|
584
|
+
expireTime?: string;
|
|
585
|
+
/** The user-generated meaningful display name of the cached content.
|
|
586
|
+
*/
|
|
587
|
+
displayName?: string;
|
|
588
|
+
/** The content to cache.
|
|
589
|
+
*/
|
|
590
|
+
contents?: ContentListUnion;
|
|
591
|
+
/** Developer set system instruction.
|
|
592
|
+
*/
|
|
593
|
+
systemInstruction?: ContentUnion;
|
|
594
|
+
/** A list of `Tools` the model may use to generate the next response.
|
|
595
|
+
*/
|
|
596
|
+
tools?: Tool[];
|
|
597
|
+
/** Configuration for the tools to use. This config is shared for all tools.
|
|
598
|
+
*/
|
|
599
|
+
toolConfig?: ToolConfig;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/** Parameters for caches.create method. */
|
|
603
|
+
export declare interface CreateCachedContentParameters {
|
|
604
|
+
/** ID of the model to use. Example: gemini-1.5-flash */
|
|
605
|
+
model: string;
|
|
606
|
+
/** Configuration that contains optional parameters.
|
|
607
|
+
*/
|
|
608
|
+
config?: CreateCachedContentConfig;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/** Parameters for initializing a new chat session.
|
|
612
|
+
|
|
613
|
+
These parameters are used when creating a chat session with the
|
|
614
|
+
`chats.create()` method.
|
|
615
|
+
*/
|
|
616
|
+
export declare interface CreateChatParameters {
|
|
617
|
+
/** The name of the model to use for the chat session.
|
|
618
|
+
|
|
619
|
+
For example: 'gemini-2.0-flash', 'gemini-1.5-pro', etc. See gemini API
|
|
620
|
+
docs to find the available models.
|
|
621
|
+
*/
|
|
622
|
+
model: string;
|
|
623
|
+
/** Config for the entire chat session.
|
|
624
|
+
|
|
625
|
+
This config applies to all requests within the session
|
|
626
|
+
unless overridden by a per-request `config` in `SendMessageParameters`.
|
|
627
|
+
*/
|
|
628
|
+
config?: GenerateContentConfig;
|
|
629
|
+
/** The initial conversation history for the chat session.
|
|
630
|
+
|
|
631
|
+
This allows you to start the chat with a pre-existing history. The history
|
|
632
|
+
must be a list of `Content` alternating between 'user' and 'model' roles.
|
|
633
|
+
It should start with a 'user' message.
|
|
634
|
+
*/
|
|
635
|
+
history?: Content[];
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/** Used to override the default configuration. */
|
|
639
|
+
export declare interface CreateFileConfig {
|
|
640
|
+
/** Used to override HTTP request options. */
|
|
641
|
+
httpOptions?: HttpOptions;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/** Generates the parameters for the private _create method. */
|
|
645
|
+
export declare interface CreateFileParameters {
|
|
646
|
+
/** The file to be uploaded.
|
|
647
|
+
mime_type: (Required) The MIME type of the file. Must be provided.
|
|
648
|
+
name: (Optional) The name of the file in the destination (e.g.
|
|
649
|
+
'files/sample-image').
|
|
650
|
+
display_name: (Optional) The display name of the file.
|
|
651
|
+
*/
|
|
652
|
+
file: File_2;
|
|
653
|
+
/** Used to override the default configuration. */
|
|
654
|
+
config?: CreateFileConfig;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/** Response for the create file method. */
|
|
658
|
+
export declare class CreateFileResponse {
|
|
659
|
+
/** Used to retain the full HTTP response. */
|
|
660
|
+
sdkHttpResponse?: HttpResponse;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Creates a `Content` object with a model role from a `PartListUnion` object or `string`.
|
|
665
|
+
*/
|
|
666
|
+
export declare function createModelContent(partOrString: PartListUnion | string): Content;
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Creates a `Part` object from a `base64` `string`.
|
|
670
|
+
*/
|
|
671
|
+
export declare function createPartFromBase64(data: string, mimeType: string): Part;
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Creates a `Part` object from the `outcome` and `output` of a `CodeExecutionResult` object.
|
|
675
|
+
*/
|
|
676
|
+
export declare function createPartFromCodeExecutionResult(outcome: Outcome, output: string): Part;
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Creates a `Part` object from the `code` and `language` of an `ExecutableCode` object.
|
|
680
|
+
*/
|
|
681
|
+
export declare function createPartFromExecutableCode(code: string, language: Language): Part;
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Creates a `Part` object from a `FunctionCall` object.
|
|
685
|
+
*/
|
|
686
|
+
export declare function createPartFromFunctionCall(name: string, args: Record<string, unknown>): Part;
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Creates a `Part` object from a `FunctionResponse` object.
|
|
690
|
+
*/
|
|
691
|
+
export declare function createPartFromFunctionResponse(id: string, name: string, response: Record<string, unknown>): Part;
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Creates a `Part` object from a `text` string.
|
|
695
|
+
*/
|
|
696
|
+
export declare function createPartFromText(text: string): Part;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Creates a `Part` object from a `URI` string.
|
|
700
|
+
*/
|
|
701
|
+
export declare function createPartFromUri(uri: string, mimeType: string): Part;
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Creates a `Content` object with a user role from a `PartListUnion` object or `string`.
|
|
705
|
+
*/
|
|
706
|
+
export declare function createUserContent(partOrString: PartListUnion | string): Content;
|
|
707
|
+
|
|
708
|
+
/** Optional parameters for caches.delete method. */
|
|
709
|
+
export declare interface DeleteCachedContentConfig {
|
|
710
|
+
/** Used to override HTTP request options. */
|
|
711
|
+
httpOptions?: HttpOptions;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/** Parameters for caches.delete method. */
|
|
715
|
+
export declare interface DeleteCachedContentParameters {
|
|
716
|
+
/** The server-generated resource name of the cached content.
|
|
717
|
+
*/
|
|
718
|
+
name: string;
|
|
719
|
+
/** Optional parameters for the request.
|
|
720
|
+
*/
|
|
721
|
+
config?: DeleteCachedContentConfig;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/** Empty response for caches.delete method. */
|
|
725
|
+
export declare class DeleteCachedContentResponse {
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/** Used to override the default configuration. */
|
|
729
|
+
export declare interface DeleteFileConfig {
|
|
730
|
+
/** Used to override HTTP request options. */
|
|
731
|
+
httpOptions?: HttpOptions;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/** Generates the parameters for the get method. */
|
|
735
|
+
export declare interface DeleteFileParameters {
|
|
736
|
+
/** The name identifier for the file to be deleted. */
|
|
737
|
+
name: string;
|
|
738
|
+
/** Used to override the default configuration. */
|
|
739
|
+
config?: DeleteFileConfig;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/** Response for the delete file method. */
|
|
743
|
+
export declare class DeleteFileResponse {
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/** Used to override the default configuration. */
|
|
747
|
+
export declare interface DownloadFileConfig {
|
|
748
|
+
/** Used to override HTTP request options. */
|
|
749
|
+
httpOptions?: HttpOptions;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/** Describes the options to customize dynamic retrieval. */
|
|
753
|
+
export declare interface DynamicRetrievalConfig {
|
|
754
|
+
/** The mode of the predictor to be used in dynamic retrieval. */
|
|
755
|
+
mode?: DynamicRetrievalConfigMode;
|
|
756
|
+
/** Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used. */
|
|
757
|
+
dynamicThreshold?: number;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
export declare enum DynamicRetrievalConfigMode {
|
|
761
|
+
MODE_UNSPECIFIED = "MODE_UNSPECIFIED",
|
|
762
|
+
MODE_DYNAMIC = "MODE_DYNAMIC"
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
export declare interface EmbedContentConfig {
|
|
766
|
+
/** Used to override HTTP request options. */
|
|
767
|
+
httpOptions?: HttpOptions;
|
|
768
|
+
/** Type of task for which the embedding will be used.
|
|
769
|
+
*/
|
|
770
|
+
taskType?: string;
|
|
771
|
+
/** Title for the text. Only applicable when TaskType is
|
|
772
|
+
`RETRIEVAL_DOCUMENT`.
|
|
773
|
+
*/
|
|
774
|
+
title?: string;
|
|
775
|
+
/** Reduced dimension for the output embedding. If set,
|
|
776
|
+
excessive values in the output embedding are truncated from the end.
|
|
777
|
+
Supported by newer models since 2024 only. You cannot set this value if
|
|
778
|
+
using the earlier model (`models/embedding-001`).
|
|
779
|
+
*/
|
|
780
|
+
outputDimensionality?: number;
|
|
781
|
+
/** Vertex API only. The MIME type of the input.
|
|
782
|
+
*/
|
|
783
|
+
mimeType?: string;
|
|
784
|
+
/** Vertex API only. Whether to silently truncate inputs longer than
|
|
785
|
+
the max sequence length. If this option is set to false, oversized inputs
|
|
786
|
+
will lead to an INVALID_ARGUMENT error, similar to other text APIs.
|
|
787
|
+
*/
|
|
788
|
+
autoTruncate?: boolean;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/** Request-level metadata for the Vertex Embed Content API. */
|
|
792
|
+
export declare interface EmbedContentMetadata {
|
|
793
|
+
/** Vertex API only. The total number of billable characters included
|
|
794
|
+
in the request.
|
|
795
|
+
*/
|
|
796
|
+
billableCharacterCount?: number;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/** Parameters for the embed_content method. */
|
|
800
|
+
export declare interface EmbedContentParameters {
|
|
801
|
+
/** ID of the model to use. For a list of models, see `Google models
|
|
802
|
+
<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
|
|
803
|
+
model: string;
|
|
804
|
+
/** The content to embed. Only the `parts.text` fields will be counted.
|
|
805
|
+
*/
|
|
806
|
+
contents: ContentListUnion;
|
|
807
|
+
/** Configuration that contains optional parameters.
|
|
808
|
+
*/
|
|
809
|
+
config?: EmbedContentConfig;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
/** Response for the embed_content method. */
|
|
813
|
+
export declare class EmbedContentResponse {
|
|
814
|
+
/** The embeddings for each request, in the same order as provided in
|
|
815
|
+
the batch request.
|
|
816
|
+
*/
|
|
817
|
+
embeddings?: ContentEmbedding[];
|
|
818
|
+
/** Vertex API only. Metadata about the request.
|
|
819
|
+
*/
|
|
820
|
+
metadata?: EmbedContentMetadata;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/** Code generated by the model that is meant to be executed, and the result returned to the model. Generated when using the [FunctionDeclaration] tool and [FunctionCallingConfig] mode is set to [Mode.CODE]. */
|
|
824
|
+
export declare interface ExecutableCode {
|
|
825
|
+
/** Required. The code to be executed. */
|
|
826
|
+
code?: string;
|
|
827
|
+
/** Required. Programming language of the `code`. */
|
|
828
|
+
language?: Language;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/** A file uploaded to the API. */
|
|
832
|
+
declare interface File_2 {
|
|
833
|
+
/** The `File` resource name. The ID (name excluding the "files/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: `files/123-456` */
|
|
834
|
+
name?: string;
|
|
835
|
+
/** Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: 'Welcome Image' */
|
|
836
|
+
displayName?: string;
|
|
837
|
+
/** Output only. MIME type of the file. */
|
|
838
|
+
mimeType?: string;
|
|
839
|
+
/** Output only. Size of the file in bytes. */
|
|
840
|
+
sizeBytes?: number;
|
|
841
|
+
/** Output only. The timestamp of when the `File` was created. */
|
|
842
|
+
createTime?: string;
|
|
843
|
+
/** Output only. The timestamp of when the `File` will be deleted. Only set if the `File` is scheduled to expire. */
|
|
844
|
+
expirationTime?: string;
|
|
845
|
+
/** Output only. The timestamp of when the `File` was last updated. */
|
|
846
|
+
updateTime?: string;
|
|
847
|
+
/** Output only. SHA-256 hash of the uploaded bytes. The hash value is encoded in base64 format. */
|
|
848
|
+
sha256Hash?: string;
|
|
849
|
+
/** Output only. The URI of the `File`. */
|
|
850
|
+
uri?: string;
|
|
851
|
+
/** Output only. The URI of the `File`, only set for downloadable (generated) files. */
|
|
852
|
+
downloadUri?: string;
|
|
853
|
+
/** Output only. Processing state of the File. */
|
|
854
|
+
state?: FileState;
|
|
855
|
+
/** Output only. The source of the `File`. */
|
|
856
|
+
source?: FileSource;
|
|
857
|
+
/** Output only. Metadata for a video. */
|
|
858
|
+
videoMetadata?: Record<string, unknown>;
|
|
859
|
+
/** Output only. Error status if File processing failed. */
|
|
860
|
+
error?: FileStatus;
|
|
861
|
+
}
|
|
862
|
+
export { File_2 as File }
|
|
863
|
+
|
|
864
|
+
/** URI based data. */
|
|
865
|
+
export declare interface FileData {
|
|
866
|
+
/** Required. URI. */
|
|
867
|
+
fileUri?: string;
|
|
868
|
+
/** Required. The IANA standard MIME type of the source data. */
|
|
869
|
+
mimeType?: string;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
declare class Files extends BaseModule {
|
|
873
|
+
private readonly apiClient;
|
|
874
|
+
constructor(apiClient: ApiClient);
|
|
875
|
+
/**
|
|
876
|
+
* Lists all current project files from the service.
|
|
877
|
+
*
|
|
878
|
+
* @param params - The parameters for the list request
|
|
879
|
+
* @return The paginated results of the list of files
|
|
880
|
+
*
|
|
881
|
+
* @example
|
|
882
|
+
* The following code prints the names of all files from the service, the
|
|
883
|
+
* size of each page is 10.
|
|
884
|
+
*
|
|
885
|
+
* ```ts
|
|
886
|
+
* const listResponse = await ai.files.list({config: {'pageSize': 10}});
|
|
887
|
+
* for await (const file of listResponse) {
|
|
888
|
+
* console.log(file.name);
|
|
889
|
+
* }
|
|
890
|
+
* ```
|
|
891
|
+
*/
|
|
892
|
+
list: (params?: types.ListFilesParameters) => Promise<Pager<types.File>>;
|
|
893
|
+
/**
|
|
894
|
+
* Uploads a file asynchronously to the Gemini API.
|
|
895
|
+
* This method is not available in Vertex AI.
|
|
896
|
+
* Supported upload sources:
|
|
897
|
+
* - Node.js: File path (string) or Blob object.
|
|
898
|
+
* - Browser: Blob object (e.g., File).
|
|
899
|
+
*
|
|
900
|
+
* @remarks
|
|
901
|
+
* The `mimeType` can be specified in the `config` parameter. If omitted:
|
|
902
|
+
* - For file path (string) inputs, the `mimeType` will be inferred from the
|
|
903
|
+
* file extension.
|
|
904
|
+
* - For Blob object inputs, the `mimeType` will be set to the Blob's `type`
|
|
905
|
+
* property.
|
|
906
|
+
* Somex eamples for file extension to mimeType mapping:
|
|
907
|
+
* .txt -> text/plain
|
|
908
|
+
* .json -> application/json
|
|
909
|
+
* .jpg -> image/jpeg
|
|
910
|
+
* .png -> image/png
|
|
911
|
+
* .mp3 -> audio/mpeg
|
|
912
|
+
* .mp4 -> video/mp4
|
|
913
|
+
*
|
|
914
|
+
* This section can contain multiple paragraphs and code examples.
|
|
915
|
+
*
|
|
916
|
+
* @param params - Optional parameters specified in the
|
|
917
|
+
* `common.UploadFileParameters` interface.
|
|
918
|
+
* Optional @see {@link common.UploadFileParameters}
|
|
919
|
+
* @return A promise that resolves to a `types.File` object.
|
|
920
|
+
* @throws An error if called on a Vertex AI client.
|
|
921
|
+
* @throws An error if the `mimeType` is not provided and can not be inferred,
|
|
922
|
+
* the `mimeType` can be provided in the `params.config` parameter.
|
|
923
|
+
* @throws An error occurs if a suitable upload location cannot be established.
|
|
924
|
+
*
|
|
925
|
+
* @example
|
|
926
|
+
* The following code uploads a file to Gemini API.
|
|
927
|
+
*
|
|
928
|
+
* ```ts
|
|
929
|
+
* const file = await ai.files.upload({file: 'file.txt', config: {
|
|
930
|
+
* mimeType: 'text/plain',
|
|
931
|
+
* }});
|
|
932
|
+
* console.log(file.name);
|
|
933
|
+
* ```
|
|
934
|
+
*/
|
|
935
|
+
upload(params: common.UploadFileParameters): Promise<types.File>;
|
|
936
|
+
private listInternal;
|
|
937
|
+
private createInternal;
|
|
938
|
+
/**
|
|
939
|
+
* Retrieves the file information from the service.
|
|
940
|
+
*
|
|
941
|
+
* @param params - The parameters for the get request
|
|
942
|
+
* @return The Promise that resolves to the types.File object requested.
|
|
943
|
+
*
|
|
944
|
+
* @example
|
|
945
|
+
* ```ts
|
|
946
|
+
* const config: GetFileParameters = {
|
|
947
|
+
* name: fileName,
|
|
948
|
+
* };
|
|
949
|
+
* file = await ai.files.get(config);
|
|
950
|
+
* console.log(file.name);
|
|
951
|
+
* ```
|
|
952
|
+
*/
|
|
953
|
+
get(params: types.GetFileParameters): Promise<types.File>;
|
|
954
|
+
/**
|
|
955
|
+
* Deletes a remotely stored file.
|
|
956
|
+
*
|
|
957
|
+
* @param params - The parameters for the delete request.
|
|
958
|
+
* @return The DeleteFileResponse, the response for the delete method.
|
|
959
|
+
*
|
|
960
|
+
* @example
|
|
961
|
+
* The following code deletes an example file named "files/mehozpxf877d".
|
|
962
|
+
*
|
|
963
|
+
* ```ts
|
|
964
|
+
* await ai.files.delete({name: file.name});
|
|
965
|
+
* ```
|
|
966
|
+
*/
|
|
967
|
+
delete(params: types.DeleteFileParameters): Promise<types.DeleteFileResponse>;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
export declare enum FileSource {
|
|
971
|
+
SOURCE_UNSPECIFIED = "SOURCE_UNSPECIFIED",
|
|
972
|
+
UPLOADED = "UPLOADED",
|
|
973
|
+
GENERATED = "GENERATED"
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* Represents the size and mimeType of a file. The information is used to
|
|
978
|
+
* request the upload URL from the https://generativelanguage.googleapis.com/upload/v1beta/files endpoint.
|
|
979
|
+
* This interface defines the structure for constructing and executing HTTP
|
|
980
|
+
* requests.
|
|
981
|
+
*/
|
|
982
|
+
declare interface FileStat {
|
|
983
|
+
/**
|
|
984
|
+
* The size of the file in bytes.
|
|
985
|
+
*/
|
|
986
|
+
size: number;
|
|
987
|
+
/**
|
|
988
|
+
* The MIME type of the file.
|
|
989
|
+
*/
|
|
990
|
+
type: string | undefined;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
export declare enum FileState {
|
|
994
|
+
STATE_UNSPECIFIED = "STATE_UNSPECIFIED",
|
|
995
|
+
PROCESSING = "PROCESSING",
|
|
996
|
+
ACTIVE = "ACTIVE",
|
|
997
|
+
FAILED = "FAILED"
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
/** Status of a File that uses a common error model. */
|
|
1001
|
+
export declare interface FileStatus {
|
|
1002
|
+
/** A list of messages that carry the error details. There is a common set of message types for APIs to use. */
|
|
1003
|
+
details?: Record<string, unknown>[];
|
|
1004
|
+
/** A list of messages that carry the error details. There is a common set of message types for APIs to use. */
|
|
1005
|
+
message?: string;
|
|
1006
|
+
/** The status code. 0 for OK, 1 for CANCELLED */
|
|
1007
|
+
code?: number;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
export declare enum FinishReason {
|
|
1011
|
+
FINISH_REASON_UNSPECIFIED = "FINISH_REASON_UNSPECIFIED",
|
|
1012
|
+
STOP = "STOP",
|
|
1013
|
+
MAX_TOKENS = "MAX_TOKENS",
|
|
1014
|
+
SAFETY = "SAFETY",
|
|
1015
|
+
RECITATION = "RECITATION",
|
|
1016
|
+
OTHER = "OTHER",
|
|
1017
|
+
BLOCKLIST = "BLOCKLIST",
|
|
1018
|
+
PROHIBITED_CONTENT = "PROHIBITED_CONTENT",
|
|
1019
|
+
SPII = "SPII",
|
|
1020
|
+
MALFORMED_FUNCTION_CALL = "MALFORMED_FUNCTION_CALL",
|
|
1021
|
+
IMAGE_SAFETY = "IMAGE_SAFETY"
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
declare function formatMap(templateString: string, valueMap: Record<string, unknown>): string;
|
|
1025
|
+
|
|
1026
|
+
/** A function call. */
|
|
1027
|
+
export declare interface FunctionCall {
|
|
1028
|
+
/** The unique id of the function call. If populated, the client to execute the
|
|
1029
|
+
`function_call` and return the response with the matching `id`. */
|
|
1030
|
+
id?: string;
|
|
1031
|
+
/** Optional. Required. The function parameters and values in JSON object format. See [FunctionDeclaration.parameters] for parameter details. */
|
|
1032
|
+
args?: Record<string, unknown>;
|
|
1033
|
+
/** Required. The name of the function to call. Matches [FunctionDeclaration.name]. */
|
|
1034
|
+
name?: string;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/** Function calling config. */
|
|
1038
|
+
export declare interface FunctionCallingConfig {
|
|
1039
|
+
/** Optional. Function calling mode. */
|
|
1040
|
+
mode?: FunctionCallingConfigMode;
|
|
1041
|
+
/** Optional. Function names to call. Only set when the Mode is ANY. Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will predict a function call from the set of function names provided. */
|
|
1042
|
+
allowedFunctionNames?: string[];
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
export declare enum FunctionCallingConfigMode {
|
|
1046
|
+
MODE_UNSPECIFIED = "MODE_UNSPECIFIED",
|
|
1047
|
+
AUTO = "AUTO",
|
|
1048
|
+
ANY = "ANY",
|
|
1049
|
+
NONE = "NONE"
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
/** Defines a function that the model can generate JSON inputs for.
|
|
1053
|
+
|
|
1054
|
+
The inputs are based on `OpenAPI 3.0 specifications
|
|
1055
|
+
<https://spec.openapis.org/oas/v3.0.3>`_.
|
|
1056
|
+
*/
|
|
1057
|
+
export declare interface FunctionDeclaration {
|
|
1058
|
+
/** Describes the output from the function in the OpenAPI JSON Schema
|
|
1059
|
+
Object format. */
|
|
1060
|
+
response?: Schema;
|
|
1061
|
+
/** Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function. */
|
|
1062
|
+
description?: string;
|
|
1063
|
+
/** Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots and dashes, with a maximum length of 64. */
|
|
1064
|
+
name?: string;
|
|
1065
|
+
/** Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. Parameter names must start with a letter or an underscore and must only contain chars a-z, A-Z, 0-9, or underscores with a maximum length of 64. Example with 1 required and 1 optional parameter: type: OBJECT properties: param1: type: STRING param2: type: INTEGER required: - param1 */
|
|
1066
|
+
parameters?: Schema;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/** A function response. */
|
|
1070
|
+
export declare class FunctionResponse {
|
|
1071
|
+
/** The id of the function call this response is for. Populated by the client
|
|
1072
|
+
to match the corresponding function call `id`. */
|
|
1073
|
+
id?: string;
|
|
1074
|
+
/** Required. The name of the function to call. Matches [FunctionDeclaration.name] and [FunctionCall.name]. */
|
|
1075
|
+
name?: string;
|
|
1076
|
+
/** Required. The function response in JSON object format. Use "output" key to specify function output and "error" key to specify error details (if any). If "output" and "error" keys are not specified, then whole "response" is treated as function output. */
|
|
1077
|
+
response?: Record<string, unknown>;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
/** Optional model configuration parameters.
|
|
1081
|
+
|
|
1082
|
+
For more information, see `Content generation parameters
|
|
1083
|
+
<https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/content-generation-parameters>`_.
|
|
1084
|
+
*/
|
|
1085
|
+
export declare interface GenerateContentConfig {
|
|
1086
|
+
/** Used to override HTTP request options. */
|
|
1087
|
+
httpOptions?: HttpOptions;
|
|
1088
|
+
/** Instructions for the model to steer it toward better performance.
|
|
1089
|
+
For example, "Answer as concisely as possible" or "Don't use technical
|
|
1090
|
+
terms in your response".
|
|
1091
|
+
*/
|
|
1092
|
+
systemInstruction?: ContentUnion;
|
|
1093
|
+
/** Value that controls the degree of randomness in token selection.
|
|
1094
|
+
Lower temperatures are good for prompts that require a less open-ended or
|
|
1095
|
+
creative response, while higher temperatures can lead to more diverse or
|
|
1096
|
+
creative results.
|
|
1097
|
+
*/
|
|
1098
|
+
temperature?: number;
|
|
1099
|
+
/** Tokens are selected from the most to least probable until the sum
|
|
1100
|
+
of their probabilities equals this value. Use a lower value for less
|
|
1101
|
+
random responses and a higher value for more random responses.
|
|
1102
|
+
*/
|
|
1103
|
+
topP?: number;
|
|
1104
|
+
/** For each token selection step, the ``top_k`` tokens with the
|
|
1105
|
+
highest probabilities are sampled. Then tokens are further filtered based
|
|
1106
|
+
on ``top_p`` with the final token selected using temperature sampling. Use
|
|
1107
|
+
a lower number for less random responses and a higher number for more
|
|
1108
|
+
random responses.
|
|
1109
|
+
*/
|
|
1110
|
+
topK?: number;
|
|
1111
|
+
/** Number of response variations to return.
|
|
1112
|
+
*/
|
|
1113
|
+
candidateCount?: number;
|
|
1114
|
+
/** Maximum number of tokens that can be generated in the response.
|
|
1115
|
+
*/
|
|
1116
|
+
maxOutputTokens?: number;
|
|
1117
|
+
/** List of strings that tells the model to stop generating text if one
|
|
1118
|
+
of the strings is encountered in the response.
|
|
1119
|
+
*/
|
|
1120
|
+
stopSequences?: string[];
|
|
1121
|
+
/** Whether to return the log probabilities of the tokens that were
|
|
1122
|
+
chosen by the model at each step.
|
|
1123
|
+
*/
|
|
1124
|
+
responseLogprobs?: boolean;
|
|
1125
|
+
/** Number of top candidate tokens to return the log probabilities for
|
|
1126
|
+
at each generation step.
|
|
1127
|
+
*/
|
|
1128
|
+
logprobs?: number;
|
|
1129
|
+
/** Positive values penalize tokens that already appear in the
|
|
1130
|
+
generated text, increasing the probability of generating more diverse
|
|
1131
|
+
content.
|
|
1132
|
+
*/
|
|
1133
|
+
presencePenalty?: number;
|
|
1134
|
+
/** Positive values penalize tokens that repeatedly appear in the
|
|
1135
|
+
generated text, increasing the probability of generating more diverse
|
|
1136
|
+
content.
|
|
1137
|
+
*/
|
|
1138
|
+
frequencyPenalty?: number;
|
|
1139
|
+
/** When ``seed`` is fixed to a specific number, the model makes a best
|
|
1140
|
+
effort to provide the same response for repeated requests. By default, a
|
|
1141
|
+
random number is used.
|
|
1142
|
+
*/
|
|
1143
|
+
seed?: number;
|
|
1144
|
+
/** Output response media type of the generated candidate text.
|
|
1145
|
+
*/
|
|
1146
|
+
responseMimeType?: string;
|
|
1147
|
+
/** Schema that the generated candidate text must adhere to.
|
|
1148
|
+
*/
|
|
1149
|
+
responseSchema?: SchemaUnion;
|
|
1150
|
+
/** Configuration for model router requests.
|
|
1151
|
+
*/
|
|
1152
|
+
routingConfig?: GenerationConfigRoutingConfig;
|
|
1153
|
+
/** Safety settings in the request to block unsafe content in the
|
|
1154
|
+
response.
|
|
1155
|
+
*/
|
|
1156
|
+
safetySettings?: SafetySetting[];
|
|
1157
|
+
/** Code that enables the system to interact with external systems to
|
|
1158
|
+
perform an action outside of the knowledge and scope of the model.
|
|
1159
|
+
*/
|
|
1160
|
+
tools?: ToolListUnion;
|
|
1161
|
+
/** Associates model output to a specific function call.
|
|
1162
|
+
*/
|
|
1163
|
+
toolConfig?: ToolConfig;
|
|
1164
|
+
/** Labels with user-defined metadata to break down billed charges. */
|
|
1165
|
+
labels?: Record<string, string>;
|
|
1166
|
+
/** Resource name of a context cache that can be used in subsequent
|
|
1167
|
+
requests.
|
|
1168
|
+
*/
|
|
1169
|
+
cachedContent?: string;
|
|
1170
|
+
/** The requested modalities of the response. Represents the set of
|
|
1171
|
+
modalities that the model can return.
|
|
1172
|
+
*/
|
|
1173
|
+
responseModalities?: string[];
|
|
1174
|
+
/** If specified, the media resolution specified will be used.
|
|
1175
|
+
*/
|
|
1176
|
+
mediaResolution?: MediaResolution;
|
|
1177
|
+
/** The speech generation configuration.
|
|
1178
|
+
*/
|
|
1179
|
+
speechConfig?: SpeechConfigUnion;
|
|
1180
|
+
/** If enabled, audio timestamp will be included in the request to the
|
|
1181
|
+
model.
|
|
1182
|
+
*/
|
|
1183
|
+
audioTimestamp?: boolean;
|
|
1184
|
+
/** The thinking features configuration.
|
|
1185
|
+
*/
|
|
1186
|
+
thinkingConfig?: ThinkingConfig;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
/** Config for models.generate_content parameters. */
|
|
1190
|
+
export declare interface GenerateContentParameters {
|
|
1191
|
+
/** ID of the model to use. For a list of models, see `Google models
|
|
1192
|
+
<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
|
|
1193
|
+
model: string;
|
|
1194
|
+
/** Content of the request.
|
|
1195
|
+
*/
|
|
1196
|
+
contents: ContentListUnion;
|
|
1197
|
+
/** Configuration that contains optional model parameters.
|
|
1198
|
+
*/
|
|
1199
|
+
config?: GenerateContentConfig;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/** Response message for PredictionService.GenerateContent. */
|
|
1203
|
+
export declare class GenerateContentResponse {
|
|
1204
|
+
/** Response variations returned by the model.
|
|
1205
|
+
*/
|
|
1206
|
+
candidates?: Candidate[];
|
|
1207
|
+
/** Timestamp when the request is made to the server.
|
|
1208
|
+
*/
|
|
1209
|
+
createTime?: string;
|
|
1210
|
+
/** Identifier for each response.
|
|
1211
|
+
*/
|
|
1212
|
+
responseId?: string;
|
|
1213
|
+
/** Output only. The model version used to generate the response. */
|
|
1214
|
+
modelVersion?: string;
|
|
1215
|
+
/** Output only. Content filter results for a prompt sent in the request. Note: Sent only in the first stream chunk. Only happens when no candidates were generated due to content violations. */
|
|
1216
|
+
promptFeedback?: GenerateContentResponsePromptFeedback;
|
|
1217
|
+
/** Usage metadata about the response(s). */
|
|
1218
|
+
usageMetadata?: GenerateContentResponseUsageMetadata;
|
|
1219
|
+
/**
|
|
1220
|
+
* Returns the concatenation of all text parts from the first candidate in the response.
|
|
1221
|
+
*
|
|
1222
|
+
* @remarks
|
|
1223
|
+
* If there are multiple candidates in the response, the text from the first
|
|
1224
|
+
* one will be returned.
|
|
1225
|
+
* If there are non-text parts in the response, the concatenation of all text
|
|
1226
|
+
* parts will be returned, and a warning will be logged.
|
|
1227
|
+
* If there are thought parts in the response, the concatenation of all text
|
|
1228
|
+
* parts excluding the thought parts will be returned.
|
|
1229
|
+
*
|
|
1230
|
+
* @example
|
|
1231
|
+
* ```ts
|
|
1232
|
+
* const response = await ai.models.generateContent({
|
|
1233
|
+
* model: 'gemini-2.0-flash',
|
|
1234
|
+
* contents:
|
|
1235
|
+
* 'Why is the sky blue?',
|
|
1236
|
+
* });
|
|
1237
|
+
*
|
|
1238
|
+
* console.debug(response.text);
|
|
1239
|
+
* ```
|
|
1240
|
+
*/
|
|
1241
|
+
get text(): string | undefined;
|
|
1242
|
+
/**
|
|
1243
|
+
* Returns the function calls from the first candidate in the response.
|
|
1244
|
+
*
|
|
1245
|
+
* @remarks
|
|
1246
|
+
* If there are multiple candidates in the response, the function calls from
|
|
1247
|
+
* the first one will be returned.
|
|
1248
|
+
* If there are no function calls in the response, undefined will be returned.
|
|
1249
|
+
*
|
|
1250
|
+
* @example
|
|
1251
|
+
* ```ts
|
|
1252
|
+
* const controlLightFunctionDeclaration: FunctionDeclaration = {
|
|
1253
|
+
* name: 'controlLight',
|
|
1254
|
+
* parameters: {
|
|
1255
|
+
* type: Type.OBJECT,
|
|
1256
|
+
* description: 'Set the brightness and color temperature of a room light.',
|
|
1257
|
+
* properties: {
|
|
1258
|
+
* brightness: {
|
|
1259
|
+
* type: Type.NUMBER,
|
|
1260
|
+
* description:
|
|
1261
|
+
* 'Light level from 0 to 100. Zero is off and 100 is full brightness.',
|
|
1262
|
+
* },
|
|
1263
|
+
* colorTemperature: {
|
|
1264
|
+
* type: Type.STRING,
|
|
1265
|
+
* description:
|
|
1266
|
+
* 'Color temperature of the light fixture which can be `daylight`, `cool` or `warm`.',
|
|
1267
|
+
* },
|
|
1268
|
+
* },
|
|
1269
|
+
* required: ['brightness', 'colorTemperature'],
|
|
1270
|
+
* };
|
|
1271
|
+
* const response = await ai.models.generateContent({
|
|
1272
|
+
* model: 'gemini-2.0-flash',
|
|
1273
|
+
* contents: 'Dim the lights so the room feels cozy and warm.',
|
|
1274
|
+
* config: {
|
|
1275
|
+
* tools: [{functionDeclarations: [controlLightFunctionDeclaration]}],
|
|
1276
|
+
* toolConfig: {
|
|
1277
|
+
* functionCallingConfig: {
|
|
1278
|
+
* mode: FunctionCallingConfigMode.ANY,
|
|
1279
|
+
* allowedFunctionNames: ['controlLight'],
|
|
1280
|
+
* },
|
|
1281
|
+
* },
|
|
1282
|
+
* },
|
|
1283
|
+
* });
|
|
1284
|
+
* console.debug(JSON.stringify(response.functionCalls));
|
|
1285
|
+
* ```
|
|
1286
|
+
*/
|
|
1287
|
+
get functionCalls(): FunctionCall[] | undefined;
|
|
1288
|
+
/**
|
|
1289
|
+
* Returns the first executable code from the first candidate in the response.
|
|
1290
|
+
*
|
|
1291
|
+
* @remarks
|
|
1292
|
+
* If there are multiple candidates in the response, the executable code from
|
|
1293
|
+
* the first one will be returned.
|
|
1294
|
+
* If there are no executable code in the response, undefined will be
|
|
1295
|
+
* returned.
|
|
1296
|
+
*
|
|
1297
|
+
* @example
|
|
1298
|
+
* ```ts
|
|
1299
|
+
* const response = await ai.models.generateContent({
|
|
1300
|
+
* model: 'gemini-2.0-flash',
|
|
1301
|
+
* contents:
|
|
1302
|
+
* 'What is the sum of the first 50 prime numbers? Generate and run code for the calculation, and make sure you get all 50.'
|
|
1303
|
+
* config: {
|
|
1304
|
+
* tools: [{codeExecution: {}}],
|
|
1305
|
+
* },
|
|
1306
|
+
* });
|
|
1307
|
+
*
|
|
1308
|
+
* console.debug(response.executableCode);
|
|
1309
|
+
* ```
|
|
1310
|
+
*/
|
|
1311
|
+
get executableCode(): string | undefined;
|
|
1312
|
+
/**
|
|
1313
|
+
* Returns the first code execution result from the first candidate in the response.
|
|
1314
|
+
*
|
|
1315
|
+
* @remarks
|
|
1316
|
+
* If there are multiple candidates in the response, the code execution result from
|
|
1317
|
+
* the first one will be returned.
|
|
1318
|
+
* If there are no code execution result in the response, undefined will be returned.
|
|
1319
|
+
*
|
|
1320
|
+
* @example
|
|
1321
|
+
* ```ts
|
|
1322
|
+
* const response = await ai.models.generateContent({
|
|
1323
|
+
* model: 'gemini-2.0-flash',
|
|
1324
|
+
* contents:
|
|
1325
|
+
* 'What is the sum of the first 50 prime numbers? Generate and run code for the calculation, and make sure you get all 50.'
|
|
1326
|
+
* config: {
|
|
1327
|
+
* tools: [{codeExecution: {}}],
|
|
1328
|
+
* },
|
|
1329
|
+
* });
|
|
1330
|
+
*
|
|
1331
|
+
* console.debug(response.codeExecutionResult);
|
|
1332
|
+
* ```
|
|
1333
|
+
*/
|
|
1334
|
+
get codeExecutionResult(): string | undefined;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
/** Content filter results for a prompt sent in the request. */
|
|
1338
|
+
export declare class GenerateContentResponsePromptFeedback {
|
|
1339
|
+
/** Output only. Blocked reason. */
|
|
1340
|
+
blockReason?: BlockedReason;
|
|
1341
|
+
/** Output only. A readable block reason message. */
|
|
1342
|
+
blockReasonMessage?: string;
|
|
1343
|
+
/** Output only. Safety ratings. */
|
|
1344
|
+
safetyRatings?: SafetyRating[];
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
/** Usage metadata about response(s). */
|
|
1348
|
+
export declare class GenerateContentResponseUsageMetadata {
|
|
1349
|
+
/** Output only. List of modalities of the cached content in the request input. */
|
|
1350
|
+
cacheTokensDetails?: ModalityTokenCount[];
|
|
1351
|
+
/** Output only. Number of tokens in the cached part in the input (the cached content). */
|
|
1352
|
+
cachedContentTokenCount?: number;
|
|
1353
|
+
/** Number of tokens in the response(s). */
|
|
1354
|
+
candidatesTokenCount?: number;
|
|
1355
|
+
/** Output only. List of modalities that were returned in the response. */
|
|
1356
|
+
candidatesTokensDetails?: ModalityTokenCount[];
|
|
1357
|
+
/** Number of tokens in the request. When `cached_content` is set, this is still the total effective prompt size meaning this includes the number of tokens in the cached content. */
|
|
1358
|
+
promptTokenCount?: number;
|
|
1359
|
+
/** Output only. List of modalities that were processed in the request input. */
|
|
1360
|
+
promptTokensDetails?: ModalityTokenCount[];
|
|
1361
|
+
/** Output only. Number of tokens present in thoughts output. */
|
|
1362
|
+
thoughtsTokenCount?: number;
|
|
1363
|
+
/** Output only. Number of tokens present in tool-use prompt(s). */
|
|
1364
|
+
toolUsePromptTokenCount?: number;
|
|
1365
|
+
/** Output only. List of modalities that were processed for tool-use request inputs. */
|
|
1366
|
+
toolUsePromptTokensDetails?: ModalityTokenCount[];
|
|
1367
|
+
/** Total token count for prompt, response candidates, and tool-use prompts (if present). */
|
|
1368
|
+
totalTokenCount?: number;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
/** An output image. */
|
|
1372
|
+
export declare interface GeneratedImage {
|
|
1373
|
+
/** The output image data.
|
|
1374
|
+
*/
|
|
1375
|
+
image?: Image_2;
|
|
1376
|
+
/** Responsible AI filter reason if the image is filtered out of the
|
|
1377
|
+
response.
|
|
1378
|
+
*/
|
|
1379
|
+
raiFilteredReason?: string;
|
|
1380
|
+
/** Safety attributes of the image. Lists of RAI categories and their
|
|
1381
|
+
scores of each content.
|
|
1382
|
+
*/
|
|
1383
|
+
safetyAttributes?: SafetyAttributes;
|
|
1384
|
+
/** The rewritten prompt used for the image generation if the prompt
|
|
1385
|
+
enhancer is enabled.
|
|
1386
|
+
*/
|
|
1387
|
+
enhancedPrompt?: string;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
/** The config for generating an images. */
|
|
1391
|
+
export declare interface GenerateImagesConfig {
|
|
1392
|
+
/** Used to override HTTP request options. */
|
|
1393
|
+
httpOptions?: HttpOptions;
|
|
1394
|
+
/** Cloud Storage URI used to store the generated images.
|
|
1395
|
+
*/
|
|
1396
|
+
outputGcsUri?: string;
|
|
1397
|
+
/** Description of what to discourage in the generated images.
|
|
1398
|
+
*/
|
|
1399
|
+
negativePrompt?: string;
|
|
1400
|
+
/** Number of images to generate.
|
|
1401
|
+
*/
|
|
1402
|
+
numberOfImages?: number;
|
|
1403
|
+
/** Aspect ratio of the generated images.
|
|
1404
|
+
*/
|
|
1405
|
+
aspectRatio?: string;
|
|
1406
|
+
/** Controls how much the model adheres to the text prompt. Large
|
|
1407
|
+
values increase output and prompt alignment, but may compromise image
|
|
1408
|
+
quality.
|
|
1409
|
+
*/
|
|
1410
|
+
guidanceScale?: number;
|
|
1411
|
+
/** Random seed for image generation. This is not available when
|
|
1412
|
+
``add_watermark`` is set to true.
|
|
1413
|
+
*/
|
|
1414
|
+
seed?: number;
|
|
1415
|
+
/** Filter level for safety filtering.
|
|
1416
|
+
*/
|
|
1417
|
+
safetyFilterLevel?: SafetyFilterLevel;
|
|
1418
|
+
/** Allows generation of people by the model.
|
|
1419
|
+
*/
|
|
1420
|
+
personGeneration?: PersonGeneration;
|
|
1421
|
+
/** Whether to report the safety scores of each generated image and
|
|
1422
|
+
the positive prompt in the response.
|
|
1423
|
+
*/
|
|
1424
|
+
includeSafetyAttributes?: boolean;
|
|
1425
|
+
/** Whether to include the Responsible AI filter reason if the image
|
|
1426
|
+
is filtered out of the response.
|
|
1427
|
+
*/
|
|
1428
|
+
includeRaiReason?: boolean;
|
|
1429
|
+
/** Language of the text in the prompt.
|
|
1430
|
+
*/
|
|
1431
|
+
language?: ImagePromptLanguage;
|
|
1432
|
+
/** MIME type of the generated image.
|
|
1433
|
+
*/
|
|
1434
|
+
outputMimeType?: string;
|
|
1435
|
+
/** Compression quality of the generated image (for ``image/jpeg``
|
|
1436
|
+
only).
|
|
1437
|
+
*/
|
|
1438
|
+
outputCompressionQuality?: number;
|
|
1439
|
+
/** Whether to add a watermark to the generated images.
|
|
1440
|
+
*/
|
|
1441
|
+
addWatermark?: boolean;
|
|
1442
|
+
/** Whether to use the prompt rewriting logic.
|
|
1443
|
+
*/
|
|
1444
|
+
enhancePrompt?: boolean;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
/** The parameters for generating images. */
|
|
1448
|
+
export declare interface GenerateImagesParameters {
|
|
1449
|
+
/** ID of the model to use. For a list of models, see `Google models
|
|
1450
|
+
<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
|
|
1451
|
+
model: string;
|
|
1452
|
+
/** Text prompt that typically describes the images to output.
|
|
1453
|
+
*/
|
|
1454
|
+
prompt: string;
|
|
1455
|
+
/** Configuration for generating images.
|
|
1456
|
+
*/
|
|
1457
|
+
config?: GenerateImagesConfig;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
/** The output images response. */
|
|
1461
|
+
export declare class GenerateImagesResponse {
|
|
1462
|
+
/** List of generated images.
|
|
1463
|
+
*/
|
|
1464
|
+
generatedImages?: GeneratedImage[];
|
|
1465
|
+
/** Safety attributes of the positive prompt. Only populated if
|
|
1466
|
+
``include_safety_attributes`` is set to True.
|
|
1467
|
+
*/
|
|
1468
|
+
positivePromptSafetyAttributes?: SafetyAttributes;
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
/** Generation config. */
|
|
1472
|
+
export declare interface GenerationConfig {
|
|
1473
|
+
/** Optional. If enabled, audio timestamp will be included in the request to the model. */
|
|
1474
|
+
audioTimestamp?: boolean;
|
|
1475
|
+
/** Optional. Number of candidates to generate. */
|
|
1476
|
+
candidateCount?: number;
|
|
1477
|
+
/** Optional. Frequency penalties. */
|
|
1478
|
+
frequencyPenalty?: number;
|
|
1479
|
+
/** Optional. Logit probabilities. */
|
|
1480
|
+
logprobs?: number;
|
|
1481
|
+
/** Optional. The maximum number of output tokens to generate per message. */
|
|
1482
|
+
maxOutputTokens?: number;
|
|
1483
|
+
/** Optional. Positive penalties. */
|
|
1484
|
+
presencePenalty?: number;
|
|
1485
|
+
/** Optional. If true, export the logprobs results in response. */
|
|
1486
|
+
responseLogprobs?: boolean;
|
|
1487
|
+
/** Optional. Output response mimetype of the generated candidate text. Supported mimetype: - `text/plain`: (default) Text output. - `application/json`: JSON response in the candidates. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. This is a preview feature. */
|
|
1488
|
+
responseMimeType?: string;
|
|
1489
|
+
/** Optional. The `Schema` object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible response_mime_type must also be set. Compatible mimetypes: `application/json`: Schema for JSON response. */
|
|
1490
|
+
responseSchema?: Schema;
|
|
1491
|
+
/** Optional. Routing configuration. */
|
|
1492
|
+
routingConfig?: GenerationConfigRoutingConfig;
|
|
1493
|
+
/** Optional. Seed. */
|
|
1494
|
+
seed?: number;
|
|
1495
|
+
/** Optional. Stop sequences. */
|
|
1496
|
+
stopSequences?: string[];
|
|
1497
|
+
/** Optional. Controls the randomness of predictions. */
|
|
1498
|
+
temperature?: number;
|
|
1499
|
+
/** Optional. If specified, top-k sampling will be used. */
|
|
1500
|
+
topK?: number;
|
|
1501
|
+
/** Optional. If specified, nucleus sampling will be used. */
|
|
1502
|
+
topP?: number;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
/** The configuration for routing the request to a specific model. */
|
|
1506
|
+
export declare interface GenerationConfigRoutingConfig {
|
|
1507
|
+
/** Automated routing. */
|
|
1508
|
+
autoMode?: GenerationConfigRoutingConfigAutoRoutingMode;
|
|
1509
|
+
/** Manual routing. */
|
|
1510
|
+
manualMode?: GenerationConfigRoutingConfigManualRoutingMode;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
/** When automated routing is specified, the routing will be determined by the pretrained routing model and customer provided model routing preference. */
|
|
1514
|
+
export declare interface GenerationConfigRoutingConfigAutoRoutingMode {
|
|
1515
|
+
/** The model routing preference. */
|
|
1516
|
+
modelRoutingPreference?: 'UNKNOWN' | 'PRIORITIZE_QUALITY' | 'BALANCED' | 'PRIORITIZE_COST';
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
/** When manual routing is set, the specified model will be used directly. */
|
|
1520
|
+
export declare interface GenerationConfigRoutingConfigManualRoutingMode {
|
|
1521
|
+
/** The model name to use. Only the public LLM models are accepted. e.g. 'gemini-1.5-pro-001'. */
|
|
1522
|
+
modelName?: string;
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
/** Optional parameters for caches.get method. */
|
|
1526
|
+
export declare interface GetCachedContentConfig {
|
|
1527
|
+
/** Used to override HTTP request options. */
|
|
1528
|
+
httpOptions?: HttpOptions;
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
/** Parameters for caches.get method. */
|
|
1532
|
+
export declare interface GetCachedContentParameters {
|
|
1533
|
+
/** The server-generated resource name of the cached content.
|
|
1534
|
+
*/
|
|
1535
|
+
name: string;
|
|
1536
|
+
/** Optional parameters for the request.
|
|
1537
|
+
*/
|
|
1538
|
+
config?: GetCachedContentConfig;
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
/** Used to override the default configuration. */
|
|
1542
|
+
export declare interface GetFileConfig {
|
|
1543
|
+
/** Used to override HTTP request options. */
|
|
1544
|
+
httpOptions?: HttpOptions;
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
/** Generates the parameters for the get method. */
|
|
1548
|
+
export declare interface GetFileParameters {
|
|
1549
|
+
/** The name identifier for the file to retrieve. */
|
|
1550
|
+
name: string;
|
|
1551
|
+
/** Used to override the default configuration. */
|
|
1552
|
+
config?: GetFileConfig;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
declare function getValueByPath(data: unknown, keys: string[]): unknown;
|
|
1556
|
+
|
|
1557
|
+
/**
|
|
1558
|
+
* The Google GenAI SDK.
|
|
1559
|
+
*
|
|
1560
|
+
* @remarks
|
|
1561
|
+
* Provides access to the GenAI features through either the {@link https://cloud.google.com/vertex-ai/docs/reference/rest | Gemini API}
|
|
1562
|
+
* or the {@link https://cloud.google.com/vertex-ai/docs/reference/rest | Vertex AI API}.
|
|
1563
|
+
*
|
|
1564
|
+
* The {@link GoogleGenAIOptions.vertexai} value determines which of the API services to use.
|
|
1565
|
+
*
|
|
1566
|
+
* When using the Gemini API, a {@link GoogleGenAIOptions.apiKey} must also be set,
|
|
1567
|
+
* when using Vertex AI {@link GoogleGenAIOptions.project} and {@link GoogleGenAIOptions.location} must also be set.
|
|
1568
|
+
*
|
|
1569
|
+
* @example
|
|
1570
|
+
* Initializing the SDK for using the Gemini API:
|
|
1571
|
+
* ```ts
|
|
1572
|
+
* import {GoogleGenAI} from '@google/genai';
|
|
1573
|
+
* const ai = new GoogleGenAI({apiKey: 'GEMINI_API_KEY'});
|
|
1574
|
+
* ```
|
|
1575
|
+
*
|
|
1576
|
+
* @example
|
|
1577
|
+
* Initializing the SDK for using the Vertex AI API:
|
|
1578
|
+
* ```ts
|
|
1579
|
+
* import {GoogleGenAI} from '@google/genai';
|
|
1580
|
+
* const ai = new GoogleGenAI({
|
|
1581
|
+
* vertexai: true,
|
|
1582
|
+
* project: 'PROJECT_ID',
|
|
1583
|
+
* location: 'PROJECT_LOCATION'
|
|
1584
|
+
* });
|
|
1585
|
+
* ```
|
|
1586
|
+
*
|
|
1587
|
+
*/
|
|
1588
|
+
export declare class GoogleGenAI {
|
|
1589
|
+
protected readonly apiClient: ApiClient;
|
|
1590
|
+
private readonly apiKey?;
|
|
1591
|
+
readonly vertexai: boolean;
|
|
1592
|
+
private readonly apiVersion?;
|
|
1593
|
+
readonly models: Models;
|
|
1594
|
+
readonly live: Live;
|
|
1595
|
+
readonly chats: Chats;
|
|
1596
|
+
readonly caches: Caches;
|
|
1597
|
+
readonly files: Files;
|
|
1598
|
+
constructor(options: GoogleGenAIOptions);
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
/**
|
|
1602
|
+
* Google Gen AI SDK's configuration options.
|
|
1603
|
+
*
|
|
1604
|
+
* See {@link GoogleGenAI} for usage samples.
|
|
1605
|
+
*/
|
|
1606
|
+
export declare interface GoogleGenAIOptions {
|
|
1607
|
+
/**
|
|
1608
|
+
* Optional. Determines whether to use the Vertex AI or the Gemini API.
|
|
1609
|
+
*
|
|
1610
|
+
* @remarks
|
|
1611
|
+
* When true, the {@link https://cloud.google.com/vertex-ai/docs/reference/rest | Vertex AI API} will used.
|
|
1612
|
+
* When false, the {@link https://cloud.google.com/vertex-ai/docs/reference/rest | Gemini API} will be used.
|
|
1613
|
+
*
|
|
1614
|
+
* If unset, default SDK behavior is to use the Gemini API service.
|
|
1615
|
+
*/
|
|
1616
|
+
vertexai?: boolean;
|
|
1617
|
+
/**
|
|
1618
|
+
* Optional. The Google Cloud project ID for Vertex AI clients.
|
|
1619
|
+
*
|
|
1620
|
+
* @remarks
|
|
1621
|
+
* Only supported on Node runtimes, ignored on browser runtimes.
|
|
1622
|
+
*/
|
|
1623
|
+
project?: string;
|
|
1624
|
+
/**
|
|
1625
|
+
* Optional. The Google Cloud project region for Vertex AI clients.
|
|
1626
|
+
*
|
|
1627
|
+
* @remarks
|
|
1628
|
+
* Only supported on Node runtimes, ignored on browser runtimes.
|
|
1629
|
+
*
|
|
1630
|
+
*/
|
|
1631
|
+
location?: string;
|
|
1632
|
+
/**
|
|
1633
|
+
* The API Key, required for Gemini API clients.
|
|
1634
|
+
*
|
|
1635
|
+
* @remarks
|
|
1636
|
+
* Required on browser runtimes.
|
|
1637
|
+
*/
|
|
1638
|
+
apiKey?: string;
|
|
1639
|
+
/**
|
|
1640
|
+
* Optional. The API version to use.
|
|
1641
|
+
*
|
|
1642
|
+
* @remarks
|
|
1643
|
+
* If unset, the default API version will be used.
|
|
1644
|
+
*/
|
|
1645
|
+
apiVersion?: string;
|
|
1646
|
+
/**
|
|
1647
|
+
* Optional. Authentication options defined by the by google-auth-library for Vertex AI clients.
|
|
1648
|
+
*
|
|
1649
|
+
* @remarks
|
|
1650
|
+
* @see {@link https://github.com/googleapis/google-auth-library-nodejs/blob/v9.15.0/src/auth/googleauth.ts | GoogleAuthOptions interface in google-auth-library-nodejs}.
|
|
1651
|
+
*
|
|
1652
|
+
* Only supported on Node runtimes, ignored on browser runtimes.
|
|
1653
|
+
*
|
|
1654
|
+
*/
|
|
1655
|
+
googleAuthOptions?: GoogleAuthOptions;
|
|
1656
|
+
/**
|
|
1657
|
+
* Optional. A set of customizable configuration for HTTP requests.
|
|
1658
|
+
*/
|
|
1659
|
+
httpOptions?: HttpOptions;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
/** Tool to support Google Search in Model. Powered by Google. */
|
|
1663
|
+
export declare interface GoogleSearch {
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
/** Tool to retrieve public web data for grounding, powered by Google. */
|
|
1667
|
+
export declare interface GoogleSearchRetrieval {
|
|
1668
|
+
/** Specifies the dynamic retrieval configuration for the given source. */
|
|
1669
|
+
dynamicRetrievalConfig?: DynamicRetrievalConfig;
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
/** Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp */
|
|
1673
|
+
export declare interface GoogleTypeDate {
|
|
1674
|
+
/** Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant. */
|
|
1675
|
+
day?: number;
|
|
1676
|
+
/** Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day. */
|
|
1677
|
+
month?: number;
|
|
1678
|
+
/** Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year. */
|
|
1679
|
+
year?: number;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
/** Grounding chunk. */
|
|
1683
|
+
export declare interface GroundingChunk {
|
|
1684
|
+
/** Grounding chunk from context retrieved by the retrieval tools. */
|
|
1685
|
+
retrievedContext?: GroundingChunkRetrievedContext;
|
|
1686
|
+
/** Grounding chunk from the web. */
|
|
1687
|
+
web?: GroundingChunkWeb;
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
/** Chunk from context retrieved by the retrieval tools. */
|
|
1691
|
+
export declare interface GroundingChunkRetrievedContext {
|
|
1692
|
+
/** Text of the attribution. */
|
|
1693
|
+
text?: string;
|
|
1694
|
+
/** Title of the attribution. */
|
|
1695
|
+
title?: string;
|
|
1696
|
+
/** URI reference of the attribution. */
|
|
1697
|
+
uri?: string;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
/** Chunk from the web. */
|
|
1701
|
+
export declare interface GroundingChunkWeb {
|
|
1702
|
+
/** Title of the chunk. */
|
|
1703
|
+
title?: string;
|
|
1704
|
+
/** URI reference of the chunk. */
|
|
1705
|
+
uri?: string;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
/** Metadata returned to client when grounding is enabled. */
|
|
1709
|
+
export declare interface GroundingMetadata {
|
|
1710
|
+
/** List of supporting references retrieved from specified grounding source. */
|
|
1711
|
+
groundingChunks?: GroundingChunk[];
|
|
1712
|
+
/** Optional. List of grounding support. */
|
|
1713
|
+
groundingSupports?: GroundingSupport[];
|
|
1714
|
+
/** Optional. Output only. Retrieval metadata. */
|
|
1715
|
+
retrievalMetadata?: RetrievalMetadata;
|
|
1716
|
+
/** Optional. Queries executed by the retrieval tools. */
|
|
1717
|
+
retrievalQueries?: string[];
|
|
1718
|
+
/** Optional. Google search entry for the following-up web searches. */
|
|
1719
|
+
searchEntryPoint?: SearchEntryPoint;
|
|
1720
|
+
/** Optional. Web search queries for the following-up web search. */
|
|
1721
|
+
webSearchQueries?: string[];
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
/** Grounding support. */
|
|
1725
|
+
export declare interface GroundingSupport {
|
|
1726
|
+
/** Confidence score of the support references. Ranges from 0 to 1. 1 is the most confident. This list must have the same size as the grounding_chunk_indices. */
|
|
1727
|
+
confidenceScores?: number[];
|
|
1728
|
+
/** A list of indices (into 'grounding_chunk') specifying the citations associated with the claim. For instance [1,3,4] means that grounding_chunk[1], grounding_chunk[3], grounding_chunk[4] are the retrieved content attributed to the claim. */
|
|
1729
|
+
groundingChunkIndices?: number[];
|
|
1730
|
+
/** Segment of the content this support belongs to. */
|
|
1731
|
+
segment?: Segment;
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
export declare enum HarmBlockMethod {
|
|
1735
|
+
HARM_BLOCK_METHOD_UNSPECIFIED = "HARM_BLOCK_METHOD_UNSPECIFIED",
|
|
1736
|
+
SEVERITY = "SEVERITY",
|
|
1737
|
+
PROBABILITY = "PROBABILITY"
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
export declare enum HarmBlockThreshold {
|
|
1741
|
+
HARM_BLOCK_THRESHOLD_UNSPECIFIED = "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
1742
|
+
BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
|
|
1743
|
+
BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE",
|
|
1744
|
+
BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH",
|
|
1745
|
+
BLOCK_NONE = "BLOCK_NONE",
|
|
1746
|
+
OFF = "OFF"
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
export declare enum HarmCategory {
|
|
1750
|
+
HARM_CATEGORY_UNSPECIFIED = "HARM_CATEGORY_UNSPECIFIED",
|
|
1751
|
+
HARM_CATEGORY_HATE_SPEECH = "HARM_CATEGORY_HATE_SPEECH",
|
|
1752
|
+
HARM_CATEGORY_DANGEROUS_CONTENT = "HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
1753
|
+
HARM_CATEGORY_HARASSMENT = "HARM_CATEGORY_HARASSMENT",
|
|
1754
|
+
HARM_CATEGORY_SEXUALLY_EXPLICIT = "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
1755
|
+
HARM_CATEGORY_CIVIC_INTEGRITY = "HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
export declare enum HarmProbability {
|
|
1759
|
+
HARM_PROBABILITY_UNSPECIFIED = "HARM_PROBABILITY_UNSPECIFIED",
|
|
1760
|
+
NEGLIGIBLE = "NEGLIGIBLE",
|
|
1761
|
+
LOW = "LOW",
|
|
1762
|
+
MEDIUM = "MEDIUM",
|
|
1763
|
+
HIGH = "HIGH"
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
export declare enum HarmSeverity {
|
|
1767
|
+
HARM_SEVERITY_UNSPECIFIED = "HARM_SEVERITY_UNSPECIFIED",
|
|
1768
|
+
HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE",
|
|
1769
|
+
HARM_SEVERITY_LOW = "HARM_SEVERITY_LOW",
|
|
1770
|
+
HARM_SEVERITY_MEDIUM = "HARM_SEVERITY_MEDIUM",
|
|
1771
|
+
HARM_SEVERITY_HIGH = "HARM_SEVERITY_HIGH"
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
/** HTTP options to be used in each of the requests. */
|
|
1775
|
+
export declare interface HttpOptions {
|
|
1776
|
+
/** The base URL for the AI platform service endpoint. */
|
|
1777
|
+
baseUrl?: string;
|
|
1778
|
+
/** Specifies the version of the API to use. */
|
|
1779
|
+
apiVersion?: string;
|
|
1780
|
+
/** Additional HTTP headers to be sent with the request. */
|
|
1781
|
+
headers?: Record<string, string>;
|
|
1782
|
+
/** Timeout for the request in milliseconds. */
|
|
1783
|
+
timeout?: number;
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
/**
|
|
1787
|
+
* Represents the necessary information to send a request to an API endpoint.
|
|
1788
|
+
* This interface defines the structure for constructing and executing HTTP
|
|
1789
|
+
* requests.
|
|
1790
|
+
*/
|
|
1791
|
+
declare interface HttpRequest {
|
|
1792
|
+
/**
|
|
1793
|
+
* URL path from the modules, this path is appended to the base API URL to
|
|
1794
|
+
* form the complete request URL.
|
|
1795
|
+
*
|
|
1796
|
+
* If you wish to set full URL, use httpOptions.baseUrl instead. Example to
|
|
1797
|
+
* set full URL in the request:
|
|
1798
|
+
*
|
|
1799
|
+
* const request: HttpRequest = {
|
|
1800
|
+
* path: '',
|
|
1801
|
+
* httpOptions: {
|
|
1802
|
+
* baseUrl: 'https://<custom-full-url>',
|
|
1803
|
+
* apiVersion: '',
|
|
1804
|
+
* },
|
|
1805
|
+
* httpMethod: 'GET',
|
|
1806
|
+
* };
|
|
1807
|
+
*
|
|
1808
|
+
* The result URL will be: https://<custom-full-url>
|
|
1809
|
+
*
|
|
1810
|
+
*/
|
|
1811
|
+
path: string;
|
|
1812
|
+
/**
|
|
1813
|
+
* Optional query parameters to be appended to the request URL.
|
|
1814
|
+
*/
|
|
1815
|
+
queryParams?: Record<string, string>;
|
|
1816
|
+
/**
|
|
1817
|
+
* Optional request body in json string or Blob format, GET request doesn't
|
|
1818
|
+
* need a request body.
|
|
1819
|
+
*/
|
|
1820
|
+
body?: string | Blob;
|
|
1821
|
+
/**
|
|
1822
|
+
* The HTTP method to be used for the request.
|
|
1823
|
+
*/
|
|
1824
|
+
httpMethod: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
1825
|
+
/**
|
|
1826
|
+
* Optional set of customizable configuration for HTTP requests.
|
|
1827
|
+
*/
|
|
1828
|
+
httpOptions?: HttpOptions;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
/** A wrapper class for the http response. */
|
|
1832
|
+
export declare class HttpResponse {
|
|
1833
|
+
/** Used to retain the processed HTTP headers in the response. */
|
|
1834
|
+
headers?: Record<string, string>;
|
|
1835
|
+
/**
|
|
1836
|
+
* The original http response.
|
|
1837
|
+
*/
|
|
1838
|
+
responseInternal: Response;
|
|
1839
|
+
constructor(response: Response);
|
|
1840
|
+
json(): Promise<unknown>;
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
/** An image. */
|
|
1844
|
+
declare interface Image_2 {
|
|
1845
|
+
/** The Cloud Storage URI of the image. ``Image`` can contain a value
|
|
1846
|
+
for this field or the ``image_bytes`` field but not both.
|
|
1847
|
+
*/
|
|
1848
|
+
gcsUri?: string;
|
|
1849
|
+
/** The image bytes data. ``Image`` can contain a value for this field
|
|
1850
|
+
or the ``gcs_uri`` field but not both.
|
|
1851
|
+
*/
|
|
1852
|
+
imageBytes?: string;
|
|
1853
|
+
/** The MIME type of the image. */
|
|
1854
|
+
mimeType?: string;
|
|
1855
|
+
}
|
|
1856
|
+
export { Image_2 as Image }
|
|
1857
|
+
|
|
1858
|
+
export declare enum ImagePromptLanguage {
|
|
1859
|
+
auto = "auto",
|
|
1860
|
+
en = "en",
|
|
1861
|
+
ja = "ja",
|
|
1862
|
+
ko = "ko",
|
|
1863
|
+
hi = "hi"
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
export declare enum Language {
|
|
1867
|
+
LANGUAGE_UNSPECIFIED = "LANGUAGE_UNSPECIFIED",
|
|
1868
|
+
PYTHON = "PYTHON"
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
/** Config for caches.list method. */
|
|
1872
|
+
export declare interface ListCachedContentsConfig {
|
|
1873
|
+
/** Used to override HTTP request options. */
|
|
1874
|
+
httpOptions?: HttpOptions;
|
|
1875
|
+
pageSize?: number;
|
|
1876
|
+
pageToken?: string;
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
/** Parameters for caches.list method. */
|
|
1880
|
+
export declare interface ListCachedContentsParameters {
|
|
1881
|
+
/** Configuration that contains optional parameters.
|
|
1882
|
+
*/
|
|
1883
|
+
config?: ListCachedContentsConfig;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
export declare class ListCachedContentsResponse {
|
|
1887
|
+
nextPageToken?: string;
|
|
1888
|
+
/** List of cached contents.
|
|
1889
|
+
*/
|
|
1890
|
+
cachedContents?: CachedContent[];
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
/** Used to override the default configuration. */
|
|
1894
|
+
export declare interface ListFilesConfig {
|
|
1895
|
+
/** Used to override HTTP request options. */
|
|
1896
|
+
httpOptions?: HttpOptions;
|
|
1897
|
+
pageSize?: number;
|
|
1898
|
+
pageToken?: string;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
/** Generates the parameters for the list method. */
|
|
1902
|
+
export declare interface ListFilesParameters {
|
|
1903
|
+
/** Used to override the default configuration. */
|
|
1904
|
+
config?: ListFilesConfig;
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
/** Response for the list files method. */
|
|
1908
|
+
export declare class ListFilesResponse {
|
|
1909
|
+
/** A token to retrieve next page of results. */
|
|
1910
|
+
nextPageToken?: string;
|
|
1911
|
+
/** The list of files. */
|
|
1912
|
+
files?: File_2[];
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
/**
|
|
1916
|
+
Live class encapsulates the configuration for live interaction with the
|
|
1917
|
+
Generative Language API. It embeds ApiClient for general API settings.
|
|
1918
|
+
|
|
1919
|
+
@experimental
|
|
1920
|
+
*/
|
|
1921
|
+
export declare class Live {
|
|
1922
|
+
private readonly apiClient;
|
|
1923
|
+
private readonly auth;
|
|
1924
|
+
private readonly webSocketFactory;
|
|
1925
|
+
constructor(apiClient: ApiClient, auth: Auth, webSocketFactory: WebSocketFactory);
|
|
1926
|
+
/**
|
|
1927
|
+
Establishes a connection to the specified model with the given
|
|
1928
|
+
configuration and returns a Session object representing that connection.
|
|
1929
|
+
|
|
1930
|
+
@experimental
|
|
1931
|
+
|
|
1932
|
+
@remarks
|
|
1933
|
+
If using the Gemini API, Live is currently only supported behind API
|
|
1934
|
+
version `v1alpha`. Ensure that the API version is set to `v1alpha` when
|
|
1935
|
+
initializing the SDK if relying on the Gemini API.
|
|
1936
|
+
|
|
1937
|
+
@param params - The parameters for establishing a connection to the model.
|
|
1938
|
+
@return A live session.
|
|
1939
|
+
|
|
1940
|
+
@example
|
|
1941
|
+
```ts
|
|
1942
|
+
const session = await ai.live.connect({
|
|
1943
|
+
model: 'gemini-2.0-flash-exp',
|
|
1944
|
+
config: {
|
|
1945
|
+
responseModalities: [Modality.AUDIO],
|
|
1946
|
+
},
|
|
1947
|
+
callbacks: {
|
|
1948
|
+
onopen: () => {
|
|
1949
|
+
console.log('Connected to the socket.');
|
|
1950
|
+
},
|
|
1951
|
+
onmessage: (e: MessageEvent) => {
|
|
1952
|
+
console.log('Received message from the server: %s\n', debug(e.data));
|
|
1953
|
+
},
|
|
1954
|
+
onerror: (e: ErrorEvent) => {
|
|
1955
|
+
console.log('Error occurred: %s\n', debug(e.error));
|
|
1956
|
+
},
|
|
1957
|
+
onclose: (e: CloseEvent) => {
|
|
1958
|
+
console.log('Connection closed.');
|
|
1959
|
+
},
|
|
1960
|
+
},
|
|
1961
|
+
});
|
|
1962
|
+
```
|
|
1963
|
+
*/
|
|
1964
|
+
connect(params: types.LiveConnectParameters): Promise<Session>;
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
/** Callbacks for the live API. */
|
|
1968
|
+
export declare interface LiveCallbacks {
|
|
1969
|
+
onopen?: (() => void) | null;
|
|
1970
|
+
onmessage: (e: LiveServerMessage) => void;
|
|
1971
|
+
onerror?: ((e: ErrorEvent) => void) | null;
|
|
1972
|
+
onclose?: ((e: CloseEvent) => void) | null;
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
/** Incremental update of the current conversation delivered from the client.
|
|
1976
|
+
|
|
1977
|
+
All the content here will unconditionally be appended to the conversation
|
|
1978
|
+
history and used as part of the prompt to the model to generate content.
|
|
1979
|
+
|
|
1980
|
+
A message here will interrupt any current model generation.
|
|
1981
|
+
*/
|
|
1982
|
+
export declare interface LiveClientContent {
|
|
1983
|
+
/** The content appended to the current conversation with the model.
|
|
1984
|
+
|
|
1985
|
+
For single-turn queries, this is a single instance. For multi-turn
|
|
1986
|
+
queries, this is a repeated field that contains conversation history and
|
|
1987
|
+
latest request.
|
|
1988
|
+
*/
|
|
1989
|
+
turns?: Content[];
|
|
1990
|
+
/** If true, indicates that the server content generation should start with
|
|
1991
|
+
the currently accumulated prompt. Otherwise, the server will await
|
|
1992
|
+
additional messages before starting generation. */
|
|
1993
|
+
turnComplete?: boolean;
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
/** Messages sent by the client in the API call. */
|
|
1997
|
+
export declare interface LiveClientMessage {
|
|
1998
|
+
/** Message to be sent by the system when connecting to the API. SDK users should not send this message. */
|
|
1999
|
+
setup?: LiveClientSetup;
|
|
2000
|
+
/** Incremental update of the current conversation delivered from the client. */
|
|
2001
|
+
clientContent?: LiveClientContent;
|
|
2002
|
+
/** User input that is sent in real time. */
|
|
2003
|
+
realtimeInput?: LiveClientRealtimeInput;
|
|
2004
|
+
/** Response to a `ToolCallMessage` received from the server. */
|
|
2005
|
+
toolResponse?: LiveClientToolResponse;
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
/** User input that is sent in real time.
|
|
2009
|
+
|
|
2010
|
+
This is different from `ClientContentUpdate` in a few ways:
|
|
2011
|
+
|
|
2012
|
+
- Can be sent continuously without interruption to model generation.
|
|
2013
|
+
- If there is a need to mix data interleaved across the
|
|
2014
|
+
`ClientContentUpdate` and the `RealtimeUpdate`, server attempts to
|
|
2015
|
+
optimize for best response, but there are no guarantees.
|
|
2016
|
+
- End of turn is not explicitly specified, but is rather derived from user
|
|
2017
|
+
activity (for example, end of speech).
|
|
2018
|
+
- Even before the end of turn, the data is processed incrementally
|
|
2019
|
+
to optimize for a fast start of the response from the model.
|
|
2020
|
+
- Is always assumed to be the user's input (cannot be used to populate
|
|
2021
|
+
conversation history).
|
|
2022
|
+
*/
|
|
2023
|
+
export declare interface LiveClientRealtimeInput {
|
|
2024
|
+
/** Inlined bytes data for media input. */
|
|
2025
|
+
mediaChunks?: Blob_2[];
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
/** Message contains configuration that will apply for the duration of the streaming session. */
|
|
2029
|
+
export declare interface LiveClientSetup {
|
|
2030
|
+
/**
|
|
2031
|
+
The fully qualified name of the publisher model or tuned model endpoint to
|
|
2032
|
+
use.
|
|
2033
|
+
*/
|
|
2034
|
+
model?: string;
|
|
2035
|
+
/** The generation configuration for the session.
|
|
2036
|
+
|
|
2037
|
+
The following fields are supported:
|
|
2038
|
+
- `response_logprobs`
|
|
2039
|
+
- `response_mime_type`
|
|
2040
|
+
- `logprobs`
|
|
2041
|
+
- `response_schema`
|
|
2042
|
+
- `stop_sequence`
|
|
2043
|
+
- `routing_config`
|
|
2044
|
+
- `audio_timestamp`
|
|
2045
|
+
*/
|
|
2046
|
+
generationConfig?: GenerationConfig;
|
|
2047
|
+
/** The user provided system instructions for the model.
|
|
2048
|
+
Note: only text should be used in parts and content in each part will be
|
|
2049
|
+
in a separate paragraph. */
|
|
2050
|
+
systemInstruction?: Content;
|
|
2051
|
+
/** A list of `Tools` the model may use to generate the next response.
|
|
2052
|
+
|
|
2053
|
+
A `Tool` is a piece of code that enables the system to interact with
|
|
2054
|
+
external systems to perform an action, or set of actions, outside of
|
|
2055
|
+
knowledge and scope of the model. */
|
|
2056
|
+
tools?: ToolListUnion;
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
/** Client generated response to a `ToolCall` received from the server.
|
|
2060
|
+
|
|
2061
|
+
Individual `FunctionResponse` objects are matched to the respective
|
|
2062
|
+
`FunctionCall` objects by the `id` field.
|
|
2063
|
+
|
|
2064
|
+
Note that in the unary and server-streaming GenerateContent APIs function
|
|
2065
|
+
calling happens by exchanging the `Content` parts, while in the bidi
|
|
2066
|
+
GenerateContent APIs function calling happens over this dedicated set of
|
|
2067
|
+
messages.
|
|
2068
|
+
*/
|
|
2069
|
+
export declare class LiveClientToolResponse {
|
|
2070
|
+
/** The response to the function calls. */
|
|
2071
|
+
functionResponses?: FunctionResponse[];
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
/** Session config for the API connection. */
|
|
2075
|
+
export declare interface LiveConnectConfig {
|
|
2076
|
+
/** The generation configuration for the session. */
|
|
2077
|
+
generationConfig?: GenerationConfig;
|
|
2078
|
+
/** The requested modalities of the response. Represents the set of
|
|
2079
|
+
modalities that the model can return. Defaults to AUDIO if not specified.
|
|
2080
|
+
*/
|
|
2081
|
+
responseModalities?: Modality[];
|
|
2082
|
+
/** The speech generation configuration.
|
|
2083
|
+
*/
|
|
2084
|
+
speechConfig?: SpeechConfig;
|
|
2085
|
+
/** The user provided system instructions for the model.
|
|
2086
|
+
Note: only text should be used in parts and content in each part will be
|
|
2087
|
+
in a separate paragraph. */
|
|
2088
|
+
systemInstruction?: Content;
|
|
2089
|
+
/** A list of `Tools` the model may use to generate the next response.
|
|
2090
|
+
|
|
2091
|
+
A `Tool` is a piece of code that enables the system to interact with
|
|
2092
|
+
external systems to perform an action, or set of actions, outside of
|
|
2093
|
+
knowledge and scope of the model. */
|
|
2094
|
+
tools?: ToolListUnion;
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
/** Parameters for connecting to the live API. */
|
|
2098
|
+
export declare interface LiveConnectParameters {
|
|
2099
|
+
/** ID of the model to use. For a list of models, see `Google models
|
|
2100
|
+
<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
|
|
2101
|
+
model: string;
|
|
2102
|
+
/** callbacks */
|
|
2103
|
+
callbacks: LiveCallbacks;
|
|
2104
|
+
/** Optional configuration parameters for the request.
|
|
2105
|
+
*/
|
|
2106
|
+
config?: LiveConnectConfig;
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
/** Parameters for sending client content to the live API. */
|
|
2110
|
+
export declare interface LiveSendClientContentParameters {
|
|
2111
|
+
/** Client content to send to the session. */
|
|
2112
|
+
turns?: ContentListUnion;
|
|
2113
|
+
/** If true, indicates that the server content generation should start with
|
|
2114
|
+
the currently accumulated prompt. Otherwise, the server will await
|
|
2115
|
+
additional messages before starting generation. */
|
|
2116
|
+
turnComplete?: boolean;
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
/** Parameters for sending realtime input to the live API. */
|
|
2120
|
+
export declare interface LiveSendRealtimeInputParameters {
|
|
2121
|
+
/** Realtime input to send to the session. */
|
|
2122
|
+
media: Blob_2;
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
/** Parameters for sending tool responses to the live API. */
|
|
2126
|
+
export declare class LiveSendToolResponseParameters {
|
|
2127
|
+
/** Tool responses to send to the session. */
|
|
2128
|
+
functionResponses: FunctionResponse[] | FunctionResponse;
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
/** Incremental server update generated by the model in response to client messages.
|
|
2132
|
+
|
|
2133
|
+
Content is generated as quickly as possible, and not in real time. Clients
|
|
2134
|
+
may choose to buffer and play it out in real time.
|
|
2135
|
+
*/
|
|
2136
|
+
export declare interface LiveServerContent {
|
|
2137
|
+
/** The content that the model has generated as part of the current conversation with the user. */
|
|
2138
|
+
modelTurn?: Content;
|
|
2139
|
+
/** If true, indicates that the model is done generating. Generation will only start in response to additional client messages. Can be set alongside `content`, indicating that the `content` is the last in the turn. */
|
|
2140
|
+
turnComplete?: boolean;
|
|
2141
|
+
/** If true, indicates that a client message has interrupted current model generation. If the client is playing out the content in realtime, this is a good signal to stop and empty the current queue. */
|
|
2142
|
+
interrupted?: boolean;
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
/** Response message for API call. */
|
|
2146
|
+
export declare interface LiveServerMessage {
|
|
2147
|
+
/** Sent in response to a `LiveClientSetup` message from the client. */
|
|
2148
|
+
setupComplete?: LiveServerSetupComplete;
|
|
2149
|
+
/** Content generated by the model in response to client messages. */
|
|
2150
|
+
serverContent?: LiveServerContent;
|
|
2151
|
+
/** Request for the client to execute the `function_calls` and return the responses with the matching `id`s. */
|
|
2152
|
+
toolCall?: LiveServerToolCall;
|
|
2153
|
+
/** Notification for the client that a previously issued `ToolCallMessage` with the specified `id`s should have been not executed and should be cancelled. */
|
|
2154
|
+
toolCallCancellation?: LiveServerToolCallCancellation;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
/** Sent in response to a `LiveGenerateContentSetup` message from the client. */
|
|
2158
|
+
export declare interface LiveServerSetupComplete {
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
/** Request for the client to execute the `function_calls` and return the responses with the matching `id`s. */
|
|
2162
|
+
export declare interface LiveServerToolCall {
|
|
2163
|
+
/** The function call to be executed. */
|
|
2164
|
+
functionCalls?: FunctionCall[];
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
/** Notification for the client that a previously issued `ToolCallMessage` with the specified `id`s should have been not executed and should be cancelled.
|
|
2168
|
+
|
|
2169
|
+
If there were side-effects to those tool calls, clients may attempt to undo
|
|
2170
|
+
the tool calls. This message occurs only in cases where the clients interrupt
|
|
2171
|
+
server turns.
|
|
2172
|
+
*/
|
|
2173
|
+
export declare interface LiveServerToolCallCancellation {
|
|
2174
|
+
/** The ids of the tool calls to be cancelled. */
|
|
2175
|
+
ids?: string[];
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
/** Logprobs Result */
|
|
2179
|
+
export declare interface LogprobsResult {
|
|
2180
|
+
/** Length = total number of decoding steps. The chosen candidates may or may not be in top_candidates. */
|
|
2181
|
+
chosenCandidates?: LogprobsResultCandidate[];
|
|
2182
|
+
/** Length = total number of decoding steps. */
|
|
2183
|
+
topCandidates?: LogprobsResultTopCandidates[];
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
/** Candidate for the logprobs token and score. */
|
|
2187
|
+
export declare interface LogprobsResultCandidate {
|
|
2188
|
+
/** The candidate's log probability. */
|
|
2189
|
+
logProbability?: number;
|
|
2190
|
+
/** The candidate's token string value. */
|
|
2191
|
+
token?: string;
|
|
2192
|
+
/** The candidate's token id value. */
|
|
2193
|
+
tokenId?: number;
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
/** Candidates with top log probabilities at each decoding step. */
|
|
2197
|
+
export declare interface LogprobsResultTopCandidates {
|
|
2198
|
+
/** Sorted by log probability in descending order. */
|
|
2199
|
+
candidates?: LogprobsResultCandidate[];
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
/** Configuration for a Mask reference image. */
|
|
2203
|
+
export declare interface MaskReferenceConfig {
|
|
2204
|
+
/** Prompts the model to generate a mask instead of you needing to
|
|
2205
|
+
provide one (unless MASK_MODE_USER_PROVIDED is used). */
|
|
2206
|
+
maskMode?: MaskReferenceMode;
|
|
2207
|
+
/** A list of up to 5 class ids to use for semantic segmentation.
|
|
2208
|
+
Automatically creates an image mask based on specific objects. */
|
|
2209
|
+
segmentationClasses?: number[];
|
|
2210
|
+
/** Dilation percentage of the mask provided.
|
|
2211
|
+
Float between 0 and 1. */
|
|
2212
|
+
maskDilation?: number;
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2215
|
+
/** A mask reference image.
|
|
2216
|
+
|
|
2217
|
+
This encapsulates either a mask image provided by the user and configs for
|
|
2218
|
+
the user provided mask, or only config parameters for the model to generate
|
|
2219
|
+
a mask.
|
|
2220
|
+
|
|
2221
|
+
A mask image is an image whose non-zero values indicate where to edit the base
|
|
2222
|
+
image. If the user provides a mask image, the mask must be in the same
|
|
2223
|
+
dimensions as the raw image.
|
|
2224
|
+
*/
|
|
2225
|
+
export declare interface MaskReferenceImage {
|
|
2226
|
+
/** The reference image for the editing operation. */
|
|
2227
|
+
referenceImage?: Image_2;
|
|
2228
|
+
/** The id of the reference image. */
|
|
2229
|
+
referenceId?: number;
|
|
2230
|
+
/** The type of the reference image. Only set by the SDK. */
|
|
2231
|
+
referenceType?: string;
|
|
2232
|
+
/** Configuration for the mask reference image. */
|
|
2233
|
+
config?: MaskReferenceConfig;
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
export declare enum MaskReferenceMode {
|
|
2237
|
+
MASK_MODE_DEFAULT = "MASK_MODE_DEFAULT",
|
|
2238
|
+
MASK_MODE_USER_PROVIDED = "MASK_MODE_USER_PROVIDED",
|
|
2239
|
+
MASK_MODE_BACKGROUND = "MASK_MODE_BACKGROUND",
|
|
2240
|
+
MASK_MODE_FOREGROUND = "MASK_MODE_FOREGROUND",
|
|
2241
|
+
MASK_MODE_SEMANTIC = "MASK_MODE_SEMANTIC"
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
export declare enum MediaResolution {
|
|
2245
|
+
MEDIA_RESOLUTION_UNSPECIFIED = "MEDIA_RESOLUTION_UNSPECIFIED",
|
|
2246
|
+
MEDIA_RESOLUTION_LOW = "MEDIA_RESOLUTION_LOW",
|
|
2247
|
+
MEDIA_RESOLUTION_MEDIUM = "MEDIA_RESOLUTION_MEDIUM",
|
|
2248
|
+
MEDIA_RESOLUTION_HIGH = "MEDIA_RESOLUTION_HIGH"
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
export declare enum Modality {
|
|
2252
|
+
MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED",
|
|
2253
|
+
TEXT = "TEXT",
|
|
2254
|
+
IMAGE = "IMAGE",
|
|
2255
|
+
AUDIO = "AUDIO"
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
/** Represents token counting info for a single modality. */
|
|
2259
|
+
export declare interface ModalityTokenCount {
|
|
2260
|
+
/** The modality associated with this token count. */
|
|
2261
|
+
modality?: Modality;
|
|
2262
|
+
/** Number of tokens. */
|
|
2263
|
+
tokenCount?: number;
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
export declare enum Mode {
|
|
2267
|
+
MODE_UNSPECIFIED = "MODE_UNSPECIFIED",
|
|
2268
|
+
MODE_DYNAMIC = "MODE_DYNAMIC"
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
export declare class Models extends BaseModule {
|
|
2272
|
+
private readonly apiClient;
|
|
2273
|
+
constructor(apiClient: ApiClient);
|
|
2274
|
+
/**
|
|
2275
|
+
* Makes an API request to generate content with a given model.
|
|
2276
|
+
*
|
|
2277
|
+
* For the `model` parameter, supported formats for Vertex AI API include:
|
|
2278
|
+
* - The Gemini model ID, for example: 'gemini-2.0-flash'
|
|
2279
|
+
* - The full resource name starts with 'projects/', for example:
|
|
2280
|
+
* 'projects/my-project-id/locations/us-central1/publishers/google/models/gemini-2.0-flash'
|
|
2281
|
+
* - The partial resource name with 'publishers/', for example:
|
|
2282
|
+
* 'publishers/google/models/gemini-2.0-flash' or
|
|
2283
|
+
* 'publishers/meta/models/llama-3.1-405b-instruct-maas'
|
|
2284
|
+
* - `/` separated publisher and model name, for example:
|
|
2285
|
+
* 'google/gemini-2.0-flash' or 'meta/llama-3.1-405b-instruct-maas'
|
|
2286
|
+
*
|
|
2287
|
+
* For the `model` parameter, supported formats for Gemini API include:
|
|
2288
|
+
* - The Gemini model ID, for example: 'gemini-2.0-flash'
|
|
2289
|
+
* - The model name starts with 'models/', for example:
|
|
2290
|
+
* 'models/gemini-2.0-flash'
|
|
2291
|
+
* - For tuned models, the model name starts with 'tunedModels/',
|
|
2292
|
+
* for example:
|
|
2293
|
+
* 'tunedModels/1234567890123456789'
|
|
2294
|
+
*
|
|
2295
|
+
* Some models support multimodal input and output.
|
|
2296
|
+
*
|
|
2297
|
+
* @param params - The parameters for generating content.
|
|
2298
|
+
* @return The response from generating content.
|
|
2299
|
+
*
|
|
2300
|
+
* @example
|
|
2301
|
+
* ```ts
|
|
2302
|
+
* const response = await ai.models.generateContent({
|
|
2303
|
+
* model: 'gemini-2.0-flash',
|
|
2304
|
+
* contents: 'why is the sky blue?',
|
|
2305
|
+
* config: {
|
|
2306
|
+
* candidateCount: 2,
|
|
2307
|
+
* }
|
|
2308
|
+
* });
|
|
2309
|
+
* console.log(response);
|
|
2310
|
+
* ```
|
|
2311
|
+
*/
|
|
2312
|
+
generateContent: (params: types.GenerateContentParameters) => Promise<types.GenerateContentResponse>;
|
|
2313
|
+
/**
|
|
2314
|
+
* Makes an API request to generate content with a given model and yields the
|
|
2315
|
+
* response in chunks.
|
|
2316
|
+
*
|
|
2317
|
+
* For the `model` parameter, supported formats for Vertex AI API include:
|
|
2318
|
+
* - The Gemini model ID, for example: 'gemini-2.0-flash'
|
|
2319
|
+
* - The full resource name starts with 'projects/', for example:
|
|
2320
|
+
* 'projects/my-project-id/locations/us-central1/publishers/google/models/gemini-2.0-flash'
|
|
2321
|
+
* - The partial resource name with 'publishers/', for example:
|
|
2322
|
+
* 'publishers/google/models/gemini-2.0-flash' or
|
|
2323
|
+
* 'publishers/meta/models/llama-3.1-405b-instruct-maas'
|
|
2324
|
+
* - `/` separated publisher and model name, for example:
|
|
2325
|
+
* 'google/gemini-2.0-flash' or 'meta/llama-3.1-405b-instruct-maas'
|
|
2326
|
+
*
|
|
2327
|
+
* For the `model` parameter, supported formats for Gemini API include:
|
|
2328
|
+
* - The Gemini model ID, for example: 'gemini-2.0-flash'
|
|
2329
|
+
* - The model name starts with 'models/', for example:
|
|
2330
|
+
* 'models/gemini-2.0-flash'
|
|
2331
|
+
* - For tuned models, the model name starts with 'tunedModels/',
|
|
2332
|
+
* for example:
|
|
2333
|
+
* 'tunedModels/1234567890123456789'
|
|
2334
|
+
*
|
|
2335
|
+
* Some models support multimodal input and output.
|
|
2336
|
+
*
|
|
2337
|
+
* @param params - The parameters for generating content with streaming response.
|
|
2338
|
+
* @return The response from generating content.
|
|
2339
|
+
*
|
|
2340
|
+
* @example
|
|
2341
|
+
* ```ts
|
|
2342
|
+
* const response = await ai.models.generateContentStream({
|
|
2343
|
+
* model: 'gemini-2.0-flash',
|
|
2344
|
+
* contents: 'why is the sky blue?',
|
|
2345
|
+
* config: {
|
|
2346
|
+
* maxOutputTokens: 200,
|
|
2347
|
+
* }
|
|
2348
|
+
* });
|
|
2349
|
+
* for await (const chunk of response) {
|
|
2350
|
+
* console.log(chunk);
|
|
2351
|
+
* }
|
|
2352
|
+
* ```
|
|
2353
|
+
*/
|
|
2354
|
+
generateContentStream: (params: types.GenerateContentParameters) => Promise<AsyncGenerator<types.GenerateContentResponse>>;
|
|
2355
|
+
/**
|
|
2356
|
+
* Generates an image based on a text description and configuration.
|
|
2357
|
+
*
|
|
2358
|
+
* @param model - The model to use.
|
|
2359
|
+
* @param prompt - A text description of the image to generate.
|
|
2360
|
+
* @param [config] - The config for image generation.
|
|
2361
|
+
* @return The response from the API.
|
|
2362
|
+
*
|
|
2363
|
+
* @example
|
|
2364
|
+
* ```ts
|
|
2365
|
+
* const response = await client.models.generateImages({
|
|
2366
|
+
* model: 'imagen-3.0-generate-002',
|
|
2367
|
+
* prompt: 'Robot holding a red skateboard',
|
|
2368
|
+
* config: {
|
|
2369
|
+
* numberOfImages: 1,
|
|
2370
|
+
* includeRaiReason: true,
|
|
2371
|
+
* },
|
|
2372
|
+
* });
|
|
2373
|
+
* console.log(response?.generatedImages?.[0]?.image?.imageBytes);
|
|
2374
|
+
* ```
|
|
2375
|
+
*/
|
|
2376
|
+
generateImages: (params: types.GenerateImagesParameters) => Promise<types.GenerateImagesResponse>;
|
|
2377
|
+
private generateContentInternal;
|
|
2378
|
+
private generateContentStreamInternal;
|
|
2379
|
+
/**
|
|
2380
|
+
* Calculates embeddings for the given contents. Only text is supported.
|
|
2381
|
+
*
|
|
2382
|
+
* @param params - The parameters for embedding contents.
|
|
2383
|
+
* @return The response from the API.
|
|
2384
|
+
*
|
|
2385
|
+
* @example
|
|
2386
|
+
* ```ts
|
|
2387
|
+
* const response = await ai.models.embedContent({
|
|
2388
|
+
* model: 'text-embedding-004',
|
|
2389
|
+
* contents: [
|
|
2390
|
+
* 'What is your name?',
|
|
2391
|
+
* 'What is your favorite color?',
|
|
2392
|
+
* ],
|
|
2393
|
+
* config: {
|
|
2394
|
+
* outputDimensionality: 64,
|
|
2395
|
+
* },
|
|
2396
|
+
* });
|
|
2397
|
+
* console.log(response);
|
|
2398
|
+
* ```
|
|
2399
|
+
*/
|
|
2400
|
+
embedContent(params: types.EmbedContentParameters): Promise<types.EmbedContentResponse>;
|
|
2401
|
+
/**
|
|
2402
|
+
* Generates an image based on a text description and configuration.
|
|
2403
|
+
*
|
|
2404
|
+
* @param params - The parameters for generating images.
|
|
2405
|
+
* @return The response from the API.
|
|
2406
|
+
*
|
|
2407
|
+
* @example
|
|
2408
|
+
* ```ts
|
|
2409
|
+
* const response = await ai.models.generateImages({
|
|
2410
|
+
* model: 'imagen-3.0-generate-002',
|
|
2411
|
+
* prompt: 'Robot holding a red skateboard',
|
|
2412
|
+
* config: {
|
|
2413
|
+
* numberOfImages: 1,
|
|
2414
|
+
* includeRaiReason: true,
|
|
2415
|
+
* },
|
|
2416
|
+
* });
|
|
2417
|
+
* console.log(response?.generatedImages?.[0]?.image?.imageBytes);
|
|
2418
|
+
* ```
|
|
2419
|
+
*/
|
|
2420
|
+
private generateImagesInternal;
|
|
2421
|
+
/**
|
|
2422
|
+
* Counts the number of tokens in the given contents. Multimodal input is
|
|
2423
|
+
* supported for Gemini models.
|
|
2424
|
+
*
|
|
2425
|
+
* @param params - The parameters for counting tokens.
|
|
2426
|
+
* @return The response from the API.
|
|
2427
|
+
*
|
|
2428
|
+
* @example
|
|
2429
|
+
* ```ts
|
|
2430
|
+
* const response = await ai.models.countTokens({
|
|
2431
|
+
* model: 'gemini-2.0-flash',
|
|
2432
|
+
* contents: 'The quick brown fox jumps over the lazy dog.'
|
|
2433
|
+
* });
|
|
2434
|
+
* console.log(response);
|
|
2435
|
+
* ```
|
|
2436
|
+
*/
|
|
2437
|
+
countTokens(params: types.CountTokensParameters): Promise<types.CountTokensResponse>;
|
|
2438
|
+
/**
|
|
2439
|
+
* Given a list of contents, returns a corresponding TokensInfo containing
|
|
2440
|
+
* the list of tokens and list of token ids.
|
|
2441
|
+
*
|
|
2442
|
+
* This method is not supported by the Gemini Developer API.
|
|
2443
|
+
*
|
|
2444
|
+
* @param params - The parameters for computing tokens.
|
|
2445
|
+
* @return The response from the API.
|
|
2446
|
+
*
|
|
2447
|
+
* @example
|
|
2448
|
+
* ```ts
|
|
2449
|
+
* const response = await ai.models.computeTokens({
|
|
2450
|
+
* model: 'gemini-2.0-flash',
|
|
2451
|
+
* contents: 'What is your name?'
|
|
2452
|
+
* });
|
|
2453
|
+
* console.log(response);
|
|
2454
|
+
* ```
|
|
2455
|
+
*/
|
|
2456
|
+
computeTokens(params: types.ComputeTokensParameters): Promise<types.ComputeTokensResponse>;
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2459
|
+
/**
|
|
2460
|
+
* @license
|
|
2461
|
+
* Copyright 2025 Google LLC
|
|
2462
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2463
|
+
*/
|
|
2464
|
+
export declare enum Outcome {
|
|
2465
|
+
OUTCOME_UNSPECIFIED = "OUTCOME_UNSPECIFIED",
|
|
2466
|
+
OUTCOME_OK = "OUTCOME_OK",
|
|
2467
|
+
OUTCOME_FAILED = "OUTCOME_FAILED",
|
|
2468
|
+
OUTCOME_DEADLINE_EXCEEDED = "OUTCOME_DEADLINE_EXCEEDED"
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
/**
|
|
2472
|
+
* @license
|
|
2473
|
+
* Copyright 2025 Google LLC
|
|
2474
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2475
|
+
*/
|
|
2476
|
+
/**
|
|
2477
|
+
* Pagers for the GenAI List APIs.
|
|
2478
|
+
*/
|
|
2479
|
+
declare enum PagedItem {
|
|
2480
|
+
PAGED_ITEM_BATCH_JOBS = "batchJobs",
|
|
2481
|
+
PAGED_ITEM_MODELS = "models",
|
|
2482
|
+
PAGED_ITEM_TUNING_JOBS = "tuningJobs",
|
|
2483
|
+
PAGED_ITEM_FILES = "files",
|
|
2484
|
+
PAGED_ITEM_CACHED_CONTENTS = "cachedContents"
|
|
2485
|
+
}
|
|
2486
|
+
|
|
2487
|
+
declare interface PagedItemConfig {
|
|
2488
|
+
config?: {
|
|
2489
|
+
pageToken?: string;
|
|
2490
|
+
pageSize?: number;
|
|
2491
|
+
};
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
declare interface PagedItemResponse<T> {
|
|
2495
|
+
nextPageToken?: string;
|
|
2496
|
+
batchJobs?: T[];
|
|
2497
|
+
models?: T[];
|
|
2498
|
+
tuningJobs?: T[];
|
|
2499
|
+
files?: T[];
|
|
2500
|
+
cachedContents?: T[];
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
/**
|
|
2504
|
+
* Pager class for iterating through paginated results.
|
|
2505
|
+
*/
|
|
2506
|
+
declare class Pager<T> implements AsyncIterable<T> {
|
|
2507
|
+
private nameInternal;
|
|
2508
|
+
private pageInternal;
|
|
2509
|
+
private paramsInternal;
|
|
2510
|
+
private pageInternalSize;
|
|
2511
|
+
protected requestInternal: (params: PagedItemConfig) => Promise<PagedItemResponse<T>>;
|
|
2512
|
+
protected idxInternal: number;
|
|
2513
|
+
constructor(name: PagedItem, request: (params: PagedItemConfig) => Promise<PagedItemResponse<T>>, response: PagedItemResponse<T>, params: PagedItemConfig);
|
|
2514
|
+
private init;
|
|
2515
|
+
private initNextPage;
|
|
2516
|
+
/**
|
|
2517
|
+
* Returns the current page, which is a list of items.
|
|
2518
|
+
*
|
|
2519
|
+
* @remarks
|
|
2520
|
+
* The first page is retrieved when the pager is created. The returned list of
|
|
2521
|
+
* items could be a subset of the entire list.
|
|
2522
|
+
*/
|
|
2523
|
+
get page(): T[];
|
|
2524
|
+
/**
|
|
2525
|
+
* Returns the type of paged item (for example, ``batch_jobs``).
|
|
2526
|
+
*/
|
|
2527
|
+
get name(): PagedItem;
|
|
2528
|
+
/**
|
|
2529
|
+
* Returns the length of the page fetched each time by this pager.
|
|
2530
|
+
*
|
|
2531
|
+
* @remarks
|
|
2532
|
+
* The number of items in the page is less than or equal to the page length.
|
|
2533
|
+
*/
|
|
2534
|
+
get pageSize(): number;
|
|
2535
|
+
/**
|
|
2536
|
+
* Returns the parameters when making the API request for the next page.
|
|
2537
|
+
*
|
|
2538
|
+
* @remarks
|
|
2539
|
+
* Parameters contain a set of optional configs that can be
|
|
2540
|
+
* used to customize the API request. For example, the `pageToken` parameter
|
|
2541
|
+
* contains the token to request the next page.
|
|
2542
|
+
*/
|
|
2543
|
+
get params(): PagedItemConfig;
|
|
2544
|
+
/**
|
|
2545
|
+
* Returns the total number of items in the current page.
|
|
2546
|
+
*/
|
|
2547
|
+
get pageLength(): number;
|
|
2548
|
+
/**
|
|
2549
|
+
* Returns the item at the given index.
|
|
2550
|
+
*/
|
|
2551
|
+
getItem(index: number): T;
|
|
2552
|
+
/**
|
|
2553
|
+
* Returns an async iterator that support iterating through all items
|
|
2554
|
+
* retrieved from the API.
|
|
2555
|
+
*
|
|
2556
|
+
* @remarks
|
|
2557
|
+
* The iterator will automatically fetch the next page if there are more items
|
|
2558
|
+
* to fetch from the API.
|
|
2559
|
+
*
|
|
2560
|
+
* @example
|
|
2561
|
+
*
|
|
2562
|
+
* ```ts
|
|
2563
|
+
* const pager = await ai.files.list({config: {pageSize: 10}});
|
|
2564
|
+
* for await (const file of pager) {
|
|
2565
|
+
* console.log(file.name);
|
|
2566
|
+
* }
|
|
2567
|
+
* ```
|
|
2568
|
+
*/
|
|
2569
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
2570
|
+
/**
|
|
2571
|
+
* Fetches the next page of items. This makes a new API request.
|
|
2572
|
+
*
|
|
2573
|
+
* @throws {Error} If there are no more pages to fetch.
|
|
2574
|
+
*
|
|
2575
|
+
* @example
|
|
2576
|
+
*
|
|
2577
|
+
* ```ts
|
|
2578
|
+
* const pager = await ai.files.list({config: {pageSize: 10}});
|
|
2579
|
+
* let page = pager.page;
|
|
2580
|
+
* while (true) {
|
|
2581
|
+
* for (const file of page) {
|
|
2582
|
+
* console.log(file.name);
|
|
2583
|
+
* }
|
|
2584
|
+
* if (!pager.hasNextPage()) {
|
|
2585
|
+
* break;
|
|
2586
|
+
* }
|
|
2587
|
+
* page = await pager.nextPage();
|
|
2588
|
+
* }
|
|
2589
|
+
* ```
|
|
2590
|
+
*/
|
|
2591
|
+
nextPage(): Promise<T[]>;
|
|
2592
|
+
/**
|
|
2593
|
+
* Returns true if there are more pages to fetch from the API.
|
|
2594
|
+
*/
|
|
2595
|
+
hasNextPage(): boolean;
|
|
2596
|
+
}
|
|
2597
|
+
|
|
2598
|
+
/** A datatype containing media content.
|
|
2599
|
+
|
|
2600
|
+
Exactly one field within a Part should be set, representing the specific type
|
|
2601
|
+
of content being conveyed. Using multiple fields within the same `Part`
|
|
2602
|
+
instance is considered invalid.
|
|
2603
|
+
*/
|
|
2604
|
+
export declare interface Part {
|
|
2605
|
+
/** Metadata for a given video. */
|
|
2606
|
+
videoMetadata?: VideoMetadata;
|
|
2607
|
+
/** Indicates if the part is thought from the model. */
|
|
2608
|
+
thought?: boolean;
|
|
2609
|
+
/** Optional. Result of executing the [ExecutableCode]. */
|
|
2610
|
+
codeExecutionResult?: CodeExecutionResult;
|
|
2611
|
+
/** Optional. Code generated by the model that is meant to be executed. */
|
|
2612
|
+
executableCode?: ExecutableCode;
|
|
2613
|
+
/** Optional. URI based data. */
|
|
2614
|
+
fileData?: FileData;
|
|
2615
|
+
/** Optional. A predicted [FunctionCall] returned from the model that contains a string representing the [FunctionDeclaration.name] with the parameters and their values. */
|
|
2616
|
+
functionCall?: FunctionCall;
|
|
2617
|
+
/** Optional. The result output of a [FunctionCall] that contains a string representing the [FunctionDeclaration.name] and a structured JSON object containing any output from the function call. It is used as context to the model. */
|
|
2618
|
+
functionResponse?: FunctionResponse;
|
|
2619
|
+
/** Optional. Inlined bytes data. */
|
|
2620
|
+
inlineData?: Blob_2;
|
|
2621
|
+
/** Optional. Text part (can be code). */
|
|
2622
|
+
text?: string;
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
export declare type PartListUnion = PartUnion[] | PartUnion;
|
|
2626
|
+
|
|
2627
|
+
export declare type PartUnion = Part | string;
|
|
2628
|
+
|
|
2629
|
+
export declare enum PersonGeneration {
|
|
2630
|
+
DONT_ALLOW = "DONT_ALLOW",
|
|
2631
|
+
ALLOW_ADULT = "ALLOW_ADULT",
|
|
2632
|
+
ALLOW_ALL = "ALLOW_ALL"
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2635
|
+
/** The configuration for the prebuilt speaker to use. */
|
|
2636
|
+
export declare interface PrebuiltVoiceConfig {
|
|
2637
|
+
/** The name of the prebuilt voice to use.
|
|
2638
|
+
*/
|
|
2639
|
+
voiceName?: string;
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
/** A raw reference image.
|
|
2643
|
+
|
|
2644
|
+
A raw reference image represents the base image to edit, provided by the user.
|
|
2645
|
+
It can optionally be provided in addition to a mask reference image or
|
|
2646
|
+
a style reference image.
|
|
2647
|
+
*/
|
|
2648
|
+
export declare interface RawReferenceImage {
|
|
2649
|
+
/** The reference image for the editing operation. */
|
|
2650
|
+
referenceImage?: Image_2;
|
|
2651
|
+
/** The id of the reference image. */
|
|
2652
|
+
referenceId?: number;
|
|
2653
|
+
/** The type of the reference image. Only set by the SDK. */
|
|
2654
|
+
referenceType?: string;
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2657
|
+
/** Represents a recorded session. */
|
|
2658
|
+
export declare interface ReplayFile {
|
|
2659
|
+
replayId?: string;
|
|
2660
|
+
interactions?: ReplayInteraction[];
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
/** Represents a single interaction, request and response in a replay. */
|
|
2664
|
+
export declare interface ReplayInteraction {
|
|
2665
|
+
request?: ReplayRequest;
|
|
2666
|
+
response?: ReplayResponse;
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
/** Represents a single request in a replay. */
|
|
2670
|
+
export declare interface ReplayRequest {
|
|
2671
|
+
method?: string;
|
|
2672
|
+
url?: string;
|
|
2673
|
+
headers?: Record<string, string>;
|
|
2674
|
+
bodySegments?: Record<string, unknown>[];
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
/** Represents a single response in a replay. */
|
|
2678
|
+
export declare class ReplayResponse {
|
|
2679
|
+
statusCode?: number;
|
|
2680
|
+
headers?: Record<string, string>;
|
|
2681
|
+
bodySegments?: Record<string, unknown>[];
|
|
2682
|
+
sdkResponseSegments?: Record<string, unknown>[];
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
/** Defines a retrieval tool that model can call to access external knowledge. */
|
|
2686
|
+
export declare interface Retrieval {
|
|
2687
|
+
/** Optional. Deprecated. This option is no longer supported. */
|
|
2688
|
+
disableAttribution?: boolean;
|
|
2689
|
+
/** Set to use data source powered by Vertex AI Search. */
|
|
2690
|
+
vertexAiSearch?: VertexAISearch;
|
|
2691
|
+
/** Set to use data source powered by Vertex RAG store. User data is uploaded via the VertexRagDataService. */
|
|
2692
|
+
vertexRagStore?: VertexRagStore;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
/** Metadata related to retrieval in the grounding flow. */
|
|
2696
|
+
export declare interface RetrievalMetadata {
|
|
2697
|
+
/** Optional. Score indicating how likely information from Google Search could help answer the prompt. The score is in the range `[0, 1]`, where 0 is the least likely and 1 is the most likely. This score is only populated when Google Search grounding and dynamic retrieval is enabled. It will be compared to the threshold to determine whether to trigger Google Search. */
|
|
2698
|
+
googleSearchDynamicRetrievalScore?: number;
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
/** Safety attributes of a GeneratedImage or the user-provided prompt. */
|
|
2702
|
+
export declare interface SafetyAttributes {
|
|
2703
|
+
/** List of RAI categories.
|
|
2704
|
+
*/
|
|
2705
|
+
categories?: string[];
|
|
2706
|
+
/** List of scores of each categories.
|
|
2707
|
+
*/
|
|
2708
|
+
scores?: number[];
|
|
2709
|
+
/** Internal use only.
|
|
2710
|
+
*/
|
|
2711
|
+
contentType?: string;
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
export declare enum SafetyFilterLevel {
|
|
2715
|
+
BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
|
|
2716
|
+
BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE",
|
|
2717
|
+
BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH",
|
|
2718
|
+
BLOCK_NONE = "BLOCK_NONE"
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2721
|
+
/** Safety rating corresponding to the generated content. */
|
|
2722
|
+
export declare interface SafetyRating {
|
|
2723
|
+
/** Output only. Indicates whether the content was filtered out because of this rating. */
|
|
2724
|
+
blocked?: boolean;
|
|
2725
|
+
/** Output only. Harm category. */
|
|
2726
|
+
category?: HarmCategory;
|
|
2727
|
+
/** Output only. Harm probability levels in the content. */
|
|
2728
|
+
probability?: HarmProbability;
|
|
2729
|
+
/** Output only. Harm probability score. */
|
|
2730
|
+
probabilityScore?: number;
|
|
2731
|
+
/** Output only. Harm severity levels in the content. */
|
|
2732
|
+
severity?: HarmSeverity;
|
|
2733
|
+
/** Output only. Harm severity score. */
|
|
2734
|
+
severityScore?: number;
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
/** Safety settings. */
|
|
2738
|
+
export declare interface SafetySetting {
|
|
2739
|
+
/** Determines if the harm block method uses probability or probability
|
|
2740
|
+
and severity scores. */
|
|
2741
|
+
method?: HarmBlockMethod;
|
|
2742
|
+
/** Required. Harm category. */
|
|
2743
|
+
category?: HarmCategory;
|
|
2744
|
+
/** Required. The harm block threshold. */
|
|
2745
|
+
threshold?: HarmBlockThreshold;
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
/** Schema that defines the format of input and output data.
|
|
2749
|
+
|
|
2750
|
+
Represents a select subset of an OpenAPI 3.0 schema object.
|
|
2751
|
+
*/
|
|
2752
|
+
export declare interface Schema {
|
|
2753
|
+
/** Optional. Example of the object. Will only populated when the object is the root. */
|
|
2754
|
+
example?: unknown;
|
|
2755
|
+
/** Optional. Pattern of the Type.STRING to restrict a string to a regular expression. */
|
|
2756
|
+
pattern?: string;
|
|
2757
|
+
/** Optional. Default value of the data. */
|
|
2758
|
+
default?: unknown;
|
|
2759
|
+
/** Optional. Maximum length of the Type.STRING */
|
|
2760
|
+
maxLength?: string;
|
|
2761
|
+
/** Optional. SCHEMA FIELDS FOR TYPE STRING Minimum length of the Type.STRING */
|
|
2762
|
+
minLength?: string;
|
|
2763
|
+
/** Optional. Minimum number of the properties for Type.OBJECT. */
|
|
2764
|
+
minProperties?: string;
|
|
2765
|
+
/** Optional. Maximum number of the properties for Type.OBJECT. */
|
|
2766
|
+
maxProperties?: string;
|
|
2767
|
+
/** Optional. The value should be validated against any (one or more) of the subschemas in the list. */
|
|
2768
|
+
anyOf?: Schema[];
|
|
2769
|
+
/** Optional. The description of the data. */
|
|
2770
|
+
description?: string;
|
|
2771
|
+
/** Optional. Possible values of the element of primitive type with enum format. Examples: 1. We can define direction as : {type:STRING, format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]} 2. We can define apartment number as : {type:INTEGER, format:enum, enum:["101", "201", "301"]} */
|
|
2772
|
+
enum?: string[];
|
|
2773
|
+
/** Optional. The format of the data. Supported formats: for NUMBER type: "float", "double" for INTEGER type: "int32", "int64" for STRING type: "email", "byte", etc */
|
|
2774
|
+
format?: string;
|
|
2775
|
+
/** Optional. SCHEMA FIELDS FOR TYPE ARRAY Schema of the elements of Type.ARRAY. */
|
|
2776
|
+
items?: Schema;
|
|
2777
|
+
/** Optional. Maximum number of the elements for Type.ARRAY. */
|
|
2778
|
+
maxItems?: string;
|
|
2779
|
+
/** Optional. Maximum value of the Type.INTEGER and Type.NUMBER */
|
|
2780
|
+
maximum?: number;
|
|
2781
|
+
/** Optional. Minimum number of the elements for Type.ARRAY. */
|
|
2782
|
+
minItems?: string;
|
|
2783
|
+
/** Optional. SCHEMA FIELDS FOR TYPE INTEGER and NUMBER Minimum value of the Type.INTEGER and Type.NUMBER */
|
|
2784
|
+
minimum?: number;
|
|
2785
|
+
/** Optional. Indicates if the value may be null. */
|
|
2786
|
+
nullable?: boolean;
|
|
2787
|
+
/** Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of Type.OBJECT. */
|
|
2788
|
+
properties?: Record<string, Schema>;
|
|
2789
|
+
/** Optional. The order of the properties. Not a standard field in open api spec. Only used to support the order of the properties. */
|
|
2790
|
+
propertyOrdering?: string[];
|
|
2791
|
+
/** Optional. Required properties of Type.OBJECT. */
|
|
2792
|
+
required?: string[];
|
|
2793
|
+
/** Optional. The title of the Schema. */
|
|
2794
|
+
title?: string;
|
|
2795
|
+
/** Optional. The type of the data. */
|
|
2796
|
+
type?: Type;
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2799
|
+
export declare type SchemaUnion = Schema;
|
|
2800
|
+
|
|
2801
|
+
/** Google search entry point. */
|
|
2802
|
+
export declare interface SearchEntryPoint {
|
|
2803
|
+
/** Optional. Web content snippet that can be embedded in a web page or an app webview. */
|
|
2804
|
+
renderedContent?: string;
|
|
2805
|
+
/** Optional. Base64 encoded JSON representing array of tuple. */
|
|
2806
|
+
sdkBlob?: string;
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
/** Segment of the content. */
|
|
2810
|
+
export declare interface Segment {
|
|
2811
|
+
/** Output only. End index in the given Part, measured in bytes. Offset from the start of the Part, exclusive, starting at zero. */
|
|
2812
|
+
endIndex?: number;
|
|
2813
|
+
/** Output only. The index of a Part object within its parent Content object. */
|
|
2814
|
+
partIndex?: number;
|
|
2815
|
+
/** Output only. Start index in the given Part, measured in bytes. Offset from the start of the Part, inclusive, starting at zero. */
|
|
2816
|
+
startIndex?: number;
|
|
2817
|
+
/** Output only. The text corresponding to the segment from the response. */
|
|
2818
|
+
text?: string;
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
/** Parameters for sending a message within a chat session.
|
|
2822
|
+
|
|
2823
|
+
These parameters are used with the `chat.sendMessage()` method.
|
|
2824
|
+
*/
|
|
2825
|
+
export declare interface SendMessageParameters {
|
|
2826
|
+
/** The message to send to the model.
|
|
2827
|
+
|
|
2828
|
+
The SDK will combine all parts into a single 'user' content to send to
|
|
2829
|
+
the model.
|
|
2830
|
+
*/
|
|
2831
|
+
message: PartListUnion;
|
|
2832
|
+
/** Config for this specific request.
|
|
2833
|
+
|
|
2834
|
+
Please note that the per-request config does not change the chat level
|
|
2835
|
+
config, nor inherit from it. If you intend to use some values from the
|
|
2836
|
+
chat's default config, you must explicitly copy them into this per-request
|
|
2837
|
+
config.
|
|
2838
|
+
*/
|
|
2839
|
+
config?: GenerateContentConfig;
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
/**
|
|
2843
|
+
Represents a connection to the API.
|
|
2844
|
+
|
|
2845
|
+
@experimental
|
|
2846
|
+
*/
|
|
2847
|
+
export declare class Session {
|
|
2848
|
+
readonly conn: WebSocket_2;
|
|
2849
|
+
private readonly apiClient;
|
|
2850
|
+
constructor(conn: WebSocket_2, apiClient: ApiClient);
|
|
2851
|
+
private tLiveClientContent;
|
|
2852
|
+
private tLiveClientRealtimeInput;
|
|
2853
|
+
private tLiveClienttToolResponse;
|
|
2854
|
+
/**
|
|
2855
|
+
Send a message over the established connection.
|
|
2856
|
+
|
|
2857
|
+
@param params - Contains two **optional** properties, `turns` and
|
|
2858
|
+
`turnComplete`.
|
|
2859
|
+
|
|
2860
|
+
- `turns` will be converted to a `Content[]`
|
|
2861
|
+
- `turnComplete: true` [default] indicates that you are done sending
|
|
2862
|
+
content and expect a response. If `turnComplete: false`, the server
|
|
2863
|
+
will wait for additional messages before starting generation.
|
|
2864
|
+
|
|
2865
|
+
@experimental
|
|
2866
|
+
|
|
2867
|
+
@remarks
|
|
2868
|
+
There are two ways to send messages to the live API:
|
|
2869
|
+
`sendClientContent` and `sendRealtimeInput`.
|
|
2870
|
+
|
|
2871
|
+
`sendClientContent` messages are added to the model context **in order**.
|
|
2872
|
+
Having a conversation using `sendClientContent` messages is roughly
|
|
2873
|
+
equivalent to using the `Chat.sendMessageStream`, except that the state of
|
|
2874
|
+
the `chat` history is stored on the API server instead of locally.
|
|
2875
|
+
|
|
2876
|
+
Because of `sendClientContent`'s order guarantee, the model cannot respons
|
|
2877
|
+
as quickly to `sendClientContent` messages as to `sendRealtimeInput`
|
|
2878
|
+
messages. This makes the biggest difference when sending objects that have
|
|
2879
|
+
significant preprocessing time (typically images).
|
|
2880
|
+
|
|
2881
|
+
The `sendClientContent` message sends a `Content[]`
|
|
2882
|
+
which has more options than the `Blob` sent by `sendRealtimeInput`.
|
|
2883
|
+
|
|
2884
|
+
So the main use-cases for `sendClientContent` over `sendRealtimeInput` are:
|
|
2885
|
+
|
|
2886
|
+
- Sending anything that can't be represented as a `Blob` (text,
|
|
2887
|
+
`sendClientContent({turns="Hello?"}`)).
|
|
2888
|
+
- Managing turns when not using audio input and voice activity detection.
|
|
2889
|
+
(`sendClientContent({turnComplete:true})` or the short form
|
|
2890
|
+
`sendClientContent()`)
|
|
2891
|
+
- Prefilling a conversation context
|
|
2892
|
+
```
|
|
2893
|
+
sendClientContent({
|
|
2894
|
+
turns: [
|
|
2895
|
+
Content({role:user, parts:...}),
|
|
2896
|
+
Content({role:user, parts:...}),
|
|
2897
|
+
...
|
|
2898
|
+
]
|
|
2899
|
+
})
|
|
2900
|
+
```
|
|
2901
|
+
@experimental
|
|
2902
|
+
*/
|
|
2903
|
+
sendClientContent(params: types.LiveSendClientContentParameters): void;
|
|
2904
|
+
/**
|
|
2905
|
+
Send a realtime message over the established connection.
|
|
2906
|
+
|
|
2907
|
+
@param params - Contains one property, `media`.
|
|
2908
|
+
|
|
2909
|
+
- `media` will be converted to a `Blob`
|
|
2910
|
+
|
|
2911
|
+
@experimental
|
|
2912
|
+
|
|
2913
|
+
@remarks
|
|
2914
|
+
Use `sendRealtimeInput` for realtime audio chunks and video frames (images).
|
|
2915
|
+
|
|
2916
|
+
With `sendRealtimeInput` the api will respond to audio automatically
|
|
2917
|
+
based on voice activity detection (VAD).
|
|
2918
|
+
|
|
2919
|
+
`sendRealtimeInput` is optimized for responsivness at the expense of
|
|
2920
|
+
deterministic ordering guarantees. Audio and video tokens are to the
|
|
2921
|
+
context when they become available.
|
|
2922
|
+
|
|
2923
|
+
Note: The Call signature expects a `Blob` object, but only a subset
|
|
2924
|
+
of audio and image mimetypes are allowed.
|
|
2925
|
+
*/
|
|
2926
|
+
sendRealtimeInput(params: types.LiveSendRealtimeInputParameters): void;
|
|
2927
|
+
/**
|
|
2928
|
+
Send a function response message over the established connection.
|
|
2929
|
+
|
|
2930
|
+
@param params - Contains property `functionResponses`.
|
|
2931
|
+
|
|
2932
|
+
- `functionResponses` will be converted to a `functionResponses[]`
|
|
2933
|
+
|
|
2934
|
+
@remarks
|
|
2935
|
+
Use `sendFunctionResponse` to reply to `LiveServerToolCall` from the server.
|
|
2936
|
+
|
|
2937
|
+
Use {@link types.LiveConnectConfig#tools} to configure the callable functions.
|
|
2938
|
+
|
|
2939
|
+
@experimental
|
|
2940
|
+
*/
|
|
2941
|
+
sendToolResponse(params: types.LiveSendToolResponseParameters): void;
|
|
2942
|
+
/**
|
|
2943
|
+
Terminates the WebSocket connection.
|
|
2944
|
+
|
|
2945
|
+
@experimental
|
|
2946
|
+
|
|
2947
|
+
@example
|
|
2948
|
+
```ts
|
|
2949
|
+
const session = await ai.live.connect({
|
|
2950
|
+
model: 'gemini-2.0-flash-exp',
|
|
2951
|
+
config: {
|
|
2952
|
+
responseModalities: [Modality.AUDIO],
|
|
2953
|
+
}
|
|
2954
|
+
});
|
|
2955
|
+
|
|
2956
|
+
session.close();
|
|
2957
|
+
```
|
|
2958
|
+
*/
|
|
2959
|
+
close(): void;
|
|
2960
|
+
}
|
|
2961
|
+
|
|
2962
|
+
declare function setValueByPath(data: Record<string, unknown>, keys: string[], value: unknown): void;
|
|
2963
|
+
|
|
2964
|
+
/** The speech generation configuration. */
|
|
2965
|
+
export declare interface SpeechConfig {
|
|
2966
|
+
/** The configuration for the speaker to use.
|
|
2967
|
+
*/
|
|
2968
|
+
voiceConfig?: VoiceConfig;
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2971
|
+
export declare type SpeechConfigUnion = SpeechConfig | string;
|
|
2972
|
+
|
|
2973
|
+
export declare enum State {
|
|
2974
|
+
STATE_UNSPECIFIED = "STATE_UNSPECIFIED",
|
|
2975
|
+
ACTIVE = "ACTIVE",
|
|
2976
|
+
ERROR = "ERROR"
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
/** Configuration for a Style reference image. */
|
|
2980
|
+
export declare interface StyleReferenceConfig {
|
|
2981
|
+
/** A text description of the style to use for the generated image. */
|
|
2982
|
+
styleDescription?: string;
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
/** A style reference image.
|
|
2986
|
+
|
|
2987
|
+
This encapsulates a style reference image provided by the user, and
|
|
2988
|
+
additionally optional config parameters for the style reference image.
|
|
2989
|
+
|
|
2990
|
+
A raw reference image can also be provided as a destination for the style to
|
|
2991
|
+
be applied to.
|
|
2992
|
+
*/
|
|
2993
|
+
export declare interface StyleReferenceImage {
|
|
2994
|
+
/** The reference image for the editing operation. */
|
|
2995
|
+
referenceImage?: Image_2;
|
|
2996
|
+
/** The id of the reference image. */
|
|
2997
|
+
referenceId?: number;
|
|
2998
|
+
/** The type of the reference image. Only set by the SDK. */
|
|
2999
|
+
referenceType?: string;
|
|
3000
|
+
/** Configuration for the style reference image. */
|
|
3001
|
+
config?: StyleReferenceConfig;
|
|
3002
|
+
}
|
|
3003
|
+
|
|
3004
|
+
/** Configuration for a Subject reference image. */
|
|
3005
|
+
export declare interface SubjectReferenceConfig {
|
|
3006
|
+
/** The subject type of a subject reference image. */
|
|
3007
|
+
subjectType?: SubjectReferenceType;
|
|
3008
|
+
/** Subject description for the image. */
|
|
3009
|
+
subjectDescription?: string;
|
|
3010
|
+
}
|
|
3011
|
+
|
|
3012
|
+
/** A subject reference image.
|
|
3013
|
+
|
|
3014
|
+
This encapsulates a subject reference image provided by the user, and
|
|
3015
|
+
additionally optional config parameters for the subject reference image.
|
|
3016
|
+
|
|
3017
|
+
A raw reference image can also be provided as a destination for the subject to
|
|
3018
|
+
be applied to.
|
|
3019
|
+
*/
|
|
3020
|
+
export declare interface SubjectReferenceImage {
|
|
3021
|
+
/** The reference image for the editing operation. */
|
|
3022
|
+
referenceImage?: Image_2;
|
|
3023
|
+
/** The id of the reference image. */
|
|
3024
|
+
referenceId?: number;
|
|
3025
|
+
/** The type of the reference image. Only set by the SDK. */
|
|
3026
|
+
referenceType?: string;
|
|
3027
|
+
/** Configuration for the subject reference image. */
|
|
3028
|
+
config?: SubjectReferenceConfig;
|
|
3029
|
+
}
|
|
3030
|
+
|
|
3031
|
+
export declare enum SubjectReferenceType {
|
|
3032
|
+
SUBJECT_TYPE_DEFAULT = "SUBJECT_TYPE_DEFAULT",
|
|
3033
|
+
SUBJECT_TYPE_PERSON = "SUBJECT_TYPE_PERSON",
|
|
3034
|
+
SUBJECT_TYPE_ANIMAL = "SUBJECT_TYPE_ANIMAL",
|
|
3035
|
+
SUBJECT_TYPE_PRODUCT = "SUBJECT_TYPE_PRODUCT"
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
export declare interface TestTableFile {
|
|
3039
|
+
comment?: string;
|
|
3040
|
+
testMethod?: string;
|
|
3041
|
+
parameterNames?: string[];
|
|
3042
|
+
testTable?: TestTableItem[];
|
|
3043
|
+
}
|
|
3044
|
+
|
|
3045
|
+
export declare interface TestTableItem {
|
|
3046
|
+
/** The name of the test. This is used to derive the replay id. */
|
|
3047
|
+
name?: string;
|
|
3048
|
+
/** The parameters to the test. Use pydantic models. */
|
|
3049
|
+
parameters?: Record<string, unknown>;
|
|
3050
|
+
/** Expects an exception for MLDev matching the string. */
|
|
3051
|
+
exceptionIfMldev?: string;
|
|
3052
|
+
/** Expects an exception for Vertex matching the string. */
|
|
3053
|
+
exceptionIfVertex?: string;
|
|
3054
|
+
/** Use if you don't want to use the default replay id which is derived from the test name. */
|
|
3055
|
+
overrideReplayId?: string;
|
|
3056
|
+
/** True if the parameters contain an unsupported union type. This test will be skipped for languages that do not support the union type. */
|
|
3057
|
+
hasUnion?: boolean;
|
|
3058
|
+
/** When set to a reason string, this test will be skipped in the API mode. Use this flag for tests that can not be reproduced with the real API. E.g. a test that deletes a resource. */
|
|
3059
|
+
skipInApiMode?: string;
|
|
3060
|
+
/** Keys to ignore when comparing the request and response. This is useful for tests that are not deterministic. */
|
|
3061
|
+
ignoreKeys?: string[];
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
/** The thinking features configuration. */
|
|
3065
|
+
export declare interface ThinkingConfig {
|
|
3066
|
+
/** Indicates whether to include thoughts in the response. If true, thoughts are returned only if the model supports thought and thoughts are available.
|
|
3067
|
+
*/
|
|
3068
|
+
includeThoughts?: boolean;
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
/** Tokens info with a list of tokens and the corresponding list of token ids. */
|
|
3072
|
+
export declare interface TokensInfo {
|
|
3073
|
+
/** Optional. Optional fields for the role from the corresponding Content. */
|
|
3074
|
+
role?: string;
|
|
3075
|
+
/** A list of token ids from the input. */
|
|
3076
|
+
tokenIds?: string[];
|
|
3077
|
+
/** A list of tokens from the input. */
|
|
3078
|
+
tokens?: string[];
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
/** Tool details of a tool that the model may use to generate a response. */
|
|
3082
|
+
export declare interface Tool {
|
|
3083
|
+
/** List of function declarations that the tool supports. */
|
|
3084
|
+
functionDeclarations?: FunctionDeclaration[];
|
|
3085
|
+
/** Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation. */
|
|
3086
|
+
retrieval?: Retrieval;
|
|
3087
|
+
/** Optional. Google Search tool type. Specialized retrieval tool
|
|
3088
|
+
that is powered by Google Search. */
|
|
3089
|
+
googleSearch?: GoogleSearch;
|
|
3090
|
+
/** Optional. GoogleSearchRetrieval tool type. Specialized retrieval tool that is powered by Google search. */
|
|
3091
|
+
googleSearchRetrieval?: GoogleSearchRetrieval;
|
|
3092
|
+
/** Optional. CodeExecution tool type. Enables the model to execute code as part of generation. This field is only used by the Gemini Developer API services. */
|
|
3093
|
+
codeExecution?: ToolCodeExecution;
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
/** Tool that executes code generated by the model, and automatically returns the result to the model. See also [ExecutableCode]and [CodeExecutionResult] which are input and output to this tool. */
|
|
3097
|
+
export declare interface ToolCodeExecution {
|
|
3098
|
+
}
|
|
3099
|
+
|
|
3100
|
+
/** Tool config.
|
|
3101
|
+
|
|
3102
|
+
This config is shared for all tools provided in the request.
|
|
3103
|
+
*/
|
|
3104
|
+
export declare interface ToolConfig {
|
|
3105
|
+
/** Optional. Function calling config. */
|
|
3106
|
+
functionCallingConfig?: FunctionCallingConfig;
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
export declare type ToolListUnion = Tool[];
|
|
3110
|
+
|
|
3111
|
+
export declare enum Type {
|
|
3112
|
+
TYPE_UNSPECIFIED = "TYPE_UNSPECIFIED",
|
|
3113
|
+
STRING = "STRING",
|
|
3114
|
+
NUMBER = "NUMBER",
|
|
3115
|
+
INTEGER = "INTEGER",
|
|
3116
|
+
BOOLEAN = "BOOLEAN",
|
|
3117
|
+
ARRAY = "ARRAY",
|
|
3118
|
+
OBJECT = "OBJECT"
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
declare namespace types {
|
|
3122
|
+
export {
|
|
3123
|
+
createPartFromUri,
|
|
3124
|
+
createPartFromText,
|
|
3125
|
+
createPartFromFunctionCall,
|
|
3126
|
+
createPartFromFunctionResponse,
|
|
3127
|
+
createPartFromBase64,
|
|
3128
|
+
createPartFromCodeExecutionResult,
|
|
3129
|
+
createPartFromExecutableCode,
|
|
3130
|
+
createUserContent,
|
|
3131
|
+
createModelContent,
|
|
3132
|
+
Outcome,
|
|
3133
|
+
Language,
|
|
3134
|
+
Type,
|
|
3135
|
+
HarmCategory,
|
|
3136
|
+
HarmBlockMethod,
|
|
3137
|
+
HarmBlockThreshold,
|
|
3138
|
+
Mode,
|
|
3139
|
+
FinishReason,
|
|
3140
|
+
HarmProbability,
|
|
3141
|
+
HarmSeverity,
|
|
3142
|
+
BlockedReason,
|
|
3143
|
+
Modality,
|
|
3144
|
+
State,
|
|
3145
|
+
DynamicRetrievalConfigMode,
|
|
3146
|
+
FunctionCallingConfigMode,
|
|
3147
|
+
MediaResolution,
|
|
3148
|
+
SafetyFilterLevel,
|
|
3149
|
+
PersonGeneration,
|
|
3150
|
+
ImagePromptLanguage,
|
|
3151
|
+
FileState,
|
|
3152
|
+
FileSource,
|
|
3153
|
+
MaskReferenceMode,
|
|
3154
|
+
ControlReferenceType,
|
|
3155
|
+
SubjectReferenceType,
|
|
3156
|
+
VideoMetadata,
|
|
3157
|
+
CodeExecutionResult,
|
|
3158
|
+
ExecutableCode,
|
|
3159
|
+
FileData,
|
|
3160
|
+
FunctionCall,
|
|
3161
|
+
FunctionResponse,
|
|
3162
|
+
Blob_2 as Blob,
|
|
3163
|
+
Part,
|
|
3164
|
+
Content,
|
|
3165
|
+
HttpOptions,
|
|
3166
|
+
Schema,
|
|
3167
|
+
SafetySetting,
|
|
3168
|
+
FunctionDeclaration,
|
|
3169
|
+
GoogleSearch,
|
|
3170
|
+
DynamicRetrievalConfig,
|
|
3171
|
+
GoogleSearchRetrieval,
|
|
3172
|
+
VertexAISearch,
|
|
3173
|
+
VertexRagStoreRagResource,
|
|
3174
|
+
VertexRagStore,
|
|
3175
|
+
Retrieval,
|
|
3176
|
+
ToolCodeExecution,
|
|
3177
|
+
Tool,
|
|
3178
|
+
FunctionCallingConfig,
|
|
3179
|
+
ToolConfig,
|
|
3180
|
+
PrebuiltVoiceConfig,
|
|
3181
|
+
VoiceConfig,
|
|
3182
|
+
SpeechConfig,
|
|
3183
|
+
ThinkingConfig,
|
|
3184
|
+
GenerationConfigRoutingConfigAutoRoutingMode,
|
|
3185
|
+
GenerationConfigRoutingConfigManualRoutingMode,
|
|
3186
|
+
GenerationConfigRoutingConfig,
|
|
3187
|
+
GenerateContentConfig,
|
|
3188
|
+
GenerateContentParameters,
|
|
3189
|
+
GoogleTypeDate,
|
|
3190
|
+
Citation,
|
|
3191
|
+
CitationMetadata,
|
|
3192
|
+
GroundingChunkRetrievedContext,
|
|
3193
|
+
GroundingChunkWeb,
|
|
3194
|
+
GroundingChunk,
|
|
3195
|
+
Segment,
|
|
3196
|
+
GroundingSupport,
|
|
3197
|
+
RetrievalMetadata,
|
|
3198
|
+
SearchEntryPoint,
|
|
3199
|
+
GroundingMetadata,
|
|
3200
|
+
LogprobsResultCandidate,
|
|
3201
|
+
LogprobsResultTopCandidates,
|
|
3202
|
+
LogprobsResult,
|
|
3203
|
+
SafetyRating,
|
|
3204
|
+
Candidate,
|
|
3205
|
+
GenerateContentResponsePromptFeedback,
|
|
3206
|
+
ModalityTokenCount,
|
|
3207
|
+
GenerateContentResponseUsageMetadata,
|
|
3208
|
+
GenerateContentResponse,
|
|
3209
|
+
EmbedContentConfig,
|
|
3210
|
+
EmbedContentParameters,
|
|
3211
|
+
ContentEmbeddingStatistics,
|
|
3212
|
+
ContentEmbedding,
|
|
3213
|
+
EmbedContentMetadata,
|
|
3214
|
+
EmbedContentResponse,
|
|
3215
|
+
GenerateImagesConfig,
|
|
3216
|
+
GenerateImagesParameters,
|
|
3217
|
+
Image_2 as Image,
|
|
3218
|
+
SafetyAttributes,
|
|
3219
|
+
GeneratedImage,
|
|
3220
|
+
GenerateImagesResponse,
|
|
3221
|
+
GenerationConfig,
|
|
3222
|
+
CountTokensConfig,
|
|
3223
|
+
CountTokensParameters,
|
|
3224
|
+
CountTokensResponse,
|
|
3225
|
+
ComputeTokensConfig,
|
|
3226
|
+
ComputeTokensParameters,
|
|
3227
|
+
TokensInfo,
|
|
3228
|
+
ComputeTokensResponse,
|
|
3229
|
+
CreateCachedContentConfig,
|
|
3230
|
+
CreateCachedContentParameters,
|
|
3231
|
+
CachedContentUsageMetadata,
|
|
3232
|
+
CachedContent,
|
|
3233
|
+
GetCachedContentConfig,
|
|
3234
|
+
GetCachedContentParameters,
|
|
3235
|
+
DeleteCachedContentConfig,
|
|
3236
|
+
DeleteCachedContentParameters,
|
|
3237
|
+
DeleteCachedContentResponse,
|
|
3238
|
+
UpdateCachedContentConfig,
|
|
3239
|
+
UpdateCachedContentParameters,
|
|
3240
|
+
ListCachedContentsConfig,
|
|
3241
|
+
ListCachedContentsParameters,
|
|
3242
|
+
ListCachedContentsResponse,
|
|
3243
|
+
ListFilesConfig,
|
|
3244
|
+
ListFilesParameters,
|
|
3245
|
+
FileStatus,
|
|
3246
|
+
File_2 as File,
|
|
3247
|
+
ListFilesResponse,
|
|
3248
|
+
CreateFileConfig,
|
|
3249
|
+
CreateFileParameters,
|
|
3250
|
+
HttpResponse,
|
|
3251
|
+
LiveCallbacks,
|
|
3252
|
+
CreateFileResponse,
|
|
3253
|
+
GetFileConfig,
|
|
3254
|
+
GetFileParameters,
|
|
3255
|
+
DeleteFileConfig,
|
|
3256
|
+
DeleteFileParameters,
|
|
3257
|
+
DeleteFileResponse,
|
|
3258
|
+
TestTableItem,
|
|
3259
|
+
TestTableFile,
|
|
3260
|
+
ReplayRequest,
|
|
3261
|
+
ReplayResponse,
|
|
3262
|
+
ReplayInteraction,
|
|
3263
|
+
ReplayFile,
|
|
3264
|
+
UploadFileConfig,
|
|
3265
|
+
DownloadFileConfig,
|
|
3266
|
+
UpscaleImageConfig,
|
|
3267
|
+
UpscaleImageParameters,
|
|
3268
|
+
RawReferenceImage,
|
|
3269
|
+
MaskReferenceConfig,
|
|
3270
|
+
MaskReferenceImage,
|
|
3271
|
+
ControlReferenceConfig,
|
|
3272
|
+
ControlReferenceImage,
|
|
3273
|
+
StyleReferenceConfig,
|
|
3274
|
+
StyleReferenceImage,
|
|
3275
|
+
SubjectReferenceConfig,
|
|
3276
|
+
SubjectReferenceImage,
|
|
3277
|
+
LiveServerSetupComplete,
|
|
3278
|
+
LiveServerContent,
|
|
3279
|
+
LiveServerToolCall,
|
|
3280
|
+
LiveServerToolCallCancellation,
|
|
3281
|
+
LiveServerMessage,
|
|
3282
|
+
LiveClientSetup,
|
|
3283
|
+
LiveClientContent,
|
|
3284
|
+
LiveClientRealtimeInput,
|
|
3285
|
+
LiveClientToolResponse,
|
|
3286
|
+
LiveClientMessage,
|
|
3287
|
+
LiveConnectConfig,
|
|
3288
|
+
LiveConnectParameters,
|
|
3289
|
+
CreateChatParameters,
|
|
3290
|
+
SendMessageParameters,
|
|
3291
|
+
LiveSendClientContentParameters,
|
|
3292
|
+
LiveSendRealtimeInputParameters,
|
|
3293
|
+
LiveSendToolResponseParameters,
|
|
3294
|
+
PartUnion,
|
|
3295
|
+
PartListUnion,
|
|
3296
|
+
ContentUnion,
|
|
3297
|
+
ContentListUnion,
|
|
3298
|
+
SchemaUnion,
|
|
3299
|
+
SpeechConfigUnion,
|
|
3300
|
+
ToolListUnion
|
|
3301
|
+
}
|
|
3302
|
+
}
|
|
3303
|
+
|
|
3304
|
+
/** Optional parameters for caches.update method. */
|
|
3305
|
+
export declare interface UpdateCachedContentConfig {
|
|
3306
|
+
/** Used to override HTTP request options. */
|
|
3307
|
+
httpOptions?: HttpOptions;
|
|
3308
|
+
/** The TTL for this resource. The expiration time is computed: now + TTL. */
|
|
3309
|
+
ttl?: string;
|
|
3310
|
+
/** Timestamp of when this resource is considered expired. */
|
|
3311
|
+
expireTime?: string;
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3314
|
+
export declare interface UpdateCachedContentParameters {
|
|
3315
|
+
/** The server-generated resource name of the cached content.
|
|
3316
|
+
*/
|
|
3317
|
+
name: string;
|
|
3318
|
+
/** Configuration that contains optional parameters.
|
|
3319
|
+
*/
|
|
3320
|
+
config?: UpdateCachedContentConfig;
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3323
|
+
declare interface Uploader {
|
|
3324
|
+
/**
|
|
3325
|
+
* Uploads a file to the given upload url.
|
|
3326
|
+
*
|
|
3327
|
+
* @param file The file to upload. file is in string type or a Blob.
|
|
3328
|
+
* @param uploadUrl The upload URL as a string is where the file will be
|
|
3329
|
+
* uploaded to. The uploadUrl must be a url that was returned by the
|
|
3330
|
+
* https://generativelanguage.googleapis.com/upload/v1beta/files endpoint
|
|
3331
|
+
* @param apiClient The ApiClient to use for uploading.
|
|
3332
|
+
* @return A Promise that resolves to types.File.
|
|
3333
|
+
*/
|
|
3334
|
+
upload(file: string | Blob, uploadUrl: string, apiClient: ApiClient): Promise<File_2>;
|
|
3335
|
+
/**
|
|
3336
|
+
* Returns the file's mimeType and the size of a given file. If the file is a
|
|
3337
|
+
* string path, the file type is determined by the file extension. If the
|
|
3338
|
+
* file's type cannot be determined, the type will be set to undefined.
|
|
3339
|
+
*
|
|
3340
|
+
* @param file The file to get the stat for. Can be a string path or a Blob.
|
|
3341
|
+
* @return A Promise that resolves to the file stat of the given file.
|
|
3342
|
+
*/
|
|
3343
|
+
stat(file: string | Blob): Promise<FileStat>;
|
|
3344
|
+
}
|
|
3345
|
+
|
|
3346
|
+
/** Used to override the default configuration. */
|
|
3347
|
+
export declare interface UploadFileConfig {
|
|
3348
|
+
/** Used to override HTTP request options. */
|
|
3349
|
+
httpOptions?: HttpOptions;
|
|
3350
|
+
/** The name of the file in the destination (e.g., 'files/sample-image'. If not provided one will be generated. */
|
|
3351
|
+
name?: string;
|
|
3352
|
+
/** mime_type: The MIME type of the file. If not provided, it will be inferred from the file extension. */
|
|
3353
|
+
mimeType?: string;
|
|
3354
|
+
/** Optional display name of the file. */
|
|
3355
|
+
displayName?: string;
|
|
3356
|
+
}
|
|
3357
|
+
|
|
3358
|
+
/** Parameters for the upload file method. */
|
|
3359
|
+
declare interface UploadFileParameters {
|
|
3360
|
+
/** The string path to the file to be uploaded or a Blob object. */
|
|
3361
|
+
file: string | Blob;
|
|
3362
|
+
/** Configuration that contains optional parameters. */
|
|
3363
|
+
config?: UploadFileConfig;
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
/** Configuration for upscaling an image.
|
|
3367
|
+
|
|
3368
|
+
For more information on this configuration, refer to
|
|
3369
|
+
the `Imagen API reference documentation
|
|
3370
|
+
<https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-api>`_.
|
|
3371
|
+
*/
|
|
3372
|
+
export declare interface UpscaleImageConfig {
|
|
3373
|
+
/** Used to override HTTP request options. */
|
|
3374
|
+
httpOptions?: HttpOptions;
|
|
3375
|
+
/** Whether to include a reason for filtered-out images in the
|
|
3376
|
+
response. */
|
|
3377
|
+
includeRaiReason?: boolean;
|
|
3378
|
+
/** The image format that the output should be saved as. */
|
|
3379
|
+
outputMimeType?: string;
|
|
3380
|
+
/** The level of compression if the ``output_mime_type`` is
|
|
3381
|
+
``image/jpeg``. */
|
|
3382
|
+
outputCompressionQuality?: number;
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3385
|
+
/** User-facing config UpscaleImageParameters. */
|
|
3386
|
+
export declare interface UpscaleImageParameters {
|
|
3387
|
+
/** The model to use. */
|
|
3388
|
+
model: string;
|
|
3389
|
+
/** The input image to upscale. */
|
|
3390
|
+
image: Image_2;
|
|
3391
|
+
/** The factor to upscale the image (x2 or x4). */
|
|
3392
|
+
upscaleFactor: string;
|
|
3393
|
+
/** Configuration for upscaling. */
|
|
3394
|
+
config?: UpscaleImageConfig;
|
|
3395
|
+
}
|
|
3396
|
+
|
|
3397
|
+
/** Retrieve from Vertex AI Search datastore or engine for grounding. datastore and engine are mutually exclusive. See https://cloud.google.com/products/agent-builder */
|
|
3398
|
+
export declare interface VertexAISearch {
|
|
3399
|
+
/** Optional. Fully-qualified Vertex AI Search data store resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}` */
|
|
3400
|
+
datastore?: string;
|
|
3401
|
+
/** Optional. Fully-qualified Vertex AI Search engine resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}` */
|
|
3402
|
+
engine?: string;
|
|
3403
|
+
}
|
|
3404
|
+
|
|
3405
|
+
/** Retrieve from Vertex RAG Store for grounding. */
|
|
3406
|
+
export declare interface VertexRagStore {
|
|
3407
|
+
/** Optional. Deprecated. Please use rag_resources instead. */
|
|
3408
|
+
ragCorpora?: string[];
|
|
3409
|
+
/** Optional. The representation of the rag source. It can be used to specify corpus only or ragfiles. Currently only support one corpus or multiple files from one corpus. In the future we may open up multiple corpora support. */
|
|
3410
|
+
ragResources?: VertexRagStoreRagResource[];
|
|
3411
|
+
/** Optional. Number of top k results to return from the selected corpora. */
|
|
3412
|
+
similarityTopK?: number;
|
|
3413
|
+
/** Optional. Only return results with vector distance smaller than the threshold. */
|
|
3414
|
+
vectorDistanceThreshold?: number;
|
|
3415
|
+
}
|
|
3416
|
+
|
|
3417
|
+
/** The definition of the Rag resource. */
|
|
3418
|
+
export declare interface VertexRagStoreRagResource {
|
|
3419
|
+
/** Optional. RagCorpora resource name. Format: `projects/{project}/locations/{location}/ragCorpora/{rag_corpus}` */
|
|
3420
|
+
ragCorpus?: string;
|
|
3421
|
+
/** Optional. rag_file_id. The files should be in the same rag_corpus set in rag_corpus field. */
|
|
3422
|
+
ragFileIds?: string[];
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
/** Metadata describes the input video content. */
|
|
3426
|
+
export declare interface VideoMetadata {
|
|
3427
|
+
/** Optional. The end offset of the video. */
|
|
3428
|
+
endOffset?: string;
|
|
3429
|
+
/** Optional. The start offset of the video. */
|
|
3430
|
+
startOffset?: string;
|
|
3431
|
+
}
|
|
3432
|
+
|
|
3433
|
+
/** The configuration for the voice to use. */
|
|
3434
|
+
export declare interface VoiceConfig {
|
|
3435
|
+
/** The configuration for the speaker to use.
|
|
3436
|
+
*/
|
|
3437
|
+
prebuiltVoiceConfig?: PrebuiltVoiceConfig;
|
|
3438
|
+
}
|
|
3439
|
+
|
|
3440
|
+
declare interface WebSocket_2 {
|
|
3441
|
+
/**
|
|
3442
|
+
* Connects the socket to the server.
|
|
3443
|
+
*/
|
|
3444
|
+
connect(): void;
|
|
3445
|
+
/**
|
|
3446
|
+
* Sends a message to the server.
|
|
3447
|
+
*/
|
|
3448
|
+
send(message: string): void;
|
|
3449
|
+
/**
|
|
3450
|
+
* Closes the socket connection.
|
|
3451
|
+
*/
|
|
3452
|
+
close(): void;
|
|
3453
|
+
}
|
|
3454
|
+
|
|
3455
|
+
/**
|
|
3456
|
+
* @license
|
|
3457
|
+
* Copyright 2025 Google LLC
|
|
3458
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
3459
|
+
*/
|
|
3460
|
+
declare interface WebSocketCallbacks {
|
|
3461
|
+
onopen: () => void;
|
|
3462
|
+
onerror: (e: any) => void;
|
|
3463
|
+
onmessage: (e: any) => void;
|
|
3464
|
+
onclose: (e: any) => void;
|
|
3465
|
+
}
|
|
3466
|
+
|
|
3467
|
+
declare interface WebSocketFactory {
|
|
3468
|
+
/**
|
|
3469
|
+
* Returns a new WebSocket instance.
|
|
3470
|
+
*/
|
|
3471
|
+
create(url: string, headers: Record<string, string>, callbacks: WebSocketCallbacks): WebSocket_2;
|
|
3472
|
+
}
|
|
3473
|
+
|
|
3474
|
+
export { }
|