Class: ReveAI::LayoutResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/reve_ai/response.rb

Overview

Response wrapper for layout-only API responses.

Returned by the v2 extract_layout and create_layout endpoints, which produce a layout object but no image. Accessors fall back to the X-Reve-* headers when the body carries no value.

Examples:

Inspecting a layout

result = client.v2.layouts.extract(image: base64_image)
result.layout # => { prompt: "...", regions: [...], width: 4096, height: 2560 }

See Also:

Instance Attribute Summary

Attributes inherited from Response

#body, #headers, #status

Instance Method Summary collapse

Methods inherited from Response

#binary?, #initialize, #request_id, #success?

Constructor Details

This class inherits a constructor from ReveAI::Response

Instance Method Details

#content_violation?Boolean

Checks if the request violates content policy.

Returns:

  • (Boolean)

    true if content policy was violated



208
209
210
211
# File 'lib/reve_ai/response.rb', line 208

def content_violation?
  body_value(:content_violation) == true ||
    headers["x-reve-content-violation"] == "true"
end

#credits_remainingInteger?

Returns the number of credits remaining after this request.

Returns:

  • (Integer, nil)

    Remaining credit balance



223
224
225
# File 'lib/reve_ai/response.rb', line 223

def credits_remaining
  body_value(:credits_remaining) || headers["x-reve-credits-remaining"]&.to_i
end

#credits_usedInteger?

Returns the number of credits used for this request.

Returns:

  • (Integer, nil)

    Credits consumed by this request



216
217
218
# File 'lib/reve_ai/response.rb', line 216

def credits_used
  body_value(:credits_used) || headers["x-reve-credits-used"]&.to_i
end

#layoutHash?

Returns the layout object.

Returns:

  • (Hash, nil)

    Layout Hash (e.g., prompt, regions, width, height), or nil when absent



201
202
203
# File 'lib/reve_ai/response.rb', line 201

def layout
  body_value(:layout)
end