Class: OpenApiOpenAIClient::ImagesApi
- Inherits:
-
Object
- Object
- OpenApiOpenAIClient::ImagesApi
- Defined in:
- lib/openapi_openai/api/images_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#create_image(create_image_request, opts = {}) ⇒ ImagesResponse
Creates an image given a prompt.
-
#create_image_edit(image, prompt, opts = {}) ⇒ ImagesResponse
Creates an edited or extended image given an original image and a prompt.
-
#create_image_edit_with_http_info(image, prompt, opts = {}) ⇒ Array<(ImagesResponse, Integer, Hash)>
Creates an edited or extended image given an original image and a prompt.
-
#create_image_variation(image, opts = {}) ⇒ ImagesResponse
Creates a variation of a given image.
-
#create_image_variation_with_http_info(image, opts = {}) ⇒ Array<(ImagesResponse, Integer, Hash)>
Creates a variation of a given image.
-
#create_image_with_http_info(create_image_request, opts = {}) ⇒ Array<(ImagesResponse, Integer, Hash)>
Creates an image given a prompt.
-
#initialize(api_client = ApiClient.default) ⇒ ImagesApi
constructor
A new instance of ImagesApi.
Constructor Details
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/openapi_openai/api/images_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#create_image(create_image_request, opts = {}) ⇒ ImagesResponse
Creates an image given a prompt.
26 27 28 29 |
# File 'lib/openapi_openai/api/images_api.rb', line 26 def create_image(create_image_request, opts = {}) data, _status_code, _headers = create_image_with_http_info(create_image_request, opts) data end |
#create_image_edit(image, prompt, opts = {}) ⇒ ImagesResponse
Creates an edited or extended image given an original image and a prompt.
99 100 101 102 |
# File 'lib/openapi_openai/api/images_api.rb', line 99 def create_image_edit(image, prompt, opts = {}) data, _status_code, _headers = create_image_edit_with_http_info(image, prompt, opts) data end |
#create_image_edit_with_http_info(image, prompt, opts = {}) ⇒ Array<(ImagesResponse, Integer, Hash)>
Creates an edited or extended image given an original image and a prompt.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/openapi_openai/api/images_api.rb', line 115 def create_image_edit_with_http_info(image, prompt, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ImagesApi.create_image_edit ...' end # verify the required parameter 'image' is set if @api_client.config.client_side_validation && image.nil? fail ArgumentError, "Missing the required parameter 'image' when calling ImagesApi.create_image_edit" end # verify the required parameter 'prompt' is set if @api_client.config.client_side_validation && prompt.nil? fail ArgumentError, "Missing the required parameter 'prompt' when calling ImagesApi.create_image_edit" end if @api_client.config.client_side_validation && !opts[:'n'].nil? && opts[:'n'] > 10 fail ArgumentError, 'invalid value for "opts[:"n"]" when calling ImagesApi.create_image_edit, must be smaller than or equal to 10.' end if @api_client.config.client_side_validation && !opts[:'n'].nil? && opts[:'n'] < 1 fail ArgumentError, 'invalid value for "opts[:"n"]" when calling ImagesApi.create_image_edit, must be greater than or equal to 1.' end allowable_values = ["256x256", "512x512", "1024x1024"] if @api_client.config.client_side_validation && opts[:'size'] && !allowable_values.include?(opts[:'size']) fail ArgumentError, "invalid value for \"size\", must be one of #{allowable_values}" end allowable_values = ["url", "b64_json"] if @api_client.config.client_side_validation && opts[:'response_format'] && !allowable_values.include?(opts[:'response_format']) fail ArgumentError, "invalid value for \"response_format\", must be one of #{allowable_values}" end # resource path local_var_path = '/images/edits' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['multipart/form-data']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} form_params['image'] = image form_params['prompt'] = prompt form_params['mask'] = opts[:'mask'] if !opts[:'mask'].nil? form_params['model'] = opts[:'model'] if !opts[:'model'].nil? form_params['n'] = opts[:'n'] if !opts[:'n'].nil? form_params['size'] = opts[:'size'] if !opts[:'size'].nil? form_params['response_format'] = opts[:'response_format'] if !opts[:'response_format'].nil? form_params['user'] = opts[:'user'] if !opts[:'user'].nil? # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'ImagesResponse' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"ImagesApi.create_image_edit", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: ImagesApi#create_image_edit\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#create_image_variation(image, opts = {}) ⇒ ImagesResponse
Creates a variation of a given image.
205 206 207 208 |
# File 'lib/openapi_openai/api/images_api.rb', line 205 def create_image_variation(image, opts = {}) data, _status_code, _headers = create_image_variation_with_http_info(image, opts) data end |
#create_image_variation_with_http_info(image, opts = {}) ⇒ Array<(ImagesResponse, Integer, Hash)>
Creates a variation of a given image.
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/openapi_openai/api/images_api.rb', line 219 def create_image_variation_with_http_info(image, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ImagesApi.create_image_variation ...' end # verify the required parameter 'image' is set if @api_client.config.client_side_validation && image.nil? fail ArgumentError, "Missing the required parameter 'image' when calling ImagesApi.create_image_variation" end if @api_client.config.client_side_validation && !opts[:'n'].nil? && opts[:'n'] > 10 fail ArgumentError, 'invalid value for "opts[:"n"]" when calling ImagesApi.create_image_variation, must be smaller than or equal to 10.' end if @api_client.config.client_side_validation && !opts[:'n'].nil? && opts[:'n'] < 1 fail ArgumentError, 'invalid value for "opts[:"n"]" when calling ImagesApi.create_image_variation, must be greater than or equal to 1.' end allowable_values = ["url", "b64_json"] if @api_client.config.client_side_validation && opts[:'response_format'] && !allowable_values.include?(opts[:'response_format']) fail ArgumentError, "invalid value for \"response_format\", must be one of #{allowable_values}" end allowable_values = ["256x256", "512x512", "1024x1024"] if @api_client.config.client_side_validation && opts[:'size'] && !allowable_values.include?(opts[:'size']) fail ArgumentError, "invalid value for \"size\", must be one of #{allowable_values}" end # resource path local_var_path = '/images/variations' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['multipart/form-data']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} form_params['image'] = image form_params['model'] = opts[:'model'] if !opts[:'model'].nil? form_params['n'] = opts[:'n'] if !opts[:'n'].nil? form_params['response_format'] = opts[:'response_format'] if !opts[:'response_format'].nil? form_params['size'] = opts[:'size'] if !opts[:'size'].nil? form_params['user'] = opts[:'user'] if !opts[:'user'].nil? # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'ImagesResponse' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"ImagesApi.create_image_variation", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: ImagesApi#create_image_variation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#create_image_with_http_info(create_image_request, opts = {}) ⇒ Array<(ImagesResponse, Integer, Hash)>
Creates an image given a prompt.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/openapi_openai/api/images_api.rb', line 35 def create_image_with_http_info(create_image_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ImagesApi.create_image ...' end # verify the required parameter 'create_image_request' is set if @api_client.config.client_side_validation && create_image_request.nil? fail ArgumentError, "Missing the required parameter 'create_image_request' when calling ImagesApi.create_image" end # resource path local_var_path = '/images/generations' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(create_image_request) # return_type return_type = opts[:debug_return_type] || 'ImagesResponse' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"ImagesApi.create_image", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: ImagesApi#create_image\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |