@google/genai 1.9.0 → 1.11.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
@@ -560,6 +560,8 @@ export declare interface BatchJobDestination {
560
560
  inlinedResponses?: InlinedResponse[];
561
561
  }
562
562
 
563
+ export declare type BatchJobDestinationUnion = BatchJobDestination | string;
564
+
563
565
  /** Config for `src` parameter. */
564
566
  export declare interface BatchJobSource {
565
567
  /** Storage format of the input files. Must be one of:
@@ -1229,7 +1231,7 @@ export declare interface CreateBatchJobConfig {
1229
1231
  /** GCS or BigQuery URI prefix for the output predictions. Example:
1230
1232
  "gs://path/to/output/data" or "bq://projectId.bqDatasetId.bqTableId".
1231
1233
  */
1232
- dest?: string;
1234
+ dest?: BatchJobDestinationUnion;
1233
1235
  }
1234
1236
 
1235
1237
  /** Config for batches.create parameters. */
@@ -1745,6 +1747,9 @@ export declare interface EditImageConfig {
1745
1747
  only).
1746
1748
  */
1747
1749
  outputCompressionQuality?: number;
1750
+ /** Whether to add a watermark to the generated images.
1751
+ */
1752
+ addWatermark?: boolean;
1748
1753
  /** Describes the editing mode for the request. */
1749
1754
  editMode?: EditMode;
1750
1755
  /** The number of sampling steps. A higher value has better image
@@ -2480,6 +2485,8 @@ export declare interface GenerateContentParameters {
2480
2485
 
2481
2486
  /** Response message for PredictionService.GenerateContent. */
