@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/genai.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.
@@ -3729,6 +3734,7 @@ export declare class GoogleGenAI {
3729
3734
  private readonly apiKey?;
3730
3735
  readonly vertexai: boolean;
3731
3736
  private readonly apiVersion?;
3737
+ private readonly httpOptions?;
3732
3738
  readonly models: Models;
3733
3739
  readonly live: Live;
3734
3740
  readonly batches: Batches;
@@ -4237,6 +4243,12 @@ export declare interface ImageConfig {
4237
4243
  values are `1K`, `2K`, `4K`. If not specified, the model will use default
4238
4244
  value `1K`. */
4239
4245
  imageSize?: string;
4246
+ /** MIME type of the generated image. This field is not
4247
+ supported in Gemini API. */
4248
+ outputMimeType?: string;
4249
+ /** Compression quality of the generated image (for
4250
+ ``image/jpeg`` only). This field is not supported in Gemini API. */
4251
+ outputCompressionQuality?: number;
4240
4252
  }
4241
4253
 
4242
4254
  /** Enum that specifies the language of the text in the prompt. */
@@ -6271,16 +6283,17 @@ export declare class Pager<T> implements AsyncIterable<T> {
6271
6283
  of content being conveyed. Using multiple fields within the same `Part`
6272
6284
  instance is considered invalid. */
6273
6285
  export declare interface Part {
6274
- /** A predicted [FunctionCall] returned from the model that contains a string
6275
- representing the [FunctionDeclaration.name] and a structured JSON object
6276
- containing the parameters and their values. */
6277
- functionCall?: FunctionCall;
6286
+ /** Media resolution for the input media.
6287
+ */
6288
+ mediaResolution?: PartMediaResolution;
6278
6289
  /** Optional. Result of executing the [ExecutableCode]. */
6279
6290
  codeExecutionResult?: CodeExecutionResult;
6280
6291
  /** Optional. Code generated by the model that is meant to be executed. */
6281
6292
  executableCode?: ExecutableCode;
6282
6293
  /** Optional. URI based data. */
6283
6294
  fileData?: FileData;
6295
+ /** Optional. A predicted [FunctionCall] returned from the model that contains a string representing the [FunctionDeclaration.name] with the parameters and their values. */
6296
+ functionCall?: FunctionCall;
6284
6297
  /** 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. */
6285
6298
  functionResponse?: FunctionResponse;
6286
6299
  /** Optional. Inlined bytes data. */
@@ -6296,8 +6309,54 @@ export declare interface Part {
6296
6309
  videoMetadata?: VideoMetadata;
6297
6310
  }
6298
6311
 
6312
+ /** Partial argument value of the function call. This data type is not supported in Gemini API. */
6313
+ export declare interface PartialArg {
6314
+ /** Optional. Represents a null value. */
6315
+ nullValue?: 'NULL_VALUE';
6316
+ /** Optional. Represents a double value. */
6317
+ numberValue?: number;
6318
+ /** Optional. Represents a string value. */
6319
+ stringValue?: string;
6320
+ /** Optional. Represents a boolean value. */
6321
+ boolValue?: boolean;
6322
+ /** Required. A JSON Path (RFC 9535) to the argument being streamed. https://datatracker.ietf.org/doc/html/rfc9535. e.g. "$.foo.bar[0].data". */
6323
+ jsonPath?: string;
6324
+ /** 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. */
6325
+ willContinue?: boolean;
6326
+ }
6327
+
6299
6328
  export declare type PartListUnion = PartUnion[] | PartUnion;
6300
6329
 
6330
+ /** Media resolution for the input media. */
6331
+ export declare interface PartMediaResolution {
6332
+ /** The tokenization quality used for given media.
6333
+ */
6334
+ level?: PartMediaResolutionLevel;
6335
+ /** Specifies the required sequence length for media tokenization.
6336
+ */
6337
+ numTokens?: number;
6338
+ }
6339
+
6340
+ /** The tokenization quality used for given media. */
6341
+ export declare enum PartMediaResolutionLevel {
6342
+ /**
6343
+ * Media resolution has not been set.
6344
+ */
6345
+ MEDIA_RESOLUTION_UNSPECIFIED = "MEDIA_RESOLUTION_UNSPECIFIED",
6346
+ /**
6347
+ * Media resolution set to low.
6348
+ */
6349
+ MEDIA_RESOLUTION_LOW = "MEDIA_RESOLUTION_LOW",
6350
+ /**
6351
+ * Media resolution set to medium.
6352
+ */
6353
+ MEDIA_RESOLUTION_MEDIUM = "MEDIA_RESOLUTION_MEDIUM",
6354
+ /**
6355
+ * Media resolution set to high.
6356
+ */
6357
+ MEDIA_RESOLUTION_HIGH = "MEDIA_RESOLUTION_HIGH"
6358
+ }
6359
+
6301
6360
  /** Tuning spec for Partner models. This data type is not supported in Gemini API. */
6302
6361
  export declare interface PartnerModelTuningSpec {
6303
6362
  /** Hyperparameters for tuning. The accepted hyper_parameters and their valid range of values will differ depending on the base model. */
@@ -7347,6 +7406,24 @@ export declare interface ThinkingConfig {
7347
7406
  /** Indicates the thinking budget in tokens. 0 is DISABLED. -1 is AUTOMATIC. The default values and allowed ranges are model dependent.
7348
7407
  */
7349
7408
  thinkingBudget?: number;
7409
+ /** Optional. The level of thoughts tokens that the model should generate. */
7410
+ thinkingLevel?: ThinkingLevel;
7411
+ }
7412
+
7413
+ /** The level of thoughts tokens that the model should generate. */
7414
+ export declare enum ThinkingLevel {
7415
+ /**
7416
+ * Default value.
7417
+ */
7418
+ THINKING_LEVEL_UNSPECIFIED = "THINKING_LEVEL_UNSPECIFIED",
7419
+ /**
7420
+ * Low thinking level.
7421
+ */
7422
+ LOW = "LOW",
7423
+ /**
7424
+ * High thinking level.
7425
+ */
7426
+ HIGH = "HIGH"
7350
7427
  }
7351
7428
 
7352
7429
  export declare class Tokens extends BaseModule {
@@ -7693,25 +7770,30 @@ declare class Tunings extends BaseModule {
7693
7770
  private readonly apiClient;
7694
7771
  constructor(apiClient: ApiClient);
7695
7772
  /**
7696
- * Gets a TuningJob.
7773
+ * Lists tuning jobs.
7697
7774
  *
7698
- * @param name - The resource name of the tuning job.
7699
- * @return - A TuningJob object.
7775
+ * @param params - The parameters for the list request.
7776
+ * @return - A pager of tuning jobs.
7700
7777
  *
7701
- * @experimental - The SDK's tuning implementation is experimental, and may
7702
- * change in future versions.
7778
+ * @example
7779
+ * ```ts
7780
+ * const tuningJobs = await ai.tunings.list({config: {'pageSize': 2}});
7781
+ * for await (const tuningJob of tuningJobs) {
7782
+ * console.log(tuningJob);
7783
+ * }
7784
+ * ```
7703
7785
  */
7704
- get: (params: types.GetTuningJobParameters) => Promise<types.TuningJob>;
7786
+ list: (params?: types.ListTuningJobsParameters) => Promise<Pager<types.TuningJob>>;
7705
7787
  /**
7706
- * Lists tuning jobs.
7788
+ * Gets a TuningJob.
7707
7789
  *
7708
- * @param config - The configuration for the list request.
7709
- * @return - A list of tuning jobs.
7790
+ * @param name - The resource name of the tuning job.
7791
+ * @return - A TuningJob object.
7710
7792
  *
7711
7793
  * @experimental - The SDK's tuning implementation is experimental, and may
7712
7794
  * change in future versions.
7713
7795
  */
7714
- list: (params?: types.ListTuningJobsParameters) => Promise<Pager<types.TuningJob>>;
7796
+ get: (params: types.GetTuningJobParameters) => Promise<types.TuningJob>;
7715
7797
  /**
7716
7798
  * Creates a supervised fine-tuning job.
7717
7799
  *
@@ -7735,7 +7817,7 @@ declare class Tunings extends BaseModule {
7735
7817
  * await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
7736
7818
  * ```
7737
7819
  */
7738
- cancel(params: types.CancelTuningJobParameters): Promise<void>;
7820
+ cancel(params: types.CancelTuningJobParameters): Promise<types.CancelTuningJobResponse>;
7739
7821
  private tuneInternal;
7740
7822
  private tuneMldevInternal;
7741
7823
  }
@@ -7861,6 +7943,7 @@ declare namespace types {
7861
7943
  AuthType,
7862
7944
  HttpElementLocation,
7863
7945
  PhishBlockThreshold,
7946
+ ThinkingLevel,
7864
7947
  HarmCategory,
7865
7948
  HarmBlockMethod,
7866
7949
  HarmBlockThreshold,
@@ -7876,6 +7959,7 @@ declare namespace types {
7876
7959
  AdapterSize,
7877
7960
  JobState,
7878
7961
  TuningTask,
7962
+ PartMediaResolutionLevel,
7879
7963
  FeatureSelectionPreference,
7880
7964
  Behavior,
7881
7965
  DynamicRetrievalConfigMode,
@@ -7905,10 +7989,12 @@ declare namespace types {
7905
7989
  Scale,
7906
7990
  MusicGenerationMode,
7907
7991
  LiveMusicPlaybackControl,
7908
- FunctionCall,
7992
+ PartMediaResolution,
7909
7993
  CodeExecutionResult,
7910
7994
  ExecutableCode,
7911
7995
  FileData,
7996
+ PartialArg,
7997
+ FunctionCall,
7912
7998
  FunctionResponseBlob,
7913
7999
  FunctionResponseFileData,
7914
8000
  FunctionResponsePart,
@@ -8099,6 +8185,7 @@ declare namespace types {
8099
8185
  ListTuningJobsResponse,
8100
8186
  CancelTuningJobConfig,
8101
8187
  CancelTuningJobParameters,
8188
+ CancelTuningJobResponse,
8102
8189
  TuningExample,
8103
8190
  TuningDataset,
8104
8191
  TuningValidationDataset,