All URIs are relative to https://api.openai.com/v1
Method | HTTP request | Description |
---|---|---|
create_image | POST /images/generations | Creates an image given a prompt. |
create_image_edit | POST /images/edits | Creates an edited or extended image given an original image and a prompt. |
create_image_variation | POST /images/variations | Creates a variation of a given image. |
create_image(create_image_request)
Creates an image given a prompt.
require 'time'
require 'openapi_client'
# setup authorization
OpenapiClient.configure do |config|
# Configure Bearer authorization: ApiKeyAuth
config.access_token = 'YOUR_BEARER_TOKEN'
end
api_instance = OpenapiClient::ImagesApi.new
create_image_request = OpenapiClient::CreateImageRequest.new({prompt: 'A cute baby sea otter'}) # CreateImageRequest |
begin
# Creates an image given a prompt.
result = api_instance.create_image(create_image_request)
p result
rescue OpenapiClient::ApiError => e
puts "Error when calling ImagesApi->create_image: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> create_image_with_http_info(create_image_request)
begin
# Creates an image given a prompt.
data, status_code, headers = api_instance.create_image_with_http_info(create_image_request)
p status_code # => 2xx
p headers # => { ... }
p data # => <ImagesResponse>
rescue OpenapiClient::ApiError => e
puts "Error when calling ImagesApi->create_image_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
create_image_request | CreateImageRequest |
- Content-Type: application/json
- Accept: application/json
create_image_edit(image, prompt, opts)
Creates an edited or extended image given an original image and a prompt.
require 'time'
require 'openapi_client'
# setup authorization
OpenapiClient.configure do |config|
# Configure Bearer authorization: ApiKeyAuth
config.access_token = 'YOUR_BEARER_TOKEN'
end
api_instance = OpenapiClient::ImagesApi.new
image = File.new('/path/to/some/file') # File | The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
prompt = 'prompt_example' # String | A text description of the desired image(s). The maximum length is 1000 characters.
opts = {
mask: File.new('/path/to/some/file'), # File | An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`.
model: OpenapiClient::CreateImageEditRequestModel.new, # CreateImageEditRequestModel |
n: 56, # Integer | The number of images to generate. Must be between 1 and 10.
size: '256x256', # String | The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.
response_format: 'url', # String | The format in which the generated images are returned. Must be one of `url` or `b64_json`.
user: 'user_example' # String | A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
}
begin
# Creates an edited or extended image given an original image and a prompt.
result = api_instance.create_image_edit(image, prompt, opts)
p result
rescue OpenapiClient::ApiError => e
puts "Error when calling ImagesApi->create_image_edit: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> create_image_edit_with_http_info(image, prompt, opts)
begin
# Creates an edited or extended image given an original image and a prompt.
data, status_code, headers = api_instance.create_image_edit_with_http_info(image, prompt, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => <ImagesResponse>
rescue OpenapiClient::ApiError => e
puts "Error when calling ImagesApi->create_image_edit_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
image | File | The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask. | |
prompt | String | A text description of the desired image(s). The maximum length is 1000 characters. | |
mask | File | An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`. | [optional] |
model | CreateImageEditRequestModel | [optional] | |
n | Integer | The number of images to generate. Must be between 1 and 10. | [optional][default to 1] |
size | String | The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. | [optional][default to '1024x1024'] |
response_format | String | The format in which the generated images are returned. Must be one of `url` or `b64_json`. | [optional][default to 'url'] |
user | String | A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more. | [optional] |
- Content-Type: multipart/form-data
- Accept: application/json
create_image_variation(image, opts)
Creates a variation of a given image.
require 'time'
require 'openapi_client'
# setup authorization
OpenapiClient.configure do |config|
# Configure Bearer authorization: ApiKeyAuth
config.access_token = 'YOUR_BEARER_TOKEN'
end
api_instance = OpenapiClient::ImagesApi.new
image = File.new('/path/to/some/file') # File | The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
opts = {
model: OpenapiClient::CreateImageEditRequestModel.new, # CreateImageEditRequestModel |
n: 56, # Integer | The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported.
response_format: 'url', # String | The format in which the generated images are returned. Must be one of `url` or `b64_json`.
size: '256x256', # String | The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.
user: 'user_example' # String | A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
}
begin
# Creates a variation of a given image.
result = api_instance.create_image_variation(image, opts)
p result
rescue OpenapiClient::ApiError => e
puts "Error when calling ImagesApi->create_image_variation: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> create_image_variation_with_http_info(image, opts)
begin
# Creates a variation of a given image.
data, status_code, headers = api_instance.create_image_variation_with_http_info(image, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => <ImagesResponse>
rescue OpenapiClient::ApiError => e
puts "Error when calling ImagesApi->create_image_variation_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
image | File | The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square. | |
model | CreateImageEditRequestModel | [optional] | |
n | Integer | The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported. | [optional][default to 1] |
response_format | String | The format in which the generated images are returned. Must be one of `url` or `b64_json`. | [optional][default to 'url'] |
size | String | The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. | [optional][default to '1024x1024'] |
user | String | A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more. | [optional] |
- Content-Type: multipart/form-data
- Accept: application/json