Class: ReveAI::Resources::V2::Layouts
- Defined in:
- lib/reve_ai/resources/v2/layouts.rb
Overview
Experimental: these endpoints require care and experimentation to achieve good results. For simple image generation and prompt-based editing, prefer Images#create.
v2 layout pipeline operations (experimental).
The layout endpoints expose lower-level control over image composition: extracting structured layouts from images, generating layouts from prompts, and rendering images from layouts.
Constant Summary collapse
- EXTRACT_ENDPOINT =
Returns API endpoint for layout extraction.
"/v2/image/extract_layout"- CREATE_ENDPOINT =
Returns API endpoint for layout generation.
"/v2/image/create_layout"- RENDER_ENDPOINT =
Returns API endpoint for layout rendering.
"/v2/image/render_layout"
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(prompt: nil, references: nil, commands: nil, aspect_ratio: nil, version: nil, breadcrumb: nil) ⇒ LayoutResponse
Generates (or edits) a structured layout without rendering an image.
-
#extract(image:, prompt: nil, version: nil, breadcrumb: nil) ⇒ LayoutResponse
Extracts a structured layout from an image.
-
#render(layout:, references: nil, postprocessing: nil, version: nil, accept: nil, breadcrumb: nil) ⇒ ImageResponse
Renders a final image from a target layout.
Methods inherited from Base
Constructor Details
This class inherits a constructor from ReveAI::Resources::Base
Instance Method Details
#create(prompt: nil, references: nil, commands: nil, aspect_ratio: nil, version: nil, breadcrumb: nil) ⇒ LayoutResponse
Experimental: layout generation commonly takes 10-40 seconds.
Generates (or edits) a structured layout without rendering an image.
88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/reve_ai/resources/v2/layouts.rb', line 88 def create(prompt: nil, references: nil, commands: nil, aspect_ratio: nil, version: nil, breadcrumb: nil) validate_prompt_or_references!(prompt, references) validate_prompt!(prompt, max_length: Configuration::V2_MAX_PROMPT_LENGTH) if prompt validate_compound_references!(references) validate_commands!(commands) validate_aspect_ratio!(aspect_ratio, Configuration::ASPECT_RATIOS) body = build_create_body(prompt: prompt, references: references, commands: commands, aspect_ratio: aspect_ratio, version: version) response = post(CREATE_ENDPOINT, body, params: ()) LayoutResponse.new(status: response.status, headers: response.headers, body: response.body) end |
#extract(image:, prompt: nil, version: nil, breadcrumb: nil) ⇒ LayoutResponse
Experimental: layout extraction commonly takes 10-40 seconds.
Extracts a structured layout from an image.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/reve_ai/resources/v2/layouts.rb', line 49 def extract(image:, prompt: nil, version: nil, breadcrumb: nil) validate_raw_image!(image, "Image") validate_prompt!(prompt, max_length: Configuration::V2_MAX_PROMPT_LENGTH) if prompt body = { image: image } body[:prompt] = prompt if prompt body[:version] = version if version response = post(EXTRACT_ENDPOINT, body, params: ()) LayoutResponse.new(status: response.status, headers: response.headers, body: response.body) end |
#render(layout:, references: nil, postprocessing: nil, version: nil, accept: nil, breadcrumb: nil) ⇒ ImageResponse
Experimental: rendering commonly takes 40-80 seconds.
Renders a final image from a target layout.
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/reve_ai/resources/v2/layouts.rb', line 131 def render(layout:, references: nil, postprocessing: nil, version: nil, accept: nil, breadcrumb: nil) validate_layout!(layout) validate_compound_references!(references) validate_postprocessing!(postprocessing) body = { layout: layout } body[:references] = references if references body[:postprocessing] = postprocessing if postprocessing body[:version] = version if version response = post(RENDER_ENDPOINT, body, params: (), accept: accept) ImageResponse.new(status: response.status, headers: response.headers, body: response.body) end |