Class: ReveAI::ImageResponse
- Defined in:
- lib/reve_ai/response.rb
Overview
Response wrapper for image generation API responses.
Provides convenient accessors for image data, version info, content policy status, and credit usage.
Instance Attribute Summary
Attributes inherited from Response
Instance Method Summary collapse
-
#base64 ⇒ String?
Alias for #image.
-
#content_violation? ⇒ Boolean
Checks if the generated image violates content policy.
-
#credits_remaining ⇒ Integer?
Returns the number of credits remaining after this request.
-
#credits_used ⇒ Integer?
Returns the number of credits used for this request.
-
#image ⇒ String?
Returns the base64 encoded image data.
-
#version ⇒ String?
Returns the model version used for generation.
Methods inherited from Response
#initialize, #request_id, #success?
Constructor Details
This class inherits a constructor from ReveAI::Response
Instance Method Details
#base64 ⇒ String?
Alias for #image.
87 88 89 |
# File 'lib/reve_ai/response.rb', line 87 def base64 image end |
#content_violation? ⇒ Boolean
Checks if the generated image violates content policy.
109 110 111 112 |
# File 'lib/reve_ai/response.rb', line 109 def content_violation? body[:content_violation] == true || headers["x-reve-content-violation"] == "true" end |
#credits_remaining ⇒ Integer?
Returns the number of credits remaining after this request.
132 133 134 |
# File 'lib/reve_ai/response.rb', line 132 def credits_remaining body[:credits_remaining] || headers["x-reve-credits-remaining"]&.to_i end |
#credits_used ⇒ Integer?
Returns the number of credits used for this request.
120 121 122 |
# File 'lib/reve_ai/response.rb', line 120 def credits_used body[:credits_used] || headers["x-reve-credits-used"]&.to_i end |
#image ⇒ String?
Returns the base64 encoded image data.
The image is in PNG format. Use Base64.decode64 to get raw bytes.
79 80 81 |
# File 'lib/reve_ai/response.rb', line 79 def image body[:image] end |
#version ⇒ String?
Returns the model version used for generation.
97 98 99 |
# File 'lib/reve_ai/response.rb', line 97 def version body[:version] || headers["x-reve-version"] end |