@google/genai 0.11.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.
@@ -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
  /**
@@ -2186,6 +2319,12 @@ export declare interface GoogleGenAIOptions {
2186
2319
  httpOptions?: HttpOptions;
2187
2320
  }
2188
2321
 
2322
+ /** Tool to support Google Maps in Model. */
2323
+ export declare interface GoogleMaps {
2324
+ /** Optional. Auth config for the Google Maps tool. */
2325
+ authConfig?: AuthConfig;
2326
+ }
2327
+
2189
2328
  /** 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). */
2190
2329
  export declare interface GoogleRpcStatus {
2191
2330
  /** The status code, which should be an enum value of google.rpc.Code. */
@@ -2434,6 +2573,20 @@ export declare enum Language {
2434
2573
  PYTHON = "PYTHON"
2435
2574
  }
2436
2575
 
2576
+ /** An object that represents a latitude/longitude pair.
2577
+
2578
+ This is expressed as a pair of doubles to represent degrees latitude and
2579
+ degrees longitude. Unless specified otherwise, this object must conform to the
2580
+ <a href="https://en.wikipedia.org/wiki/World_Geodetic_System#1984_version">
2581
+ WGS84 standard</a>. Values must be within normalized ranges.
2582
+ */
2583
+ export declare interface LatLng {
2584
+ /** The latitude in degrees. It must be in the range [-90.0, +90.0]. */
2585
+ latitude?: number;
2586
+ /** The longitude in degrees. It must be in the range [-180.0, +180.0] */
2587
+ longitude?: number;
2588
+ }
2589
+
2437
2590
  /** Config for caches.list method. */
2438
2591
  export declare interface ListCachedContentsConfig {
2439
2592
  /** Used to override HTTP request options. */
@@ -2492,6 +2645,32 @@ export declare class ListFilesResponse {
2492
2645
  files?: File_2[];
2493
2646
  }
2494
2647
 
2648
+ export declare interface ListModelsConfig {
2649
+ /** Used to override HTTP request options. */
2650
+ httpOptions?: HttpOptions;
2651
+ /** Abort signal which can be used to cancel the request.
2652
+
2653
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
2654
+ operation will not cancel the request in the service. You will still
2655
+ be charged usage for any applicable operations.
2656
+ */
2657
+ abortSignal?: AbortSignal;
2658
+ pageSize?: number;
2659
+ pageToken?: string;
2660
+ filter?: string;
2661
+ /** Set true to list base models, false to list tuned models. */
2662
+ queryBase?: boolean;
2663
+ }
2664
+
2665
+ export declare interface ListModelsParameters {
2666
+ config?: ListModelsConfig;
2667
+ }
2668
+
2669
+ export declare class ListModelsResponse {
2670
+ nextPageToken?: string;
2671
+ models?: Model[];
2672
+ }
2673
+
2495
2674
  /** Configuration for the list tuning jobs method. */
2496
2675
  export declare interface ListTuningJobsConfig {
2497
2676
  /** Used to override HTTP request options. */
@@ -2859,6 +3038,8 @@ export declare interface LiveServerContent {
2859
3038
  turnComplete?: boolean;
2860
3039
  /** 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. */
2861
3040
  interrupted?: boolean;
3041
+ /** Metadata returned to client when grounding is enabled. */
3042
+ groundingMetadata?: GroundingMetadata;
2862
3043
  /** If true, indicates that the model is done generating. When model is
2863
3044
  interrupted while generating there will be no generation_complete message
2864
3045
  in interrupted turn, it will go through interrupted > turn_complete.
@@ -2886,7 +3067,7 @@ export declare interface LiveServerGoAway {
2886
3067
  }
2887
3068
 
2888
3069
  /** Response message for API call. */
2889
- export declare interface LiveServerMessage {
3070
+ export declare class LiveServerMessage {
2890
3071
  /** Sent in response to a `LiveClientSetup` message from the client. */
2891
3072
  setupComplete?: LiveServerSetupComplete;
2892
3073
  /** Content generated by the model in response to client messages. */
@@ -2901,6 +3082,23 @@ export declare interface LiveServerMessage {
2901
3082
  goAway?: LiveServerGoAway;
2902
3083
  /** Update of the session resumption state. */
2903
3084
  sessionResumptionUpdate?: LiveServerSessionResumptionUpdate;
3085
+ /**
3086
+ * Returns the concatenation of all text parts from the server content if present.
3087
+ *
3088
+ * @remarks
3089
+ * If there are non-text parts in the response, the concatenation of all text
3090
+ * parts will be returned, and a warning will be logged.
3091
+ */
3092
+ get text(): string | undefined;
3093
+ /**
3094
+ * Returns the concatenation of all inline data parts from the server content if present.
3095
+ *
3096
+ * @remarks
3097
+ * If there are non-inline data parts in the
3098
+ * response, the concatenation of all inline data parts will be returned, and
3099
+ * a warning will be logged.
3100
+ */
3101
+ get data(): string | undefined;
2904
3102
  }
2905
3103
 
2906
3104
  /** Update of the session resumption state.
@@ -3182,6 +3380,7 @@ export declare class Models extends BaseModule {
3182
3380
  * ```
3183
3381
  */
3184
3382
  generateImages: (params: types.GenerateImagesParameters) => Promise<types.GenerateImagesResponse>;
3383
+ list: (params?: types.ListModelsParameters) => Promise<Pager<types.Model>>;
3185
3384
  private generateContentInternal;
3186
3385
  private generateContentStreamInternal;
3187
3386
  /**
@@ -3235,6 +3434,7 @@ export declare class Models extends BaseModule {
3235
3434
  * ```
3236
3435
  */
3237
3436
  get(params: types.GetModelParameters): Promise<types.Model>;
3437
+ private listInternal;
3238
3438
  /**
3239
3439
  * Updates a tuned model by its name.
3240
3440
  *
@@ -3677,6 +3877,13 @@ export declare interface Retrieval {
3677
3877
  vertexRagStore?: VertexRagStore;
3678
3878
  }
3679
3879
 
3880
+ /** Retrieval config.
3881
+ */
3882
+ export declare interface RetrievalConfig {
3883
+ /** Optional. The location of the user. */
3884
+ latLng?: LatLng;
3885
+ }
3886
+
3680
3887
  /** Metadata related to retrieval in the grounding flow. */
3681
3888
  export declare interface RetrievalMetadata {
3682
3889
  /** 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. */
@@ -4208,6 +4415,12 @@ export declare interface Tool {
4208
4415
  googleSearch?: GoogleSearch;
4209
4416
  /** Optional. GoogleSearchRetrieval tool type. Specialized retrieval tool that is powered by Google search. */
4210
4417
  googleSearchRetrieval?: GoogleSearchRetrieval;
4418
+ /** Optional. Enterprise web search tool type. Specialized retrieval
4419
+ tool that is powered by Vertex AI Search and Sec4 compliance. */
4420
+ enterpriseWebSearch?: EnterpriseWebSearch;
4421
+ /** Optional. Google Maps tool type. Specialized retrieval tool
4422
+ that is powered by Google Maps. */
4423
+ googleMaps?: GoogleMaps;
4211
4424
  /** 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. */
4212
4425
  codeExecution?: ToolCodeExecution;
4213
4426
  /** 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. */
@@ -4225,6 +4438,8 @@ export declare interface ToolCodeExecution {
4225
4438
  export declare interface ToolConfig {
4226
4439
  /** Optional. Function calling config. */
4227
4440
  functionCallingConfig?: FunctionCallingConfig;
4441
+ /** Optional. Retrieval config. */
4442
+ retrievalConfig?: RetrievalConfig;
4228
4443
  }
4229
4444
 
4230
4445
  export declare type ToolListUnion = Tool[];
@@ -4407,6 +4622,7 @@ declare namespace types {
4407
4622
  HarmBlockMethod,
4408
4623
  HarmBlockThreshold,
4409
4624
  Mode,
4625
+ AuthType,
4410
4626
  Type,
4411
4627
  FinishReason,
4412
4628
  HarmProbability,
@@ -4448,6 +4664,14 @@ declare namespace types {
4448
4664
  GoogleSearch,
4449
4665
  DynamicRetrievalConfig,
4450
4666
  GoogleSearchRetrieval,
4667
+ EnterpriseWebSearch,
4668
+ ApiKeyConfig,
4669
+ AuthConfigGoogleServiceAccountConfig,
4670
+ AuthConfigHttpBasicAuthConfig,
4671
+ AuthConfigOauthConfig,
4672
+ AuthConfigOidcConfig,
4673
+ AuthConfig,
4674
+ GoogleMaps,
4451
4675
  VertexAISearch,
4452
4676
  VertexRagStoreRagResource,
4453
4677
  RagRetrievalConfigFilter,
@@ -4463,6 +4687,8 @@ declare namespace types {
4463
4687
  FunctionDeclaration,
4464
4688
  Tool,
4465
4689
  FunctionCallingConfig,
4690
+ LatLng,
4691
+ RetrievalConfig,
4466
4692
  ToolConfig,
4467
4693
  PrebuiltVoiceConfig,
4468
4694
  VoiceConfig,
@@ -4510,6 +4736,9 @@ declare namespace types {
4510
4736
  Endpoint,
4511
4737
  TunedModelInfo,
4512
4738
  Model,
4739
+ ListModelsConfig,
4740
+ ListModelsParameters,
4741
+ ListModelsResponse,
4513
4742
  UpdateModelConfig,
4514
4743
  UpdateModelParameters,
4515
4744
  DeleteModelConfig,
@@ -4599,6 +4828,7 @@ declare namespace types {
4599
4828
  ReplayFile,
4600
4829
  UploadFileConfig,
4601
4830
  DownloadFileConfig,
4831
+ DownloadFileParameters,
4602
4832
  UpscaleImageConfig,
4603
4833
  UpscaleImageParameters,
4604
4834
  RawReferenceImage,
@@ -4647,7 +4877,8 @@ declare namespace types {
4647
4877
  ContentListUnion,
4648
4878
  SchemaUnion,
4649
4879
  SpeechConfigUnion,
4650
- ToolListUnion
4880
+ ToolListUnion,
4881
+ DownloadableFileUnion
4651
4882
  }
4652
4883
  }
4653
4884