@google/genai 1.10.0 → 1.12.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
@@ -1041,6 +1041,8 @@ export declare interface ComputeTokensParameters {
1041
1041
 
1042
1042
  /** Response for computing tokens. */
1043
1043
  export declare class ComputeTokensResponse {
1044
+ /** Used to retain the full HTTP response. */
1045
+ sdkHttpResponse?: HttpResponse;
1044
1046
  /** Lists of tokens info from the input. A ComputeTokensRequest could have multiple instances with a prompt in each instance. We also need to return lists of tokens info for the request with multiple instances. */
1045
1047
  tokensInfo?: TokensInfo[];
1046
1048
  }
@@ -1168,6 +1170,8 @@ export declare interface CountTokensParameters {
1168
1170
 
1169
1171
  /** Response for counting tokens. */
1170
1172
  export declare class CountTokensResponse {
1173
+ /** Used to retain the full HTTP response. */
1174
+ sdkHttpResponse?: HttpResponse;
1171
1175
  /** Total number of tokens. */
1172
1176
  totalTokens?: number;
1173
1177
  /** Number of tokens in the cached part of the prompt (the cached content). */
@@ -1771,6 +1775,8 @@ export declare interface EditImageParameters {
1771
1775
 
1772
1776
  /** Response for the request to edit an image. */
1773
1777
  export declare class EditImageResponse {
1778
+ /** Used to retain the full HTTP response. */
1779
+ sdkHttpResponse?: HttpResponse;
1774
1780
  /** Generated images. */
1775
1781
  generatedImages?: GeneratedImage[];
1776
1782
  }
@@ -1844,6 +1850,8 @@ export declare interface EmbedContentParameters {
1844
1850
 
1845
1851
  /** Response for the embed_content method. */
1846
1852
  export declare class EmbedContentResponse {
1853
+ /** Used to retain the full HTTP response. */
1854
+ sdkHttpResponse?: HttpResponse;
1847
1855
  /** The embeddings for each request, in the same order as provided in
1848
1856
  the batch request.
1849
1857
  */
@@ -2755,6 +2763,10 @@ export declare interface GenerateImagesConfig {
2755
2763
  /** Whether to add a watermark to the generated images.
2756
2764
  */
2757
2765
  addWatermark?: boolean;
2766
+ /** The size of the largest dimension of the generated image.
2767
+ Supported sizes are 1K and 2K (not supported for Imagen 3 models).
2768
+ */
2769
+ imageSize?: string;
2758
2770
  /** Whether to use the prompt rewriting logic.
2759
2771
  */
2760
2772
  enhancePrompt?: boolean;
@@ -2775,6 +2787,8 @@ export declare interface GenerateImagesParameters {
2775
2787
 
2776
2788
  /** The output images response. */
2777
2789
  export declare class GenerateImagesResponse {
2790
+ /** Used to retain the full HTTP response. */
2791
+ sdkHttpResponse?: HttpResponse;
2778
2792
  /** List of generated images.
2779
2793
  */
2780
2794
  generatedImages?: GeneratedImage[];
@@ -2825,8 +2839,8 @@ export declare interface GenerateVideosConfig {
2825
2839
  compressionQuality?: VideoCompressionQuality;
2826
2840
  }
2827
2841
 
2828
- /** A video generation operation. */
2829
- export declare interface GenerateVideosOperation {
2842
+ /** A video generation long-running operation. */
2843
+ export declare class GenerateVideosOperation implements Operation<GenerateVideosResponse> {
2830
2844
  /** 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}`. */
2831
2845
  name?: string;
2832
2846
  /** 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. */
@@ -2835,8 +2849,15 @@ export declare interface GenerateVideosOperation {
2835
2849
  done?: boolean;
2836
2850
  /** The error result of the operation in case of failure or cancellation. */
2837
2851
  error?: Record<string, unknown>;
2838
- /** The generated videos. */
2852
+ /** The response if the operation is successful. */
2839
2853
  response?: GenerateVideosResponse;
2854
+ /** The full HTTP response. */
2855
+ sdkHttpResponse?: HttpResponse;
2856
+ /**
2857
+ * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
2858
+ * @internal
2859
+ */
2860
+ _fromAPIResponse({ apiResponse, isVertexAI, }: OperationFromAPIResponseParameters): Operation<GenerateVideosResponse>;
2840
2861
  }
2841
2862
 
2842
2863
  /** Class that represents the parameters for generating videos. */
@@ -3695,6 +3716,8 @@ export declare interface ListBatchJobsParameters {
3695
3716
 
3696
3717
  /** Config for batches.list return value. */
3697
3718
  export declare class ListBatchJobsResponse {
3719
+ /** Used to retain the full HTTP response. */
3720
+ sdkHttpResponse?: HttpResponse;
3698
3721
  nextPageToken?: string;
3699
3722
  batchJobs?: BatchJob[];
3700
3723
  }
@@ -3722,6 +3745,8 @@ export declare interface ListCachedContentsParameters {
3722
3745
  }
3723
3746
 
3724
3747
  export declare class ListCachedContentsResponse {
3748
+ /** Used to retain the full HTTP response. */
3749
+ sdkHttpResponse?: HttpResponse;
3725
3750
  nextPageToken?: string;
3726
3751
  /** List of cached contents.
3727
3752
  */
@@ -3751,6 +3776,8 @@ export declare interface ListFilesParameters {
3751
3776
 
3752
3777
  /** Response for the list files method. */
3753
3778
  export declare class ListFilesResponse {
3779
+ /** Used to retain the full HTTP response. */
3780
+ sdkHttpResponse?: HttpResponse;
3754
3781
  /** A token to retrieve next page of results. */
3755
3782
  nextPageToken?: string;
3756
3783
  /** The list of files. */
@@ -3779,6 +3806,8 @@ export declare interface ListModelsParameters {
3779
3806
  }
3780
3807
 
3781
3808
  export declare class ListModelsResponse {
3809
+ /** Used to retain the full HTTP response. */
3810
+ sdkHttpResponse?: HttpResponse;
3782
3811
  nextPageToken?: string;
3783
3812
  models?: Model[];
3784
3813
  }
@@ -3806,6 +3835,8 @@ export declare interface ListTuningJobsParameters {
3806
3835
 
3807
3836
  /** Response for the list tuning jobs method. */
3808
3837
  export declare class ListTuningJobsResponse {
3838
+ /** Used to retain the full HTTP response. */
3839
+ sdkHttpResponse?: HttpResponse;
3809
3840
  /** A token to retrieve the next page of results. Pass to ListTuningJobsRequest.page_token to obtain that page. */
3810
3841
  nextPageToken?: string;
3811
3842
  /** List of TuningJobs in the requested page. */
@@ -4864,7 +4895,7 @@ export declare class Models extends BaseModule {
4864
4895
  * modify the original params. Also sets the MCP usage header if there are
4865
4896
  * MCP tools in the parameters.
4866
4897
  */
4867
- private processParamsForMcpUsage;
4898
+ private processParamsMaybeAddMcpUsage;
4868
4899
  private initAfcToolsMap;
4869
4900
  private processAfcStream;
4870
4901
  /**
@@ -4930,6 +4961,30 @@ export declare class Models extends BaseModule {
4930
4961
  * ```
4931
4962
  */
4932
4963
  upscaleImage: (params: types.UpscaleImageParameters) => Promise<types.UpscaleImageResponse>;
4964
+ /**
4965
+ * Generates videos based on a text description and configuration.
4966
+ *
4967
+ * @param params - The parameters for generating videos.
4968
+ * @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
4969
+ *
4970
+ * @example
4971
+ * ```ts
4972
+ * const operation = await ai.models.generateVideos({
4973
+ * model: 'veo-2.0-generate-001',
4974
+ * prompt: 'A neon hologram of a cat driving at top speed',
4975
+ * config: {
4976
+ * numberOfVideos: 1
4977
+ * });
4978
+ *
4979
+ * while (!operation.done) {
4980
+ * await new Promise(resolve => setTimeout(resolve, 10000));
4981
+ * operation = await ai.operations.getVideosOperation({operation: operation});
4982
+ * }
4983
+ *
4984
+ * console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
4985
+ * ```
4986
+ */
4987
+ generateVideos: (params: types.GenerateVideosParameters) => Promise<types.GenerateVideosOperation>;
4933
4988
  private generateContentInternal;
4934
4989
  private generateContentStreamInternal;
4935
4990
  /**
@@ -5075,7 +5130,7 @@ export declare class Models extends BaseModule {
5075
5130
  * console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
5076
5131
  * ```
5077
5132
  */
5078
- generateVideos(params: types.GenerateVideosParameters): Promise<types.GenerateVideosOperation>;
5133
+ private generateVideosInternal;
5079
5134
  }
5080
5135
 
5081
5136
  /** Config for model selection. */
@@ -5090,10 +5145,37 @@ export declare interface MultiSpeakerVoiceConfig {
5090
5145
  speakerVoiceConfigs?: SpeakerVoiceConfig[];
5091
5146
  }
5092
5147
 
5148
+ /** A long-running operation. */
5149
+ export declare interface Operation<T> {
5150
+ /** 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}`. */
5151
+ name?: string;
5152
+ /** 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. */
5153
+ metadata?: Record<string, unknown>;
5154
+ /** 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. */
5155
+ done?: boolean;
5156
+ /** The error result of the operation in case of failure or cancellation. */
5157
+ error?: Record<string, unknown>;
5158
+ /** The response if the operation is successful. */
5159
+ response?: T;
5160
+ /**
5161
+ * Instantiates an Operation of the same type as the one being called with the fields set from the API response.
5162
+ * @internal
5163
+ */
5164
+ _fromAPIResponse({ apiResponse, isVertexAI, }: OperationFromAPIResponseParameters): Operation<T>;
5165
+ }
5166
+
5167
+ /** Parameters of the fromAPIResponse method of the Operation class. */
5168
+ export declare interface OperationFromAPIResponseParameters {
5169
+ /** The API response to be converted to an Operation. */
5170
+ apiResponse: Record<string, unknown>;
5171
+ /** Whether the API response is from Vertex AI. */
5172
+ isVertexAI: boolean;
5173
+ }
5174
+
5093
5175
  /** Parameters for the get method of the operations module. */
5094
- export declare interface OperationGetParameters {
5176
+ export declare interface OperationGetParameters<T, U extends Operation<T>> {
5095
5177
  /** The operation to be retrieved. */
5096
- operation: GenerateVideosOperation;
5178
+ operation: U;
5097
5179
  /** Used to override the default configuration. */
5098
5180
  config?: GetOperationConfig;
5099
5181
  }
@@ -5107,7 +5189,14 @@ export declare class Operations extends BaseModule {
5107
5189
  * @param parameters The parameters for the get operation request.
5108
5190
  * @return The updated Operation object, with the latest status or result.
5109
5191
  */
5110
- getVideosOperation(parameters: types.OperationGetParameters): Promise<types.GenerateVideosOperation>;
5192
+ getVideosOperation(parameters: types.OperationGetParameters<types.GenerateVideosResponse, types.GenerateVideosOperation>): Promise<types.GenerateVideosOperation>;
5193
+ /**
5194
+ * Gets the status of a long-running operation.
5195
+ *
5196
+ * @param parameters The parameters for the get operation request.
5197
+ * @return The updated Operation object, with the latest status or result.
5198
+ */
5199
+ get<T, U extends types.Operation<T>>(parameters: types.OperationGetParameters<T, U>): Promise<types.Operation<T>>;
5111
5200
  private getVideosOperationInternal;
5112
5201
  private fetchPredictVideosOperationInternal;
5113
5202
  }
@@ -5132,14 +5221,6 @@ export declare enum Outcome {
5132
5221
  OUTCOME_DEADLINE_EXCEEDED = "OUTCOME_DEADLINE_EXCEEDED"
5133
5222
  }
5134
5223
 
5135
- /**
5136
- * @license
5137
- * Copyright 2025 Google LLC
5138
- * SPDX-License-Identifier: Apache-2.0
5139
- */
5140
- /**
5141
- * Pagers for the GenAI List APIs.
5142
- */
5143
5224
  export declare enum PagedItem {
5144
5225
  PAGED_ITEM_BATCH_JOBS = "batchJobs",
5145
5226
  PAGED_ITEM_MODELS = "models",
@@ -5157,6 +5238,7 @@ declare interface PagedItemConfig {
5157
5238
 
5158
5239
  declare interface PagedItemResponse<T> {
5159
5240
  nextPageToken?: string;
5241
+ sdkHttpResponse?: types.HttpResponse;
5160
5242
  batchJobs?: T[];
5161
5243
  models?: T[];
5162
5244
  tuningJobs?: T[];
@@ -5172,6 +5254,7 @@ export declare class Pager<T> implements AsyncIterable<T> {
5172
5254
  private pageInternal;
5173
5255
  private paramsInternal;
5174
5256
  private pageInternalSize;
5257
+ private sdkHttpResponseInternal?;
5175
5258
  protected requestInternal: (params: PagedItemConfig) => Promise<PagedItemResponse<T>>;
5176
5259
  protected idxInternal: number;
5177
5260
  constructor(name: PagedItem, request: (params: PagedItemConfig) => Promise<PagedItemResponse<T>>, response: PagedItemResponse<T>, params: PagedItemConfig);
@@ -5196,6 +5279,10 @@ export declare class Pager<T> implements AsyncIterable<T> {
5196
5279
  * The number of items in the page is less than or equal to the page length.
5197
5280
  */
5198
5281
  get pageSize(): number;
5282
+ /**
5283
+ * Returns the headers of the API response.
5284
+ */
5285
+ get sdkHttpResponse(): types.HttpResponse | undefined;
5199
5286
  /**
5200
5287
  * Returns the parameters when making the API request for the next page.
5201
5288
  *
@@ -6343,6 +6430,8 @@ export declare interface TuningExample {
6343
6430
 
6344
6431
  /** A tuning job. */
6345
6432
  export declare interface TuningJob {
6433
+ /** Used to retain the full HTTP response. */
6434
+ sdkHttpResponse?: HttpResponse;
6346
6435
  /** Output only. Identifier. Resource name of a TuningJob. Format: `projects/{project}/locations/{location}/tuningJobs/{tuning_job}` */
6347
6436
  name?: string;
6348
6437
  /** Output only. The detailed state of the job. */
@@ -6391,6 +6480,8 @@ export declare interface TuningJob {
6391
6480
 
6392
6481
  /** A long-running operation. */
6393
6482
  export declare interface TuningOperation {
6483
+ /** Used to retain the full HTTP response. */
6484
+ sdkHttpResponse?: HttpResponse;
6394
6485
  /** 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}`. */
6395
6486
  name?: string;
6396
6487
  /** 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. */
@@ -6689,7 +6780,6 @@ declare namespace types {
6689
6780
  GenerateVideosParameters,
6690
6781
  GeneratedVideo,
6691
6782
  GenerateVideosResponse,
6692
- GenerateVideosOperation,
6693
6783
  GetTuningJobConfig,
6694
6784
  GetTuningJobParameters,
6695
6785
  TunedModelCheckpoint,
@@ -6793,6 +6883,10 @@ declare namespace types {
6793
6883
  LiveServerGoAway,
6794
6884
  LiveServerSessionResumptionUpdate,
6795
6885
  LiveServerMessage,
6886
+ OperationGetParameters,
6887
+ OperationFromAPIResponseParameters,
6888
+ Operation,
6889
+ GenerateVideosOperation,
6796
6890
  AutomaticActivityDetection,
6797
6891
  RealtimeInputConfig,
6798
6892
  SessionResumptionConfig,
@@ -6836,7 +6930,6 @@ declare namespace types {
6836
6930
  LiveConnectConstraints,
6837
6931
  CreateAuthTokenConfig,
6838
6932
  CreateAuthTokenParameters,
6839
- OperationGetParameters,
6840
6933
  BlobImageUnion,
6841
6934
  PartUnion,
6842
6935
  PartListUnion,
@@ -6998,6 +7091,8 @@ export declare interface UpscaleImageParameters {
6998
7091
  }
6999
7092
 
7000
7093
  export declare class UpscaleImageResponse {
7094
+ /** Used to retain the full HTTP response. */
7095
+ sdkHttpResponse?: HttpResponse;
7001
7096
  /** Generated images. */
7002
7097
  generatedImages?: GeneratedImage[];
7003
7098
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/genai",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/node/index.mjs",
@@ -42,9 +42,9 @@
42
42
  "build-prod": "rollup -c && api-extractor run --verbose && api-extractor run -c api-extractor.node.json --verbose && api-extractor run -c api-extractor.web.json --verbose && node scripts/ignore_missing_mcp_dep.js",
43
43
  "unit-test": "tsc && jasmine dist/test/unit/**/*_test.js dist/test/unit/*_test.js",
44
44
  "system-test": "tsc && jasmine dist/test/system/**/*_test.js",
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
- "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",
45
+ "test-server-tests": "tsc && GOOGLE_CLOUD_PROJECT=googcloudproj GOOGLE_CLOUD_LOCATION=googcloudloc jasmine dist/test/system/node/*_test.js -- --test-server",
46
+ "test-server-tests:record": "tsc && jasmine --fail-fast dist/test/system/node/*_test.js -- --test-server --record",
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",
@@ -85,7 +85,7 @@
85
85
  "prettier": "3.3.3",
86
86
  "prettier-plugin-organize-imports": "^4.1.0",
87
87
  "rollup-plugin-typescript2": "^0.36.0",
88
- "test-server-sdk": "^0.2.3",
88
+ "test-server-sdk": "^0.2.6",
89
89
  "ts-node": "^10.9.2",
90
90
  "tslib": "^2.8.1",
91
91
  "tsx": "^4.19.4",