@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.
package/dist/web/web.d.ts CHANGED
@@ -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;
@@ -4635,6 +4702,7 @@ export declare interface LiveServerSessionResumptionUpdate {
4635
4702
  lastConsumedClientMessageIndex?: string;
4636
4703
  }
4637
4704
 
4705
+ /** Sent in response to a `LiveGenerateContentSetup` message from the client. */
4638
4706
  export declare interface LiveServerSetupComplete {
4639
4707
  /** The session id of the live session. */
4640
4708
  sessionId?: string;
@@ -5033,7 +5101,9 @@ export declare class Models extends BaseModule {
5033
5101
  * ```ts
5034
5102
  * const operation = await ai.models.generateVideos({
5035
5103
  * model: 'veo-2.0-generate-001',
5036
- * prompt: 'A neon hologram of a cat driving at top speed',
5104
+ * source: {
5105
+ * prompt: 'A neon hologram of a cat driving at top speed',
5106
+ * },
5037
5107
  * config: {
5038
5108
  * numberOfVideos: 1
5039
5109
  * });
@@ -5132,6 +5202,27 @@ export declare class Models extends BaseModule {
5132
5202
  * ```
5133
5203
  */
5134
5204
  recontextImage(params: types.RecontextImageParameters): Promise<types.RecontextImageResponse>;
5205
+ /**
5206
+ * Segments an image, creating a mask of a specified area.
5207
+ *
5208
+ * @param params - The parameters for segmenting an image.
5209
+ * @return The response from the API.
5210
+ *
5211
+ * @example
5212
+ * ```ts
5213
+ * const response = await ai.models.segmentImage({
5214
+ * model: 'image-segmentation-001',
5215
+ * source: {
5216
+ * image: image,
5217
+ * },
5218
+ * config: {
5219
+ * mode: 'foreground',
5220
+ * },
5221
+ * });
5222
+ * console.log(response?.generatedMasks?.[0]?.mask?.imageBytes);
5223
+ * ```
5224
+ */
5225
+ segmentImage(params: types.SegmentImageParameters): Promise<types.SegmentImageResponse>;
5135
5226
  /**
5136
5227
  * Fetches information about a model by name.
5137
5228
  *
@@ -5298,10 +5389,10 @@ export declare interface OperationFromAPIResponseParameters {
5298
5389
 
5299
5390
  /** Parameters for the get method of the operations module. */
5300
5391
  export declare interface OperationGetParameters<T, U extends Operation<T>> {
5301
- /** The operation to be retrieved. */
5302
- operation: U;
5303
5392
  /** Used to override the default configuration. */
5304
5393
  config?: GetOperationConfig;
5394
+ /** The operation to be retrieved. */
5395
+ operation: U;
5305
5396
  }
5306
5397
 
5307
5398
  export declare class Operations extends BaseModule {
@@ -5700,6 +5791,8 @@ export declare interface RecontextImageConfig {
5700
5791
  /** Whether allow to generate person images, and restrict to specific
5701
5792
  ages. */
5702
5793
  personGeneration?: PersonGeneration;
5794
+ /** Whether to add a SynthID watermark to the generated images. */
5795
+ addWatermark?: boolean;
5703
5796
  /** MIME type of the generated image. */
5704
5797
  outputMimeType?: string;
5705
5798
  /** Compression quality of the generated image (for ``image/jpeg``
@@ -5974,6 +6067,12 @@ export declare interface Schema {
5974
6067
 
5975
6068
  export declare type SchemaUnion = Schema | unknown;
5976
6069
 
6070
+ /** An image mask representing a brush scribble. */
6071
+ export declare interface ScribbleImage {
6072
+ /** The brush scribble to guide segmentation. Valid for the interactive mode. */
6073
+ image?: Image_2;
6074
+ }
6075
+
5977
6076
  /** Google search entry point. */
5978
6077
  export declare interface SearchEntryPoint {
5979
6078
  /** Optional. Web content snippet that can be embedded in a web page or an app webview. */
@@ -5995,6 +6094,75 @@ export declare interface Segment {
5995
6094
  text?: string;
5996
6095
  }
5997
6096
 
6097
+ /** Configuration for segmenting an image. */
6098
+ export declare interface SegmentImageConfig {
6099
+ /** Used to override HTTP request options. */
6100
+ httpOptions?: HttpOptions;
6101
+ /** Abort signal which can be used to cancel the request.
6102
+
6103
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
6104
+ operation will not cancel the request in the service. You will still
6105
+ be charged usage for any applicable operations.
6106
+ */
6107
+ abortSignal?: AbortSignal;
6108
+ /** The segmentation mode to use. */
6109
+ mode?: SegmentMode;
6110
+ /** The maximum number of predictions to return up to, by top
6111
+ confidence score. */
6112
+ maxPredictions?: number;
6113
+ /** The confidence score threshold for the detections as a decimal
6114
+ value. Only predictions with a confidence score higher than this
6115
+ threshold will be returned. */
6116
+ confidenceThreshold?: number;
6117
+ /** A decimal value representing how much dilation to apply to the
6118
+ masks. 0 for no dilation. 1.0 means the masked area covers the whole
6119
+ image. */
6120
+ maskDilation?: number;
6121
+ /** The binary color threshold to apply to the masks. The threshold
6122
+ can be set to a decimal value between 0 and 255 non-inclusive.
6123
+ Set to -1 for no binary color thresholding. */
6124
+ binaryColorThreshold?: number;
6125
+ }
6126
+
6127
+ /** The parameters for segmenting an image. */
6128
+ export declare interface SegmentImageParameters {
6129
+ /** ID of the model to use. For a list of models, see `Google models
6130
+ <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
6131
+ model: string;
6132
+ /** A set of source input(s) for image segmentation. */
6133
+ source: SegmentImageSource;
6134
+ /** Configuration for image segmentation. */
6135
+ config?: SegmentImageConfig;
6136
+ }
6137
+
6138
+ /** The output images response. */
6139
+ export declare class SegmentImageResponse {
6140
+ /** List of generated image masks.
6141
+ */
6142
+ generatedMasks?: GeneratedImageMask[];
6143
+ }
6144
+
6145
+ /** A set of source input(s) for image segmentation. */
6146
+ export declare interface SegmentImageSource {
6147
+ /** A text prompt for guiding the model during image segmentation.
6148
+ Required for prompt mode and semantic mode, disallowed for other modes. */
6149
+ prompt?: string;
6150
+ /** The image to be segmented. */
6151
+ image?: Image_2;
6152
+ /** The brush scribble to guide segmentation.
6153
+ Required for the interactive mode, disallowed for other modes. */
6154
+ scribbleImage?: ScribbleImage;
6155
+ }
6156
+
6157
+ /** Enum that represents the segmentation mode. */
6158
+ export declare enum SegmentMode {
6159
+ FOREGROUND = "FOREGROUND",
6160
+ BACKGROUND = "BACKGROUND",
6161
+ PROMPT = "PROMPT",
6162
+ SEMANTIC = "SEMANTIC",
6163
+ INTERACTIVE = "INTERACTIVE"
6164
+ }
6165
+
5998
6166
  /** Parameters for sending a message within a chat session.
5999
6167
 
6000
6168
  These parameters are used with the `chat.sendMessage()` method.
@@ -6509,7 +6677,7 @@ export declare class Tokens extends BaseModule {
6509
6677
 
6510
6678
  /** Tokens info with a list of tokens and the corresponding list of token ids. */
6511
6679
  export declare interface TokensInfo {
6512
- /** Optional. Optional fields for the role from the corresponding Content. */
6680
+ /** Optional fields for the role from the corresponding Content. */
6513
6681
  role?: string;
6514
6682
  /** A list of token ids from the input. */
6515
6683
  tokenIds?: string[];
@@ -6776,6 +6944,18 @@ declare class Tunings extends BaseModule {
6776
6944
  tune: (params: types.CreateTuningJobParameters) => Promise<types.TuningJob>;
6777
6945
  private getInternal;
6778
6946
  private listInternal;
6947
+ /**
6948
+ * Cancels a tuning job.
6949
+ *
6950
+ * @param params - The parameters for the cancel request.
6951
+ * @return The empty response returned by the API.
6952
+ *
6953
+ * @example
6954
+ * ```ts
6955
+ * await ai.tunings.cancel({name: '...'}); // The server-generated resource name.
6956
+ * ```
6957
+ */
6958
+ cancel(params: types.CancelTuningJobParameters): Promise<void>;
6779
6959
  private tuneInternal;
6780
6960
  private tuneMldevInternal;
6781
6961
  }
@@ -6882,6 +7062,8 @@ declare namespace types {
6882
7062
  ControlReferenceType,
6883
7063
  SubjectReferenceType,
6884
7064
  EditMode,
7065
+ SegmentMode,
7066
+ VideoGenerationReferenceType,
6885
7067
  VideoCompressionQuality,
6886
7068
  FileState,
6887
7069
  FileSource,
@@ -7012,6 +7194,13 @@ declare namespace types {
7012
7194
  RecontextImageConfig,
7013
7195
  RecontextImageParameters,
7014
7196
  RecontextImageResponse,
7197
+ ScribbleImage,
7198
+ SegmentImageSource,
7199
+ SegmentImageConfig,
7200
+ SegmentImageParameters,
7201
+ EntityLabel,
7202
+ GeneratedImageMask,
7203
+ SegmentImageResponse,
7015
7204
  GetModelConfig,
7016
7205
  GetModelParameters,
7017
7206
  Endpoint,
@@ -7036,10 +7225,14 @@ declare namespace types {
7036
7225
  TokensInfo,
7037
7226
  ComputeTokensResponse,
7038
7227
  Video,
7228
+ GenerateVideosSource,
7229
+ VideoGenerationReferenceImage,
7039
7230
  GenerateVideosConfig,
7040
7231
  GenerateVideosParameters,
7041
7232
  GeneratedVideo,
7042
7233
  GenerateVideosResponse,
7234
+ Operation,
7235
+ GenerateVideosOperation,
7043
7236
  GetTuningJobConfig,
7044
7237
  GetTuningJobParameters,
7045
7238
  TunedModelCheckpoint,
@@ -7065,6 +7258,8 @@ declare namespace types {
7065
7258
  ListTuningJobsConfig,
7066
7259
  ListTuningJobsParameters,
7067
7260
  ListTuningJobsResponse,
7261
+ CancelTuningJobConfig,
7262
+ CancelTuningJobParameters,
7068
7263
  TuningExample,
7069
7264
  TuningDataset,
7070
7265
  TuningValidationDataset,
@@ -7145,10 +7340,7 @@ declare namespace types {
7145
7340
  LiveServerGoAway,
7146
7341
  LiveServerSessionResumptionUpdate,
7147
7342
  LiveServerMessage,
7148
- OperationGetParameters,
7149
7343
  OperationFromAPIResponseParameters,
7150
- Operation,
7151
- GenerateVideosOperation,
7152
7344
  AutomaticActivityDetection,
7153
7345
  RealtimeInputConfig,
7154
7346
  SessionResumptionConfig,
@@ -7192,6 +7384,7 @@ declare namespace types {
7192
7384
  LiveConnectConstraints,
7193
7385
  CreateAuthTokenConfig,
7194
7386
  CreateAuthTokenParameters,
7387
+ OperationGetParameters,
7195
7388
  CreateTuningJobParameters,
7196
7389
  BlobImageUnion,
7197
7390
  PartUnion,
@@ -7322,6 +7515,8 @@ export declare interface UpscaleImageConfig {
7322
7515
  be charged usage for any applicable operations.
7323
7516
  */
7324
7517
  abortSignal?: AbortSignal;
7518
+ /** Cloud Storage URI used to store the generated images. */
7519
+ outputGcsUri?: string;
7325
7520
  /** Whether to include a reason for filtered-out images in the
7326
7521
  response. */
7327
7522
  includeRaiReason?: boolean;
@@ -7500,6 +7695,31 @@ export declare enum VideoCompressionQuality {
7500
7695
  LOSSLESS = "LOSSLESS"
7501
7696
  }
7502
7697
 
7698
+ /** A reference image for video generation. */
7699
+ export declare interface VideoGenerationReferenceImage {
7700
+ /** The reference image.
7701
+ */
7702
+ image?: Image_2;
7703
+ /** The type of the reference image, which defines how the reference
7704
+ image will be used to generate the video. */
7705
+ referenceType?: VideoGenerationReferenceType;
7706
+ }
7707
+
7708
+ /** Enum for the reference type of a video generation reference image. */
7709
+ export declare enum VideoGenerationReferenceType {
7710
+ /**
7711
+ * A reference image that provides assets to the generated video,
7712
+ such as the scene, an object, a character, etc.
7713
+ */
7714
+ ASSET = "ASSET",
7715
+ /**
7716
+ * A reference image that provides aesthetics including colors,
7717
+ lighting, texture, etc., to be used as the style of the generated video,
7718
+ such as 'anime', 'photography', 'origami', etc.
7719
+ */
7720
+ STYLE = "STYLE"
7721
+ }
7722
+
7503
7723
  /** Describes how the video in the Part should be used by the model. */
7504
7724
  export declare interface VideoMetadata {
7505
7725
  /** The frame rate of the video sent to the model. If not specified, the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/genai",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/node/index.mjs",
@@ -94,7 +94,7 @@
94
94
  "prettier": "3.3.3",
95
95
  "prettier-plugin-organize-imports": "^4.1.0",
96
96
  "rollup-plugin-typescript2": "^0.36.0",
97
- "test-server-sdk": "^0.2.6",
97
+ "test-server-sdk": "^0.2.7",
98
98
  "ts-node": "^10.9.2",
99
99
  "tslib": "^2.8.1",
100
100
  "tsx": "^4.19.4",
@@ -109,7 +109,7 @@
109
109
  "ws": "^8.18.0"
110
110
  },
111
111
  "peerDependencies": {
112
- "@modelcontextprotocol/sdk": "^1.11.0"
112
+ "@modelcontextprotocol/sdk": "^1.11.4"
113
113
  },
114
114
  "peerDependenciesMeta": {
115
115
  "@modelcontextprotocol/sdk": {