@google/genai 1.14.0 → 1.16.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.
@@ -817,6 +817,27 @@ export declare interface CancelBatchJobParameters {
817
817
  config?: CancelBatchJobConfig;
818
818
  }
819
819
 
820
+ /** Optional parameters for tunings.cancel method. */
821
+ export declare interface CancelTuningJobConfig {
822
+ /** Used to override HTTP request options. */
823
+ httpOptions?: HttpOptions;
824
+ /** Abort signal which can be used to cancel the request.
825
+
826
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
827
+ operation will not cancel the request in the service. You will still
828
+ be charged usage for any applicable operations.
829
+ */
830
+ abortSignal?: AbortSignal;
831
+ }
832
+
833
+ /** Parameters for the cancel method. */
834
+ export declare interface CancelTuningJobParameters {
835
+ /** The resource name of the tuning job. */
836
+ name: string;
837
+ /** Optional parameters for the request. */
838
+ config?: CancelTuningJobConfig;
839
+ }
840
+
820
841
  /** A response candidate generated from the model. */
821
842
  export declare interface Candidate {
822
843
  /** Contains the multi-part content of the response.
@@ -1561,6 +1582,8 @@ export declare interface DeleteCachedContentParameters {
1561
1582
 
1562
1583
  /** Empty response for caches.delete method. */
1563
1584
  export declare class DeleteCachedContentResponse {
1585
+ /** Used to retain the full HTTP response. */
1586
+ sdkHttpResponse?: HttpResponse;
1564
1587
  }
1565
1588
 
1566
1589
  /** Used to override the default configuration. */
@@ -1586,6 +1609,8 @@ export declare interface DeleteFileParameters {
1586
1609
 
1587
1610
  /** Response for the delete file method. */
1588
1611
  export declare class DeleteFileResponse {
1612
+ /** Used to retain the full HTTP response. */
1613
+ sdkHttpResponse?: HttpResponse;
1589
1614
  }
1590
1615
 
1591
1616
  /** Configuration for deleting a tuned model. */
@@ -1609,6 +1634,8 @@ export declare interface DeleteModelParameters {
1609
1634
  }
1610
1635
 
1611
1636
  export declare class DeleteModelResponse {
1637
+ /** Used to retain the full HTTP response. */
1638
+ sdkHttpResponse?: HttpResponse;
1612
1639
  }
1613
1640
 
1614
1641
  /** The return value of delete operation. */
@@ -1885,6 +1912,14 @@ export declare interface EnterpriseWebSearch {
1885
1912
  excludeDomains?: string[];
1886
1913
  }
1887
1914
 
1915
+ /** An entity representing the segmented area. */
1916
+ export declare interface EntityLabel {
1917
+ /** The label of the segmented entity. */
1918
+ label?: string;
1919
+ /** The confidence score of the detected label. */
1920
+ score?: number;
1921
+ }
1922
+
1888
1923
  /** The environment being operated. */
1889
1924
  export declare enum Environment {
1890
1925
  /**
@@ -2260,7 +2295,11 @@ export declare enum FunctionCallingConfigMode {
2260
2295
  /**
2261
2296
  * Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
2262
2297
  */
2263
- NONE = "NONE"
2298
+ NONE = "NONE",
2299
+ /**
2300
+ * Model decides to predict either a function call or a natural language response, but will validate function calls with constrained decoding. If "allowed_function_names" are set, the predicted function call will be limited to any one of "allowed_function_names", else the predicted function call will be any one of the provided "function_declarations".
2301
+ */
2302
+ VALIDATED = "VALIDATED"
2264
2303
  }
2265
2304
 
2266
2305
  /** Defines a function that the model can generate JSON inputs for.
@@ -2702,6 +2741,14 @@ export declare interface GeneratedImage {
2702
2741
  enhancedPrompt?: string;
2703
2742
  }
2704
2743
 
2744
+ /** A generated image mask. */
2745
+ export declare interface GeneratedImageMask {
2746
+ /** The generated image mask. */
2747
+ mask?: Image_2;
2748
+ /** The detected entities on the segmented area. */
2749
+ labels?: EntityLabel[];
2750
+ }
2751
+
2705
2752
  /** A generated video. */
2706
2753
  export declare interface GeneratedVideo {
2707
2754
  /** The output video */
@@ -2840,11 +2887,17 @@ export declare interface GenerateVideosConfig {
2840
2887
  generateAudio?: boolean;
2841
2888
  /** Image to use as the last frame of generated videos. Only supported for image to video use cases. */
2842
2889
  lastFrame?: Image_2;
2890
+ /** The images to use as the references to generate the videos.
2891
+ If this field is provided, the text prompt field must also be provided.
2892
+ The image, video, or last_frame field are not supported. Each image must
2893
+ be associated with a type. Veo 2 supports up to 3 asset images *or* 1
2894
+ style image. */
2895
+ referenceImages?: VideoGenerationReferenceImage[];
2843
2896
  /** Compression quality of the generated videos. */
2844
2897
  compressionQuality?: VideoCompressionQuality;
2845
2898
  }
2846
2899
 
2847
- /** A video generation long-running operation. */
2900
+ /** A video generation operation. */
2848
2901
  export declare class GenerateVideosOperation implements Operation<GenerateVideosResponse> {
2849
2902
  /** 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}`. */
2850
2903
  name?: string;
@@ -2854,7 +2907,7 @@ export declare class GenerateVideosOperation implements Operation<GenerateVideos
2854
2907
  done?: boolean;
2855
2908
  /** The error result of the operation in case of failure or cancellation. */
2856
2909
  error?: Record<string, unknown>;
2857
- /** The response if the operation is successful. */
2910
+ /** The generated videos. */
2858
2911
  response?: GenerateVideosResponse;
2859
2912
  /** The full HTTP response. */
2860
2913
  sdkHttpResponse?: HttpResponse;
@@ -2878,6 +2931,8 @@ export declare interface GenerateVideosParameters {
2878
2931
  /** The input video for video extension use cases.
2879
2932
  Optional if prompt or image is provided. */
2880
2933
  video?: Video;
2934
+ /** A set of source input(s) for video generation. */
2935
+ source?: GenerateVideosSource;
2881
2936
  /** Configuration for generating videos. */
2882
2937
  config?: GenerateVideosConfig;
2883
2938
  }
@@ -2892,6 +2947,19 @@ export declare class GenerateVideosResponse {
2892
2947
  raiMediaFilteredReasons?: string[];
2893
2948
  }
2894
2949
 
2950
+ /** A set of source input(s) for video generation. */
2951
+ export declare interface GenerateVideosSource {
2952
+ /** The text prompt for generating the videos.
2953
+ Optional if image or video is provided. */
2954
+ prompt?: string;
2955
+ /** The input image for generating the videos.
2956
+ Optional if prompt or video is provided. */
2957
+ image?: Image_2;
2958
+ /** The input video for video extension use cases.
2959
+ Optional if prompt or image is provided. */
2960
+ video?: Video;
2961
+ }
2962
+
2895
2963
  /** Generation config. */
2896
2964
  export declare interface GenerationConfig {
2897
2965
  /** Optional. Config for model selection. */
@@ -3075,7 +3143,6 @@ export declare interface GetOperationParameters {
3075
3143
  config?: GetOperationConfig;
3076
3144
  }
3077
3145
 
3078
- /** Optional parameters for tunings.get method. */
3079
3146
  export declare interface GetTuningJobConfig {
3080
3147
  /** Used to override HTTP request options. */
3081
3148
  httpOptions?: HttpOptions;
@@ -4642,6 +4709,7 @@ export declare interface LiveServerSessionResumptionUpdate {
4642
4709
  lastConsumedClientMessageIndex?: string;
4643
4710
  }
4644
4711
 
4712
+ /** Sent in response to a `LiveGenerateContentSetup` message from the client. */
4645
4713
  export declare interface LiveServerSetupComplete {
4646
4714
  /** The session id of the live session. */
4647
4715
  sessionId?: string;
@@ -5040,7 +5108,9 @@ export declare class Models extends BaseModule {
5040
5108
  * ```ts
5041
5109
  * const operation = await ai.models.generateVideos({
5042
5110
  * model: 'veo-2.0-generate-001',
5043
- * prompt: 'A neon hologram of a cat driving at top speed',
5111
+ * source: {
5112
+ * prompt: 'A neon hologram of a cat driving at top speed',
5113
+ * },
5044
5114
  * config: {
5045
5115
  * numberOfVideos: 1
5046
5116
  * });
@@ -5139,6 +5209,27 @@ export declare class Models extends BaseModule {
5139
5209
  * ```
5140
5210
  */
5141
5211
  recontextImage(params: types.RecontextImageParameters): Promise<types.RecontextImageResponse>;
5212
+ /**
5213
+ * Segments an image, creating a mask of a specified area.
5214
+ *
5215
+ * @param params - The parameters for segmenting an image.
5216
+ * @return The response from the API.
5217
+ *
5218
+ * @example
5219
+ * ```ts
5220
+ * const response = await ai.models.segmentImage({
5221
+ * model: 'image-segmentation-001',
5222
+ * source: {
5223
+ * image: image,
5224
+ * },
5225
+ * config: {
5226
+ * mode: 'foreground',
5227
+ * },
5228
+ * });
5229
+ * console.log(response?.generatedMasks?.[0]?.mask?.imageBytes);
5230
+ * ```
5231
+ */
5232
+ segmentImage(params: types.SegmentImageParameters): Promise<types.SegmentImageResponse>;
5142
5233
  /**
5143
5234
  * Fetches information about a model by name.
5144
5235
  *
@@ -5305,10 +5396,10 @@ export declare interface OperationFromAPIResponseParameters {
5305
5396
 
5306
5397
  /** Parameters for the get method of the operations module. */
5307
5398
  export declare interface OperationGetParameters<T, U extends Operation<T>> {
5308
- /** The operation to be retrieved. */
5309
- operation: U;
5310
5399
  /** Used to override the default configuration. */
5311
5400
  config?: GetOperationConfig;
5401
+ /** The operation to be retrieved. */
5402
+ operation: U;
5312
5403
  }
5313
5404
 
5314
5405
  export declare class Operations extends BaseModule {
@@ -5707,6 +5798,8 @@ export declare interface RecontextImageConfig {
5707
5798
  /** Whether allow to generate person images, and restrict to specific
5708
5799
  ages. */
5709
5800
  personGeneration?: PersonGeneration;
5801
+ /** Whether to add a SynthID watermark to the generated images. */
5802
+ addWatermark?: boolean;
5710
5803
  /** MIME type of the generated image. */
5711
5804
  outputMimeType?: string;
5712
5805
  /** Compression quality of the generated image (for ``image/jpeg``
@@ -5981,6 +6074,12 @@ export declare interface Schema {
5981
6074
 
5982
6075
  export declare type SchemaUnion = Schema | unknown;
5983
6076
 
6077
+ /** An image mask representing a brush scribble. */
6078
+ export declare interface ScribbleImage {
6079
+ /** The brush scribble to guide segmentation. Valid for the interactive mode. */
6080
+ image?: Image_2;
6081
+ }
6082
+
5984
6083
  /** Google search entry point. */
5985
6084
  export declare interface SearchEntryPoint {
5986
6085
  /** Optional. Web content snippet that can be embedded in a web page or an app webview. */
@@ -6002,6 +6101,75 @@ export declare interface Segment {
6002
6101
  text?: string;
6003
6102
  }
6004
6103
 
6104
+ /** Configuration for segmenting an image. */
6105
+ export declare interface SegmentImageConfig {
6106
+ /** Used to override HTTP request options. */
6107
+ httpOptions?: HttpOptions;
6108
+ /** Abort signal which can be used to cancel the request.
6109
+
6110
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
6111
+ operation will not cancel the request in the service. You will still
6112
+ be charged usage for any applicable operations.
6113
+ */
6114
+ abortSignal?: AbortSignal;
6115
+ /** The segmentation mode to use. */
6116
+ mode?: SegmentMode;
6117
+ /** The maximum number of predictions to return up to, by top
6118
+ confidence score. */
6119
+ maxPredictions?: number;
6120
+ /** The confidence score threshold for the detections as a decimal
6121
+ value. Only predictions with a confidence score higher than this
6122
+ threshold will be returned. */
6123
+ confidenceThreshold?: number;
6124
+ /** A decimal value representing how much dilation to apply to the
6125
+ masks. 0 for no dilation. 1.0 means the masked area covers the whole
6126
+ image. */
6127
+ maskDilation?: number;
6128
+ /** The binary color threshold to apply to the masks. The threshold
6129
+ can be set to a decimal value between 0 and 255 non-inclusive.
6130
+ Set to -1 for no binary color thresholding. */
6131
+ binaryColorThreshold?: number;
6132
+ }
6133
+
6134
+ /** The parameters for segmenting an image. */
6135
+ export declare interface SegmentImageParameters {
6136
+ /** ID of the model to use. For a list of models, see `Google models
6137
+ <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
6138
+ model: string;
6139
+ /** A set of source input(s) for image segmentation. */
6140
+ source: SegmentImageSource;
6141
+ /** Configuration for image segmentation. */
6142
+ config?: SegmentImageConfig;
6143
+ }
6144
+
6145
+ /** The output images response. */
6146
+ export declare class SegmentImageResponse {
6147
+ /** List of generated image masks.
6148
+ */
6149
+ generatedMasks?: GeneratedImageMask[];
6150
+ }
6151
+
6152
+ /** A set of source input(s) for image segmentation. */
6153
+ export declare interface SegmentImageSource {
6154
+ /** A text prompt for guiding the model during image segmentation.
6155
+ Required for prompt mode and semantic mode, disallowed for other modes. */
6156
+ prompt?: string;
6157
+ /** The image to be segmented. */
6158
+ image?: Image_2;
6159
+ /** The brush scribble to guide segmentation.
6160
+ Required for the interactive mode, disallowed for other modes. */
6161
+ scribbleImage?: ScribbleImage;
6162
+ }
6163
+
6164
+ /** Enum that represents the segmentation mode. */
6165
+ export declare enum SegmentMode {
6166
+ FOREGROUND = "FOREGROUND",
6167
+ BACKGROUND = "BACKGROUND",
6168
+ PROMPT = "PROMPT",
6169
+ SEMANTIC = "SEMANTIC",
6170
+ INTERACTIVE = "INTERACTIVE"
6171
+ }
6172
+
6005
6173
  /** Parameters for sending a message within a chat session.
6006
6174
 
6007
6175
  These parameters are used with the `chat.sendMessage()` method.
@@ -6516,7 +6684,7 @@ export declare class Tokens extends BaseModule {
6516
6684
 
6517
6685
  /** Tokens info with a list of tokens and the corresponding list of token ids. */
6518
6686
  export declare interface TokensInfo {
6519
- /** Optional. Optional fields for the role from the corresponding Content. */
6687
+ /** Optional fields for the role from the corresponding Content. */
6520
6688
  role?: string;
6521
6689
  /** A list of token ids from the input. */
6522
6690
  tokenIds?: string[];
@@ -6783,6 +6951,18 @@ declare class Tunings extends BaseModule {
6783
6951
  tune: (params: types.CreateTuningJobParameters) => Promise<types.TuningJob>;
6784
6952
  private getInternal;
6785
6953
  private listInternal;
6954
+ /**
6955
+ * Cancels a tuning job.
6956
+ *
6957
+ * @param params - The parameters for the cancel request.
6958
+ * @return The empty response returned by the API.
6959
+ *
6960
+ * @example
6961
+ * ```ts
6962
+ * await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
6963
+ * ```
6964
+ */
6965
+ cancel(params: types.CancelTuningJobParameters): Promise<void>;
6786
6966
  private tuneInternal;
6787
6967
  private tuneMldevInternal;
6788
6968
  }
@@ -6889,6 +7069,8 @@ declare namespace types {
6889
7069
  ControlReferenceType,
6890
7070
  SubjectReferenceType,
6891
7071
  EditMode,
7072
+ SegmentMode,
7073
+ VideoGenerationReferenceType,
6892
7074
  VideoCompressionQuality,
6893
7075
  FileState,
6894
7076
  FileSource,
@@ -7019,6 +7201,13 @@ declare namespace types {
7019
7201
  RecontextImageConfig,
7020
7202
  RecontextImageParameters,
7021
7203
  RecontextImageResponse,
7204
+ ScribbleImage,
7205
+ SegmentImageSource,
7206
+ SegmentImageConfig,
7207
+ SegmentImageParameters,
7208
+ EntityLabel,
7209
+ GeneratedImageMask,
7210
+ SegmentImageResponse,
7022
7211
  GetModelConfig,
7023
7212
  GetModelParameters,
7024
7213
  Endpoint,
@@ -7043,10 +7232,14 @@ declare namespace types {
7043
7232
  TokensInfo,
7044
7233
  ComputeTokensResponse,
7045
7234
  Video,
7235
+ GenerateVideosSource,
7236
+ VideoGenerationReferenceImage,
7046
7237
  GenerateVideosConfig,
7047
7238
  GenerateVideosParameters,
7048
7239
  GeneratedVideo,
7049
7240
  GenerateVideosResponse,
7241
+ Operation,
7242
+ GenerateVideosOperation,
7050
7243
  GetTuningJobConfig,
7051
7244
  GetTuningJobParameters,
7052
7245
  TunedModelCheckpoint,
@@ -7072,6 +7265,8 @@ declare namespace types {
7072
7265
  ListTuningJobsConfig,
7073
7266
  ListTuningJobsParameters,
7074
7267
  ListTuningJobsResponse,
7268
+ CancelTuningJobConfig,
7269
+ CancelTuningJobParameters,
7075
7270
  TuningExample,
7076
7271
  TuningDataset,
7077
7272
  TuningValidationDataset,
@@ -7152,10 +7347,7 @@ declare namespace types {
7152
7347
  LiveServerGoAway,
7153
7348
  LiveServerSessionResumptionUpdate,
7154
7349
  LiveServerMessage,
7155
- OperationGetParameters,
7156
7350
  OperationFromAPIResponseParameters,
7157
- Operation,
7158
- GenerateVideosOperation,
7159
7351
  AutomaticActivityDetection,
7160
7352
  RealtimeInputConfig,
7161
7353
  SessionResumptionConfig,
@@ -7199,6 +7391,7 @@ declare namespace types {
7199
7391
  LiveConnectConstraints,
7200
7392
  CreateAuthTokenConfig,
7201
7393
  CreateAuthTokenParameters,
7394
+ OperationGetParameters,
7202
7395
  CreateTuningJobParameters,
7203
7396
  BlobImageUnion,
7204
7397
  PartUnion,
@@ -7329,6 +7522,8 @@ export declare interface UpscaleImageConfig {
7329
7522
  be charged usage for any applicable operations.
7330
7523
  */
7331
7524
  abortSignal?: AbortSignal;
7525
+ /** Cloud Storage URI used to store the generated images. */
7526
+ outputGcsUri?: string;
7332
7527
  /** Whether to include a reason for filtered-out images in the
7333
7528
  response. */
7334
7529
  includeRaiReason?: boolean;
@@ -7507,6 +7702,31 @@ export declare enum VideoCompressionQuality {
7507
7702
  LOSSLESS = "LOSSLESS"
7508
7703
  }
7509
7704
 
7705
+ /** A reference image for video generation. */
7706
+ export declare interface VideoGenerationReferenceImage {
7707
+ /** The reference image.
7708
+ */
7709
+ image?: Image_2;
7710
+ /** The type of the reference image, which defines how the reference
7711
+ image will be used to generate the video. */
7712
+ referenceType?: VideoGenerationReferenceType;
7713
+ }
7714
+
7715
+ /** Enum for the reference type of a video generation reference image. */
7716
+ export declare enum VideoGenerationReferenceType {
7717
+ /**
7718
+ * A reference image that provides assets to the generated video,
7719
+ such as the scene, an object, a character, etc.
7720
+ */
7721
+ ASSET = "ASSET",
7722
+ /**
7723
+ * A reference image that provides aesthetics including colors,
7724
+ lighting, texture, etc., to be used as the style of the generated video,
7725
+ such as 'anime', 'photography', 'origami', etc.
7726
+ */
7727
+ STYLE = "STYLE"
7728
+ }
7729
+
7510
7730
  /** Describes how the video in the Part should be used by the model. */
7511
7731
  export declare interface VideoMetadata {
7512
7732
  /** The frame rate of the video sent to the model. If not specified, the