@google/genai 1.6.0 → 1.7.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
@@ -384,6 +384,162 @@ export declare interface BaseUrlParameters {
384
384
  vertexUrl?: string;
385
385
  }
386
386
 
387
+ export declare class Batches extends BaseModule {
388
+ private readonly apiClient;
389
+ constructor(apiClient: ApiClient);
390
+ /**
391
+ * Create batch job.
392
+ *
393
+ * @param params - The parameters for create batch job request.
394
+ * @return The created batch job.
395
+ *
396
+ * @example
397
+ * ```ts
398
+ * const response = await ai.batches.create({
399
+ * model: 'gemini-2.0-flash',
400
+ * src: {gcsUri: 'gs://bucket/path/to/file.jsonl', format: 'jsonl'},
401
+ * config: {
402
+ * dest: {gcsUri: 'gs://bucket/path/output/directory', format: 'jsonl'},
403
+ * }
404
+ * });
405
+ * console.log(response);
406
+ * ```
407
+ */
408
+ create: (params: types.CreateBatchJobParameters) => Promise<types.BatchJob>;
409
+ /**
410
+ * Lists batch job configurations.
411
+ *
412
+ * @param params - The parameters for the list request.
413
+ * @return The paginated results of the list of batch jobs.
414
+ *
415
+ * @example
416
+ * ```ts
417
+ * const batchJobs = await ai.batches.list({config: {'pageSize': 2}});
418
+ * for await (const batchJob of batchJobs) {
419
+ * console.log(batchJob);
420
+ * }
421
+ * ```
422
+ */
423
+ list: (params?: types.ListBatchJobsParameters) => Promise<Pager<types.BatchJob>>;
424
+ /**
425
+ * Internal method to create batch job.
426
+ *
427
+ * @param params - The parameters for create batch job request.
428
+ * @return The created batch job.
429
+ *
430
+ */
431
+ private createInternal;
432
+ /**
433
+ * Gets batch job configurations.
434
+ *
435
+ * @param params - The parameters for the get request.
436
+ * @return The batch job.
437
+ *
438
+ * @example
439
+ * ```ts
440
+ * await ai.batches.get({name: '...'}); // The server-generated resource name.
441
+ * ```
442
+ */
443
+ get(params: types.GetBatchJobParameters): Promise<types.BatchJob>;
444
+ /**
445
+ * Cancels a batch job.
446
+ *
447
+ * @param params - The parameters for the cancel request.
448
+ * @return The empty response returned by the API.
449
+ *
450
+ * @example
451
+ * ```ts
452
+ * await ai.batches.cancel({name: '...'}); // The server-generated resource name.
453
+ * ```
454
+ */
455
+ cancel(params: types.CancelBatchJobParameters): Promise<void>;
456
+ private listInternal;
457
+ }
458
+
459
+ /** Config for batches.create return value. */
460
+ export declare interface BatchJob {
461
+ /** The resource name of the BatchJob. Output only.".
462
+ */
463
+ name?: string;
464
+ /** The display name of the BatchJob.
465
+ */
466
+ displayName?: string;
467
+ /** The state of the BatchJob.
468
+ */
469
+ state?: JobState;
470
+ /** Output only. Only populated when the job's state is JOB_STATE_FAILED or JOB_STATE_CANCELLED. */
471
+ error?: JobError;
472
+ /** The time when the BatchJob was created.
473
+ */
474
+ createTime?: string;
475
+ /** Output only. Time when the Job for the first time entered the `JOB_STATE_RUNNING` state. */
476
+ startTime?: string;
477
+ /** The time when the BatchJob was completed.
478
+ */
479
+ endTime?: string;
480
+ /** The time when the BatchJob was last updated.
481
+ */
482
+ updateTime?: string;
483
+ /** The name of the model that produces the predictions via the BatchJob.
484
+ */
485
+ model?: string;
486
+ /** Configuration for the input data.
487
+ */
488
+ src?: BatchJobSource;
489
+ /** Configuration for the output data.
490
+ */
491
+ dest?: BatchJobDestination;
492
+ }
493
+
494
+ /** Config for `des` parameter. */
495
+ export declare interface BatchJobDestination {
496
+ /** Storage format of the output files. Must be one of:
497
+ 'jsonl', 'bigquery'.
498
+ */
499
+ format?: string;
500
+ /** The Google Cloud Storage URI to the output file.
501
+ */
502
+ gcsUri?: string;
503
+ /** The BigQuery URI to the output table.
504
+ */
505
+ bigqueryUri?: string;
506
+ /** The Gemini Developer API's file resource name of the output data
507
+ (e.g. "files/12345"). The file will be a JSONL file with a single response
508
+ per line. The responses will be GenerateContentResponse messages formatted
509
+ as JSON. The responses will be written in the same order as the input
510
+ requests.
511
+ */
512
+ fileName?: string;
513
+ /** The responses to the requests in the batch. Returned when the batch was
514
+ built using inlined requests. The responses will be in the same order as
515
+ the input requests.
516
+ */
517
+ inlinedResponses?: InlinedResponse[];
518
+ }
519
+
520
+ /** Config for `src` parameter. */
521
+ export declare interface BatchJobSource {
522
+ /** Storage format of the input files. Must be one of:
523
+ 'jsonl', 'bigquery'.
524
+ */
525
+ format?: string;
526
+ /** The Google Cloud Storage URIs to input files.
527
+ */
528
+ gcsUri?: string[];
529
+ /** The BigQuery URI to input table.
530
+ */
531
+ bigqueryUri?: string;
532
+ /** The Gemini Developer API's file resource name of the input data
533
+ (e.g. "files/12345").
534
+ */
535
+ fileName?: string;
536
+ /** The Gemini Developer API's inlined input data to run batch job.
537
+ */
538
+ inlinedRequests?: InlinedRequest[];
539
+ }
540
+
541
+ export declare type BatchJobSourceUnion = BatchJobSource | InlinedRequest[] | string;
542
+
387
543
  /** Defines the function behavior. Defaults to `BLOCKING`. */
