Class: ReveAI::Resources::Images
- Defined in:
- lib/reve_ai/resources/images.rb
Overview
By default all images are returned as base64 encoded PNG data; pass accept: "image/png", "image/jpeg", or "image/webp" to any method for raw image bytes instead (see method docs).
Image generation, editing, and remixing operations.
Provides methods for creating images from text prompts, editing existing images, and remixing multiple reference images into new compositions.
Constant Summary collapse
- CREATE_ENDPOINT =
Returns API endpoint for image creation.
"/v1/image/create"- EDIT_ENDPOINT =
Returns API endpoint for image editing.
"/v1/image/edit"- REMIX_ENDPOINT =
Returns API endpoint for image remixing.
"/v1/image/remix"
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(prompt:, aspect_ratio: nil, version: nil, postprocessing: nil, test_time_scaling: nil, accept: nil, breadcrumb: nil) ⇒ ImageResponse
Generates an image from a text prompt.
-
#edit(edit_instruction:, reference_image:, aspect_ratio: nil, version: nil, postprocessing: nil, test_time_scaling: nil, accept: nil, breadcrumb: nil) ⇒ ImageResponse
Edits an existing image using text instructions.
-
#remix(prompt:, reference_images:, aspect_ratio: nil, version: nil, postprocessing: nil, test_time_scaling: nil, accept: nil, breadcrumb: nil) ⇒ ImageResponse
Creates a new image by remixing multiple reference images.
Methods inherited from Base
Constructor Details
This class inherits a constructor from ReveAI::Resources::Base
Instance Method Details
#create(prompt:, aspect_ratio: nil, version: nil, postprocessing: nil, test_time_scaling: nil, accept: nil, breadcrumb: nil) ⇒ ImageResponse
Generates an image from a text prompt.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/reve_ai/resources/images.rb', line 111 def create(prompt:, aspect_ratio: nil, version: nil, postprocessing: nil, test_time_scaling: nil, accept: nil, breadcrumb: nil) validate_prompt!(prompt) validate_aspect_ratio!(aspect_ratio) validate_postprocessing!(postprocessing) validate_test_time_scaling!(test_time_scaling) body = { prompt: prompt } body[:aspect_ratio] = aspect_ratio if aspect_ratio body[:version] = version if version body[:postprocessing] = postprocessing if postprocessing body[:test_time_scaling] = test_time_scaling if test_time_scaling params = ? { breadcrumb: } : nil response = post(CREATE_ENDPOINT, body, params: params, accept: accept) ImageResponse.new(status: response.status, headers: response.headers, body: response.body) end |
#edit(edit_instruction:, reference_image:, aspect_ratio: nil, version: nil, postprocessing: nil, test_time_scaling: nil, accept: nil, breadcrumb: nil) ⇒ ImageResponse
Edits an existing image using text instructions.
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/reve_ai/resources/images.rb', line 178 def edit(edit_instruction:, reference_image:, aspect_ratio: nil, version: nil, postprocessing: nil, test_time_scaling: nil, accept: nil, breadcrumb: nil) validate_prompt!(edit_instruction, field_name: "Edit instruction") validate_reference_image!(reference_image) validate_postprocessing!(postprocessing) validate_test_time_scaling!(test_time_scaling) body = { edit_instruction: edit_instruction, reference_image: reference_image } body[:aspect_ratio] = aspect_ratio if aspect_ratio body[:version] = version if version body[:postprocessing] = postprocessing if postprocessing body[:test_time_scaling] = test_time_scaling if test_time_scaling params = ? { breadcrumb: } : nil response = post(EDIT_ENDPOINT, body, params: params, accept: accept) ImageResponse.new(status: response.status, headers: response.headers, body: response.body) end |
#remix(prompt:, reference_images:, aspect_ratio: nil, version: nil, postprocessing: nil, test_time_scaling: nil, accept: nil, breadcrumb: nil) ⇒ ImageResponse
Creates a new image by remixing multiple reference images.
Use <img>N</img> tags in the prompt to reference specific images,
where N is the 0-based index into the reference_images array.
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/reve_ai/resources/images.rb', line 247 def remix(prompt:, reference_images:, aspect_ratio: nil, version: nil, postprocessing: nil, test_time_scaling: nil, accept: nil, breadcrumb: nil) validate_prompt!(prompt) validate_reference_images!(reference_images) validate_aspect_ratio!(aspect_ratio) validate_postprocessing!(postprocessing) validate_test_time_scaling!(test_time_scaling) body = { prompt: prompt, reference_images: reference_images } body[:aspect_ratio] = aspect_ratio if aspect_ratio body[:version] = version if version body[:postprocessing] = postprocessing if postprocessing body[:test_time_scaling] = test_time_scaling if test_time_scaling params = ? { breadcrumb: } : nil response = post(REMIX_ENDPOINT, body, params: params, accept: accept) ImageResponse.new(status: response.status, headers: response.headers, body: response.body) end |