@google/genai 1.16.0 → 1.17.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.
@@ -1720,54 +1720,40 @@ export declare interface EditImageConfig {
1720
1720
  be charged usage for any applicable operations.
1721
1721
  */
1722
1722
  abortSignal?: AbortSignal;
1723
- /** Cloud Storage URI used to store the generated images.
1724
- */
1723
+ /** Cloud Storage URI used to store the generated images. */
1725
1724
  outputGcsUri?: string;
1726
- /** Description of what to discourage in the generated images.
1727
- */
1725
+ /** Description of what to discourage in the generated images. */
1728
1726
  negativePrompt?: string;
1729
- /** Number of images to generate.
1730
- */
1727
+ /** Number of images to generate. */
1731
1728
  numberOfImages?: number;
1732
1729
  /** Aspect ratio of the generated images. Supported values are
1733
- "1:1", "3:4", "4:3", "9:16", and "16:9".
1734
- */
1730
+ "1:1", "3:4", "4:3", "9:16", and "16:9". */
1735
1731
  aspectRatio?: string;
1736
1732
  /** Controls how much the model adheres to the text prompt. Large
1737
1733
  values increase output and prompt alignment, but may compromise image
1738
- quality.
1739
- */
1734
+ quality. */
1740
1735
  guidanceScale?: number;
1741
1736
  /** Random seed for image generation. This is not available when
1742
- ``add_watermark`` is set to true.
1743
- */
1737
+ ``add_watermark`` is set to true. */
1744
1738
  seed?: number;
1745
- /** Filter level for safety filtering.
1746
- */
1739
+ /** Filter level for safety filtering. */
1747
1740
  safetyFilterLevel?: SafetyFilterLevel;
1748
- /** Allows generation of people by the model.
1749
- */
1741
+ /** Allows generation of people by the model. */
1750
1742
  personGeneration?: PersonGeneration;
1751
1743
  /** Whether to report the safety scores of each generated image and
1752
- the positive prompt in the response.
1753
- */
1744
+ the positive prompt in the response. */
1754
1745
  includeSafetyAttributes?: boolean;
1755
1746
  /** Whether to include the Responsible AI filter reason if the image
1756
- is filtered out of the response.
1757
- */
1747
+ is filtered out of the response. */
1758
1748
  includeRaiReason?: boolean;
1759
- /** Language of the text in the prompt.
1760
- */
1749
+ /** Language of the text in the prompt. */
1761
1750
  language?: ImagePromptLanguage;
1762
- /** MIME type of the generated image.
1763
- */
1751
+ /** MIME type of the generated image. */
1764
1752
  outputMimeType?: string;
1765
1753
  /** Compression quality of the generated image (for ``image/jpeg``
1766
- only).
1767
- */
1754
+ only). */
1768
1755
  outputCompressionQuality?: number;
1769
- /** Whether to add a watermark to the generated images.
1770
- */
1756
+ /** Whether to add a watermark to the generated images. */
1771
1757
  addWatermark?: boolean;
1772
1758
  /** Describes the editing mode for the request. */
1773
1759
  editMode?: EditMode;
@@ -1796,7 +1782,7 @@ export declare class EditImageResponse {
1796
1782
  generatedImages?: GeneratedImage[];
1797
1783
  }
1798
1784
 
