@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.
package/dist/web/web.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
  /**
@@ -2179,6 +2312,12 @@ export declare interface GoogleGenAIOptions {
2179
2312
  httpOptions?: HttpOptions;
2180
2313
  }
2181
2314
 
2315
+ /** Tool to support Google Maps in Model. */
2316
+ export declare interface GoogleMaps {
2317
+ /** Optional. Auth config for the Google Maps tool. */
2318
+ authConfig?: AuthConfig;
2319
+ }
2320
+
2182
2321
  /** 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). */
2183
2322
  export declare interface GoogleRpcStatus {
2184
2323
  /** The status code, which should be an enum value of google.rpc.Code. */
@@ -2427,6 +2566,20 @@ export declare enum Language {
2427
2566
  PYTHON = "PYTHON"
2428
2567
  }
2429
2568
 
2569
+ /** An object that represents a latitude/longitude pair.
2570
+
2571
+ This is expressed as a pair of doubles to represent degrees latitude and
2572
+ degrees longitude. Unless specified otherwise, this object must conform to the
2573
+ <a href="https://en.wikipedia.org/wiki/World_Geodetic_System#1984_version">
2574
+ WGS84 standard</a>. Values must be within normalized ranges.
2575
+ */
2576
+ export declare interface LatLng {
2577
+ /** The latitude in degrees. It must be in the range [-90.0, +90.0]. */
2578
+ latitude?: number;
2579
+ /** The longitude in degrees. It must be in the range [-180.0, +180.0] */
2580
+ longitude?: number;
2581
+ }
2582
+
2430
2583
  /** Config for caches.list method. */
2431
2584
  export declare interface ListCachedContentsConfig {
2432
2585
  /** Used to override HTTP request options. */
@@ -2485,6 +2638,32 @@ export declare class ListFilesResponse {
2485
2638
  files?: File_2[];
2486
2639
  }
2487
2640
 
2641
+ export declare interface ListModelsConfig {
2642
+ /** Used to override HTTP request options. */
2643
+ httpOptions?: HttpOptions;
2644
+ /** Abort signal which can be used to cancel the request.
2645
+
2646
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
2647
+ operation will not cancel the request in the service. You will still
2648
+ be charged usage for any applicable operations.
2649
+ */
2650
+ abortSignal?: AbortSignal;
2651
+ pageSize?: number;
2652
+ pageToken?: string;
2653
+ filter?: string;
2654
+ /** Set true to list base models, false to list tuned models. */
2655
+ queryBase?: boolean;
2656
+ }
2657
+
2658
+ export declare interface ListModelsParameters {
2659
+ config?: ListModelsConfig;
2660
+ }
2661
+
2662
+ export declare class ListModelsResponse {
2663
+ nextPageToken?: string;
2664
+ models?: Model[];
2665
+ }
2666
+
2488
2667
  /** Configuration for the list tuning jobs method. */
2489
2668
  export declare interface ListTuningJobsConfig {
2490
2669
  /** Used to override HTTP request options. */
@@ -2852,6 +3031,8 @@ export declare interface LiveServerContent {
2852
3031
  turnComplete?: boolean;
2853
3032
  /** 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. */
2854
3033
  interrupted?: boolean;
3034
+ /** Metadata returned to client when grounding is enabled. */
3035
+ groundingMetadata?: GroundingMetadata;
2855
3036
  /** If true, indicates that the model is done generating. When model is
2856
3037
  interrupted while generating there will be no generation_complete message
2857
3038
  in interrupted turn, it will go through interrupted > turn_complete.
@@ -2879,7 +3060,7 @@ export declare interface LiveServerGoAway {
2879
3060
  }
2880
3061
 
2881
3062
  /** Response message for API call. */
2882
- export declare interface LiveServerMessage {
3063
+ export declare class LiveServerMessage {
2883
3064
  /** Sent in response to a `LiveClientSetup` message from the client. */
2884
3065
  setupComplete?: LiveServerSetupComplete;
2885
3066
  /** Content generated by the model in response to client messages. */
@@ -2894,6 +3075,23 @@ export declare interface LiveServerMessage {
2894
3075
  goAway?: LiveServerGoAway;
2895
3076
  /** Update of the session resumption state. */
2896
3077
  sessionResumptionUpdate?: LiveServerSessionResumptionUpdate;
3078
+ /**
3079
+ * Returns the concatenation of all text parts from the server content if present.
3080
+ *
3081
+ * @remarks
3082
+ * If there are non-text parts in the response, the concatenation of all text
3083
+ * parts will be returned, and a warning will be logged.
3084
+ */
3085
+ get text(): string | undefined;
3086
+ /**
3087
+ * Returns the concatenation of all inline data parts from the server content if present.
3088
+ *
3089
+ * @remarks
3090
+ * If there are non-inline data parts in the
3091
+ * response, the concatenation of all inline data parts will be returned, and
3092
+ * a warning will be logged.
3093
+ */
3094
+ get data(): string | undefined;
2897
3095
  }
2898
3096
 
2899
3097
  /** Update of the session resumption state.
@@ -3175,6 +3373,7 @@ export declare class Models extends BaseModule {
3175
3373
  * ```
3176
3374
  */
3177
3375
  generateImages: (params: types.GenerateImagesParameters) => Promise<types.GenerateImagesResponse>;
3376
+ list: (params?: types.ListModelsParameters) => Promise<Pager<types.Model>>;
3178
3377
  private generateContentInternal;
3179
3378
  private generateContentStreamInternal;
3180
3379
  /**
@@ -3228,6 +3427,7 @@ export declare class Models extends BaseModule {
3228
3427
  * ```
3229
3428
  */
3230
3429
  get(params: types.GetModelParameters): Promise<types.Model>;
3430
+ private listInternal;
3231
3431
  /**
3232
3432
  * Updates a tuned model by its name.
3233
3433
  *
@@ -3670,6 +3870,13 @@ export declare interface Retrieval {
3670
3870
  vertexRagStore?: VertexRagStore;
3671
3871
  }
3672
3872
 
3873
+ /** Retrieval config.
3874
+ */
3875
+ export declare interface RetrievalConfig {
3876
+ /** Optional. The location of the user. */
3877
+ latLng?: LatLng;
3878
+ }
3879
+
3673
3880
  /** Metadata related to retrieval in the grounding flow. */
3674
3881
  export declare interface RetrievalMetadata {
3675
3882
  /** 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. */
@@ -4201,6 +4408,12 @@ export declare interface Tool {
4201
4408
  googleSearch?: GoogleSearch;
4202
4409
  /** Optional. GoogleSearchRetrieval tool type. Specialized retrieval tool that is powered by Google search. */
4203
4410
  googleSearchRetrieval?: GoogleSearchRetrieval;
4411
+ /** Optional. Enterprise web search tool type. Specialized retrieval
4412
+ tool that is powered by Vertex AI Search and Sec4 compliance. */
4413
+ enterpriseWebSearch?: EnterpriseWebSearch;
4414
+ /** Optional. Google Maps tool type. Specialized retrieval tool
4415
+ that is powered by Google Maps. */
4416
+ googleMaps?: GoogleMaps;
4204
4417
  /** 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. */
4205
4418
  codeExecution?: ToolCodeExecution;
4206
4419
  /** 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. */
@@ -4218,6 +4431,8 @@ export declare interface ToolCodeExecution {
4218
4431
  export declare interface ToolConfig {
4219
4432
  /** Optional. Function calling config. */
4220
4433
  functionCallingConfig?: FunctionCallingConfig;
4434
+ /** Optional. Retrieval config. */
4435
+ retrievalConfig?: RetrievalConfig;
4221
4436
  }
4222
4437
 
4223
4438
  export declare type ToolListUnion = Tool[];
@@ -4400,6 +4615,7 @@ declare namespace types {
4400
4615
  HarmBlockMethod,
4401
4616
  HarmBlockThreshold,
4402
4617
  Mode,
4618
+ AuthType,
4403
4619
  Type,
4404
4620
  FinishReason,
4405
4621
  HarmProbability,
@@ -4441,6 +4657,14 @@ declare namespace types {
4441
4657
  GoogleSearch,
4442
4658
  DynamicRetrievalConfig,
4443
4659
  GoogleSearchRetrieval,
4660
+ EnterpriseWebSearch,
4661
+ ApiKeyConfig,
4662
+ AuthConfigGoogleServiceAccountConfig,
4663
+ AuthConfigHttpBasicAuthConfig,
4664
+ AuthConfigOauthConfig,
4665
+ AuthConfigOidcConfig,
4666
+ AuthConfig,
4667
+ GoogleMaps,
4444
4668
  VertexAISearch,
4445
4669
  VertexRagStoreRagResource,
4446
4670
  RagRetrievalConfigFilter,
@@ -4456,6 +4680,8 @@ declare namespace types {
4456
4680
  FunctionDeclaration,
4457
4681
  Tool,
4458
4682
  FunctionCallingConfig,
4683
+ LatLng,
4684
+ RetrievalConfig,
4459
4685
  ToolConfig,
4460
4686
  PrebuiltVoiceConfig,
4461
4687
  VoiceConfig,
@@ -4503,6 +4729,9 @@ declare namespace types {
4503
4729
  Endpoint,
4504
4730
  TunedModelInfo,
4505
4731
  Model,
4732
+ ListModelsConfig,
4733
+ ListModelsParameters,
4734
+ ListModelsResponse,
4506
4735
  UpdateModelConfig,
4507
4736
  UpdateModelParameters,
4508
4737
  DeleteModelConfig,
@@ -4592,6 +4821,7 @@ declare namespace types {
4592
4821
  ReplayFile,
4593
4822
  UploadFileConfig,
4594
4823
  DownloadFileConfig,
4824
+ DownloadFileParameters,
4595
4825
  UpscaleImageConfig,
4596
4826
  UpscaleImageParameters,
4597
4827
  RawReferenceImage,
@@ -4640,7 +4870,8 @@ declare namespace types {
4640
4870
  ContentListUnion,
4641
4871
  SchemaUnion,
4642
4872
  SpeechConfigUnion,
4643
- ToolListUnion
4873
+ ToolListUnion,
4874
+ DownloadableFileUnion
4644
4875
  }
4645
4876
  }
4646
4877
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/genai",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "",
5
5
  "main": "dist/node/index.js",
6
6
  "module": "dist/web/index.mjs",