388
544
  export declare enum Behavior {
389
545
  /**
@@ -587,6 +743,30 @@ export declare interface CallableToolConfig {
587
743
  timeout?: number;
588
744
  }
589
745
 
746
+ /** Optional parameters. */
747
+ export declare interface CancelBatchJobConfig {
748
+ /** Used to override HTTP request options. */
749
+ httpOptions?: HttpOptions;
750
+ /** Abort signal which can be used to cancel the request.
751
+
752
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
753
+ operation will not cancel the request in the service. You will still
754
+ be charged usage for any applicable operations.
755
+ */
756
+ abortSignal?: AbortSignal;
757
+ }
758
+
759
+ /** Config for batches.cancel parameters. */
760
+ export declare interface CancelBatchJobParameters {
761
+ /** A fully-qualified BatchJob resource name or ID.
762
+ Example: "projects/.../locations/.../batchPredictionJobs/456"
763
+ or "456" when project and location are initialized in the client.
764
+ */
765
+ name: string;
766
+ /** Optional parameters for the request. */
767
+ config?: CancelBatchJobConfig;
768
+ }
769
+
590
770
  /** A response candidate generated from the model. */
591
771
  export declare interface Candidate {
592
772
  /** Contains the multi-part content of the response.
@@ -984,6 +1164,40 @@ export declare interface CreateAuthTokenParameters {
984
1164
  config?: CreateAuthTokenConfig;
985
1165
  }
986
1166
 
1167
+ /** Config for optional parameters. */
1168
+ export declare interface CreateBatchJobConfig {
1169
+ /** Used to override HTTP request options. */
1170
+ httpOptions?: HttpOptions;
1171
+ /** Abort signal which can be used to cancel the request.
1172
+
1173
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
1174
+ operation will not cancel the request in the service. You will still
1175
+ be charged usage for any applicable operations.
1176
+ */
1177
+ abortSignal?: AbortSignal;
1178
+ /** The user-defined name of this BatchJob.
1179
+ */
1180
+ displayName?: string;
1181
+ /** GCS or BigQuery URI prefix for the output predictions. Example:
1182
+ "gs://path/to/output/data" or "bq://projectId.bqDatasetId.bqTableId".
1183
+ */
1184
+ dest?: string;
1185
+ }
1186
+
1187
+ /** Config for batches.create parameters. */
1188
+ export declare interface CreateBatchJobParameters {
1189
+ /** The name of the model to produces the predictions via the BatchJob.
1190
+ */
1191
+ model?: string;
1192
+ /** GCS URI(-s) or BigQuery URI to your input data to run batch job.
1193
+ Example: "gs://path/to/input/data" or "bq://projectId.bqDatasetId.bqTableId".
1194
+ */
1195
+ src: BatchJobSourceUnion;
1196
+ /** Optional parameters for creating a BatchJob.
1197
+ */
1198
+ config?: CreateBatchJobConfig;
1199
+ }
1200
+
987
1201
  /** Optional configuration for cached content creation. */
988
1202
  export declare interface CreateCachedContentConfig {
989
1203
  /** Used to override HTTP request options. */
@@ -1415,7 +1629,8 @@ export declare interface EditImageConfig {
1415
1629
  /** Number of images to generate.
1416
1630
  */
1417
1631
  numberOfImages?: number;
1418
- /** Aspect ratio of the generated images.
1632
+ /** Aspect ratio of the generated images. Supported values are
1633
+ "1:1", "3:4", "4:3", "9:16", and "16:9".
1419
1634
  */
1420
1635
  aspectRatio?: string;
1421
1636
  /** Controls how much the model adheres to the text prompt. Large
@@ -2068,6 +2283,22 @@ export declare interface GenerateContentConfig {
2068
2283
  Compatible mimetypes: `application/json`: Schema for JSON response.
2069
2284
  */
2070
2285
  responseSchema?: SchemaUnion;
2286
+ /** Optional. Output schema of the generated response.
2287
+ This is an alternative to `response_schema` that accepts [JSON
2288
+ Schema](https://json-schema.org/). If set, `response_schema` must be
2289
+ omitted, but `response_mime_type` is required. While the full JSON Schema
2290
+ may be sent, not all features are supported. Specifically, only the
2291
+ following properties are supported: - `$id` - `$defs` - `$ref` - `$anchor`
2292
+ - `type` - `format` - `title` - `description` - `enum` (for strings and
2293
+ numbers) - `items` - `prefixItems` - `minItems` - `maxItems` - `minimum` -
2294
+ `maximum` - `anyOf` - `oneOf` (interpreted the same as `anyOf`) -
2295
+ `properties` - `additionalProperties` - `required` The non-standard
2296
+ `propertyOrdering` property may also be set. Cyclic references are
2297
+ unrolled to a limited degree and, as such, may only be used within
2298
+ non-required properties. (Nullable properties are not sufficient.) If
2299
+ `$ref` is set on a sub-schema, no other properties, except for than those
2300
+ starting as a `$`, may be set. */
2301
+ responseJsonSchema?: unknown;
2071
2302
  /** Configuration for model router requests.
2072
2303
  */
2073
2304
  routingConfig?: GenerationConfigRoutingConfig;
@@ -2356,7 +2587,8 @@ export declare interface GenerateImagesConfig {
2356
2587
  /** Number of images to generate.
2357
2588
  */
2358
2589
  numberOfImages?: number;
2359
- /** Aspect ratio of the generated images.
2590
+ /** Aspect ratio of the generated images. Supported values are
2591
+ "1:1", "3:4", "4:3", "9:16", and "16:9".
2360
2592
  */
2361
2593
  aspectRatio?: string;
2362
2594
  /** Controls how much the model adheres to the text prompt. Large
@@ -2461,6 +2693,8 @@ export declare interface GenerateVideosConfig {
2461
2693
  generateAudio?: boolean;
2462
2694
  /** Image to use as the last frame of generated videos. Only supported for image to video use cases. */
2463
2695
  lastFrame?: Image_2;
2696
+ /** Compression quality of the generated videos. */
2697
+ compressionQuality?: VideoCompressionQuality;
2464
2698
  }
2465
2699
 
2466
2700
  /** A video generation operation. */
@@ -2578,6 +2812,30 @@ export declare interface GenerationConfigThinkingConfig {
2578
2812
  thinkingBudget?: number;
2579
2813
  }
2580
2814
 
2815
+ /** Optional parameters. */
2816
+ export declare interface GetBatchJobConfig {
2817
+ /** Used to override HTTP request options. */
2818
+ httpOptions?: HttpOptions;
2819
+ /** Abort signal which can be used to cancel the request.
2820
+
2821
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
2822
+ operation will not cancel the request in the service. You will still
2823
+ be charged usage for any applicable operations.
2824
+ */
2825
+ abortSignal?: AbortSignal;
2826
+ }
2827
+
2828
+ /** Config for batches.get parameters. */
2829
+ export declare interface GetBatchJobParameters {
2830
+ /** A fully-qualified BatchJob resource name or ID.
2831
+ Example: "projects/.../locations/.../batchPredictionJobs/456"
2832
+ or "456" when project and location are initialized in the client.
2833
+ */
2834
+ name: string;
2835
+ /** Optional parameters for the request. */
2836
+ config?: GetBatchJobConfig;
2837
+ }
2838
+
2581
2839
  /** Optional parameters for caches.get method. */
2582
2840
  export declare interface GetCachedContentConfig {
2583
2841
  /** Used to override HTTP request options. */
@@ -2719,6 +2977,7 @@ export declare class GoogleGenAI {
2719
2977
  private readonly apiVersion?;
2720
2978
  readonly models: Models;
2721
2979
  readonly live: Live;
2980
+ readonly batches: Batches;
2722
2981
  readonly chats: Chats;
2723
2982
  readonly caches: Caches;
2724
2983
  readonly files: Files;
@@ -3106,6 +3365,29 @@ export declare enum ImagePromptLanguage {
3106
3365
  hi = "hi"
3107
3366
  }
3108
3367
 
3368
+ /** Config for inlined request. */
3369
+ export declare interface InlinedRequest {
3370
+ /** ID of the model to use. For a list of models, see `Google models
3371
+ <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
3372
+ model?: string;
3373
+ /** Content of the request.
3374
+ */
3375
+ contents?: ContentListUnion;
3376
+ /** Configuration that contains optional model parameters.
3377
+ */
3378
+ config?: GenerateContentConfig;
3379
+ }
3380
+
3381
+ /** Config for `inlined_responses` parameter. */
3382
+ export declare class InlinedResponse {
3383
+ /** The response to the request.
3384
+ */
3385
+ response?: GenerateContentResponse;
3386
+ /** The error encountered while processing the request.
3387
+ */
3388
+ error?: JobError;
3389
+ }
3390
+
3109
3391
  /** Represents a time interval, encoded as a start time (inclusive) and an end time (exclusive).
3110
3392
 
3111
3393
  The start time must be less than or equal to the end time.
@@ -3120,7 +3402,17 @@ export declare interface Interval {
3120
3402
  endTime?: string;
3121
3403
  }
3122
3404
 
3123
- /** Output only. The detailed state of the job. */
3405
+ /** Job error. */
3406
+ export declare interface JobError {
3407
+ /** A list of messages that carry the error details. There is a common set of message types for APIs to use. */
3408
+ details?: string[];
3409
+ /** The status code. */
3410
+ code?: number;
3411
+ /** A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the `details` field. */
3412
+ message?: string;
3413
+ }
3414
+
3415
+ /** Job state. */
3124
3416
  export declare enum JobState {
3125
3417
  /**
3126
3418
  * The job state is unspecified.
@@ -3163,7 +3455,7 @@ export declare enum JobState {
3163
3455
  */
3164
3456
  JOB_STATE_EXPIRED = "JOB_STATE_EXPIRED",
3165
3457
  /**
3166
- * The job is being updated. Only jobs in the `RUNNING` state can be updated. After updating, the job goes back to the `RUNNING` state.
3458
+ * The job is being updated. Only jobs in the `JOB_STATE_RUNNING` state can be updated. After updating, the job goes back to the `JOB_STATE_RUNNING` state.
3167
3459
  */
3168
3460
  JOB_STATE_UPDATING = "JOB_STATE_UPDATING",
3169
3461
  /**
@@ -3198,6 +3490,33 @@ export declare interface LatLng {
3198
3490
  longitude?: number;
3199
3491
  }
3200
3492
 
3493
+ /** Config for optional parameters. */
3494
+ export declare interface ListBatchJobsConfig {
3495
+ /** Used to override HTTP request options. */
3496
+ httpOptions?: HttpOptions;
3497
+ /** Abort signal which can be used to cancel the request.
3498
+
3499
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
3500
+ operation will not cancel the request in the service. You will still
3501
+ be charged usage for any applicable operations.
3502
+ */
3503
+ abortSignal?: AbortSignal;
3504
+ pageSize?: number;
3505
+ pageToken?: string;
3506
+ filter?: string;
3507
+ }
3508
+
3509
+ /** Config for batches.list parameters. */
3510
+ export declare interface ListBatchJobsParameters {
3511
+ config?: ListBatchJobsConfig;
3512
+ }
3513
+
3514
+ /** Config for batches.list return value. */
3515
+ export declare class ListBatchJobsResponse {
3516
+ nextPageToken?: string;
3517
+ batchJobs?: BatchJob[];
3518
+ }
3519
+
3201
3520
  /** Config for caches.list method. */
3202
3521
  export declare interface ListCachedContentsConfig {
3203
3522
  /** Used to override HTTP request options. */
@@ -4805,8 +5124,17 @@ export declare type PartUnion = Part | string;
4805
5124
 
4806
5125
  /** Enum that controls the generation of people. */
4807
5126
  export declare enum PersonGeneration {
5127
+ /**
5128
+ * Block generation of images of people.
5129
+ */
4808
5130
  DONT_ALLOW = "DONT_ALLOW",
5131
+ /**
5132
+ * Generate images of adults, but not children.
5133
+ */
4809
5134
  ALLOW_ADULT = "ALLOW_ADULT",
5135
+ /**
5136
+ * Generate images that include adults and children.
5137
+ */
4810
5138
  ALLOW_ALL = "ALLOW_ALL"
4811
5139
  }
4812
5140
 
@@ -5990,6 +6318,7 @@ declare namespace types {
5990
6318
  ControlReferenceType,
5991
6319
  SubjectReferenceType,
5992
6320
  EditMode,
6321
+ VideoCompressionQuality,
5993
6322
  FileState,
5994
6323
  FileSource,
5995
6324
  MediaModality,
@@ -6188,6 +6517,21 @@ declare namespace types {
6188
6517
  DeleteFileConfig,
6189
6518
  DeleteFileParameters,
6190
6519
  DeleteFileResponse,
6520
+ InlinedRequest,
6521
+ BatchJobSource,
6522
+ JobError,
6523
+ InlinedResponse,
6524
+ BatchJobDestination,
6525
+ CreateBatchJobConfig,
6526
+ CreateBatchJobParameters,
6527
+ BatchJob,
6528
+ GetBatchJobConfig,
6529
+ GetBatchJobParameters,
6530
+ CancelBatchJobConfig,
6531
+ CancelBatchJobParameters,
6532
+ ListBatchJobsConfig,
6533
+ ListBatchJobsParameters,
6534
+ ListBatchJobsResponse,
6191
6535
  GetOperationConfig,
6192
6536
  GetOperationParameters,
6193
6537
  FetchPredictOperationConfig,
@@ -6270,7 +6614,8 @@ declare namespace types {
6270
6614
  SpeechConfigUnion,
6271
6615
  ToolUnion,
6272
6616
  ToolListUnion,
6273
- DownloadableFileUnion
6617
+ DownloadableFileUnion,
6618
+ BatchJobSourceUnion
6274
6619
  }
6275
6620
  }
6276
6621
 
@@ -6396,6 +6741,15 @@ export declare interface UpscaleImageConfig {
6396
6741
  /** The level of compression if the ``output_mime_type`` is
6397
6742
  ``image/jpeg``. */
6398
6743
  outputCompressionQuality?: number;
6744
+ /** Whether to add an image enhancing step before upscaling.
6745
+ It is expected to suppress the noise and JPEG compression artifacts
6746
+ from the input image. */
6747
+ enhanceInputImage?: boolean;
6748
+ /** With a higher image preservation factor, the original image
6749
+ pixels are more respected. With a lower image preservation factor, the
6750
+ output image will have be more different from the input image, but
6751
+ with finer details and less noise. */
6752
+ imagePreservationFactor?: number;
6399
6753
  }
6400
6754
 
6401
6755
  /** User-facing config UpscaleImageParameters. */
@@ -6532,6 +6886,20 @@ export declare interface Video {
6532
6886
  mimeType?: string;
6533
6887
  }
6534
6888
 
6889
+ /** Enum that controls the compression quality of the generated videos. */
6890
+ export declare enum VideoCompressionQuality {
6891
+ /**
6892
+ * Optimized video compression quality. This will produce videos
6893
+ with a compressed, smaller file size.
6894
+ */
6895
+ OPTIMIZED = "OPTIMIZED",
6896
+ /**
6897
+ * Lossless video compression quality. This will produce videos
6898
+ with a larger file size.
6899
+ */
6900
+ LOSSLESS = "LOSSLESS"
6901
+ }
6902
+
6535
6903
  /** Describes how the video in the Part should be used by the model. */
6536
6904
  export declare interface VideoMetadata {
6537
6905
  /** The frame rate of the video sent to the model. If not specified, the