Class: OpenAI::Models::Responses::Tool::ImageGeneration

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/openai/models/responses/tool.rb,
sig/openai/models/responses/tool.rbs

Defined Under Namespace

Modules: Action, Background, InputFidelity, Model, Moderation, OutputFormat, Quality, Size Classes: InputImageMask

Instance Attribute Summary collapse

Attributes inherited from Internal::Type::BaseModel

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Internal::Type::BaseModel

==, #==, #[], #_request_id, #_set_last_response, coerce, #deconstruct_keys, #deep_to_h, dump, #encode_with, fields, hash, #hash, inherited, #inspect, inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

#coerce, coerce, coerce_with_error, dump, #dump, #inspect, inspect, meta_info, new_coerce_state, type_info

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Constructor Details

#initialize(file_id: nil, image_url: nil) ⇒ Object

Parameters:

  • action —

    Whether to generate a new image or edit an existing image. Default: auto.

  • background —

    Allows to set transparency for the background of the generated image(s). Must be one of transparent, opaque, or auto (default value). When auto is used, the model will automatically determine the best background for the image.

    gpt-image-2.5-sunburst and gpt-image-2.5-flare, including their 2026-09-08 snapshots, support opaque and transparent backgrounds. Transparent backgrounds are available for supported GPT Image models. For gpt-image-2 and gpt-image-2-2026-04-21, this support is in preview. When using transparent, set the output format to png or webp.

  • input_fidelity —

    Controls fidelity to the original input image(s). This parameter is supported for GPT image models that support input fidelity. gpt-image-2 and gpt-image-2-2026-04-21 ignore this parameter.

  • input_image_mask —

    Optional mask for inpainting. Contains image_url (string, optional) and file_id (string, optional).

  • model —

    The image generation model to use. One of gpt-image-1, gpt-image-1-mini, gpt-image-1.5, gpt-image-2, gpt-image-2-2026-04-21, gpt-image-2.5-sunburst, gpt-image-2.5-sunburst-2026-09-08, gpt-image-2.5-flare, gpt-image-2.5-flare-2026-09-08, or chatgpt-image-latest. Default: gpt-image-1.

  • moderation —

    Moderation level for the generated image. Default: auto.

  • output_compression —

    Compression level for the output image. Default: 100.

  • output_format —

    The output format of the generated image. One of png, webp, or jpeg. Default: png.

  • partial_images —

    Number of partial images to generate in streaming mode, from 0 (default value) to 3.

  • quality —

    The quality of the generated image. The GPT image models support low, medium, and high. gpt-image-2.5-sunburst and gpt-image-2.5-flare, including their 2026-09-08 snapshots, also support xhigh and max. Default: auto.

  • size —

    The size of the generated images. For gpt-image-2, gpt-image-2-2026-04-21, gpt-image-2.5-sunburst, gpt-image-2.5-sunburst-2026-09-08, gpt-image-2.5-flare, and gpt-image-2.5-flare-2026-09-08, arbitrary resolutions are supported as WIDTHxHEIGHT strings, for example 1536x864. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above 2560x1440 are experimental, and the maximum supported resolution is 3840x2160. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes 1024x1024, 1536x1024, and 1024x1536 are supported by the GPT image models; auto is supported for models that allow automatic sizing. For dall-e-2, use one of 256x256, 512x512, or 1024x1024. For dall-e-3, use one of 1024x1024, 1792x1024, or 1024x1792.

  • type —

    The type of the image generation tool. Always image_generation.



# File 'lib/openai/models/responses/tool.rb', line 719

Instance Attribute Details

#action ⇒ OpenAI::Models::Responses::Tool::ImageGeneration::action?

Whether to generate a new image or edit an existing image. Default: auto.

Returns:

  • (OpenAI::Models::Responses::Tool::ImageGeneration::action, nil)


620
# File 'lib/openai/models/responses/tool.rb', line 620

optional :action, enum: -> { OpenAI::Responses::Tool::ImageGeneration::Action }

#background ⇒ OpenAI::Models::Responses::Tool::ImageGeneration::background?

Allows to set transparency for the background of the generated image(s). Must be one of transparent, opaque, or auto (default value). When auto is used, the model will automatically determine the best background for the image.

gpt-image-2.5-sunburst and gpt-image-2.5-flare, including their 2026-09-08 snapshots, support opaque and transparent backgrounds. Transparent backgrounds are available for supported GPT Image models. For gpt-image-2 and gpt-image-2-2026-04-21, this support is in preview. When using transparent, set the output format to png or webp.

Returns:

  • (OpenAI::Models::Responses::Tool::ImageGeneration::background, nil)


634
# File 'lib/openai/models/responses/tool.rb', line 634

optional :background, enum: -> { OpenAI::Responses::Tool::ImageGeneration::Background }

#input_fidelity ⇒ OpenAI::Models::Responses::Tool::ImageGeneration::input_fidelity?

Controls fidelity to the original input image(s). This parameter is supported for GPT image models that support input fidelity. gpt-image-2 and gpt-image-2-2026-04-21 ignore this parameter.

