@google/genai 1.51.0 → 1.52.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
@@ -2595,6 +2595,10 @@ export declare interface CreateFileSearchStoreConfig {
2595
2595
  /** The human-readable display name for the file search store.
2596
2596
  */
2597
2597
  displayName?: string;
2598
+ /** The embedding model to use for the FileSearchStore.
2599
+ Format: `models/{model}`. If not specified, the default embedding model will be used.
2600
+ */
2601
+ embeddingModel?: string;
2598
2602
  }
2599
2603
 
2600
2604
  /** Config for file_search_stores.create parameters. */
@@ -3211,6 +3215,19 @@ export declare interface DownloadFileParameters {
3211
3215
  config?: DownloadFileConfig;
3212
3216
  }
3213
3217
 
3218
+ /** Used to override the default configuration. */
3219
+ export declare interface DownloadMediaConfig {
3220
+ /** Used to override HTTP request options. */
3221
+ httpOptions?: HttpOptions;
3222
+ /** Abort signal which can be used to cancel the request.
3223
+
3224
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
3225
+ operation will not cancel the request in the service. You will still
3226
+ be charged usage for any applicable operations.
3227
+ */
3228
+ abortSignal?: AbortSignal;
3229
+ }
3230
+
3214
3231
  /**
3215
3232
  * Configuration for dynamic agents.
3216
3233
  */
@@ -3945,6 +3962,8 @@ export declare interface FileSearchStore {
3945
3962
  /** The size of raw bytes ingested into the FileSearchStore. This is the
3946
3963
  total size of all the documents in the FileSearchStore. */
3947
3964
  sizeBytes?: string;
3965
+ /** The embedding model used by the FileSearchStore. */
3966
+ embeddingModel?: string;
3948
3967
  }
3949
3968
 
