Class: OpenAI::Resources::Images
- Inherits:
-
Object
- Object
- OpenAI::Resources::Images
- Defined in:
- lib/openai/resources/images.rb
Instance Method Summary collapse
-
#create_variation(image: , model: nil, n: nil, response_format: nil, size: nil, user: nil, request_options: {}) ⇒ OpenAI::Models::ImagesResponse
Some parameter documentations has been truncated, see Models::ImageCreateVariationParams for more details.
-
#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.
-
#edit_stream_raw(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::Internal::Stream<OpenAI::Models::ImageEditPartialImageEvent, OpenAI::Models::ImageEditCompletedEvent>
See #edit for non-streaming counterpart.
-
#generate(prompt: , background: nil, model: nil, moderation: nil, n: nil, output_compression: nil, output_format: nil, partial_images: nil, quality: nil, response_format: nil, size: nil, style: nil, user: nil, request_options: {}) ⇒ OpenAI::Models::ImagesResponse
See #generate_stream_raw for streaming counterpart.
-
#generate_stream_raw(prompt: , background: nil, model: nil, moderation: nil, n: nil, output_compression: nil, output_format: nil, partial_images: nil, quality: nil, response_format: nil, size: nil, style: nil, user: nil, request_options: {}) ⇒ OpenAI::Internal::Stream<OpenAI::Models::ImageGenPartialImageEvent, OpenAI::Models::ImageGenCompletedEvent>
See #generate for non-streaming counterpart.
-
#initialize(client:) ⇒ Images
constructor
private
A new instance of Images.
Constructor Details
#initialize(client:) ⇒ Images
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Images.
280 281 282 |
# File 'lib/openai/resources/images.rb', line 280 def initialize(client:) @client = client end |
Instance Method Details
#create_variation(image: , model: nil, n: nil, response_format: nil, size: nil, user: nil, request_options: {}) ⇒ OpenAI::Models::ImagesResponse
Some parameter documentations has been truncated, see Models::ImageCreateVariationParams for more details.
Creates a variation of a given image. This endpoint only supports dall-e-2
.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/openai/resources/images.rb', line 30 def create_variation(params) parsed, = OpenAI::ImageCreateVariationParams.dump_request(params) @client.request( method: :post, path: "images/variations", headers: {"content-type" => "multipart/form-data"}, body: parsed, model: OpenAI::ImagesResponse, options: ) end |
#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
.
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, = OpenAI::ImageEditParams.dump_request(params) if parsed[:stream] = "Please use `#edit_stream_raw` for the streaming use case." raise ArgumentError.new() end @client.request( method: :post, path: "images/edits", headers: {"content-type" => "multipart/form-data"}, body: parsed, model: OpenAI::ImagesResponse, options: ) end |
#edit_stream_raw(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::Internal::Stream<OpenAI::Models::ImageEditPartialImageEvent, OpenAI::Models::ImageEditCompletedEvent>
See #edit for non-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
.
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/openai/resources/images.rb', line 144 def edit_stream_raw(params) parsed, = OpenAI::ImageEditParams.dump_request(params) unless parsed.fetch(:stream, true) = "Please use `#edit` for the non-streaming use case." raise ArgumentError.new() end parsed.store(:stream, true) @client.request( method: :post, path: "images/edits", headers: {"content-type" => "multipart/form-data", "accept" => "text/event-stream"}, body: parsed, stream: OpenAI::Internal::Stream, model: OpenAI::ImageEditStreamEvent, options: ) end |
#generate(prompt: , background: nil, model: nil, moderation: nil, n: nil, output_compression: nil, output_format: nil, partial_images: nil, quality: nil, response_format: nil, size: nil, style: nil, user: nil, request_options: {}) ⇒ OpenAI::Models::ImagesResponse
See #generate_stream_raw for streaming counterpart.
Some parameter documentations has been truncated, see Models::ImageGenerateParams for more details.
Creates an image given a prompt. Learn more.
203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/openai/resources/images.rb', line 203 def generate(params) parsed, = OpenAI::ImageGenerateParams.dump_request(params) if parsed[:stream] = "Please use `#generate_stream_raw` for the streaming use case." raise ArgumentError.new() end @client.request( method: :post, path: "images/generations", body: parsed, model: OpenAI::ImagesResponse, options: ) end |
#generate_stream_raw(prompt: , background: nil, model: nil, moderation: nil, n: nil, output_compression: nil, output_format: nil, partial_images: nil, quality: nil, response_format: nil, size: nil, style: nil, user: nil, request_options: {}) ⇒ OpenAI::Internal::Stream<OpenAI::Models::ImageGenPartialImageEvent, OpenAI::Models::ImageGenCompletedEvent>
See #generate for non-streaming counterpart.
Some parameter documentations has been truncated, see Models::ImageGenerateParams for more details.
Creates an image given a prompt. Learn more.
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/openai/resources/images.rb', line 259 def generate_stream_raw(params) parsed, = OpenAI::ImageGenerateParams.dump_request(params) unless parsed.fetch(:stream, true) = "Please use `#generate` for the non-streaming use case." raise ArgumentError.new() end parsed.store(:stream, true) @client.request( method: :post, path: "images/generations", headers: {"accept" => "text/event-stream"}, body: parsed, stream: OpenAI::Internal::Stream, model: OpenAI::ImageGenStreamEvent, options: ) end |