@google/genai 0.13.0 → 0.14.1

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.
@@ -274,6 +274,8 @@ export declare interface BaseUrlParameters {
274
274
 
275
275
  /** Content blob. */
276
276
  declare interface Blob_2 {
277
+ /** Optional. Display name of the blob. Used to provide a label or filename to distinguish blobs. This field is not currently used in the Gemini GenerateContent calls. */
278
+ displayName?: string;
277
279
  /** Required. Raw bytes. */
278
280
  data?: string;
279
281
  /** Required. The IANA standard MIME type of the source data. */
@@ -560,6 +562,19 @@ export declare class Chats {
560
562
  create(params: types.CreateChatParameters): Chat;
561
563
  }
562
564
 
565
+ /** Describes the machine learning model version checkpoint. */
566
+ export declare interface Checkpoint {
567
+ /** The ID of the checkpoint.
568
+ */
569
+ checkpointId?: string;
570
+ /** The epoch of the checkpoint.
571
+ */
572
+ epoch?: string;
573
+ /** The step of the checkpoint.
574
+ */
575
+ step?: string;
576
+ }
577
+
563
578
  /** Source attributions for content. */
564
579
  export declare interface Citation {
565
580
  /** Output only. End index into the content. */
@@ -689,7 +704,7 @@ export declare interface ControlReferenceConfig {
689
704
  A control image is an image that represents a sketch image of areas for the
690
705
  model to fill in based on the prompt.
691
706
  */
692
- export declare interface ControlReferenceImage {
707
+ export declare class ControlReferenceImage {
693
708
  /** The reference image for the editing operation. */
694
709
  referenceImage?: Image_2;
695
710
  /** The id of the reference image. */
@@ -698,6 +713,8 @@ export declare interface ControlReferenceImage {
698
713
  referenceType?: string;
699
714
  /** Configuration for the control reference image. */
700
715
  config?: ControlReferenceConfig;
716
+ /** Internal method to convert to ReferenceImageAPIInternal. */
717
+ toReferenceImageAPI(): any;
701
718
  }
702
719
 
703
720
  /** Enum representing the control type of a control reference image. */
@@ -912,6 +929,8 @@ export declare interface CreateTuningJobConfig {
912
929
  epochCount?: number;
913
930
  /** Multiplier for adjusting the default learning rate. */
914
931
  learningRateMultiplier?: number;
932
+ /** If set to true, disable intermediate checkpoints for SFT and only the last checkpoint will be exported. Otherwise, enable intermediate checkpoints for SFT. */
933
+ exportLastCheckpointOnly?: boolean;
915
934
  /** Adapter size for tuning. */
916
935
  adapterSize?: AdapterSize;
917
936
  /** The batch size hyperparameter for tuning. If not set, a default of 4 or 16 will be used based on the number of training examples. */
@@ -1144,6 +1163,100 @@ export declare enum DynamicRetrievalConfigMode {
1144
1163
  MODE_DYNAMIC = "MODE_DYNAMIC"
1145
1164
  }
1146
1165
 
1166
+ /** Configuration for editing an image. */
1167
+ export declare interface EditImageConfig {
1168
+ /** Used to override HTTP request options. */
1169
+ httpOptions?: HttpOptions;
1170
+ /** Abort signal which can be used to cancel the request.
1171
+
1172
+ NOTE: AbortSignal is a client-only operation. Using it to cancel an
1173
+ operation will not cancel the request in the service. You will still
1174
+ be charged usage for any applicable operations.
1175
+ */
1176
+ abortSignal?: AbortSignal;
1177
+ /** Cloud Storage URI used to store the generated images.
1178
+ */
1179
+ outputGcsUri?: string;
1180
+ /** Description of what to discourage in the generated images.
1181
+ */
1182
+ negativePrompt?: string;
1183
+ /** Number of images to generate.
1184
+ */
1185
+ numberOfImages?: number;
1186
+ /** Aspect ratio of the generated images.
1187
+ */
1188
+ aspectRatio?: string;
1189
+ /** Controls how much the model adheres to the text prompt. Large
1190
+ values increase output and prompt alignment, but may compromise image
1191
+ quality.
1192
+ */
1193
+ guidanceScale?: number;
1194
+ /** Random seed for image generation. This is not available when
1195
+ ``add_watermark`` is set to true.
1196
+ */
1197
+ seed?: number;
1198
+ /** Filter level for safety filtering.
1199
+ */
1200
+ safetyFilterLevel?: SafetyFilterLevel;
1201
+ /** Allows generation of people by the model.
1202
+ */
1203
+ personGeneration?: PersonGeneration;
1204
+ /** Whether to report the safety scores of each generated image and
1205
+ the positive prompt in the response.
1206
+ */
1207
+ includeSafetyAttributes?: boolean;
1208
+ /** Whether to include the Responsible AI filter reason if the image
1209
+ is filtered out of the response.
1210
+ */
1211
+ includeRaiReason?: boolean;
1212
+ /** Language of the text in the prompt.
1213
+ */
1214
+ language?: ImagePromptLanguage;
1215
+ /** MIME type of the generated image.
1216
+ */
1217
+ outputMimeType?: string;
1218
+ /** Compression quality of the generated image (for ``image/jpeg``
1219
+ only).
1220
+ */
1221
+ outputCompressionQuality?: number;
1222
+ /** Describes the editing mode for the request. */
1223
+ editMode?: EditMode;
1224
+ /** The number of sampling steps. A higher value has better image
1225
+ quality, while a lower value has better latency. */
1226
+ baseSteps?: number;
1227
+ }
1228
+
1229
+ /** Parameters for the request to edit an image. */
1230
+ export declare interface EditImageParameters {
1231
+ /** The model to use. */
1232
+ model: string;
1233
+ /** A text description of the edit to apply to the image. */
1234
+ prompt: string;
1235
+ /** The reference images for Imagen 3 editing. */
1236
+ referenceImages: ReferenceImage[];
1237
+ /** Configuration for editing. */
1238
+ config?: EditImageConfig;
1239
+ }
1240
+
1241
+ /** Response for the request to edit an image. */
1242
+ export declare class EditImageResponse {
1243
+ /** Generated images. */
1244
+ generatedImages?: GeneratedImage[];
1245
+ }
1246
+
1247
+ /** Enum representing the Imagen 3 Edit mode. */
1248
+ export declare enum EditMode {
1249
+ EDIT_MODE_DEFAULT = "EDIT_MODE_DEFAULT",
1250
+ EDIT_MODE_INPAINT_REMOVAL = "EDIT_MODE_INPAINT_REMOVAL",
1251
+ EDIT_MODE_INPAINT_INSERTION = "EDIT_MODE_INPAINT_INSERTION",
1252
+ EDIT_MODE_OUTPAINT = "EDIT_MODE_OUTPAINT",
1253
+ EDIT_MODE_CONTROLLED_EDITING = "EDIT_MODE_CONTROLLED_EDITING",
1254
+ EDIT_MODE_STYLE = "EDIT_MODE_STYLE",
1255
+ EDIT_MODE_BGSWAP = "EDIT_MODE_BGSWAP",
1256
+ EDIT_MODE_PRODUCT_IMAGE = "EDIT_MODE_PRODUCT_IMAGE"
1257
+ }
1258
+
1259
+ /** Optional parameters for the embed_content method. */
1147
1260
  export declare interface EmbedContentConfig {
1148
1261
  /** Used to override HTTP request options. */
1149
1262
  httpOptions?: HttpOptions;
@@ -1610,10 +1723,21 @@ export declare interface GenerateContentConfig {
1610
1723
  random number is used.
1611
1724
  */
1612
1725
  seed?: number;
1613
- /** Output response media type of the generated candidate text.
1726
+ /** Output response mimetype of the generated candidate text.
1727
+ Supported mimetype:
1728
+ - `text/plain`: (default) Text output.
1729
+ - `application/json`: JSON response in the candidates.
1730
+ The model needs to be prompted to output the appropriate response type,
1731
+ otherwise the behavior is undefined.
1732
+ This is a preview feature.
1614
1733
  */
1615
1734
  responseMimeType?: string;
1616
- /** Schema that the generated candidate text must adhere to.
1735
+ /** The `Schema` object allows the definition of input and output data types.
1736
+ These types can be objects, but also primitives and arrays.
1737
+ Represents a select subset of an [OpenAPI 3.0 schema
1738
+ object](https://spec.openapis.org/oas/v3.0.3#schema).
1739
+ If set, a compatible response_mime_type must also be set.
1740
+ Compatible mimetypes: `application/json`: Schema for JSON response.
1617
1741
  */
1618
1742
  responseSchema?: SchemaUnion;
1619
1743
  /** Configuration for model router requests.
@@ -3118,7 +3242,6 @@ export declare interface LiveServerSessionResumptionUpdate {
3118
3242
  lastConsumedClientMessageIndex?: string;
3119
3243
  }
3120
3244
 
3121
- /** Sent in response to a `LiveGenerateContentSetup` message from the client. */
3122
3245
  export declare interface LiveServerSetupComplete {
3123
3246
  }
3124
3247
 
@@ -3186,7 +3309,7 @@ export declare interface MaskReferenceConfig {
3186
3309
  image. If the user provides a mask image, the mask must be in the same
3187
3310
  dimensions as the raw image.
3188
3311
  */
3189
- export declare interface MaskReferenceImage {
3312
+ export declare class MaskReferenceImage {
3190
3313
  /** The reference image for the editing operation. */
3191
3314
  referenceImage?: Image_2;
3192
3315
  /** The id of the reference image. */
@@ -3195,6 +3318,8 @@ export declare interface MaskReferenceImage {
3195
3318
  referenceType?: string;
3196
3319
  /** Configuration for the mask reference image. */
3197
3320
  config?: MaskReferenceConfig;
3321
+ /** Internal method to convert to ReferenceImageAPIInternal. */
3322
+ toReferenceImageAPI(): any;
3198
3323
  }
3199
3324
 
3200
3325
  /** Enum representing the mask mode of a mask reference image. */
@@ -3272,6 +3397,11 @@ export declare interface Model {
3272
3397
  outputTokenLimit?: number;
3273
3398
  /** List of actions that are supported by the model. */
3274
3399
  supportedActions?: string[];
3400
+ /** The default checkpoint id of a model version.
3401
+ */
3402
+ defaultCheckpointId?: string;
3403
+ /** The checkpoints of the model. */
3404
+ checkpoints?: Checkpoint[];
3275
3405
  }
3276
3406
 
3277
3407
  export declare class Models extends BaseModule {
@@ -3361,9 +3491,7 @@ export declare class Models extends BaseModule {
3361
3491
  /**
3362
3492
  * Generates an image based on a text description and configuration.
3363
3493
  *
3364
- * @param model - The model to use.
3365
- * @param prompt - A text description of the image to generate.
3366
- * @param [config] - The config for image generation.
3494
+ * @param params - The parameters for generating images.
3367
3495
  * @return The response from the API.
3368
3496
  *
3369
3497
  * @example
@@ -3381,6 +3509,48 @@ export declare class Models extends BaseModule {
3381
3509
  */
3382
3510
  generateImages: (params: types.GenerateImagesParameters) => Promise<types.GenerateImagesResponse>;
3383
3511
  list: (params?: types.ListModelsParameters) => Promise<Pager<types.Model>>;
3512
+ /**
3513
+ * Edits an image based on a prompt, list of reference images, and configuration.
3514
+ *
3515
+ * @param params - The parameters for editing an image.
3516
+ * @return The response from the API.
3517
+ *
3518
+ * @example
3519
+ * ```ts
3520
+ * const response = await client.models.editImage({
3521
+ * model: 'imagen-3.0-capability-001',
3522
+ * prompt: 'Generate an image containing a mug with the product logo [1] visible on the side of the mug.',
3523
+ * referenceImages: [subjectReferenceImage]
3524
+ * config: {
3525
+ * numberOfImages: 1,
3526
+ * includeRaiReason: true,
3527
+ * },
3528
+ * });
3529
+ * console.log(response?.generatedImages?.[0]?.image?.imageBytes);
3530
+ * ```
3531
+ */
3532
+ editImage: (params: types.EditImageParameters) => Promise<types.EditImageResponse>;
3533
+ /**
3534
+ * Upscales an image based on an image, upscale factor, and configuration.
3535
+ * Only supported in Vertex AI currently.
3536
+ *
3537
+ * @param params - The parameters for upscaling an image.
3538
+ * @return The response from the API.
3539
+ *
3540
+ * @example
3541
+ * ```ts
3542
+ * const response = await client.models.upscaleImage({
3543
+ * model: 'imagen-3.0-generate-002',
3544
+ * image: image,
3545
+ * upscaleFactor: 'x2',
3546
+ * config: {
3547
+ * includeRaiReason: true,
3548
+ * },
3549
+ * });
3550
+ * console.log(response?.generatedImages?.[0]?.image?.imageBytes);
3551
+ * ```
3552
+ */
3553
+ upscaleImage: (params: types.UpscaleImageParameters) => Promise<types.UpscaleImageResponse>;
3384
3554
  private generateContentInternal;
3385
3555
  private generateContentStreamInternal;
3386
3556
  /**
@@ -3425,6 +3595,8 @@ export declare class Models extends BaseModule {
3425
3595
  * ```
3426
3596
  */
3427
3597
  private generateImagesInternal;
3598
+ private editImageInternal;
3599
+ private upscaleImageInternal;
3428
3600
  /**
3429
3601
  * Fetches information about a model by name.
3430
3602
  *
@@ -3718,6 +3890,8 @@ export declare interface Part {
3718
3890
  videoMetadata?: VideoMetadata;
3719
3891
  /** Indicates if the part is thought from the model. */
3720
3892
  thought?: boolean;
3893
+ /** Optional. Inlined bytes data. */
3894
+ inlineData?: Blob_2;
3721
3895
  /** Optional. Result of executing the [ExecutableCode]. */
3722
3896
  codeExecutionResult?: CodeExecutionResult;
3723
3897
  /** Optional. Code generated by the model that is meant to be executed. */
@@ -3728,8 +3902,6 @@ export declare interface Part {
3728
3902
  functionCall?: FunctionCall;
3729
3903
  /** Optional. The result output of a [FunctionCall] that contains a string representing the [FunctionDeclaration.name] and a structured JSON object containing any output from the function call. It is used as context to the model. */
3730
3904
  functionResponse?: FunctionResponse;
3731
- /** Optional. Inlined bytes data. */
3732
- inlineData?: Blob_2;
3733
3905
  /** Optional. Text part (can be code). */
3734
3906
  text?: string;
3735
3907
  }
@@ -3816,13 +3988,15 @@ export declare interface RagRetrievalConfigRankingRankService {
3816
3988
  It can optionally be provided in addition to a mask reference image or
3817
3989
  a style reference image.
3818
3990
  */
3819
- export declare interface RawReferenceImage {
3991
+ export declare class RawReferenceImage {
3820
3992
  /** The reference image for the editing operation. */
3821
3993
  referenceImage?: Image_2;
3822
3994
  /** The id of the reference image. */
3823
3995
  referenceId?: number;
3824
3996
  /** The type of the reference image. Only set by the SDK. */
3825
3997
  referenceType?: string;
3998
+ /** Internal method to convert to ReferenceImageAPIInternal. */
3999
+ toReferenceImageAPI(): any;
3826
4000
  }
3827
4001
 
3828
4002
  /** Marks the end of user activity.
@@ -3839,6 +4013,8 @@ export declare interface RealtimeInputConfig {
3839
4013
  turnCoverage?: TurnCoverage;
3840
4014
  }
3841
4015
 
4016
+ export declare type ReferenceImage = RawReferenceImage | MaskReferenceImage | ControlReferenceImage | StyleReferenceImage | SubjectReferenceImage;
4017
+
3842
4018
  /** Represents a recorded session. */
3843
4019
  export declare interface ReplayFile {
3844
4020
  replayId?: string;
@@ -4236,7 +4412,7 @@ export declare interface StyleReferenceConfig {
4236
4412
  A raw reference image can also be provided as a destination for the style to
4237
4413
  be applied to.
4238
4414
  */
4239
- export declare interface StyleReferenceImage {
4415
+ export declare class StyleReferenceImage {
4240
4416
  /** The reference image for the editing operation. */
4241
4417
  referenceImage?: Image_2;
4242
4418
  /** The id of the reference image. */
@@ -4245,6 +4421,8 @@ export declare interface StyleReferenceImage {
4245
4421
  referenceType?: string;
4246
4422
  /** Configuration for the style reference image. */
4247
4423
  config?: StyleReferenceConfig;
4424
+ /** Internal method to convert to ReferenceImageAPIInternal. */
4425
+ toReferenceImageAPI(): any;
4248
4426
  }
4249
4427
 
4250
4428
  /** Configuration for a Subject reference image. */
@@ -4263,7 +4441,7 @@ export declare interface SubjectReferenceConfig {
4263
4441
  A raw reference image can also be provided as a destination for the subject to
4264
4442
  be applied to.
4265
4443
  */
4266
- export declare interface SubjectReferenceImage {
4444
+ export declare class SubjectReferenceImage {
4267
4445
  /** The reference image for the editing operation. */
4268
4446
  referenceImage?: Image_2;
4269
4447
  /** The id of the reference image. */
@@ -4272,6 +4450,7 @@ export declare interface SubjectReferenceImage {
4272
4450
  referenceType?: string;
4273
4451
  /** Configuration for the subject reference image. */
4274
4452
  config?: SubjectReferenceConfig;
4453
+ toReferenceImageAPI(): any;
4275
4454
  }
4276
4455
 
4277
4456
  /** Enum representing the subject type of a subject reference image. */
@@ -4358,6 +4537,8 @@ export declare interface SupervisedTuningSpec {
4358
4537
  trainingDatasetUri?: string;
4359
4538
  /** Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file. */
4360
4539
  validationDatasetUri?: string;
4540
+ /** Optional. If set to true, disable intermediate checkpoints for SFT and only the last checkpoint will be exported. */
4541
+ exportLastCheckpointOnly?: boolean;
4361
4542
  }
4362
4543
 
4363
4544
  export declare interface TestTableFile {
@@ -4466,6 +4647,27 @@ export declare interface TunedModel {
4466
4647
  model?: string;
4467
4648
  /** Output only. A resource name of an Endpoint. Format: `projects/{project}/locations/{location}/endpoints/{endpoint}`. */
4468
4649
  endpoint?: string;
4650
+ /** The checkpoints associated with this TunedModel.
4651
+ This field is only populated for tuning jobs that enable intermediate
4652
+ checkpoints. */
4653
+ checkpoints?: TunedModelCheckpoint[];
4654
+ }
4655
+
4656
+ /** TunedModelCheckpoint for the Tuned Model of a Tuning Job. */
4657
+ export declare interface TunedModelCheckpoint {
4658
+ /** The ID of the checkpoint.
4659
+ */
4660
+ checkpointId?: string;
4661
+ /** The epoch of the checkpoint.
4662
+ */
4663
+ epoch?: string;
4664
+ /** The step of the checkpoint.
4665
+ */
4666
+ step?: string;
4667
+ /** The Endpoint resource name that the checkpoint is deployed to.
4668
+ Format: `projects/{project}/locations/{location}/endpoints/{endpoint}`.
4669
+ */
4670
+ endpoint?: string;
4469
4671
  }
4470
4672
 
4471
4673
  /** A tuned machine learning model. */
@@ -4639,23 +4841,24 @@ declare namespace types {
4639
4841
  SafetyFilterLevel,
4640
4842
  PersonGeneration,
4641
4843
  ImagePromptLanguage,
4642
- FileState,
4643
- FileSource,
4644
4844
  MaskReferenceMode,
4645
4845
  ControlReferenceType,
4646
4846
  SubjectReferenceType,
4847
+ EditMode,
4848
+ FileState,
4849
+ FileSource,
4647
4850
  MediaModality,
4648
4851
  StartSensitivity,
4649
4852
  EndSensitivity,
4650
4853
  ActivityHandling,
4651
4854
  TurnCoverage,
4855
+ Blob_2 as Blob,
4652
4856
  VideoMetadata,
4653
4857
  CodeExecutionResult,
4654
4858
  ExecutableCode,
4655
4859
  FileData,
4656
4860
  FunctionCall,
4657
4861
  FunctionResponse,
4658
- Blob_2 as Blob,
4659
4862
  Part,
4660
4863
  Content,
4661
4864
  HttpOptions,
@@ -4719,6 +4922,8 @@ declare namespace types {
4719
4922
  ModalityTokenCount,
4720
4923
  GenerateContentResponseUsageMetadata,
4721
4924
  GenerateContentResponse,
4925
+ ReferenceImage,
4926
+ EditImageParameters,
4722
4927
  EmbedContentConfig,
4723
4928
  EmbedContentParameters,
4724
4929
  ContentEmbeddingStatistics,
@@ -4731,10 +4936,18 @@ declare namespace types {
4731
4936
  SafetyAttributes,
4732
4937
  GeneratedImage,
4733
4938
  GenerateImagesResponse,
4939
+ MaskReferenceConfig,
4940
+ ControlReferenceConfig,
4941
+ StyleReferenceConfig,
4942
+ SubjectReferenceConfig,
4943
+ EditImageConfig,
4944
+ EditImageResponse,
4945
+ UpscaleImageResponse,
4734
4946
  GetModelConfig,
4735
4947
  GetModelParameters,
4736
4948
  Endpoint,
4737
4949
  TunedModelInfo,
4950
+ Checkpoint,
4738
4951
  Model,
4739
4952
  ListModelsConfig,
4740
4953
  ListModelsParameters,
@@ -4760,6 +4973,7 @@ declare namespace types {
4760
4973
  GenerateVideosOperation,
4761
4974
  GetTuningJobConfig,
4762
4975
  GetTuningJobParameters,
4976
+ TunedModelCheckpoint,
4763
4977
  TunedModel,
4764
4978
  GoogleRpcStatus,
4765
4979
  SupervisedHyperParameters,
@@ -4832,13 +5046,9 @@ declare namespace types {
4832
5046
  UpscaleImageConfig,
4833
5047
  UpscaleImageParameters,
4834
5048
  RawReferenceImage,
4835
- MaskReferenceConfig,
4836
5049
  MaskReferenceImage,
4837
- ControlReferenceConfig,
4838
5050
  ControlReferenceImage,
4839
- StyleReferenceConfig,
4840
5051
  StyleReferenceImage,
4841
- SubjectReferenceConfig,
4842
5052
  SubjectReferenceImage,
4843
5053
  LiveServerSetupComplete,
4844
5054
  Transcription,
@@ -4860,6 +5070,7 @@ declare namespace types {
4860
5070
  ActivityStart,
4861
5071
  ActivityEnd,
4862
5072
  LiveClientRealtimeInput,
5073
+ LiveSendRealtimeInputParameters,
4863
5074
  LiveClientToolResponse,
4864
5075
  LiveClientMessage,
4865
5076
  LiveConnectConfig,
@@ -4867,7 +5078,6 @@ declare namespace types {
4867
5078
  CreateChatParameters,
4868
5079
  SendMessageParameters,
4869
5080
  LiveSendClientContentParameters,
4870
- LiveSendRealtimeInputParameters,
4871
5081
  LiveSendToolResponseParameters,
4872
5082
  OperationGetParameters,
4873
5083
  BlobImageUnion,
@@ -4921,6 +5131,7 @@ export declare interface UpdateModelConfig {
4921
5131
  abortSignal?: AbortSignal;
4922
5132
  displayName?: string;
4923
5133
  description?: string;
5134
+ defaultCheckpointId?: string;
4924
5135
  }
4925
5136
 
4926
5137
  /** Configuration for updating a tuned model. */
@@ -5017,6 +5228,11 @@ export declare interface UpscaleImageParameters {
5017
5228
  config?: UpscaleImageConfig;
5018
5229
  }
5019
5230
 
5231
+ export declare class UpscaleImageResponse {
5232
+ /** Generated images. */
5233
+ generatedImages?: GeneratedImage[];
5234
+ }
5235
+
5020
5236
  /** Usage metadata about response(s). */
5021
5237
  export declare interface UsageMetadata {
5022
5238
  /** Number of tokens in the prompt. When `cached_content` is set, this is still the total effective prompt size meaning this includes the number of tokens in the cached content. */