Class Tool.ImageGeneration
-
- All Implemented Interfaces:
public final class Tool.ImageGenerationA tool that generates images using the GPT image models.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classTool.ImageGeneration.BuilderA builder for ImageGeneration.
public final classTool.ImageGeneration.ActionWhether to generate a new image or edit an existing image. Default:
auto.public final classTool.ImageGeneration.BackgroundAllows to set transparency for the background of the generated image(s). This parameter is only supported for GPT image models that support transparent backgrounds. Must be one of
transparent,opaque, orauto(default value). Whenautois used, the model will automatically determine the best background for the image.gpt-image-2andgpt-image-2-2026-04-21do not support transparent backgrounds. Requests withbackgroundset totransparentwill return an error for these models; useopaqueorautoinstead.If
transparent, the output format needs to support transparency, so it should be set to eitherpng(default value) orwebp.public final classTool.ImageGeneration.InputFidelityControl how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for
gpt-image-1andgpt-image-1.5and later models, unsupported forgpt-image-1-mini. Supportshighandlow. Defaults tolow.public final classTool.ImageGeneration.InputImageMaskOptional mask for inpainting. Contains
image_url(string, optional) andfile_id(string, optional).public final classTool.ImageGeneration.ModelThe image generation model to use. Default:
gpt-image-1.public final classTool.ImageGeneration.ModerationModeration level for the generated image. Default:
auto.public final classTool.ImageGeneration.OutputFormatThe output format of the generated image. One of
png,webp, orjpeg. Default:png.public final classTool.ImageGeneration.QualityThe quality of the generated image. One of
low,medium,high, orauto. Default:auto.public final classTool.ImageGeneration.SizeThe size of the generated images. For
gpt-image-2andgpt-image-2-2026-04-21, arbitrary resolutions are supported asWIDTHxHEIGHTstrings, for example1536x864. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above2560x1440are experimental, and the maximum supported resolution is3840x2160. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes1024x1024,1536x1024, and1024x1536are supported by the GPT image models;autois supported for models that allow automatic sizing. Fordall-e-2, use one of256x256,512x512, or1024x1024. Fordall-e-3, use one of1024x1024,1792x1024, or1024x1792.
-
Method Summary
Modifier and Type Method Description final JsonValue_type()The type of the image generation tool. final Optional<Tool.ImageGeneration.Action>action()Whether to generate a new image or edit an existing image. final Optional<Tool.ImageGeneration.Background>background()Allows to set transparency for the background of the generated image(s). final Optional<Tool.ImageGeneration.InputFidelity>inputFidelity()Control how much effort the model will exert to match the style and features, especially facial features, of input images. final Optional<Tool.ImageGeneration.InputImageMask>inputImageMask()Optional mask for inpainting. final Optional<Tool.ImageGeneration.Model>model()The image generation model to use. final Optional<Tool.ImageGeneration.Moderation>moderation()Moderation level for the generated image. final Optional<Long>outputCompression()Compression level for the output image. final Optional<Tool.ImageGeneration.OutputFormat>outputFormat()The output format of the generated image. final Optional<Long>partialImages()Number of partial images to generate in streaming mode, from 0 (default value) to 3. final Optional<Tool.ImageGeneration.Quality>quality()The quality of the generated image. final Optional<Tool.ImageGeneration.Size>size()The size of the generated images. final JsonField<Tool.ImageGeneration.Action>_action()Returns the raw JSON value of action. final JsonField<Tool.ImageGeneration.Background>_background()Returns the raw JSON value of background. final JsonField<Tool.ImageGeneration.InputFidelity>_inputFidelity()Returns the raw JSON value of inputFidelity. final JsonField<Tool.ImageGeneration.InputImageMask>_inputImageMask()Returns the raw JSON value of inputImageMask. final JsonField<Tool.ImageGeneration.Model>_model()Returns the raw JSON value of model. final JsonField<Tool.ImageGeneration.Moderation>_moderation()Returns the raw JSON value of moderation. final JsonField<Long>_outputCompression()Returns the raw JSON value of outputCompression. final JsonField<Tool.ImageGeneration.OutputFormat>_outputFormat()Returns the raw JSON value of outputFormat. final JsonField<Long>_partialImages()Returns the raw JSON value of partialImages. final JsonField<Tool.ImageGeneration.Quality>_quality()Returns the raw JSON value of quality. final JsonField<Tool.ImageGeneration.Size>_size()Returns the raw JSON value of size. final Map<String, JsonValue>_additionalProperties()final Tool.ImageGeneration.BuildertoBuilder()final Tool.ImageGenerationvalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static Tool.ImageGeneration.Builderbuilder()Returns a mutable builder for constructing an instance of ImageGeneration. -
-
Method Detail
-
_type
final JsonValue _type()
The type of the image generation tool. Always
image_generation.Expected to always return the following:
JsonValue.from("image_generation")However, this method can be useful for debugging and logging (e.g. if the server responded with an unexpected value).
-
action
final Optional<Tool.ImageGeneration.Action> action()
Whether to generate a new image or edit an existing image. Default:
auto.
-
background
final Optional<Tool.ImageGeneration.Background> background()
Allows to set transparency for the background of the generated image(s). This parameter is only supported for GPT image models that support transparent backgrounds. Must be one of
transparent,opaque, orauto(default value). Whenautois used, the model will automatically determine the best background for the image.gpt-image-2andgpt-image-2-2026-04-21do not support transparent backgrounds. Requests withbackgroundset totransparentwill return an error for these models; useopaqueorautoinstead.If
transparent, the output format needs to support transparency, so it should be set to eitherpng(default value) orwebp.
-
inputFidelity
final Optional<Tool.ImageGeneration.InputFidelity> inputFidelity()
Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for
gpt-image-1andgpt-image-1.5and later models, unsupported forgpt-image-1-mini. Supportshighandlow. Defaults tolow.
-
inputImageMask
final Optional<Tool.ImageGeneration.InputImageMask> inputImageMask()
Optional mask for inpainting. Contains
image_url(string, optional) andfile_id(string, optional).
-
model
final Optional<Tool.ImageGeneration.Model> model()
The image generation model to use. Default:
gpt-image-1.
-
moderation
final Optional<Tool.ImageGeneration.Moderation> moderation()
Moderation level for the generated image. Default:
auto.
-
outputCompression
final Optional<Long> outputCompression()
Compression level for the output image. Default: 100.
-
outputFormat
final Optional<Tool.ImageGeneration.OutputFormat> outputFormat()
The output format of the generated image. One of
png,webp, orjpeg. Default:png.
-
partialImages
final Optional<Long> partialImages()
Number of partial images to generate in streaming mode, from 0 (default value) to 3.
-
quality
final Optional<Tool.ImageGeneration.Quality> quality()
The quality of the generated image. One of
low,medium,high, orauto. Default:auto.
-
size
final Optional<Tool.ImageGeneration.Size> size()
The size of the generated images. For
gpt-image-2andgpt-image-2-2026-04-21, arbitrary resolutions are supported asWIDTHxHEIGHTstrings, for example1536x864. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above2560x1440are experimental, and the maximum supported resolution is3840x2160. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes1024x1024,1536x1024, and1024x1536are supported by the GPT image models;autois supported for models that allow automatic sizing. Fordall-e-2, use one of256x256,512x512, or1024x1024. Fordall-e-3, use one of1024x1024,1792x1024, or1024x1792.
-
_action
final JsonField<Tool.ImageGeneration.Action> _action()
Returns the raw JSON value of action.
Unlike action, this method doesn't throw if the JSON field has an unexpected type.
-
_background
final JsonField<Tool.ImageGeneration.Background> _background()
Returns the raw JSON value of background.
Unlike background, this method doesn't throw if the JSON field has an unexpected type.
-
_inputFidelity
final JsonField<Tool.ImageGeneration.InputFidelity> _inputFidelity()
Returns the raw JSON value of inputFidelity.
Unlike inputFidelity, this method doesn't throw if the JSON field has an unexpected type.
-
_inputImageMask
final JsonField<Tool.ImageGeneration.InputImageMask> _inputImageMask()
Returns the raw JSON value of inputImageMask.
Unlike inputImageMask, this method doesn't throw if the JSON field has an unexpected type.
-
_model
final JsonField<Tool.ImageGeneration.Model> _model()
Returns the raw JSON value of model.
Unlike model, this method doesn't throw if the JSON field has an unexpected type.
-
_moderation
final JsonField<Tool.ImageGeneration.Moderation> _moderation()
Returns the raw JSON value of moderation.
Unlike moderation, this method doesn't throw if the JSON field has an unexpected type.
-
_outputCompression
final JsonField<Long> _outputCompression()
Returns the raw JSON value of outputCompression.
Unlike outputCompression, this method doesn't throw if the JSON field has an unexpected type.
-
_outputFormat
final JsonField<Tool.ImageGeneration.OutputFormat> _outputFormat()
Returns the raw JSON value of outputFormat.
Unlike outputFormat, this method doesn't throw if the JSON field has an unexpected type.
-
_partialImages
final JsonField<Long> _partialImages()
Returns the raw JSON value of partialImages.
Unlike partialImages, this method doesn't throw if the JSON field has an unexpected type.
-
_quality
final JsonField<Tool.ImageGeneration.Quality> _quality()
Returns the raw JSON value of quality.
Unlike quality, this method doesn't throw if the JSON field has an unexpected type.
-
_size
final JsonField<Tool.ImageGeneration.Size> _size()
Returns the raw JSON value of size.
Unlike size, this method doesn't throw if the JSON field has an unexpected type.
-
_additionalProperties
final Map<String, JsonValue> _additionalProperties()
-
toBuilder
final Tool.ImageGeneration.Builder toBuilder()
-
validate
final Tool.ImageGeneration validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
builder
final static Tool.ImageGeneration.Builder builder()
Returns a mutable builder for constructing an instance of ImageGeneration.
-
-
-
-