Class: Asimov::ApiV1::Images
Overview
Class interface for API methods in the “/images” URI subspace.
Instance Method Summary collapse
-
#create(prompt:, parameters: {}) ⇒ Object
Creates an image using the specified prompt.
-
#create_edit(image:, prompt:, parameters: {}) ⇒ Object
Creates edits of the specified image based on the prompt.
-
#create_variation(image:, parameters: {}) ⇒ Object
Creates variations of the specified image.
Methods inherited from Base
#initialize, #rest_create_w_json_params, #rest_create_w_multipart_params, #rest_delete, #rest_get, #rest_get_streamed_download, #rest_index
Constructor Details
This class inherits a constructor from Asimov::ApiV1::Base
Instance Method Details
#create(prompt:, parameters: {}) ⇒ Object
Creates an image using the specified prompt.
18 19 20 21 22 23 |
# File 'lib/asimov/api_v1/images.rb', line 18 def create(prompt:, parameters: {}) raise MissingRequiredParameterError.new(:prompt) unless prompt rest_create_w_json_params(resource: [RESOURCE, "generations"], parameters: parameters.merge({ prompt: prompt })) end |
#create_edit(image:, prompt:, parameters: {}) ⇒ Object
Creates edits of the specified image based on the prompt.
32 33 34 35 36 37 38 39 40 |
# File 'lib/asimov/api_v1/images.rb', line 32 def create_edit(image:, prompt:, parameters: {}) raise MissingRequiredParameterError.new(:prompt) unless prompt rest_create_w_multipart_params(resource: [RESOURCE, "edits"], parameters: open_files(parameters.merge({ image: image, prompt: prompt }))) end |
#create_variation(image:, parameters: {}) ⇒ Object
Creates variations of the specified image.
49 50 51 52 |
# File 'lib/asimov/api_v1/images.rb', line 49 def create_variation(image:, parameters: {}) rest_create_w_multipart_params(resource: [RESOURCE, "variations"], parameters: open_files(parameters.merge({ image: image }))) end |