@google/genai 0.12.0 → 0.13.0

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 CHANGED
@@ -41,6 +41,21 @@ export declare enum AdapterSize {
41
41
  declare class ApiClient {
42
42
  readonly clientOptions: ApiClientInitOptions;
43
43
  constructor(opts: ApiClientInitOptions);
44
+ /**
45
+ * Determines the base URL for Vertex AI based on project and location.
46
+ * Uses the global endpoint if location is 'global' or if project/location
47
+ * are not specified (implying API key usage).
48
+ * @private
49
+ */
50
+ private baseUrlFromProjectLocation;
51
+ /**
52
+ * Normalizes authentication parameters for Vertex AI.
53
+ * If project and location are provided, API key is cleared.
54
+ * If project and location are not provided (implying API key usage),
55
+ * project and location are cleared.
56
+ * @private
57
+ */
58
+ private normalizeAuthParameters;
44
59
  isVertexAI(): boolean;
45
60
  getProject(): string | undefined;
46
61
  getLocation(): string | undefined;
@@ -77,6 +92,13 @@ declare class ApiClient {
77
92
  * @throws An error if the `mimeType` is not provided and can not be inferred,
78
93
  */
79
94
  uploadFile(file: string | Blob, config?: UploadFileConfig): Promise<File_2>;
95
+ /**
96
+ * Downloads a file asynchronously to the specified path.
97
+ *
98
+ * @params params - The parameters for the download request, see {@link
99
+ * DownloadFileParameters}
100
+ */
101
+ downloadFile(params: DownloadFileParameters): Promise<void>;
80
102
  private fetchUploadUrl;
81
103
  }
82
104
 
@@ -95,6 +117,12 @@ declare interface ApiClientInitOptions {
95
117
  * creating a client, will be set through the Node_client or Web_client.
96
118
  */
97
119
  uploader: Uploader;
120
+ /**
121
+ * Optional. The downloader to use for downloading files. This field is
122
+ * required for creating a client, will be set through the Node_client or
123
+ * Web_client.
124
+ */
125
+ downloader: Downloader;
98
126
  /**
99
127
  * Optional. The Google Cloud project ID for Vertex AI users.
100
128
  * It is not the numeric project name.
@@ -132,6 +160,12 @@ declare interface ApiClientInitOptions {
132
160
  userAgentExtra?: string;
133
161
  }
134
162
 
163
+ /** Config for authentication with API key. */
164
+ export declare interface ApiKeyConfig {
165
+ /** The API key to be used in the request directly. */
166
+ apiKeyString?: string;
167
+ }
168
+
135
169
  /** The audio transcription configuration in Setup. */
136
170
  export declare interface AudioTranscriptionConfig {
137
171
  }
@@ -153,6 +187,61 @@ declare interface Auth {
153
187
  addAuthHeaders(headers: Headers): Promise<void>;
154
188
  }
155
189
 
190
+ /** Auth configuration to run the extension. */
191
+ export declare interface AuthConfig {
192
+ /** Config for API key auth. */
193
+ apiKeyConfig?: ApiKeyConfig;
194
+ /** Type of auth scheme. */
195
+ authType?: AuthType;
196
+ /** Config for Google Service Account auth. */
197
+ googleServiceAccountConfig?: AuthConfigGoogleServiceAccountConfig;
198
+ /** Config for HTTP Basic auth. */
199
+ httpBasicAuthConfig?: AuthConfigHttpBasicAuthConfig;
200
+ /** Config for user oauth. */
201
+ oauthConfig?: AuthConfigOauthConfig;
202
+ /** Config for user OIDC auth. */
203
+ oidcConfig?: AuthConfigOidcConfig;
204
+ }
205
+
206
+ /** Config for Google Service Account Authentication. */
207
+ export declare interface AuthConfigGoogleServiceAccountConfig {
208
+ /** Optional. The service account that the extension execution service runs as. - If the service account is specified, the `iam.serviceAccounts.getAccessToken` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified service account. - If not specified, the Vertex AI Extension Service Agent will be used to execute the Extension. */
209
+ serviceAccount?: string;
210
+ }
211
+
212
+ /** Config for HTTP Basic Authentication. */
213
+ export declare interface AuthConfigHttpBasicAuthConfig {
214
+ /** Required. The name of the SecretManager secret version resource storing the base64 encoded credentials. Format: `projects/{project}/secrets/{secrete}/versions/{version}` - If specified, the `secretmanager.versions.access` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified resource. */
215
+ credentialSecret?: string;
216
+ }
217
+
218
+ /** Config for user oauth. */
219
+ export declare interface AuthConfigOauthConfig {
220
+ /** Access token for extension endpoint. Only used to propagate token from [[ExecuteExtensionRequest.runtime_auth_config]] at request time. */
221
+ accessToken?: string;
222
+ /** The service account used to generate access tokens for executing the Extension. - If the service account is specified, the `iam.serviceAccounts.getAccessToken` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the provided service account. */
223
+ serviceAccount?: string;
224
+ }
225
+
226
+ /** Config for user OIDC auth. */
227
+ export declare interface AuthConfigOidcConfig {
228
+ /** OpenID Connect formatted ID token for extension endpoint. Only used to propagate token from [[ExecuteExtensionRequest.runtime_auth_config]] at request time. */
229
+ idToken?: string;
230
+ /** The service account used to generate an OpenID Connect (OIDC)-compatible JWT token signed by the Google OIDC Provider (accounts.google.com) for extension endpoint (https://cloud.google.com/iam/docs/create-short-lived-credentials-direct#sa-credentials-oidc). - The audience for the token will be set to the URL in the server url defined in the OpenApi spec. - If the service account is provided, the service account should grant `iam.serviceAccounts.getOpenIdToken` permission to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents). */
231
+ serviceAccount?: string;
232
+ }
233
+
234
+ /** Type of auth scheme. */
235
+ export declare enum AuthType {
236
+ AUTH_TYPE_UNSPECIFIED = "AUTH_TYPE_UNSPECIFIED",
237
+ NO_AUTH = "NO_AUTH",
238
+ API_KEY_AUTH = "API_KEY_AUTH",
239
+ HTTP_BASIC_AUTH = "HTTP_BASIC_AUTH",
240
+ GOOGLE_SERVICE_ACCOUNT_AUTH = "GOOGLE_SERVICE_ACCOUNT_AUTH",
241
+ OAUTH = "OAUTH",
242
+ OIDC_AUTH = "OIDC_AUTH"
243
+ }
244
+
156
245
  /** Configures automatic detection of activity. */
157
246
  export declare interface AutomaticActivityDetection {
158
247
  /** If enabled, detected voice and text input count as activity. If disabled, the client must send activity signals. */
@@ -1005,6 +1094,19 @@ export declare interface DistillationSpec {
1005
1094
  validationDatasetUri?: string;
1006
1095
  }
1007
1096
 
1097
+ export declare type DownloadableFileUnion = string | File_2 | GeneratedVideo | Video;
1098
+
1099
+ declare interface Downloader {
1100
+ /**
1101
+ * Downloads a file to the given location.
1102
+ *
1103
+ * @param params The parameters for downloading the file.
1104
+ * @param apiClient The ApiClient to use for uploading.
1105
+ * @return A Promises that resolves when the download is complete.
1106
+ */
1107
+ download(params: DownloadFileParameters, apiClient: ApiClient): Promise<void>;
1108
+ }
1109
+
1008
1110
  /** Used to override the default configuration. */
1009
1111
  export declare interface DownloadFileConfig {
1010
1112
  /** Used to override HTTP request options. */
@@ -1018,6 +1120,16 @@ export declare interface DownloadFileConfig {
1018
1120
  abortSignal?: AbortSignal;
1019
1121
  }
1020
1122
 
1123
+ /** Parameters used to download a file. */
1124
+ export declare interface DownloadFileParameters {
1125
+ /** The file to download. It can be a file name, a file object or a generated video. */
1126
+ file: DownloadableFileUnion;
1127
+ /** Location where the file should be downloaded to. */
1128
+ downloadPath: string;
1129
+ /** Configuration to for the download operation. */
1130
+ config?: DownloadFileConfig;
1131
+ }
1132
+
1021
1133
  /** Describes the options to customize dynamic retrieval. */
1022
1134
  export declare interface DynamicRetrievalConfig {
1023
1135
  /** The mode of the predictor to be used in dynamic retrieval. */
@@ -1118,6 +1230,10 @@ export declare enum EndSensitivity {
1118
1230
  END_SENSITIVITY_LOW = "END_SENSITIVITY_LOW"
1119
1231
  }
1120
1232
 
1233
+ /** Tool to search public web data, powered by Vertex AI Search and Sec4 compliance. */
1234
+ export declare interface EnterpriseWebSearch {
1235
+ }
1236
+
1121
1237
  /** 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]. */
1122
1238
  export declare interface ExecutableCode {
1123
1239
  /** Required. The code to be executed. */
@@ -1261,6 +1377,23 @@ export declare class Files extends BaseModule {
1261
1377
  * ```
1262
1378
  */
1263
1379
  upload(params: types.UploadFileParameters): Promise<types.File>;
1380
+ /**
1381
+ * Downloads a remotely stored file asynchronously to a location specified in
1382
+ * the `params` object. This method only works on Node environment, to
1383
+ * download files in the browser, use a browser compliant method like an <a>
1384
+ * tag.
1385
+ *
1386
+ * @param params - The parameters for the download request.
1387
+ *
1388
+ * @example
1389
+ * The following code downloads an example file named "files/mehozpxf877d" as
1390
+ * "file.txt".
1391
+ *
1392
+ * ```ts
1393
+ * await ai.files.download({file: file.name, downloadPath: 'file.txt'});
1394
+ * ```
1395
+ */
1396
+ download(params: types.DownloadFileParameters): Promise<void>;
1264
1397
  private listInternal;
1265
1398
  private createInternal;
1266
1399
  /**
@@ -2174,6 +2307,12 @@ export declare interface GoogleGenAIOptions {
2174
2307
  httpOptions?: HttpOptions;
2175
2308
  }
2176
2309
 
2310
+ /** Tool to support Google Maps in Model. */
2311
+ export declare interface GoogleMaps {
2312
+ /** Optional. Auth config for the Google Maps tool. */
2313
+ authConfig?: AuthConfig;
2314
+ }
2315
+
2177
2316
  /** The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). */
2178
2317
  export declare interface GoogleRpcStatus {
2179
2318
  /** The status code, which should be an enum value of google.rpc.Code. */
@@ -2422,6 +2561,20 @@ export declare enum Language {
2422
2561
  PYTHON = "PYTHON"
2423
2562
  }
2424
2563
 
2564
+ /** An object that represents a latitude/longitude pair.
2565
+
2566
+ This is expressed as a pair of doubles to represent degrees latitude and
2567
+ degrees longitude. Unless specified otherwise, this object must conform to the
2568
+ <a href="https://en.wikipedia.org/wiki/World_Geodetic_System#1984_version">
2569
+ WGS84 standard</a>. Values must be within normalized ranges.
2570
+ */
2571
+ export declare interface LatLng {
2572
+ /** The latitude in degrees. It must be in the range [-90.0, +90.0]. */
2573
+ latitude?: number;
2574
+ /** The longitude in degrees. It must be in the range [-180.0, +180.0] */
2575
+ longitude?: number;
2576
+ }
2577
+
2425
2578
  /** Config for caches.list method. */
2426
2579
  export declare interface ListCachedContentsConfig {
2427
2580
  /** Used to override HTTP request options. */
@@ -2480,6 +2633,32 @@ export declare class ListFilesResponse {
2480
2633
  files?: File_2[];
2481
2634
  }
2482
2635
 
2636
+ export declare interface ListModelsConfig {
2637
+ /** Used to override HTTP request options. */
2638
+ httpOptions?: HttpOptions;
2639
+ /** Abort signal which can be used to cancel the request.
2640
+
2641
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
2642
+ operation will not cancel the request in the service. You will still
2643
+ be charged usage for any applicable operations.
2644
+ */
2645
+ abortSignal?: AbortSignal;
2646
+ pageSize?: number;
2647
+ pageToken?: string;
2648
+ filter?: string;
2649
+ /** Set true to list base models, false to list tuned models. */
2650
+ queryBase?: boolean;
2651
+ }
2652
+
2653
+ export declare interface ListModelsParameters {
2654
+ config?: ListModelsConfig;
2655
+ }
2656
+
2657
+ export declare class ListModelsResponse {
2658
+ nextPageToken?: string;
2659
+ models?: Model[];
2660
+ }
2661
+
2483
2662
  /** Configuration for the list tuning jobs method. */
2484
2663
  export declare interface ListTuningJobsConfig {
2485
2664
  /** Used to override HTTP request options. */
@@ -2876,7 +3055,7 @@ export declare interface LiveServerGoAway {
2876
3055
  }
2877
3056
 
2878
3057
  /** Response message for API call. */
2879
- export declare interface LiveServerMessage {
3058
+ export declare class LiveServerMessage {
2880
3059
  /** Sent in response to a `LiveClientSetup` message from the client. */
2881
3060
  setupComplete?: LiveServerSetupComplete;
2882
3061
  /** Content generated by the model in response to client messages. */
@@ -2891,6 +3070,23 @@ export declare interface LiveServerMessage {
2891
3070
  goAway?: LiveServerGoAway;
2892
3071
  /** Update of the session resumption state. */
2893
3072
  sessionResumptionUpdate?: LiveServerSessionResumptionUpdate;
3073
+ /**
3074
+ * Returns the concatenation of all text parts from the server content if present.
3075
+ *
3076
+ * @remarks
3077
+ * If there are non-text parts in the response, the concatenation of all text
3078
+ * parts will be returned, and a warning will be logged.
3079
+ */
3080
+ get text(): string | undefined;
3081
+ /**
3082
+ * Returns the concatenation of all inline data parts from the server content if present.
3083
+ *
3084
+ * @remarks
3085
+ * If there are non-inline data parts in the
3086
+ * response, the concatenation of all inline data parts will be returned, and
3087
+ * a warning will be logged.
3088
+ */
3089
+ get data(): string | undefined;
2894
3090
  }
2895
3091
 
2896
3092
  /** Update of the session resumption state.
@@ -3172,6 +3368,7 @@ export declare class Models extends BaseModule {
3172
3368
  * ```
3173
3369
  */
3174
3370
  generateImages: (params: types.GenerateImagesParameters) => Promise<types.GenerateImagesResponse>;
3371
+ list: (params?: types.ListModelsParameters) => Promise<Pager<types.Model>>;
3175
3372
  private generateContentInternal;
3176
3373
  private generateContentStreamInternal;
3177
3374
  /**
@@ -3225,6 +3422,7 @@ export declare class Models extends BaseModule {
3225
3422
  * ```
3226
3423
  */
3227
3424
  get(params: types.GetModelParameters): Promise<types.Model>;
3425
+ private listInternal;
3228
3426
  /**
3229
3427
  * Updates a tuned model by its name.
3230
3428
  *
@@ -3667,6 +3865,13 @@ export declare interface Retrieval {
3667
3865
  vertexRagStore?: VertexRagStore;
3668
3866
  }
3669
3867
 
3868
+ /** Retrieval config.
3869
+ */
3870
+ export declare interface RetrievalConfig {
3871
+ /** Optional. The location of the user. */
3872
+ latLng?: LatLng;
3873
+ }
3874
+
3670
3875
  /** Metadata related to retrieval in the grounding flow. */
3671
3876
  export declare interface RetrievalMetadata {
3672
3877
  /** 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. */
@@ -4198,6 +4403,12 @@ export declare interface Tool {
4198
4403
  googleSearch?: GoogleSearch;
4199
4404
  /** Optional. GoogleSearchRetrieval tool type. Specialized retrieval tool that is powered by Google search. */
4200
4405
  googleSearchRetrieval?: GoogleSearchRetrieval;
4406
+ /** Optional. Enterprise web search tool type. Specialized retrieval
4407
+ tool that is powered by Vertex AI Search and Sec4 compliance. */
4408
+ enterpriseWebSearch?: EnterpriseWebSearch;
4409
+ /** Optional. Google Maps tool type. Specialized retrieval tool
4410
+ that is powered by Google Maps. */
4411
+ googleMaps?: GoogleMaps;
4201
4412
  /** 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. */
4202
4413
  codeExecution?: ToolCodeExecution;
4203
4414
  /** Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating FunctionCall in the response. User should provide a FunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 128 function declarations can be provided. */
@@ -4215,6 +4426,8 @@ export declare interface ToolCodeExecution {
4215
4426
  export declare interface ToolConfig {
4216
4427
  /** Optional. Function calling config. */
4217
4428
  functionCallingConfig?: FunctionCallingConfig;
4429
+ /** Optional. Retrieval config. */
4430
+ retrievalConfig?: RetrievalConfig;
4218
4431
  }
4219
4432
 
4220
4433
  export declare type ToolListUnion = Tool[];
@@ -4397,6 +4610,7 @@ declare namespace types {
4397
4610
  HarmBlockMethod,
4398
4611
  HarmBlockThreshold,
4399
4612
  Mode,
4613
+ AuthType,
4400
4614
  Type,
4401
4615
  FinishReason,
4402
4616
  HarmProbability,
@@ -4438,6 +4652,14 @@ declare namespace types {
4438
4652
  GoogleSearch,
4439
4653
  DynamicRetrievalConfig,
4440
4654
  GoogleSearchRetrieval,
4655
+ EnterpriseWebSearch,
4656
+ ApiKeyConfig,
4657
+ AuthConfigGoogleServiceAccountConfig,
4658
+ AuthConfigHttpBasicAuthConfig,
4659
+ AuthConfigOauthConfig,
4660
+ AuthConfigOidcConfig,
4661
+ AuthConfig,
4662
+ GoogleMaps,
4441
4663
  VertexAISearch,
4442
4664
  VertexRagStoreRagResource,
4443
4665
  RagRetrievalConfigFilter,
@@ -4453,6 +4675,8 @@ declare namespace types {
4453
4675
  FunctionDeclaration,
4454
4676
  Tool,
4455
4677
  FunctionCallingConfig,
4678
+ LatLng,
4679
+ RetrievalConfig,
4456
4680
  ToolConfig,
4457
4681
  PrebuiltVoiceConfig,
4458
4682
  VoiceConfig,
@@ -4500,6 +4724,9 @@ declare namespace types {
4500
4724
  Endpoint,
4501
4725
  TunedModelInfo,
4502
4726
  Model,
4727
+ ListModelsConfig,
4728
+ ListModelsParameters,
4729
+ ListModelsResponse,
4503
4730
  UpdateModelConfig,
4504
4731
  UpdateModelParameters,
4505
4732
  DeleteModelConfig,
@@ -4589,6 +4816,7 @@ declare namespace types {
4589
4816
  ReplayFile,
4590
4817
  UploadFileConfig,
4591
4818
  DownloadFileConfig,
4819
+ DownloadFileParameters,
4592
4820
  UpscaleImageConfig,
4593
4821
  UpscaleImageParameters,
4594
4822
  RawReferenceImage,
@@ -4637,7 +4865,8 @@ declare namespace types {
4637
4865
  ContentListUnion,
4638
4866
  SchemaUnion,
4639
4867
  SpeechConfigUnion,
4640
- ToolListUnion
4868
+ ToolListUnion,
4869
+ DownloadableFileUnion
4641
4870
  }
4642
4871
  }
4643
4872