2482
2487
  export declare class GenerateContentResponse {
2488
+ /** Used to retain the full HTTP response. */
2489
+ sdkHttpResponse?: HttpResponse;
2483
2490
  /** Response variations returned by the model.
2484
2491
  */
2485
2492
  candidates?: Candidate[];
@@ -2748,6 +2755,10 @@ export declare interface GenerateImagesConfig {
2748
2755
  /** Whether to add a watermark to the generated images.
2749
2756
  */
2750
2757
  addWatermark?: boolean;
2758
+ /** The size of the largest dimension of the generated image.
2759
+ Supported sizes are 1K and 2K (not supported for Imagen 3 models).
2760
+ */
2761
+ imageSize?: string;
2751
2762
  /** Whether to use the prompt rewriting logic.
2752
2763
  */
2753
2764
  enhancePrompt?: boolean;
@@ -2800,7 +2811,7 @@ export declare interface GenerateVideosConfig {
2800
2811
  seed?: number;
2801
2812
  /** The aspect ratio for the generated video. 16:9 (landscape) and 9:16 (portrait) are supported. */
2802
2813
  aspectRatio?: string;
2803
- /** The resolution for the generated video. 1280x720, 1920x1080 are supported. */
2814
+ /** The resolution for the generated video. 720p and 1080p are supported. */
2804
2815
  resolution?: string;
2805
2816
  /** Whether allow to generate person videos, and restrict to specific ages. Supported values are: dont_allow, allow_adult. */
2806
2817
  personGeneration?: string;
@@ -2818,8 +2829,8 @@ export declare interface GenerateVideosConfig {
2818
2829
  compressionQuality?: VideoCompressionQuality;
2819
2830
  }
2820
2831
 
2821
- /** A video generation operation. */
2822
- export declare interface GenerateVideosOperation {
2832
+ /** A video generation long-running operation. */
2833
+ export declare class GenerateVideosOperation implements Operation<GenerateVideosResponse> {
2823
2834
  /** The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`. */
2824
2835
  name?: string;
2825
2836
  /** Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. */
@@ -2828,8 +2839,13 @@ export declare interface GenerateVideosOperation {
2828
2839
  done?: boolean;
2829
2840
  /** The error result of the operation in case of failure or cancellation. */
2830
2841
  error?: Record<string, unknown>;
2831
- /** The generated videos. */
2842
+ /** The response if the operation is successful. */
2832
2843
  response?: GenerateVideosResponse;
2844
+ /**
2845
+ * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
2846
+ * @internal
2847
+ */
2848
+ _fromAPIResponse({ apiResponse, isVertexAI, }: OperationFromAPIResponseParameters): Operation<GenerateVideosResponse>;
2833
2849
  }
2834
2850
 
2835
2851
  /** Class that represents the parameters for generating videos. */
@@ -3420,7 +3436,10 @@ export declare interface HttpOptions {
3420
3436
  headers?: Record<string, string>;
3421
3437
  /** Timeout for the request in milliseconds. */
3422
3438
  timeout?: number;
3423
- /** Extra parameters to add to the request body. */
3439
+ /** Extra parameters to add to the request body.
3440
+ The structure must match the backend API's request structure.
3441
+ - VertexAI backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest
3442
+ - GeminiAPI backend API docs: https://ai.google.dev/api/rest */
3424
3443
  extraBody?: Record<string, unknown>;
3425
3444
  }
3426
3445
 
@@ -3685,6 +3704,8 @@ export declare interface ListBatchJobsParameters {
3685
3704
 
3686
3705
  /** Config for batches.list return value. */
3687
3706
  export declare class ListBatchJobsResponse {
3707
+ /** Used to retain the full HTTP response. */
3708
+ sdkHttpResponse?: HttpResponse;
3688
3709
  nextPageToken?: string;
3689
3710
  batchJobs?: BatchJob[];
3690
3711
  }
@@ -3712,6 +3733,8 @@ export declare interface ListCachedContentsParameters {
3712
3733
  }
3713
3734
 
3714
3735
  export declare class ListCachedContentsResponse {
3736
+ /** Used to retain the full HTTP response. */
3737
+ sdkHttpResponse?: HttpResponse;
3715
3738
  nextPageToken?: string;
3716
3739
  /** List of cached contents.
3717
3740
  */
@@ -3741,6 +3764,8 @@ export declare interface ListFilesParameters {
3741
3764
 
3742
3765
  /** Response for the list files method. */
3743
3766
  export declare class ListFilesResponse {
3767
+ /** Used to retain the full HTTP response. */
3768
+ sdkHttpResponse?: HttpResponse;
3744
3769
  /** A token to retrieve next page of results. */
3745
3770
  nextPageToken?: string;
3746
3771
  /** The list of files. */
@@ -3769,6 +3794,8 @@ export declare interface ListModelsParameters {
3769
3794
  }
3770
3795
 
3771
3796
  export declare class ListModelsResponse {
3797
+ /** Used to retain the full HTTP response. */
3798
+ sdkHttpResponse?: HttpResponse;
3772
3799
  nextPageToken?: string;
3773
3800
  models?: Model[];
3774
3801
  }
@@ -3796,6 +3823,8 @@ export declare interface ListTuningJobsParameters {
3796
3823
 
3797
3824
  /** Response for the list tuning jobs method. */
3798
3825
  export declare class ListTuningJobsResponse {
3826
+ /** Used to retain the full HTTP response. */
3827
+ sdkHttpResponse?: HttpResponse;
3799
3828
  /** A token to retrieve the next page of results. Pass to ListTuningJobsRequest.page_token to obtain that page. */
3800
3829
  nextPageToken?: string;
3801
3830
  /** List of TuningJobs in the requested page. */
@@ -4854,7 +4883,7 @@ export declare class Models extends BaseModule {
4854
4883
  * modify the original params. Also sets the MCP usage header if there are
4855
4884
  * MCP tools in the parameters.
4856
4885
  */
4857
- private processParamsForMcpUsage;
4886
+ private processParamsMaybeAddMcpUsage;
4858
4887
  private initAfcToolsMap;
4859
4888
  private processAfcStream;
4860
4889
  /**
@@ -4920,6 +4949,30 @@ export declare class Models extends BaseModule {
4920
4949
  * ```
4921
4950
  */
4922
4951
  upscaleImage: (params: types.UpscaleImageParameters) => Promise<types.UpscaleImageResponse>;
4952
+ /**
4953
+ * Generates videos based on a text description and configuration.
4954
+ *
4955
+ * @param params - The parameters for generating videos.
4956
+ * @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
4957
+ *
4958
+ * @example
4959
+ * ```ts
4960
+ * const operation = await ai.models.generateVideos({
4961
+ * model: 'veo-2.0-generate-001',
4962
+ * prompt: 'A neon hologram of a cat driving at top speed',
4963
+ * config: {
4964
+ * numberOfVideos: 1
4965
+ * });
4966
+ *
4967
+ * while (!operation.done) {
4968
+ * await new Promise(resolve => setTimeout(resolve, 10000));
4969
+ * operation = await ai.operations.getVideosOperation({operation: operation});
4970
+ * }
4971
+ *
4972
+ * console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
4973
+ * ```
4974
+ */
4975
+ generateVideos: (params: types.GenerateVideosParameters) => Promise<types.GenerateVideosOperation>;
4923
4976
  private generateContentInternal;
4924
4977
  private generateContentStreamInternal;
4925
4978
  /**
@@ -5065,7 +5118,7 @@ export declare class Models extends BaseModule {
5065
5118
  * console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
5066
5119
  * ```
5067
5120
  */
5068
- generateVideos(params: types.GenerateVideosParameters): Promise<types.GenerateVideosOperation>;
5121
+ private generateVideosInternal;
5069
5122
  }
5070
5123
 
5071
5124
  /** Config for model selection. */
@@ -5081,7 +5134,7 @@ export declare interface MultiSpeakerVoiceConfig {
5081
5134
  }
5082
5135
 
5083
5136
  /** A long-running operation. */
5084
- export declare interface Operation {
5137
+ export declare interface Operation<T> {
5085
5138
  /** The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`. */
5086
5139
  name?: string;
5087
5140
  /** Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. */
@@ -5090,12 +5143,27 @@ export declare interface Operation {
5090
5143
  done?: boolean;
5091
5144
  /** The error result of the operation in case of failure or cancellation. */
5092
5145
  error?: Record<string, unknown>;
5146
+ /** The response if the operation is successful. */
5147
+ response?: T;
5148
+ /**
5149
+ * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
5150
+ * @internal
5151
+ */
5152
+ _fromAPIResponse({ apiResponse, isVertexAI, }: OperationFromAPIResponseParameters): Operation<T>;
5153
+ }
5154
+
5155
+ /** Parameters of the fromAPIResponse method of the Operation class. */
5156
+ export declare interface OperationFromAPIResponseParameters {
5157
+ /** The API response to be converted to an Operation. */
5158
+ apiResponse: Record<string, unknown>;
5159
+ /** Whether the API response is from Vertex AI. */
5160
+ isVertexAI: boolean;
5093
5161
  }
5094
5162
 
5095
5163
  /** Parameters for the get method of the operations module. */
5096
- export declare interface OperationGetParameters {
5164
+ export declare interface OperationGetParameters<T, U extends Operation<T>> {
5097
5165
  /** The operation to be retrieved. */
5098
- operation: GenerateVideosOperation;
5166
+ operation: U;
5099
5167
  /** Used to override the default configuration. */
5100
5168
  config?: GetOperationConfig;
5101
5169
  }
@@ -5109,7 +5177,14 @@ export declare class Operations extends BaseModule {
5109
5177
  * @param parameters The parameters for the get operation request.
5110
5178
  * @return The updated Operation object, with the latest status or result.
5111
5179
  */
5112
- getVideosOperation(parameters: types.OperationGetParameters): Promise<types.GenerateVideosOperation>;
5180
+ getVideosOperation(parameters: types.OperationGetParameters<types.GenerateVideosResponse, types.GenerateVideosOperation>): Promise<types.GenerateVideosOperation>;
5181
+ /**
5182
+ * Gets the status of a long-running operation.
5183
+ *
5184
+ * @param parameters The parameters for the get operation request.
5185
+ * @return The updated Operation object, with the latest status or result.
5186
+ */
5187
+ get<T, U extends types.Operation<T>>(parameters: types.OperationGetParameters<T, U>): Promise<types.Operation<T>>;
5113
5188
  private getVideosOperationInternal;
5114
5189
  private fetchPredictVideosOperationInternal;
5115
5190
  }
@@ -5134,14 +5209,6 @@ export declare enum Outcome {
5134
5209
  OUTCOME_DEADLINE_EXCEEDED = "OUTCOME_DEADLINE_EXCEEDED"
5135
5210
  }
5136
5211
 
5137
- /**
5138
- * @license
5139
- * Copyright 2025 Google LLC
5140
- * SPDX-License-Identifier: Apache-2.0
5141
- */
5142
- /**
5143
- * Pagers for the GenAI List APIs.
5144
- */
5145
5212
  export declare enum PagedItem {
5146
5213
  PAGED_ITEM_BATCH_JOBS = "batchJobs",
5147
5214
  PAGED_ITEM_MODELS = "models",
@@ -5159,6 +5226,7 @@ declare interface PagedItemConfig {
5159
5226
 
5160
5227
  declare interface PagedItemResponse<T> {
5161
5228
  nextPageToken?: string;
5229
+ sdkHttpResponse?: types.HttpResponse;
5162
5230
  batchJobs?: T[];
5163
5231
  models?: T[];
5164
5232
  tuningJobs?: T[];
@@ -5174,6 +5242,7 @@ export declare class Pager<T> implements AsyncIterable<T> {
5174
5242
  private pageInternal;
5175
5243
  private paramsInternal;
5176
5244
  private pageInternalSize;
5245
+ private sdkHttpResponseInternal?;
5177
5246
  protected requestInternal: (params: PagedItemConfig) => Promise<PagedItemResponse<T>>;
5178
5247
  protected idxInternal: number;
5179
5248
  constructor(name: PagedItem, request: (params: PagedItemConfig) => Promise<PagedItemResponse<T>>, response: PagedItemResponse<T>, params: PagedItemConfig);
@@ -5198,6 +5267,10 @@ export declare class Pager<T> implements AsyncIterable<T> {
5198
5267
  * The number of items in the page is less than or equal to the page length.
5199
5268
  */
5200
5269
  get pageSize(): number;
5270
+ /**
5271
+ * Returns the headers of the API response.
5272
+ */
5273
+ get sdkHttpResponse(): types.HttpResponse | undefined;
5201
5274
  /**
5202
5275
  * Returns the parameters when making the API request for the next page.
5203
5276
  *
@@ -6391,6 +6464,18 @@ export declare interface TuningJob {
6391
6464
  tunedModelDisplayName?: string;
6392
6465
  }
6393
6466
 
6467
+ /** A long-running operation. */
6468
+ export declare interface TuningOperation {
6469
+ /** The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`. */
6470
+ name?: string;
6471
+ /** Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. */
6472
+ metadata?: Record<string, unknown>;
6473
+ /** If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available. */
6474
+ done?: boolean;
6475
+ /** The error result of the operation in case of failure or cancellation. */
6476
+ error?: Record<string, unknown>;
6477
+ }
6478
+
6394
6479
  declare class Tunings extends BaseModule {
6395
6480
  private readonly apiClient;
6396
6481
  constructor(apiClient: ApiClient);
@@ -6679,7 +6764,6 @@ declare namespace types {
6679
6764
  GenerateVideosParameters,
6680
6765
  GeneratedVideo,
6681
6766
  GenerateVideosResponse,
6682
- GenerateVideosOperation,
6683
6767
  GetTuningJobConfig,
6684
6768
  GetTuningJobParameters,
6685
6769
  TunedModelCheckpoint,
@@ -6708,7 +6792,7 @@ declare namespace types {
6708
6792
  TuningValidationDataset,
6709
6793
  CreateTuningJobConfig,
6710
6794
  CreateTuningJobParameters,
6711
- Operation,
6795
+ TuningOperation,
6712
6796
  CreateCachedContentConfig,
6713
6797
  CreateCachedContentParameters,
6714
6798
  CachedContentUsageMetadata,
@@ -6783,6 +6867,10 @@ declare namespace types {
6783
6867
  LiveServerGoAway,
6784
6868
  LiveServerSessionResumptionUpdate,
6785
6869
  LiveServerMessage,
6870
+ OperationGetParameters,
6871
+ OperationFromAPIResponseParameters,
6872
+ Operation,
6873
+ GenerateVideosOperation,
6786
6874
  AutomaticActivityDetection,
6787
6875
  RealtimeInputConfig,
6788
6876
  SessionResumptionConfig,
@@ -6826,7 +6914,6 @@ declare namespace types {
6826
6914
  LiveConnectConstraints,
6827
6915
  CreateAuthTokenConfig,
6828
6916
  CreateAuthTokenParameters,
6829
- OperationGetParameters,
6830
6917
  BlobImageUnion,
6831
6918
  PartUnion,
6832
6919
  PartListUnion,
@@ -6837,7 +6924,8 @@ declare namespace types {
6837
6924
  ToolUnion,
6838
6925
  ToolListUnion,
6839
6926
  DownloadableFileUnion,
6840
- BatchJobSourceUnion
6927
+ BatchJobSourceUnion,
6928
+ BatchJobDestinationUnion
6841
6929
  }
6842
6930
  }
6843
6931
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/genai",
3
- "version": "1.9.0",
3
+ "version": "1.11.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/node/index.mjs",
@@ -44,7 +44,7 @@
44
44
  "system-test": "tsc && jasmine dist/test/system/**/*_test.js",
45
45
  "test-server-tests": "tsc && GOOGLE_CLOUD_PROJECT=googcloudproj GOOGLE_CLOUD_LOCATION=googcloudloc jasmine dist/test/system/node/*_test.js !dist/test/system/node/live_test.js -- --test-server",
46
46
  "test-server-tests:record": "tsc && jasmine --fail-fast dist/test/system/node/*_test.js !dist/test/system/node/live_test.js -- --test-server --record",
47
- "docs": "typedoc && ts-node scripts/add_docsite_license_headers.ts",
47
+ "docs": "typedoc && node --loader ts-node/esm scripts/add_docsite_license_headers.ts",
48
48
  "pages-main": "node --loader ts-node/esm scripts/generate_pages.ts main",
49
49
  "pages-release": "node --loader ts-node/esm scripts/generate_pages.ts release",
50
50
  "format": "prettier '**/*.ts' '**/*.mjs' '**/*.json' --write",