@google/genai 1.29.1 → 1.31.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
@@ -1,4 +1,3 @@
1
- // @ts-ignore
2
1
  import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
3
2
  import { GoogleAuthOptions } from 'google-auth-library';
4
3
 
@@ -437,6 +436,21 @@ export declare interface BaseUrlParameters {
437
436
  export declare class Batches extends BaseModule {
438
437
  private readonly apiClient;
439
438
  constructor(apiClient: ApiClient);
439
+ /**
440
+ * Lists batch jobs.
441
+ *
442
+ * @param params - The parameters for the list request.
443
+ * @return - A pager of batch jobs.
444
+ *
445
+ * @example
446
+ * ```ts
447
+ * const batchJobs = await ai.batches.list({config: {'pageSize': 2}});
448
+ * for await (const batchJob of batchJobs) {
449
+ * console.log(batchJob);
450
+ * }
451
+ * ```
452
+ */
453
+ list: (params?: types.ListBatchJobsParameters) => Promise<Pager<types.BatchJob>>;
440
454
  /**
441
455
  * Create batch job.
442
456
  *
@@ -472,21 +486,6 @@ export declare class Batches extends BaseModule {
472
486
  * ```
473
487
  */
474
488
  createEmbeddings: (params: types.CreateEmbeddingsBatchJobParameters) => Promise<types.BatchJob>;
475
- /**
476
- * Lists batch job configurations.
477
- *
478
- * @param params - The parameters for the list request.
479
- * @return The paginated results of the list of batch jobs.
480
- *
481
- * @example
482
- * ```ts
483
- * const batchJobs = await ai.batches.list({config: {'pageSize': 2}});
484
- * for await (const batchJob of batchJobs) {
485
- * console.log(batchJob);
486
- * }
487
- * ```
488
- */
489
- list: (params?: types.ListBatchJobsParameters) => Promise<Pager<types.BatchJob>>;
490
489
  private createInlinedGenerateContentRequest;
491
490
  private getGcsUri;
492
491
  private getBigqueryUri;
@@ -742,10 +741,10 @@ export declare class Caches extends BaseModule {
742
741
  private readonly apiClient;
743
742
  constructor(apiClient: ApiClient);
744
743
  /**
745
- * Lists cached content configurations.
744
+ * Lists cached contents.
746
745
  *
747
746
  * @param params - The parameters for the list request.
748
- * @return The paginated results of the list of cached contents.
747
+ * @return - A pager of cached contents.
749
748
  *
750
749
  * @example
751
750
  * ```ts
@@ -901,6 +900,12 @@ export declare interface CancelTuningJobParameters {
901
900
  config?: CancelTuningJobConfig;
902
901
  }
903
902
 
903
+ /** Empty response for tunings.cancel method. */
904
+ export declare class CancelTuningJobResponse {
905
+ /** Used to retain the full HTTP response. */
906
+ sdkHttpResponse?: HttpResponse;
907
+ }
908
+
904
909
  /** A response candidate generated from the model. */
905
910
  export declare interface Candidate {
906
911
  /** Contains the multi-part content of the response.
@@ -1558,7 +1563,7 @@ export declare function createModelContent(partOrString: PartListUnion | string)
1558
1563
  /**
1559
1564
  * Creates a `Part` object from a `base64` encoded `string`.
1560
1565
  */
1561
- export declare function createPartFromBase64(data: string, mimeType: string): Part;
1566
+ export declare function createPartFromBase64(data: string, mimeType: string, mediaResolution?: PartMediaResolutionLevel): Part;
1562
1567
 
1563
1568
  /**
1564
1569
  * Creates a `Part` object from the `outcome` and `output` of a `CodeExecutionResult` object.
@@ -1588,7 +1593,7 @@ export declare function createPartFromText(text: string): Part;
1588
1593
  /**
1589
1594
  * Creates a `Part` object from a `URI` string.
1590
1595
  */
1591
- export declare function createPartFromUri(uri: string, mimeType: string): Part;
1596
+ export declare function createPartFromUri(uri: string, mimeType: string, mediaResolution?: PartMediaResolutionLevel): Part;
1592
1597
 
1593
1598
  /** Fine-tuning job creation request - optional fields. */
1594
1599
  export declare interface CreateTuningJobConfig {
@@ -1923,7 +1928,7 @@ declare class Documents extends BaseModule {
1923
1928
  *
1924
1929
  * @example
1925
1930
  * ```ts
1926
- * const documents = await ai.documents.list({config: {'pageSize': 2}});
1931
+ * const documents = await ai.documents.list({parent:'rag_store_name', config: {'pageSize': 2}});
1927
1932
  * for await (const document of documents) {
1928
1933
  * console.log(document);
1929
1934
  * }
@@ -1943,12 +1948,6 @@ declare class Documents extends BaseModule {
1943
1948
  * @param params - The parameters for deleting a document.
1944
1949
  */
1945
1950
  delete(params: types.DeleteDocumentParameters): Promise<void>;
1946
- /**
1947
- * Lists all Documents in a FileSearchStore.
1948
- *
1949
- * @param params - The parameters for listing documents.
1950
- * @return ListDocumentsResponse.
1951
- */
1952
1951
  private listInternal;
1953
1952
  }
1954
1953
 
@@ -2363,19 +2362,16 @@ export declare class Files extends BaseModule {
2363
2362
  private readonly apiClient;
2364
2363
  constructor(apiClient: ApiClient);
2365
2364
  /**
2366
- * Lists all current project files from the service.
2365
+ * Lists files.
2367
2366
  *
2368
- * @param params - The parameters for the list request
2369
- * @return The paginated results of the list of files
2367
+ * @param params - The parameters for the list request.
2368
+ * @return - A pager of files.
2370
2369
  *
2371
2370
  * @example
2372
- * The following code prints the names of all files from the service, the
2373
- * size of each page is 10.
2374
- *
2375
2371
  * ```ts
2376
- * const listResponse = await ai.files.list({config: {'pageSize': 10}});
2377
- * for await (const file of listResponse) {
2378
- * console.log(file.name);
2372
+ * const files = await ai.files.list({config: {'pageSize': 2}});
2373
+ * for await (const file of files) {
2374
+ * console.log(file);
2379
2375
  * }
2380
2376
  * ```
2381
2377
  */
@@ -2511,6 +2507,21 @@ declare class FileSearchStores extends BaseModule {
2511
2507
  private readonly apiClient;
2512
2508
  readonly documents: Documents;
2513
2509
  constructor(apiClient: ApiClient, documents?: Documents);
2510
+ /**
2511
+ * Lists file search stores.
2512
+ *
2513
+ * @param params - The parameters for the list request.
2514
+ * @return - A pager of file search stores.
2515
+ *
2516
+ * @example
2517
+ * ```ts
2518
+ * const fileSearchStores = await ai.fileSearchStores.list({config: {'pageSize': 2}});
2519
+ * for await (const fileSearchStore of fileSearchStores) {
2520
+ * console.log(fileSearchStore);
2521
+ * }
2522
+ * ```
2523
+ */
2524
+ list: (params?: types.ListFileSearchStoresParameters) => Promise<Pager<types.FileSearchStore>>;
2514
2525
  /**
2515
2526
  * Uploads a file asynchronously to a given File Search Store.
2516
2527
  * This method is not available in Vertex AI.
@@ -2548,21 +2559,6 @@ declare class FileSearchStores extends BaseModule {
2548
2559
  * ```
2549
2560
  */
2550
2561
  uploadToFileSearchStore(params: types.UploadToFileSearchStoreParameters): Promise<types.UploadToFileSearchStoreOperation>;
2551
- /**
2552
- * Lists file search stores.
2553
- *
2554
- * @param params - The parameters for the list request.
2555
- * @return - A pager of file search stores.
2556
- *
2557
- * @example
2558
- * ```ts
2559
- * const fileSearchStores = await ai.fileSearchStores.list({config: {'pageSize': 2}});
2560
- * for await (const fileSearchStore of fileSearchStores) {
2561
- * console.log(fileSearchStore);
2562
- * }
2563
- * ```
2564
- */
2565
- list: (params?: types.ListFileSearchStoresParameters) => Promise<Pager<types.FileSearchStore>>;
2566
2562
  /**
2567
2563
  * Creates a File Search Store.
2568
2564
  *
@@ -2583,12 +2579,6 @@ declare class FileSearchStores extends BaseModule {
2583
2579
  * @param params - The parameters for deleting a File Search Store.
2584
2580
  */
2585
2581
  delete(params: types.DeleteFileSearchStoreParameters): Promise<void>;
2586
- /**
2587
- * Lists all FileSearchStore owned by the user.
2588
- *
2589
- * @param params - The parameters for listing file search stores.
2590
- * @return ListFileSearchStoresResponse.
2591
- */
2592
2582
  private listInternal;
2593
2583
  private uploadToFileSearchStoreInternal;
2594
2584
  /**
@@ -2719,6 +2709,10 @@ export declare interface FunctionCall {
2719
2709
  args?: Record<string, unknown>;
2720
2710
  /** Optional. The name of the function to call. Matches [FunctionDeclaration.name]. */
2721
2711
  name?: string;
2712
+ /** Optional. The partial argument value of the function call. If provided, represents the arguments/fields that are streamed incrementally. This field is not supported in Gemini API. */
2713
+ partialArgs?: PartialArg[];
2714
+ /** Optional. Whether this is the last part of the FunctionCall. If true, another partial message for the current FunctionCall is expected to follow. This field is not supported in Gemini API. */
2715
+ willContinue?: boolean;
2722
2716
  }
2723
2717
 
2724
2718
  /** Function calling config. */
@@ -2727,6 +2721,8 @@ export declare interface FunctionCallingConfig {
2727
2721
  mode?: FunctionCallingConfigMode;
2728
2722
  /** 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. */
2729
2723
  allowedFunctionNames?: string[];
2724
+ /** Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the [FunctionCall.partial_args] field. This field is not supported in Gemini API. */
2725
+ streamFunctionCallArguments?: boolean;
2730
2726
  }
2731
2727
 
2732
2728
  /** Config for the function calling config mode. */
@@ -2801,6 +2797,9 @@ export declare class FunctionResponseBlob {
2801
2797
  /** Required. Inline media bytes.
2802
2798
  * @remarks Encoded as base64 string. */
2803
2799
  data?: string;
2800
+ /** Optional. Display name of the blob.
2801
+ Used to provide a label or filename to distinguish blobs. */
2802
+ displayName?: string;
2804
2803
  }
2805
2804
 
2806
2805
  /** URI based data for function response. */
@@ -2809,6 +2808,9 @@ export declare class FunctionResponseFileData {
2809
2808
  fileUri?: string;
2810
2809
  /** Required. The IANA standard MIME type of the source data. */
2811
2810
  mimeType?: string;
2811
+ /** Optional. Display name of the file.
2812
+ Used to provide a label or filename to distinguish files. */
2813
+ displayName?: string;
2812
2814
  }
2813
2815
 
2814
2816
  /** A datatype containing media that is part of a `FunctionResponse` message.
@@ -2948,6 +2950,9 @@ export declare interface GenerateContentConfig {
2948
2950
  object](https://spec.openapis.org/oas/v3.0.3#schema).
2949
2951
  If set, a compatible response_mime_type must also be set.
2950
2952
  Compatible mimetypes: `application/json`: Schema for JSON response.
2953
+
2954
+ If `response_schema` doesn't process your schema correctly, try using
2955
+ `response_json_schema` instead.
2951
2956
  */
2952
2957
  responseSchema?: SchemaUnion;
2953
2958
  /** Optional. Output schema of the generated response.
@@ -3734,6 +3739,7 @@ export declare class GoogleGenAI {
3734
3739
  private readonly apiKey?;
3735
3740
  readonly vertexai: boolean;
3736
3741
  private readonly apiVersion?;
3742
+ private readonly httpOptions?;
3737
3743
  readonly models: Models;
3738
3744
  readonly live: Live;
3739
3745
  readonly batches: Batches;
@@ -4242,6 +4248,12 @@ export declare interface ImageConfig {
4242
4248
  values are `1K`, `2K`, `4K`. If not specified, the model will use default
4243
4249
  value `1K`. */
4244
4250
  imageSize?: string;
4251
+ /** MIME type of the generated image. This field is not
4252
+ supported in Gemini API. */
4253
+ outputMimeType?: string;
4254
+ /** Compression quality of the generated image (for
4255
+ ``image/jpeg`` only). This field is not supported in Gemini API. */
4256
+ outputCompressionQuality?: number;
4245
4257
  }
4246
4258
 
4247
4259
  /** Enum that specifies the language of the text in the prompt. */
@@ -6276,16 +6288,17 @@ export declare class Pager<T> implements AsyncIterable<T> {
6276
6288
  of content being conveyed. Using multiple fields within the same `Part`
6277
6289
  instance is considered invalid. */
6278
6290
  export declare interface Part {
6279
- /** A predicted [FunctionCall] returned from the model that contains a string
6280
- representing the [FunctionDeclaration.name] and a structured JSON object
6281
- containing the parameters and their values. */
6282
- functionCall?: FunctionCall;
6291
+ /** Media resolution for the input media.
6292
+ */
6293
+ mediaResolution?: PartMediaResolution;
6283
6294
  /** Optional. Result of executing the [ExecutableCode]. */
6284
6295
  codeExecutionResult?: CodeExecutionResult;
6285
6296
  /** Optional. Code generated by the model that is meant to be executed. */
6286
6297
  executableCode?: ExecutableCode;
6287
6298
  /** Optional. URI based data. */
6288
6299
  fileData?: FileData;
6300
+ /** Optional. A predicted [FunctionCall] returned from the model that contains a string representing the [FunctionDeclaration.name] with the parameters and their values. */
6301
+ functionCall?: FunctionCall;
6289
6302
  /** 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. */
6290
6303
  functionResponse?: FunctionResponse;
6291
6304
  /** Optional. Inlined bytes data. */
@@ -6301,8 +6314,54 @@ export declare interface Part {
6301
6314
  videoMetadata?: VideoMetadata;
6302
6315
  }
6303
6316
 
6317
+ /** Partial argument value of the function call. This data type is not supported in Gemini API. */
6318
+ export declare interface PartialArg {
6319
+ /** Optional. Represents a null value. */
6320
+ nullValue?: 'NULL_VALUE';
6321
+ /** Optional. Represents a double value. */
6322
+ numberValue?: number;
6323
+ /** Optional. Represents a string value. */
6324
+ stringValue?: string;
6325
+ /** Optional. Represents a boolean value. */
6326
+ boolValue?: boolean;
6327
+ /** Required. A JSON Path (RFC 9535) to the argument being streamed. https://datatracker.ietf.org/doc/html/rfc9535. e.g. "$.foo.bar[0].data". */
6328
+ jsonPath?: string;
6329
+ /** Optional. Whether this is not the last part of the same json_path. If true, another PartialArg message for the current json_path is expected to follow. */
6330
+ willContinue?: boolean;
6331
+ }
6332
+
6304
6333
  export declare type PartListUnion = PartUnion[] | PartUnion;
6305
6334
 
6335
+ /** Media resolution for the input media. */
6336
+ export declare interface PartMediaResolution {
6337
+ /** The tokenization quality used for given media.
6338
+ */
6339
+ level?: PartMediaResolutionLevel;
6340
+ /** Specifies the required sequence length for media tokenization.
6341
+ */
6342
+ numTokens?: number;
6343
+ }
6344
+
6345
+ /** The tokenization quality used for given media. */
6346
+ export declare enum PartMediaResolutionLevel {
6347
+ /**
6348
+ * Media resolution has not been set.
6349
+ */
6350
+ MEDIA_RESOLUTION_UNSPECIFIED = "MEDIA_RESOLUTION_UNSPECIFIED",
6351
+ /**
6352
+ * Media resolution set to low.
6353
+ */
6354
+ MEDIA_RESOLUTION_LOW = "MEDIA_RESOLUTION_LOW",
6355
+ /**
6356
+ * Media resolution set to medium.
6357
+ */
6358
+ MEDIA_RESOLUTION_MEDIUM = "MEDIA_RESOLUTION_MEDIUM",
6359
+ /**
6360
+ * Media resolution set to high.
6361
+ */
6362
+ MEDIA_RESOLUTION_HIGH = "MEDIA_RESOLUTION_HIGH"
6363
+ }
6364
+
6306
6365
  /** Tuning spec for Partner models. This data type is not supported in Gemini API. */
6307
6366
  export declare interface PartnerModelTuningSpec {
6308
6367
  /** Hyperparameters for tuning. The accepted hyper_parameters and their valid range of values will differ depending on the base model. */
@@ -7352,6 +7411,24 @@ export declare interface ThinkingConfig {
7352
7411
  /** Indicates the thinking budget in tokens. 0 is DISABLED. -1 is AUTOMATIC. The default values and allowed ranges are model dependent.
7353
7412
  */
7354
7413
  thinkingBudget?: number;
7414
+ /** Optional. The level of thoughts tokens that the model should generate. */
7415
+ thinkingLevel?: ThinkingLevel;
7416
+ }
7417
+
7418
+ /** The level of thoughts tokens that the model should generate. */
7419
+ export declare enum ThinkingLevel {
7420
+ /**
7421
+ * Default value.
7422
+ */
7423
+ THINKING_LEVEL_UNSPECIFIED = "THINKING_LEVEL_UNSPECIFIED",
7424
+ /**
7425
+ * Low thinking level.
7426
+ */
7427
+ LOW = "LOW",
7428
+ /**
7429
+ * High thinking level.
7430
+ */
7431
+ HIGH = "HIGH"
7355
7432
  }
7356
7433
 
7357
7434
  export declare class Tokens extends BaseModule {
@@ -7698,25 +7775,30 @@ declare class Tunings extends BaseModule {
7698
7775
  private readonly apiClient;
7699
7776
  constructor(apiClient: ApiClient);
7700
7777
  /**
7701
- * Gets a TuningJob.
7778
+ * Lists tuning jobs.
7702
7779
  *
7703
- * @param name - The resource name of the tuning job.
7704
- * @return - A TuningJob object.
7780
+ * @param params - The parameters for the list request.
7781
+ * @return - A pager of tuning jobs.
7705
7782
  *
7706
- * @experimental - The SDK's tuning implementation is experimental, and may
7707
- * change in future versions.
7783
+ * @example
7784
+ * ```ts
7785
+ * const tuningJobs = await ai.tunings.list({config: {'pageSize': 2}});
7786
+ * for await (const tuningJob of tuningJobs) {
7787
+ * console.log(tuningJob);
7788
+ * }
7789
+ * ```
7708
7790
  */
7709
- get: (params: types.GetTuningJobParameters) => Promise<types.TuningJob>;
7791
+ list: (params?: types.ListTuningJobsParameters) => Promise<Pager<types.TuningJob>>;
7710
7792
  /**
7711
- * Lists tuning jobs.
7793
+ * Gets a TuningJob.
7712
7794
  *
7713
- * @param config - The configuration for the list request.
7714
- * @return - A list of tuning jobs.
7795
+ * @param name - The resource name of the tuning job.
7796
+ * @return - A TuningJob object.
7715
7797
  *
7716
7798
  * @experimental - The SDK's tuning implementation is experimental, and may
7717
7799
  * change in future versions.
7718
7800
  */
7719
- list: (params?: types.ListTuningJobsParameters) => Promise<Pager<types.TuningJob>>;
7801
+ get: (params: types.GetTuningJobParameters) => Promise<types.TuningJob>;
7720
7802
  /**
7721
7803
  * Creates a supervised fine-tuning job.
7722
7804
  *
@@ -7740,7 +7822,7 @@ declare class Tunings extends BaseModule {
7740
7822
  * await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
7741
7823
  * ```
7742
7824
  */
7743
- cancel(params: types.CancelTuningJobParameters): Promise<void>;
7825
+ cancel(params: types.CancelTuningJobParameters): Promise<types.CancelTuningJobResponse>;
7744
7826
  private tuneInternal;
7745
7827
  private tuneMldevInternal;
7746
7828
  }
@@ -7866,6 +7948,7 @@ declare namespace types {
7866
7948
  AuthType,
7867
7949
  HttpElementLocation,
7868
7950
  PhishBlockThreshold,
7951
+ ThinkingLevel,
7869
7952
  HarmCategory,
7870
7953
  HarmBlockMethod,
7871
7954
  HarmBlockThreshold,
@@ -7881,6 +7964,7 @@ declare namespace types {
7881
7964
  AdapterSize,
7882
7965
  JobState,
7883
7966
  TuningTask,
7967
+ PartMediaResolutionLevel,
7884
7968
  FeatureSelectionPreference,
7885
7969
  Behavior,
7886
7970
  DynamicRetrievalConfigMode,
@@ -7910,10 +7994,12 @@ declare namespace types {
7910
7994
  Scale,
7911
7995
  MusicGenerationMode,
7912
7996
  LiveMusicPlaybackControl,
7913
- FunctionCall,
7997
+ PartMediaResolution,
7914
7998
  CodeExecutionResult,
7915
7999
  ExecutableCode,
7916
8000
  FileData,
8001
+ PartialArg,
8002
+ FunctionCall,
7917
8003
  FunctionResponseBlob,
7918
8004
  FunctionResponseFileData,
7919
8005
  FunctionResponsePart,
@@ -8104,6 +8190,7 @@ declare namespace types {
8104
8190
  ListTuningJobsResponse,
8105
8191
  CancelTuningJobConfig,
8106
8192
  CancelTuningJobParameters,
8193
+ CancelTuningJobResponse,
8107
8194
  TuningExample,
8108
8195
  TuningDataset,
8109
8196
  TuningValidationDataset,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/genai",
3
- "version": "1.29.1",
3
+ "version": "1.31.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/node/index.mjs",
@@ -37,7 +37,7 @@
37
37
  }
38
38
  },
39
39
  "scripts": {
40
- "prepare": "npm run build-prod",
40
+ "prepare": "node scripts/prepare.js",
41
41
  "build": "patch-package && rollup -c && npm-run-all --parallel api-extractor:dev:* && node scripts/ignore_missing_mcp_dep.js",
42
42
  "build-prod": "patch-package && rollup -c && npm-run-all --parallel api-extractor:prod:* && node scripts/ignore_missing_mcp_dep.js",
43
43
  "api-extractor:dev:main": "api-extractor run --local --verbose",