3950
3969
  declare class FileSearchStores extends BaseModule {
@@ -4003,6 +4022,15 @@ declare class FileSearchStores extends BaseModule {
4003
4022
  * ```
4004
4023
  */
4005
4024
  uploadToFileSearchStore(params: types.UploadToFileSearchStoreParameters): Promise<types.UploadToFileSearchStoreOperation>;
4025
+ /**
4026
+ * Downloads media using a Media ID or URI.
4027
+ * This method is only supported in the Gemini Developer client.
4028
+ *
4029
+ * @param uri - The URI or Media ID of the blob.
4030
+ * @param config - Optional configuration for the download.
4031
+ * @returns A promise that resolves to the blob data as a Uint8Array.
4032
+ */
4033
+ downloadMedia(uri: string, config?: types.DownloadMediaConfig): Promise<Uint8Array>;
4006
4034
  /**
4007
4035
  * Creates a File Search Store.
4008
4036
  *
@@ -5814,6 +5842,8 @@ export declare interface GroundingChunkRetrievedContext {
5814
5842
  fileSearchStore?: string;
5815
5843
  /** Optional. Page number of the retrieved context. This field is not supported in Vertex AI. */
5816
5844
  pageNumber?: number;
5845
+ /** Optional. Media ID. This field is not supported in Vertex AI. */
5846
+ mediaId?: string;
5817
5847
  }
5818
5848
 
5819
5849
  /** A list of string values. This data type is not supported in Vertex AI. */
@@ -11748,6 +11778,7 @@ declare namespace types {
11748
11778
  EmbedContentParameters,
11749
11779
  UploadToFileSearchStoreResponse,
11750
11780
  UploadToFileSearchStoreOperation,
11781
+ DownloadMediaConfig,
11751
11782
  BlobImageUnion,
11752
11783
  PartUnion,
11753
11784
  PartListUnion,
package/dist/index.cjs CHANGED
@@ -7370,20 +7370,25 @@ class Chat {
7370
7370
  * Copyright 2025 Google LLC
7371
7371
  * SPDX-License-Identifier: Apache-2.0
7372
7372
  */
7373
- // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
7374
- function createFileSearchStoreConfigToMldev(fromObject, parentObject) {
7373
+ function createFileSearchStoreConfigToMldev(apiClient, fromObject, parentObject) {
7375
7374
  const toObject = {};
7376
7375
  const fromDisplayName = getValueByPath(fromObject, ['displayName']);
7377
7376
  if (parentObject !== undefined && fromDisplayName != null) {
7378
7377
  setValueByPath(parentObject, ['displayName'], fromDisplayName);
7379
7378
  }
7379
+ const fromEmbeddingModel = getValueByPath(fromObject, [
7380
+ 'embeddingModel',
7381
+ ]);
7382
+ if (parentObject !== undefined && fromEmbeddingModel != null) {
7383
+ setValueByPath(parentObject, ['embeddingModel'], tModel(apiClient, fromEmbeddingModel));
7384
+ }
7380
7385
  return toObject;
7381
7386
  }
7382
- function createFileSearchStoreParametersToMldev(fromObject) {
7387
+ function createFileSearchStoreParametersToMldev(apiClient, fromObject) {
7383
7388
  const toObject = {};
7384
7389
  const fromConfig = getValueByPath(fromObject, ['config']);
7385
7390
  if (fromConfig != null) {
7386
- createFileSearchStoreConfigToMldev(fromConfig, toObject);
7391
+ createFileSearchStoreConfigToMldev(apiClient, fromConfig, toObject);
7387
7392
  }
7388
7393
  return toObject;
7389
7394
  }
@@ -7626,7 +7631,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
7626
7631
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
7627
7632
  const USER_AGENT_HEADER = 'User-Agent';
7628
7633
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
7629
- const SDK_VERSION = '1.51.0'; // x-release-please-version
7634
+ const SDK_VERSION = '1.52.0'; // x-release-please-version
7630
7635
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
7631
7636
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
7632
7637
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -9175,6 +9180,46 @@ class FileSearchStores extends BaseModule {
9175
9180
  }
9176
9181
  return this.apiClient.uploadFileToFileSearchStore(params.fileSearchStoreName, params.file, params.config);
9177
9182
  }
9183
+ /**
9184
+ * Downloads media using a Media ID or URI.
9185
+ * This method is only supported in the Gemini Developer client.
9186
+ *
9187
+ * @param uri - The URI or Media ID of the blob.
9188
+ * @param config - Optional configuration for the download.
9189
+ * @returns A promise that resolves to the blob data as a Uint8Array.
9190
+ */
9191
+ async downloadMedia(uri, config) {
9192
+ if (this.apiClient.isVertexAI()) {
9193
+ throw new Error('This method is only supported in the Gemini Developer client.');
9194
+ }
9195
+ const parsedUri = new URL(uri, 'http://dummy.com');
9196
+ let pathname = parsedUri.pathname;
9197
+ if (pathname.startsWith('/')) {
9198
+ pathname = pathname.slice(1);
9199
+ }
9200
+ if (!pathname.includes('/media/')) {
9201
+ throw new Error(`Invalid uri format: ${uri}. Expected to contain /media/`);
9202
+ }
9203
+ const queryParams = {};
9204
+ parsedUri.searchParams.forEach((value, key) => {
9205
+ queryParams[key] = value;
9206
+ });
9207
+ queryParams['alt'] = 'media';
9208
+ const httpOptions = Object.assign({}, config === null || config === void 0 ? void 0 : config.httpOptions);
9209
+ const response = await this.apiClient.request({
9210
+ path: pathname,
9211
+ httpMethod: 'GET',
9212
+ queryParams: queryParams,
9213
+ httpOptions: httpOptions,
9214
+ });
9215
+ if (response instanceof HttpResponse) {
9216
+ const arrayBuffer = await response.responseInternal.arrayBuffer();
9217
+ return new Uint8Array(arrayBuffer);
9218
+ }
9219
+ else {
9220
+ throw new Error('Unexpected response type from downloadMedia');
9221
+ }
9222
+ }
9178
9223
  /**
9179
9224
  * Creates a File Search Store.
9180
9225
  *
@@ -9190,7 +9235,7 @@ class FileSearchStores extends BaseModule {
9190
9235
  throw new Error('This method is only supported by the Gemini Developer API.');
9191
9236
  }
9192
9237
  else {
9193
- const body = createFileSearchStoreParametersToMldev(params);
9238
+ const body = createFileSearchStoreParametersToMldev(this.apiClient, params);
9194
9239
  path = formatMap('fileSearchStores', body['_url']);
9195
9240
  queryParams = body['_query'];
9196
9241
  delete body['_url'];
package/dist/index.mjs CHANGED
@@ -7368,20 +7368,25 @@ class Chat {
7368
7368
  * Copyright 2025 Google LLC
7369
7369
  * SPDX-License-Identifier: Apache-2.0
7370
7370
  */
7371
- // Code generated by the Google Gen AI SDK generator DO NOT EDIT.
7372
- function createFileSearchStoreConfigToMldev(fromObject, parentObject) {
7371
+ function createFileSearchStoreConfigToMldev(apiClient, fromObject, parentObject) {
7373
7372
  const toObject = {};
7374
7373
  const fromDisplayName = getValueByPath(fromObject, ['displayName']);
7375
7374
  if (parentObject !== undefined && fromDisplayName != null) {
7376
7375
  setValueByPath(parentObject, ['displayName'], fromDisplayName);
7377
7376
  }
7377
+ const fromEmbeddingModel = getValueByPath(fromObject, [
7378
+ 'embeddingModel',
7379
+ ]);
7380
+ if (parentObject !== undefined && fromEmbeddingModel != null) {
7381
+ setValueByPath(parentObject, ['embeddingModel'], tModel(apiClient, fromEmbeddingModel));
7382
+ }
7378
7383
  return toObject;
7379
7384
  }
7380
- function createFileSearchStoreParametersToMldev(fromObject) {
7385
+ function createFileSearchStoreParametersToMldev(apiClient, fromObject) {
7381
7386
  const toObject = {};
7382
7387
  const fromConfig = getValueByPath(fromObject, ['config']);
7383
7388
  if (fromConfig != null) {
7384
- createFileSearchStoreConfigToMldev(fromConfig, toObject);
7389
+ createFileSearchStoreConfigToMldev(apiClient, fromConfig, toObject);
7385
7390
  }
7386
7391
  return toObject;
7387
7392
  }
@@ -7624,7 +7629,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
7624
7629
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
7625
7630
  const USER_AGENT_HEADER = 'User-Agent';
7626
7631
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
7627
- const SDK_VERSION = '1.51.0'; // x-release-please-version
7632
+ const SDK_VERSION = '1.52.0'; // x-release-please-version
7628
7633
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
7629
7634
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
7630
7635
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -9173,6 +9178,46 @@ class FileSearchStores extends BaseModule {
9173
9178
  }
9174
9179
  return this.apiClient.uploadFileToFileSearchStore(params.fileSearchStoreName, params.file, params.config);
9175
9180
  }
9181
+ /**
9182
+ * Downloads media using a Media ID or URI.
9183
+ * This method is only supported in the Gemini Developer client.
9184
+ *
9185
+ * @param uri - The URI or Media ID of the blob.
9186
+ * @param config - Optional configuration for the download.
9187
+ * @returns A promise that resolves to the blob data as a Uint8Array.
9188
+ */
9189
+ async downloadMedia(uri, config) {
9190
+ if (this.apiClient.isVertexAI()) {
9191
+ throw new Error('This method is only supported in the Gemini Developer client.');
9192
+ }
9193
+ const parsedUri = new URL(uri, 'http://dummy.com');
9194
+ let pathname = parsedUri.pathname;
9195
+ if (pathname.startsWith('/')) {
9196
+ pathname = pathname.slice(1);
9197
+ }
9198
+ if (!pathname.includes('/media/')) {
9199
+ throw new Error(`Invalid uri format: ${uri}. Expected to contain /media/`);
9200
+ }
9201
+ const queryParams = {};
9202
+ parsedUri.searchParams.forEach((value, key) => {
9203
+ queryParams[key] = value;
9204
+ });
9205
+ queryParams['alt'] = 'media';
9206
+ const httpOptions = Object.assign({}, config === null || config === void 0 ? void 0 : config.httpOptions);
9207
+ const response = await this.apiClient.request({
9208
+ path: pathname,
9209
+ httpMethod: 'GET',
9210
+ queryParams: queryParams,
9211
+ httpOptions: httpOptions,
9212
+ });
9213
+ if (response instanceof HttpResponse) {
9214
+ const arrayBuffer = await response.responseInternal.arrayBuffer();
9215
+ return new Uint8Array(arrayBuffer);
9216
+ }
9217
+ else {
9218
+ throw new Error('Unexpected response type from downloadMedia');
9219
+ }
9220
+ }
9176
9221
  /**
9177
9222
  * Creates a File Search Store.
9178
9223
  *
@@ -9188,7 +9233,7 @@ class FileSearchStores extends BaseModule {
9188
9233
  throw new Error('This method is only supported by the Gemini Developer API.');
9189
9234
  }
9190
9235
  else {
9191
- const body = createFileSearchStoreParametersToMldev(params);
9236
+ const body = createFileSearchStoreParametersToMldev(this.apiClient, params);
9192
9237
  path = formatMap('fileSearchStores', body['_url']);
9193
9238
  queryParams = body['_query'];
9194
9239
  delete body['_url'];