1799
- /** Enum representing the Imagen 3 Edit mode. */
1785
+ /** Enum representing the editing mode. */
1800
1786
  export declare enum EditMode {
1801
1787
  EDIT_MODE_DEFAULT = "EDIT_MODE_DEFAULT",
1802
1788
  EDIT_MODE_INPAINT_REMOVAL = "EDIT_MODE_INPAINT_REMOVAL",
@@ -2724,20 +2710,16 @@ export declare class GenerateContentResponseUsageMetadata {
2724
2710
 
2725
2711
  /** An output image. */
2726
2712
  export declare interface GeneratedImage {
2727
- /** The output image data.
2728
- */
2713
+ /** The output image data. */
2729
2714
  image?: Image_2;
2730
2715
  /** Responsible AI filter reason if the image is filtered out of the
2731
- response.
2732
- */
2716
+ response. */
2733
2717
  raiFilteredReason?: string;
2734
2718
  /** Safety attributes of the image. Lists of RAI categories and their
2735
- scores of each content.
2736
- */
2719
+ scores of each content. */
2737
2720
  safetyAttributes?: SafetyAttributes;
2738
2721
  /** The rewritten prompt used for the image generation if the prompt
2739
- enhancer is enabled.
2740
- */
2722
+ enhancer is enabled. */
2741
2723
  enhancedPrompt?: string;
2742
2724
  }
2743
2725
 
@@ -2766,61 +2748,45 @@ export declare interface GenerateImagesConfig {
2766
2748
  be charged usage for any applicable operations.
2767
2749
  */
2768
2750
  abortSignal?: AbortSignal;
2769
- /** Cloud Storage URI used to store the generated images.
2770
- */
2751
+ /** Cloud Storage URI used to store the generated images. */
2771
2752
  outputGcsUri?: string;
2772
- /** Description of what to discourage in the generated images.
2773
- */
2753
+ /** Description of what to discourage in the generated images. */
2774
2754
  negativePrompt?: string;
2775
- /** Number of images to generate.
2776
- */
2755
+ /** Number of images to generate. */
2777
2756
  numberOfImages?: number;
2778
2757
  /** Aspect ratio of the generated images. Supported values are
2779
- "1:1", "3:4", "4:3", "9:16", and "16:9".
2780
- */
2758
+ "1:1", "3:4", "4:3", "9:16", and "16:9". */
2781
2759
  aspectRatio?: string;
2782
2760
  /** Controls how much the model adheres to the text prompt. Large
2783
2761
  values increase output and prompt alignment, but may compromise image
2784
- quality.
2785
- */
2762
+ quality. */
2786
2763
  guidanceScale?: number;
2787
2764
  /** Random seed for image generation. This is not available when
2788
- ``add_watermark`` is set to true.
2789
- */
2765
+ ``add_watermark`` is set to true. */
2790
2766
  seed?: number;
2791
- /** Filter level for safety filtering.
2792
- */
2767
+ /** Filter level for safety filtering. */
2793
2768
  safetyFilterLevel?: SafetyFilterLevel;
2794
- /** Allows generation of people by the model.
2795
- */
2769
+ /** Allows generation of people by the model. */
2796
2770
  personGeneration?: PersonGeneration;
2797
2771
  /** Whether to report the safety scores of each generated image and
2798
- the positive prompt in the response.
2799
- */
2772
+ the positive prompt in the response. */
2800
2773
  includeSafetyAttributes?: boolean;
2801
2774
  /** Whether to include the Responsible AI filter reason if the image
2802
- is filtered out of the response.
2803
- */
2775
+ is filtered out of the response. */
2804
2776
  includeRaiReason?: boolean;
2805
- /** Language of the text in the prompt.
2806
- */
2777
+ /** Language of the text in the prompt. */
2807
2778
  language?: ImagePromptLanguage;
2808
- /** MIME type of the generated image.
2809
- */
2779
+ /** MIME type of the generated image. */
2810
2780
  outputMimeType?: string;
2811
2781
  /** Compression quality of the generated image (for ``image/jpeg``
2812
- only).
2813
- */
2782
+ only). */
2814
2783
  outputCompressionQuality?: number;
2815
- /** Whether to add a watermark to the generated images.
2816
- */
2784
+ /** Whether to add a watermark to the generated images. */
2817
2785
  addWatermark?: boolean;
2818
2786
  /** The size of the largest dimension of the generated image.
2819
- Supported sizes are 1K and 2K (not supported for Imagen 3 models).
2820
- */
2787
+ Supported sizes are 1K and 2K (not supported for Imagen 3 models). */
2821
2788
  imageSize?: string;
2822
- /** Whether to use the prompt rewriting logic.
2823
- */
2789
+ /** Whether to use the prompt rewriting logic. */
2824
2790
  enhancePrompt?: boolean;
2825
2791
  }
2826
2792
 
@@ -2841,12 +2807,10 @@ export declare interface GenerateImagesParameters {
2841
2807
  export declare class GenerateImagesResponse {
2842
2808
  /** Used to retain the full HTTP response. */
2843
2809
  sdkHttpResponse?: HttpResponse;
2844
- /** List of generated images.
2845
- */
2810
+ /** List of generated images. */
2846
2811
  generatedImages?: GeneratedImage[];
2847
2812
  /** Safety attributes of the positive prompt. Only populated if
2848
- ``include_safety_attributes`` is set to True.
2849
- */
2813
+ ``include_safety_attributes`` is set to True. */
2850
2814
  positivePromptSafetyAttributes?: SafetyAttributes;
2851
2815
  }
2852
2816
 
@@ -2869,23 +2833,32 @@ export declare interface GenerateVideosConfig {
2869
2833
  fps?: number;
2870
2834
  /** Duration of the clip for video generation in seconds. */
2871
2835
  durationSeconds?: number;
2872
- /** The RNG seed. If RNG seed is exactly same for each request with unchanged inputs, the prediction results will be consistent. Otherwise, a random RNG seed will be used each time to produce a different result. */
2836
+ /** The RNG seed. If RNG seed is exactly same for each request with
2837
+ unchanged inputs, the prediction results will be consistent. Otherwise,
2838
+ a random RNG seed will be used each time to produce a different
2839
+ result. */
2873
2840
  seed?: number;
2874
- /** The aspect ratio for the generated video. 16:9 (landscape) and 9:16 (portrait) are supported. */
2841
+ /** The aspect ratio for the generated video. 16:9 (landscape) and
2842
+ 9:16 (portrait) are supported. */
2875
2843
  aspectRatio?: string;
2876
- /** The resolution for the generated video. 720p and 1080p are supported. */
2844
+ /** The resolution for the generated video. 720p and 1080p are
2845
+ supported. */
2877
2846
  resolution?: string;
2878
- /** Whether allow to generate person videos, and restrict to specific ages. Supported values are: dont_allow, allow_adult. */
2847
+ /** Whether allow to generate person videos, and restrict to specific
2848
+ ages. Supported values are: dont_allow, allow_adult. */
2879
2849
  personGeneration?: string;
2880
- /** The pubsub topic where to publish the video generation progress. */
2850
+ /** The pubsub topic where to publish the video generation
2851
+ progress. */
2881
2852
  pubsubTopic?: string;
2882
- /** Optional field in addition to the text content. Negative prompts can be explicitly stated here to help generate the video. */
2853
+ /** Explicitly state what should not be included in the generated
2854
+ videos. */
2883
2855
  negativePrompt?: string;
2884
2856
  /** Whether to use the prompt rewriting logic. */
2885
2857
  enhancePrompt?: boolean;
2886
2858
  /** Whether to generate audio along with the video. */
2887
2859
  generateAudio?: boolean;
2888
- /** Image to use as the last frame of generated videos. Only supported for image to video use cases. */
2860
+ /** Image to use as the last frame of generated videos.
2861
+ Only supported for image to video use cases. */
2889
2862
  lastFrame?: Image_2;
2890
2863
  /** The images to use as the references to generate the videos.
2891
2864
  If this field is provided, the text prompt field must also be provided.
@@ -2923,13 +2896,14 @@ export declare interface GenerateVideosParameters {
2923
2896
  /** ID of the model to use. For a list of models, see `Google models
2924
2897
  <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */
2925
2898
  model: string;
2926
- /** The text prompt for generating the videos. Optional for image to video use cases. */
2899
+ /** The text prompt for generating the videos.
2900
+ Optional if image or video is provided. */
2927
2901
  prompt?: string;
2928
2902
  /** The input image for generating the videos.
2929
- Optional if prompt or video is provided. */
2903
+ Optional if prompt is provided. Not allowed if video is provided. */
2930
2904
  image?: Image_2;
2931
2905
  /** The input video for video extension use cases.
2932
- Optional if prompt or image is provided. */
2906
+ Optional if prompt is provided. Not allowed if image is provided. */
2933
2907
  video?: Video;
2934
2908
  /** A set of source input(s) for video generation. */
2935
2909
  source?: GenerateVideosSource;
@@ -2953,10 +2927,10 @@ export declare interface GenerateVideosSource {
2953
2927
  Optional if image or video is provided. */
2954
2928
  prompt?: string;
2955
2929
  /** The input image for generating the videos.
2956
- Optional if prompt or video is provided. */
2930
+ Optional if prompt is provided. Not allowed if video is provided. */
2957
2931
  image?: Image_2;
2958
2932
  /** The input video for video extension use cases.
2959
- Optional if prompt or image is provided. */
2933
+ Optional if prompt is provided. Not allowed if image is provided. */
2960
2934
  video?: Video;
2961
2935
  }
2962
2936
 
@@ -3653,12 +3627,10 @@ export declare class HttpResponse {
3653
3627
  /** An image. */
3654
3628
  declare interface Image_2 {
3655
3629
  /** The Cloud Storage URI of the image. ``Image`` can contain a value
3656
- for this field or the ``image_bytes`` field but not both.
3657
- */
3630
+ for this field or the ``image_bytes`` field but not both. */
3658
3631
  gcsUri?: string;
3659
3632
  /** The image bytes data. ``Image`` can contain a value for this field
3660
3633
  or the ``gcs_uri`` field but not both.
3661
-
3662
3634
  * @remarks Encoded as base64 string. */
3663
3635
  imageBytes?: string;
3664
3636
  /** The MIME type of the image. */
@@ -5149,26 +5121,16 @@ export declare class Models extends BaseModule {
5149
5121
  */
5150
5122
  embedContent(params: types.EmbedContentParameters): Promise<types.EmbedContentResponse>;
5151
5123
  /**
5152
- * Generates an image based on a text description and configuration.
5153
- *
5154
- * @param params - The parameters for generating images.
5155
- * @return The response from the API.
5156
- *
5157
- * @example
5158
- * ```ts
5159
- * const response = await ai.models.generateImages({
5160
- * model: 'imagen-3.0-generate-002',
5161
- * prompt: 'Robot holding a red skateboard',
5162
- * config: {
5163
- * numberOfImages: 1,
5164
- * includeRaiReason: true,
5165
- * },
5166
- * });
5167
- * console.log(response?.generatedImages?.[0]?.image?.imageBytes);
5168
- * ```
5124
+ * Private method for generating images.
5169
5125
  */
5170
5126
  private generateImagesInternal;
5127
+ /**
5128
+ * Private method for editing an image.
5129
+ */
5171
5130
  private editImageInternal;
5131
+ /**
5132
+ * Private method for upscaling an image.
5133
+ */
5172
5134
  private upscaleImageInternal;
5173
5135
  /**
5174
5136
  * Recontextualizes an image.
@@ -5307,27 +5269,7 @@ export declare class Models extends BaseModule {
5307
5269
  */
5308
5270
  computeTokens(params: types.ComputeTokensParameters): Promise<types.ComputeTokensResponse>;
5309
5271
  /**
5310
- * Generates videos based on a text description and configuration.
5311
- *
5312
- * @param params - The parameters for generating videos.
5313
- * @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
5314
- *
5315
- * @example
5316
- * ```ts
5317
- * const operation = await ai.models.generateVideos({
5318
- * model: 'veo-2.0-generate-001',
5319
- * prompt: 'A neon hologram of a cat driving at top speed',
5320
- * config: {
5321
- * numberOfVideos: 1
5322
- * });
5323
- *
5324
- * while (!operation.done) {
5325
- * await new Promise(resolve => setTimeout(resolve, 10000));
5326
- * operation = await ai.operations.getVideosOperation({operation: operation});
5327
- * }
5328
- *
5329
- * console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
5330
- * ```
5272
+ * Private method for generating videos.
5331
5273
  */
5332
5274
  private generateVideosInternal;
5333
5275
  }
@@ -5915,14 +5857,11 @@ export declare interface RetrievalMetadata {
5915
5857
 
5916
5858
  /** Safety attributes of a GeneratedImage or the user-provided prompt. */
5917
5859
  export declare interface SafetyAttributes {
5918
- /** List of RAI categories.
5919
- */
5860
+ /** List of RAI categories. */
5920
5861
  categories?: string[];
5921
- /** List of scores of each categories.
5922
- */
5862
+ /** List of scores of each categories. */
5923
5863
  scores?: number[];
5924
- /** Internal use only.
5925
- */
5864
+ /** Internal use only. */
5926
5865
  contentType?: string;
5927
5866
  }
5928
5867
 
@@ -7529,8 +7468,8 @@ export declare interface UpscaleImageConfig {
7529
7468
  includeRaiReason?: boolean;
7530
7469
  /** The image format that the output should be saved as. */
7531
7470
  outputMimeType?: string;
7532
- /** The level of compression if the ``output_mime_type`` is
7533
- ``image/jpeg``. */
7471
+ /** The level of compression. Only applicable if the
7472
+ ``output_mime_type`` is ``image/jpeg``. */
7534
7473
  outputCompressionQuality?: number;
7535
7474
  /** Whether to add an image enhancing step before upscaling.
7536
7475
  It is expected to suppress the noise and JPEG compression artifacts
@@ -7684,7 +7623,7 @@ export declare interface Video {
7684
7623
  /** Video bytes.
7685
7624
  * @remarks Encoded as base64 string. */
7686
7625
  videoBytes?: string;
7687
- /** Video encoding, for example "video/mp4". */
7626
+ /** Video encoding, for example ``video/mp4``. */
7688
7627
  mimeType?: string;
7689
7628
  }
7690
7629
 
@@ -7704,8 +7643,7 @@ export declare enum VideoCompressionQuality {
7704
7643
 
7705
7644
  /** A reference image for video generation. */
7706
7645
  export declare interface VideoGenerationReferenceImage {
7707
- /** The reference image.
7708
- */
7646
+ /** The reference image. */
7709
7647
  image?: Image_2;
7710
7648
  /** The type of the reference image, which defines how the reference
7711
7649
  image will be used to generate the video. */
@@ -889,7 +889,7 @@ var SubjectReferenceType;
889
889
  SubjectReferenceType["SUBJECT_TYPE_ANIMAL"] = "SUBJECT_TYPE_ANIMAL";
890
890
  SubjectReferenceType["SUBJECT_TYPE_PRODUCT"] = "SUBJECT_TYPE_PRODUCT";
891
891
  })(SubjectReferenceType || (SubjectReferenceType = {}));
892
- /** Enum representing the Imagen 3 Edit mode. */
892
+ /** Enum representing the editing mode. */
893
893
  var EditMode;
894
894
  (function (EditMode) {
895
895
  EditMode["EDIT_MODE_DEFAULT"] = "EDIT_MODE_DEFAULT";
@@ -10524,8 +10524,9 @@ function generateVideosConfigToMldev(fromObject, parentObject) {
10524
10524
  if (parentObject !== undefined && fromAspectRatio != null) {
10525
10525
  setValueByPath(parentObject, ['parameters', 'aspectRatio'], fromAspectRatio);
10526
10526
  }
10527
- if (getValueByPath(fromObject, ['resolution']) !== undefined) {
10528
- throw new Error('resolution parameter is not supported in Gemini API.');
10527
+ const fromResolution = getValueByPath(fromObject, ['resolution']);
10528
+ if (parentObject !== undefined && fromResolution != null) {
10529
+ setValueByPath(parentObject, ['parameters', 'resolution'], fromResolution);
10529
10530
  }
10530
10531
  const fromPersonGeneration = getValueByPath(fromObject, [
10531
10532
  'personGeneration',
@@ -13583,7 +13584,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
13583
13584
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
13584
13585
  const USER_AGENT_HEADER = 'User-Agent';
13585
13586
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
13586
- const SDK_VERSION = '1.16.0'; // x-release-please-version
13587
+ const SDK_VERSION = '1.17.0'; // x-release-please-version
13587
13588
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
13588
13589
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
13589
13590
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -15788,23 +15789,7 @@ class Models extends BaseModule {
15788
15789
  }
15789
15790
  }
15790
15791
  /**
15791
- * Generates an image based on a text description and configuration.
15792
- *
15793
- * @param params - The parameters for generating images.
15794
- * @return The response from the API.
15795
- *
15796
- * @example
15797
- * ```ts
15798
- * const response = await ai.models.generateImages({
15799
- * model: 'imagen-3.0-generate-002',
15800
- * prompt: 'Robot holding a red skateboard',
15801
- * config: {
15802
- * numberOfImages: 1,
15803
- * includeRaiReason: true,
15804
- * },
15805
- * });
15806
- * console.log(response?.generatedImages?.[0]?.image?.imageBytes);
15807
- * ```
15792
+ * Private method for generating images.
15808
15793
  */
15809
15794
  async generateImagesInternal(params) {
15810
15795
  var _a, _b, _c, _d;
@@ -15876,6 +15861,9 @@ class Models extends BaseModule {
15876
15861
  });
15877
15862
  }
15878
15863
  }
15864
+ /**
15865
+ * Private method for editing an image.
15866
+ */
15879
15867
  async editImageInternal(params) {
15880
15868
  var _a, _b;
15881
15869
  let response;
@@ -15917,6 +15905,9 @@ class Models extends BaseModule {
15917
15905
  throw new Error('This method is only supported by the Vertex AI.');
15918
15906
  }
15919
15907
  }
15908
+ /**
15909
+ * Private method for upscaling an image.
15910
+ */
15920
15911
  async upscaleImageInternal(params) {
15921
15912
  var _a, _b;
15922
15913
  let response;
@@ -16516,27 +16507,7 @@ class Models extends BaseModule {
16516
16507
  }
16517
16508
  }
16518
16509
  /**
16519
- * Generates videos based on a text description and configuration.
16520
- *
16521
- * @param params - The parameters for generating videos.
16522
- * @return A Promise<GenerateVideosOperation> which allows you to track the progress and eventually retrieve the generated videos using the operations.get method.
16523
- *
16524
- * @example
16525
- * ```ts
16526
- * const operation = await ai.models.generateVideos({
16527
- * model: 'veo-2.0-generate-001',
16528
- * prompt: 'A neon hologram of a cat driving at top speed',
16529
- * config: {
16530
- * numberOfVideos: 1
16531
- * });
16532
- *
16533
- * while (!operation.done) {
16534
- * await new Promise(resolve => setTimeout(resolve, 10000));
16535
- * operation = await ai.operations.getVideosOperation({operation: operation});
16536
- * }
16537
- *
16538
- * console.log(operation.response?.generatedVideos?.[0]?.video?.uri);
16539
- * ```
16510
+ * Private method for generating videos.
16540
16511
  */
16541
16512
  async generateVideosInternal(params) {
16542
16513
  var _a, _b, _c, _d;