Method: OpenAI::Resources::Images#edit

Defined in:
lib/openai/resources/images.rb

#edit(image: , prompt: , background: nil, input_fidelity: nil, mask: nil, model: nil, n: nil, output_compression: nil, output_format: nil, partial_images: nil, quality: nil, response_format: nil, size: nil, user: nil, request_options: {}) ⇒ OpenAI::Models::ImagesResponse

See #edit_stream_raw for streaming counterpart.

Some parameter documentations has been truncated, see Models::ImageEditParams for more details.

Creates an edited or extended image given one or more source images and a prompt. This endpoint only supports gpt-image-1 and dall-e-2.

Parameters:

  • image (Pathname, StringIO, IO, String, OpenAI::FilePart, Array<Pathname, StringIO, IO, String, OpenAI::FilePart>)

    The image(s) to edit. Must be a supported image file or an array of images.

  • prompt (String)

    A text description of the desired image(s). The maximum length is 1000 character

  • background (Symbol, OpenAI::Models::ImageEditParams::Background, nil)

    Allows to set transparency for the background of the generated image(s).

  • input_fidelity (Symbol, OpenAI::Models::ImageEditParams::InputFidelity, nil)

    Control how much effort the model will exert to match the style and features,

  • mask (Pathname, StringIO, IO, String, OpenAI::FilePart)

    An additional image whose fully transparent areas (e.g. where alpha is zero) ind

  • model (String, Symbol, OpenAI::Models::ImageModel, nil)

    The model to use for image generation. Only dall-e-2 and gpt-image-1 are sup

  • n (Integer, nil)

    The number of images to generate. Must be between 1 and 10.

  • output_compression (Integer, nil)

    The compression level (0-100%) for the generated images. This parameter

  • output_format (Symbol, OpenAI::Models::ImageEditParams::OutputFormat, nil)

    The format in which the generated images are returned. This parameter is

  • partial_images (Integer, nil)

    The number of partial images to generate. This parameter is used for

  • quality (Symbol, OpenAI::Models::ImageEditParams::Quality, nil)

    The quality of the image that will be generated. high, medium and low are

  • response_format (Symbol, OpenAI::Models::ImageEditParams::ResponseFormat, nil)

    The format in which the generated images are returned. Must be one of url or `

  • size (Symbol, OpenAI::Models::ImageEditParams::Size, nil)

    The size of the generated images. Must be one of 1024x1024, 1536x1024 (lands

  • user (String)

    A unique identifier representing your end-user, which can help OpenAI to monitor

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/openai/resources/images.rb', line 85

def edit(params)
  parsed, options = OpenAI::ImageEditParams.dump_request(params)
  if parsed[:stream]
    message = "Please use `#edit_stream_raw` for the streaming use case."
    raise ArgumentError.new(message)
  end
  @client.request(
    method: :post,
    path: "images/edits",
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: OpenAI::ImagesResponse,
    options: options
  )
end