@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/README.md +7 -12
- package/dist/genai.d.ts +112 -24
- package/dist/index.cjs +1637 -1466
- package/dist/index.mjs +1637 -1467
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.cjs +1644 -1473
- package/dist/node/index.mjs +1644 -1474
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/node.d.ts +112 -24
- package/dist/web/index.mjs +1645 -1475
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +112 -24
- package/package.json +2 -2
package/dist/node/node.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?:
|
|
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.
|
|
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
|
|
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
|
|
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. */
|
|
@@ -3427,7 +3443,10 @@ export declare interface HttpOptions {
|
|
|
3427
3443
|
headers?: Record<string, string>;
|
|
3428
3444
|
/** Timeout for the request in milliseconds. */
|
|
3429
3445
|
timeout?: number;
|
|
3430
|
-
/** Extra parameters to add to the request body.
|
|
3446
|
+
/** Extra parameters to add to the request body.
|
|
3447
|
+
The structure must match the backend API's request structure.
|
|
3448
|
+
- VertexAI backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest
|
|
3449
|
+
- GeminiAPI backend API docs: https://ai.google.dev/api/rest */
|
|
3431
3450
|
extraBody?: Record<string, unknown>;
|
|
3432
3451
|
}
|
|
3433
3452
|
|
|
@@ -3692,6 +3711,8 @@ export declare interface ListBatchJobsParameters {
|
|
|
3692
3711
|
|
|
3693
3712
|
/** Config for batches.list return value. */
|
|
3694
3713
|
export declare class ListBatchJobsResponse {
|
|
3714
|
+
/** Used to retain the full HTTP response. */
|
|
3715
|
+
sdkHttpResponse?: HttpResponse;
|
|
3695
3716
|
nextPageToken?: string;
|
|
3696
3717
|
batchJobs?: BatchJob[];
|
|
3697
3718
|
}
|
|
@@ -3719,6 +3740,8 @@ export declare interface ListCachedContentsParameters {
|
|
|
3719
3740
|
}
|
|
3720
3741
|
|
|
3721
3742
|
export declare class ListCachedContentsResponse {
|
|
3743
|
+
/** Used to retain the full HTTP response. */
|
|
3744
|
+
sdkHttpResponse?: HttpResponse;
|
|
3722
3745
|
nextPageToken?: string;
|
|
3723
3746
|
/** List of cached contents.
|
|
3724
3747
|
*/
|
|
@@ -3748,6 +3771,8 @@ export declare interface ListFilesParameters {
|
|
|
3748
3771
|
|
|
3749
3772
|
/** Response for the list files method. */
|
|
3750
3773
|
export declare class ListFilesResponse {
|
|
3774
|
+
/** Used to retain the full HTTP response. */
|
|
3775
|
+
sdkHttpResponse?: HttpResponse;
|
|
3751
3776
|
/** A token to retrieve next page of results. */
|
|
3752
3777
|
nextPageToken?: string;
|
|
3753
3778
|
/** The list of files. */
|
|
@@ -3776,6 +3801,8 @@ export declare interface ListModelsParameters {
|
|
|
3776
3801
|
}
|
|
3777
3802
|
|
|
3778
3803
|
export declare class ListModelsResponse {
|
|
3804
|
+
/** Used to retain the full HTTP response. */
|
|
3805
|
+
sdkHttpResponse?: HttpResponse;
|
|
3779
3806
|
nextPageToken?: string;
|
|
3780
3807
|
models?: Model[];
|
|
3781
3808
|
}
|
|
@@ -3803,6 +3830,8 @@ export declare interface ListTuningJobsParameters {
|
|
|
3803
3830
|
|
|
3804
3831
|
/** Response for the list tuning jobs method. */
|
|
3805
3832
|
export declare class ListTuningJobsResponse {
|
|
3833
|
+
/** Used to retain the full HTTP response. */
|
|
3834
|
+
sdkHttpResponse?: HttpResponse;
|
|
3806
3835
|
/** A token to retrieve the next page of results. Pass to ListTuningJobsRequest.page_token to obtain that page. */
|
|
3807
3836
|
nextPageToken?: string;
|
|
3808
3837
|
/** List of TuningJobs in the requested page. */
|
|
@@ -4861,7 +4890,7 @@ export declare class Models extends BaseModule {
|
|
|
4861
4890
|
* modify the original params. Also sets the MCP usage header if there are
|
|
4862
4891
|
* MCP tools in the parameters.
|
|
4863
4892
|
*/
|
|
4864
|
-
private
|
|
4893
|
+
private processParamsMaybeAddMcpUsage;
|
|
4865
4894
|
private initAfcToolsMap;
|
|
4866
4895
|
private processAfcStream;
|
|
4867
4896
|
/**
|
|
@@ -4927,6 +4956,30 @@ export declare class Models extends BaseModule {
|
|
|
4927
4956
|
* ```
|
|
4928
4957
|
*/
|
|
4929
4958
|
upscaleImage: (params: types.UpscaleImageParameters) => Promise<types.UpscaleImageResponse>;
|
|
4959
|
+
/**
|
|
4960
|
+
* Generates videos based on a text description and configuration.
|
|
4961
|
+
*
|
|
4962
|
+
* @param params - The parameters for generating videos.
|
|
4963
|
+
* @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
|
|
4964
|
+
*
|
|
4965
|
+
* @example
|
|
4966
|
+
* ```ts
|
|
4967
|
+
* const operation = await ai.models.generateVideos({
|
|
4968
|
+
* model: 'veo-2.0-generate-001',
|
|
4969
|
+
* prompt: 'A neon hologram of a cat driving at top speed',
|
|
4970
|
+
* config: {
|
|
4971
|
+
* numberOfVideos: 1
|
|
4972
|
+
* });
|
|
4973
|
+
*
|
|
4974
|
+
* while (!operation.done) {
|
|
4975
|
+
* await new Promise(resolve => setTimeout(resolve, 10000));
|
|
4976
|
+
* operation = await ai.operations.getVideosOperation({operation: operation});
|
|
4977
|
+
* }
|
|
4978
|
+
*
|
|
4979
|
+
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
4980
|
+
* ```
|
|
4981
|
+
*/
|
|
4982
|
+
generateVideos: (params: types.GenerateVideosParameters) => Promise<types.GenerateVideosOperation>;
|
|
4930
4983
|
private generateContentInternal;
|
|
4931
4984
|
private generateContentStreamInternal;
|
|
4932
4985
|
/**
|
|
@@ -5072,7 +5125,7 @@ export declare class Models extends BaseModule {
|
|
|
5072
5125
|
* console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
|
|
5073
5126
|
* ```
|
|
5074
5127
|
*/
|
|
5075
|
-
|
|
5128
|
+
private generateVideosInternal;
|
|
5076
5129
|
}
|
|
5077
5130
|
|
|
5078
5131
|
/** Config for model selection. */
|
|
@@ -5088,7 +5141,7 @@ export declare interface MultiSpeakerVoiceConfig {
|
|
|
5088
5141
|
}
|
|
5089
5142
|
|
|
5090
5143
|
/** A long-running operation. */
|
|
5091
|
-
export declare interface Operation {
|
|
5144
|
+
export declare interface Operation<T> {
|
|
5092
5145
|
/** 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}`. */
|
|
5093
5146
|
name?: string;
|
|
5094
5147
|
/** 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. */
|
|
@@ -5097,12 +5150,27 @@ export declare interface Operation {
|
|
|
5097
5150
|
done?: boolean;
|
|
5098
5151
|
/** The error result of the operation in case of failure or cancellation. */
|
|
5099
5152
|
error?: Record<string, unknown>;
|
|
5153
|
+
/** The response if the operation is successful. */
|
|
5154
|
+
response?: T;
|
|
5155
|
+
/**
|
|
5156
|
+
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
5157
|
+
* @internal
|
|
5158
|
+
*/
|
|
5159
|
+
_fromAPIResponse({ apiResponse, isVertexAI, }: OperationFromAPIResponseParameters): Operation<T>;
|
|
5160
|
+
}
|
|
5161
|
+
|
|
5162
|
+
/** Parameters of the fromAPIResponse method of the Operation class. */
|
|
5163
|
+
export declare interface OperationFromAPIResponseParameters {
|
|
5164
|
+
/** The API response to be converted to an Operation. */
|
|
5165
|
+
apiResponse: Record<string, unknown>;
|
|
5166
|
+
/** Whether the API response is from Vertex AI. */
|
|
5167
|
+
isVertexAI: boolean;
|
|
5100
5168
|
}
|
|
5101
5169
|
|
|
5102
5170
|
/** Parameters for the get method of the operations module. */
|
|
5103
|
-
export declare interface OperationGetParameters {
|
|
5171
|
+
export declare interface OperationGetParameters<T, U extends Operation<T>> {
|
|
5104
5172
|
/** The operation to be retrieved. */
|
|
5105
|
-
operation:
|
|
5173
|
+
operation: U;
|
|
5106
5174
|
/** Used to override the default configuration. */
|
|
5107
5175
|
config?: GetOperationConfig;
|
|
5108
5176
|
}
|
|
@@ -5116,7 +5184,14 @@ export declare class Operations extends BaseModule {
|
|
|
5116
5184
|
* @param parameters The parameters for the get operation request.
|
|
5117
5185
|
* @return The updated Operation object, with the latest status or result.
|
|
5118
5186
|
*/
|
|
5119
|
-
getVideosOperation(parameters: types.OperationGetParameters): Promise<types.GenerateVideosOperation>;
|
|
5187
|
+
getVideosOperation(parameters: types.OperationGetParameters<types.GenerateVideosResponse, types.GenerateVideosOperation>): Promise<types.GenerateVideosOperation>;
|
|
5188
|
+
/**
|
|
5189
|
+
* Gets the status of a long-running operation.
|
|
5190
|
+
*
|
|
5191
|
+
* @param parameters The parameters for the get operation request.
|
|
5192
|
+
* @return The updated Operation object, with the latest status or result.
|
|
5193
|
+
*/
|
|
5194
|
+
get<T, U extends types.Operation<T>>(parameters: types.OperationGetParameters<T, U>): Promise<types.Operation<T>>;
|
|
5120
5195
|
private getVideosOperationInternal;
|
|
5121
5196
|
private fetchPredictVideosOperationInternal;
|
|
5122
5197
|
}
|
|
@@ -5141,14 +5216,6 @@ export declare enum Outcome {
|
|
|
5141
5216
|
OUTCOME_DEADLINE_EXCEEDED = "OUTCOME_DEADLINE_EXCEEDED"
|
|
5142
5217
|
}
|
|
5143
5218
|
|
|
5144
|
-
/**
|
|
5145
|
-
* @license
|
|
5146
|
-
* Copyright 2025 Google LLC
|
|
5147
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5148
|
-
*/
|
|
5149
|
-
/**
|
|
5150
|
-
* Pagers for the GenAI List APIs.
|
|
5151
|
-
*/
|
|
5152
5219
|
export declare enum PagedItem {
|
|
5153
5220
|
PAGED_ITEM_BATCH_JOBS = "batchJobs",
|
|
5154
5221
|
PAGED_ITEM_MODELS = "models",
|
|
@@ -5166,6 +5233,7 @@ declare interface PagedItemConfig {
|
|
|
5166
5233
|
|
|
5167
5234
|
declare interface PagedItemResponse<T> {
|
|
5168
5235
|
nextPageToken?: string;
|
|
5236
|
+
sdkHttpResponse?: types.HttpResponse;
|
|
5169
5237
|
batchJobs?: T[];
|
|
5170
5238
|
models?: T[];
|
|
5171
5239
|
tuningJobs?: T[];
|
|
@@ -5181,6 +5249,7 @@ export declare class Pager<T> implements AsyncIterable<T> {
|
|
|
5181
5249
|
private pageInternal;
|
|
5182
5250
|
private paramsInternal;
|
|
5183
5251
|
private pageInternalSize;
|
|
5252
|
+
private sdkHttpResponseInternal?;
|
|
5184
5253
|
protected requestInternal: (params: PagedItemConfig) => Promise<PagedItemResponse<T>>;
|
|
5185
5254
|
protected idxInternal: number;
|
|
5186
5255
|
constructor(name: PagedItem, request: (params: PagedItemConfig) => Promise<PagedItemResponse<T>>, response: PagedItemResponse<T>, params: PagedItemConfig);
|
|
@@ -5205,6 +5274,10 @@ export declare class Pager<T> implements AsyncIterable<T> {
|
|
|
5205
5274
|
* The number of items in the page is less than or equal to the page length.
|
|
5206
5275
|
*/
|
|
5207
5276
|
get pageSize(): number;
|
|
5277
|
+
/**
|
|
5278
|
+
* Returns the headers of the API response.
|
|
5279
|
+
*/
|
|
5280
|
+
get sdkHttpResponse(): types.HttpResponse | undefined;
|
|
5208
5281
|
/**
|
|
5209
5282
|
* Returns the parameters when making the API request for the next page.
|
|
5210
5283
|
*
|
|
@@ -6398,6 +6471,18 @@ export declare interface TuningJob {
|
|
|
6398
6471
|
tunedModelDisplayName?: string;
|
|
6399
6472
|
}
|
|
6400
6473
|
|
|
6474
|
+
/** A long-running operation. */
|
|
6475
|
+
export declare interface TuningOperation {
|
|
6476
|
+
/** 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}`. */
|
|
6477
|
+
name?: string;
|
|
6478
|
+
/** 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. */
|
|
6479
|
+
metadata?: Record<string, unknown>;
|
|
6480
|
+
/** 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. */
|
|
6481
|
+
done?: boolean;
|
|
6482
|
+
/** The error result of the operation in case of failure or cancellation. */
|
|
6483
|
+
error?: Record<string, unknown>;
|
|
6484
|
+
}
|
|
6485
|
+
|
|
6401
6486
|
declare class Tunings extends BaseModule {
|
|
6402
6487
|
private readonly apiClient;
|
|
6403
6488
|
constructor(apiClient: ApiClient);
|
|
@@ -6686,7 +6771,6 @@ declare namespace types {
|
|
|
6686
6771
|
GenerateVideosParameters,
|
|
6687
6772
|
GeneratedVideo,
|
|
6688
6773
|
GenerateVideosResponse,
|
|
6689
|
-
GenerateVideosOperation,
|
|
6690
6774
|
GetTuningJobConfig,
|
|
6691
6775
|
GetTuningJobParameters,
|
|
6692
6776
|
TunedModelCheckpoint,
|
|
@@ -6715,7 +6799,7 @@ declare namespace types {
|
|
|
6715
6799
|
TuningValidationDataset,
|
|
6716
6800
|
CreateTuningJobConfig,
|
|
6717
6801
|
CreateTuningJobParameters,
|
|
6718
|
-
|
|
6802
|
+
TuningOperation,
|
|
6719
6803
|
CreateCachedContentConfig,
|
|
6720
6804
|
CreateCachedContentParameters,
|
|
6721
6805
|
CachedContentUsageMetadata,
|
|
@@ -6790,6 +6874,10 @@ declare namespace types {
|
|
|
6790
6874
|
LiveServerGoAway,
|
|
6791
6875
|
LiveServerSessionResumptionUpdate,
|
|
6792
6876
|
LiveServerMessage,
|
|
6877
|
+
OperationGetParameters,
|
|
6878
|
+
OperationFromAPIResponseParameters,
|
|
6879
|
+
Operation,
|
|
6880
|
+
GenerateVideosOperation,
|
|
6793
6881
|
AutomaticActivityDetection,
|
|
6794
6882
|
RealtimeInputConfig,
|
|
6795
6883
|
SessionResumptionConfig,
|
|
@@ -6833,7 +6921,6 @@ declare namespace types {
|
|
|
6833
6921
|
LiveConnectConstraints,
|
|
6834
6922
|
CreateAuthTokenConfig,
|
|
6835
6923
|
CreateAuthTokenParameters,
|
|
6836
|
-
OperationGetParameters,
|
|
6837
6924
|
BlobImageUnion,
|
|
6838
6925
|
PartUnion,
|
|
6839
6926
|
PartListUnion,
|
|
@@ -6844,7 +6931,8 @@ declare namespace types {
|
|
|
6844
6931
|
ToolUnion,
|
|
6845
6932
|
ToolListUnion,
|
|
6846
6933
|
DownloadableFileUnion,
|
|
6847
|
-
BatchJobSourceUnion
|
|
6934
|
+
BatchJobSourceUnion,
|
|
6935
|
+
BatchJobDestinationUnion
|
|
6848
6936
|
}
|
|
6849
6937
|
}
|
|
6850
6938
|
|