Class: Openai::Client::Images
- Inherits:
-
Object
- Object
- Openai::Client::Images
- Defined in:
- lib/openai/client/images.rb
Constant Summary collapse
- CREATE_PATH =
'images/generations'
- EDIT_PATH =
'images/edits'
- VARIATION_PATH =
'images/variations'
Instance Method Summary collapse
-
#create(body) ⇒ Hash
Public: Makes an API call to create an image given a prompt.
-
#edit(body) ⇒ Hash
Public: Makes an API call to create an edited or extended image given an original image and a prompt.
-
#variations(body) ⇒ Hash
Public: Makes an API call to creates a variation of a given image.
Instance Method Details
#create(body) ⇒ Hash
Public: Makes an API call to create an image given a prompt.
18 19 20 21 22 |
# File 'lib/openai/client/images.rb', line 18 def create(body) Http.new.post(CREATE_PATH, body).body rescue Faraday::Error nil end |
#edit(body) ⇒ Hash
Public: Makes an API call to create an edited or extended image given an original image and a prompt.
30 31 32 33 34 |
# File 'lib/openai/client/images.rb', line 30 def edit(body) Http.new.multipart_post(EDIT_PATH, Utils.upload_io(body, %i[image mask], 'png')).body rescue Faraday::Error nil end |
#variations(body) ⇒ Hash
Public: Makes an API call to creates a variation of a given image.
42 43 44 45 46 |
# File 'lib/openai/client/images.rb', line 42 def variations(body) Http.new.multipart_post(VARIATION_PATH, Utils.upload_io(body, %i[image], 'png')).body rescue Faraday::Error nil end |