Class: ReveAI::Resources::V2::Images
- Defined in:
- lib/reve_ai/resources/v2/images.rb
Overview
Image generation requests commonly take 40-80 seconds; the API documentation mandates request timeouts of at least 120 seconds (the gem default).
v2 image generation operations.
The v2 create endpoint unifies the v1 create, edit, and remix
workflows: a single prompt plus an ordered list of reference images.
JSON responses include a structured layout alongside the image.
Constant Summary collapse
- CREATE_ENDPOINT =
Returns API endpoint for v2 image creation.
"/v2/image/create"
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(prompt:, references: nil, aspect_ratio: nil, postprocessing: nil, test_time_scaling: nil, version: nil, accept: nil, breadcrumb: nil) ⇒ ImageResponse
Generates an image from a text prompt with optional reference images.
Methods inherited from Base
Constructor Details
This class inherits a constructor from ReveAI::Resources::Base
Instance Method Details
#create(prompt:, references: nil, aspect_ratio: nil, postprocessing: nil, test_time_scaling: nil, version: nil, accept: nil, breadcrumb: nil) ⇒ ImageResponse
v2 images are significantly larger than v1 images; the API
documentation suggests capping the output size with
postprocessing: [{ process: "fit_image", max_dim: 2048 }].
The API documentation does not recommend test_time_scaling
for v2 models.
Generates an image from a text prompt with optional reference images.
Reference images are addressed from the prompt with <frame>N</frame>
tags, where N is the 0-based index into the references array (so
the first reference is <frame>0</frame>).
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/reve_ai/resources/v2/images.rb', line 95 def create(prompt:, references: nil, aspect_ratio: nil, postprocessing: nil, test_time_scaling: nil, version: nil, accept: nil, breadcrumb: nil) validate_prompt!(prompt, max_length: Configuration::V2_MAX_PROMPT_LENGTH) validate_references!(references) validate_aspect_ratio!(aspect_ratio, Configuration::ASPECT_RATIOS) validate_postprocessing!(postprocessing) validate_test_time_scaling!(test_time_scaling) body = build_create_body(prompt: prompt, references: references, aspect_ratio: aspect_ratio, postprocessing: postprocessing, test_time_scaling: test_time_scaling, version: version) params = ? { breadcrumb: } : nil response = post(CREATE_ENDPOINT, body, params: params, accept: accept) ImageResponse.new(status: response.status, headers: response.headers, body: response.body) end |