Returns:

  • (OpenAI::Models::Responses::Tool::ImageGeneration::input_fidelity, nil)


642
643
644
645
646
647
648
# File 'lib/openai/models/responses/tool.rb', line 642

optional(
  :input_fidelity,
  enum: -> {
    OpenAI::Responses::Tool::ImageGeneration::InputFidelity
  },
  nil?: true
)

#input_image_mask ⇒ OpenAI::Responses::Tool::ImageGeneration::InputImageMask?

Optional mask for inpainting. Contains image_url (string, optional) and file_id (string, optional).

Returns:

  • (OpenAI::Responses::Tool::ImageGeneration::InputImageMask, nil)


655
# File 'lib/openai/models/responses/tool.rb', line 655

optional :input_image_mask, -> { OpenAI::Responses::Tool::ImageGeneration::InputImageMask }

#model ⇒ OpenAI::Models::Responses::Tool::ImageGeneration::model?

The image generation model to use. One of gpt-image-1, gpt-image-1-mini, gpt-image-1.5, gpt-image-2, gpt-image-2-2026-04-21, gpt-image-2.5-sunburst, gpt-image-2.5-sunburst-2026-09-08, gpt-image-2.5-flare, gpt-image-2.5-flare-2026-09-08, or chatgpt-image-latest. Default: gpt-image-1.

Returns:

  • (OpenAI::Models::Responses::Tool::ImageGeneration::model, nil)


665
# File 'lib/openai/models/responses/tool.rb', line 665

optional :model, union: -> { OpenAI::Responses::Tool::ImageGeneration::Model }

#moderation ⇒ OpenAI::Models::Responses::Tool::ImageGeneration::moderation?

Moderation level for the generated image. Default: auto.

Returns:

  • (OpenAI::Models::Responses::Tool::ImageGeneration::moderation, nil)


671
# File 'lib/openai/models/responses/tool.rb', line 671

optional :moderation, enum: -> { OpenAI::Responses::Tool::ImageGeneration::Moderation }

#output_compression ⇒ Integer?

Compression level for the output image. Default: 100.

Returns:

  • (Integer, nil)


677
# File 'lib/openai/models/responses/tool.rb', line 677

optional :output_compression, Integer

#output_format ⇒ OpenAI::Models::Responses::Tool::ImageGeneration::output_format?

The output format of the generated image. One of png, webp, or jpeg. Default: png.

Returns:

  • (OpenAI::Models::Responses::Tool::ImageGeneration::output_format, nil)


684
# File 'lib/openai/models/responses/tool.rb', line 684

optional :output_format, enum: -> { OpenAI::Responses::Tool::ImageGeneration::OutputFormat }

#partial_images ⇒ Integer?

Number of partial images to generate in streaming mode, from 0 (default value) to 3.

Returns:

  • (Integer, nil)


691
# File 'lib/openai/models/responses/tool.rb', line 691

optional :partial_images, Integer

#quality ⇒ OpenAI::Models::Responses::Tool::ImageGeneration::quality?

The quality of the generated image. The GPT image models support low, medium, and high. gpt-image-2.5-sunburst and gpt-image-2.5-flare, including their 2026-09-08 snapshots, also support xhigh and max. Default: auto.

Returns:

  • (OpenAI::Models::Responses::Tool::ImageGeneration::quality, nil)


700
# File 'lib/openai/models/responses/tool.rb', line 700

optional :quality, enum: -> { OpenAI::Responses::Tool::ImageGeneration::Quality }

#size ⇒ OpenAI::Models::Responses::Tool::ImageGeneration::size?

The size of the generated images. For gpt-image-2, gpt-image-2-2026-04-21, gpt-image-2.5-sunburst, gpt-image-2.5-sunburst-2026-09-08, gpt-image-2.5-flare, and gpt-image-2.5-flare-2026-09-08, arbitrary resolutions are supported as WIDTHxHEIGHT strings, for example 1536x864. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above 2560x1440 are experimental, and the maximum supported resolution is 3840x2160. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes 1024x1024, 1536x1024, and 1024x1536 are supported by the GPT image models; auto is supported for models that allow automatic sizing. For dall-e-2, use one of 256x256, 512x512, or 1024x1024. For dall-e-3, use one of 1024x1024, 1792x1024, or 1024x1792.

Returns:

  • (OpenAI::Models::Responses::Tool::ImageGeneration::size, nil)


717
# File 'lib/openai/models/responses/tool.rb', line 717

optional :size, union: -> { OpenAI::Responses::Tool::ImageGeneration::Size }

#type ⇒ :image_generation

The type of the image generation tool. Always image_generation.

Returns:

  • (:image_generation)


614
# File 'lib/openai/models/responses/tool.rb', line 614

required :type, const: :image_generation

Class Method Details

.values ⇒ Array<Symbol>

Returns:

  • (Array<Symbol>)


# File 'lib/openai/models/responses/tool.rb', line 799

Instance Method Details

#to_hash ⇒ {

Returns:

  • ({)


821
# File 'sig/openai/models/responses/tool.rbs', line 821

def to_hash: -> {