reve_ai 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +275 -7
- data/lib/reve_ai/client.rb +28 -1
- data/lib/reve_ai/configuration.rb +10 -1
- data/lib/reve_ai/errors.rb +15 -4
- data/lib/reve_ai/http/client.rb +100 -18
- data/lib/reve_ai/resources/base.rb +63 -7
- data/lib/reve_ai/resources/effects.rb +83 -0
- data/lib/reve_ai/resources/images.rb +100 -16
- data/lib/reve_ai/resources/v2/images.rb +188 -0
- data/lib/reve_ai/resources/v2/layouts.rb +309 -0
- data/lib/reve_ai/resources/v2.rb +42 -0
- data/lib/reve_ai/response.rb +108 -17
- data/lib/reve_ai/version.rb +1 -1
- data/lib/reve_ai.rb +4 -0
- metadata +30 -4
data/lib/reve_ai/response.rb
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
module ReveAI
|
|
4
4
|
# Base response wrapper for API responses.
|
|
5
5
|
#
|
|
6
|
-
# Provides access to HTTP status, headers, and
|
|
6
|
+
# Provides access to HTTP status, headers, and response body. The body is a
|
|
7
|
+
# parsed Hash for JSON responses, or the raw image String (bytes) when the
|
|
8
|
+
# API answers with a binary body (Accept: image/*); in that case all
|
|
9
|
+
# metadata is carried by the X-Reve-* response headers.
|
|
7
10
|
#
|
|
8
11
|
# @see ImageResponse
|
|
12
|
+
# @see LayoutResponse
|
|
9
13
|
class Response
|
|
10
14
|
# @return [Integer] HTTP status code
|
|
11
15
|
attr_reader :status
|
|
@@ -13,14 +17,15 @@ module ReveAI
|
|
|
13
17
|
# @return [Hash] Response headers
|
|
14
18
|
attr_reader :headers
|
|
15
19
|
|
|
16
|
-
# @return [Hash] Parsed response body
|
|
20
|
+
# @return [Hash, String] Parsed response body, or raw bytes String
|
|
21
|
+
# for binary (image/*) responses
|
|
17
22
|
attr_reader :body
|
|
18
23
|
|
|
19
24
|
# Creates a new response wrapper.
|
|
20
25
|
#
|
|
21
26
|
# @param status [Integer] HTTP status code
|
|
22
27
|
# @param headers [Hash] Response headers
|
|
23
|
-
# @param body [Hash] Parsed response body
|
|
28
|
+
# @param body [Hash, String] Parsed response body, or raw bytes String
|
|
24
29
|
def initialize(status:, headers:, body:)
|
|
25
30
|
@status = status
|
|
26
31
|
@headers = headers
|
|
@@ -34,20 +39,42 @@ module ReveAI
|
|
|
34
39
|
status >= 200 && status < 300
|
|
35
40
|
end
|
|
36
41
|
|
|
42
|
+
# Checks if the response body is raw binary data (e.g., image bytes).
|
|
43
|
+
#
|
|
44
|
+
# @return [Boolean] true if body is not a parsed JSON Hash
|
|
45
|
+
def binary?
|
|
46
|
+
!body.is_a?(Hash)
|
|
47
|
+
end
|
|
48
|
+
|
|
37
49
|
# Returns the request ID for this response.
|
|
38
50
|
#
|
|
39
51
|
# Useful for debugging and support requests.
|
|
40
52
|
#
|
|
41
53
|
# @return [String, nil] Request ID from body or headers
|
|
42
54
|
def request_id
|
|
43
|
-
|
|
55
|
+
body_value(:request_id) || headers["x-reve-request-id"]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
# Reads a key from the body when it is a Hash (JSON response).
|
|
61
|
+
#
|
|
62
|
+
# Binary (String) bodies have no keys; header fallbacks apply instead.
|
|
63
|
+
#
|
|
64
|
+
# @param key [Symbol] Body key to read
|
|
65
|
+
# @return [Object, nil] Body value, or nil for binary bodies
|
|
66
|
+
# @api private
|
|
67
|
+
def body_value(key)
|
|
68
|
+
body[key] if body.is_a?(Hash)
|
|
44
69
|
end
|
|
45
70
|
end
|
|
46
71
|
|
|
47
72
|
# Response wrapper for image generation API responses.
|
|
48
73
|
#
|
|
49
74
|
# Provides convenient accessors for image data, version info,
|
|
50
|
-
# content policy status, and credit usage.
|
|
75
|
+
# content policy status, and credit usage. All accessors work for both
|
|
76
|
+
# JSON responses (values from the parsed body) and binary responses
|
|
77
|
+
# (values from the X-Reve-* headers).
|
|
51
78
|
#
|
|
52
79
|
# @example Accessing image data
|
|
53
80
|
# result = client.images.create(prompt: "A sunset")
|
|
@@ -66,28 +93,48 @@ module ReveAI
|
|
|
66
93
|
#
|
|
67
94
|
# @see Response
|
|
68
95
|
class ImageResponse < Response
|
|
69
|
-
# Returns the
|
|
96
|
+
# Returns the image data.
|
|
70
97
|
#
|
|
71
|
-
#
|
|
98
|
+
# For JSON responses this is the base64 encoded image; for binary
|
|
99
|
+
# responses (Accept: image/*) it is the raw image bytes in the
|
|
100
|
+
# negotiated format, ready to write to disk without decoding.
|
|
72
101
|
#
|
|
73
|
-
# @return [String, nil] Base64 encoded
|
|
102
|
+
# @return [String, nil] Base64 encoded image data (JSON response) or
|
|
103
|
+
# raw image bytes (binary response)
|
|
74
104
|
#
|
|
75
|
-
# @example Save to file
|
|
105
|
+
# @example Save a JSON (base64) response to file
|
|
76
106
|
# require "base64"
|
|
77
|
-
#
|
|
78
|
-
#
|
|
107
|
+
# File.binwrite("output.png", Base64.decode64(result.image))
|
|
108
|
+
#
|
|
109
|
+
# @example Save a binary response to file (no Base64 decode needed)
|
|
110
|
+
# File.binwrite("output.webp", result.image)
|
|
79
111
|
def image
|
|
80
|
-
body[:image]
|
|
112
|
+
binary? ? body : body[:image]
|
|
81
113
|
end
|
|
82
114
|
|
|
83
115
|
# Alias for {#image}.
|
|
84
116
|
#
|
|
85
|
-
# @
|
|
117
|
+
# @note Despite the name, binary responses (Accept: image/*) return raw
|
|
118
|
+
# image bytes here, not base64 data.
|
|
119
|
+
#
|
|
120
|
+
# @return [String, nil] Base64 encoded image data (JSON response) or
|
|
121
|
+
# raw image bytes (binary response)
|
|
86
122
|
# @see #image
|
|
87
123
|
def base64
|
|
88
124
|
image
|
|
89
125
|
end
|
|
90
126
|
|
|
127
|
+
# Returns the layout object for this generation.
|
|
128
|
+
#
|
|
129
|
+
# Present on v2 create/render JSON responses; nil on v1 responses and
|
|
130
|
+
# on binary (Accept: image/*) responses.
|
|
131
|
+
#
|
|
132
|
+
# @return [Hash, nil] Layout Hash (e.g., +prompt+, +regions+, +width+,
|
|
133
|
+
# +height+), or nil when absent
|
|
134
|
+
def layout
|
|
135
|
+
body_value(:layout)
|
|
136
|
+
end
|
|
137
|
+
|
|
91
138
|
# Returns the model version used for generation.
|
|
92
139
|
#
|
|
93
140
|
# @return [String, nil] Model version (e.g., "reve-create@20250915")
|
|
@@ -95,7 +142,7 @@ module ReveAI
|
|
|
95
142
|
# @example
|
|
96
143
|
# result.version # => "reve-create@20250915"
|
|
97
144
|
def version
|
|
98
|
-
|
|
145
|
+
body_value(:version) || headers["x-reve-version"]
|
|
99
146
|
end
|
|
100
147
|
|
|
101
148
|
# Checks if the generated image violates content policy.
|
|
@@ -107,7 +154,7 @@ module ReveAI
|
|
|
107
154
|
# puts "Warning: Content policy violated"
|
|
108
155
|
# end
|
|
109
156
|
def content_violation?
|
|
110
|
-
|
|
157
|
+
body_value(:content_violation) == true ||
|
|
111
158
|
headers["x-reve-content-violation"] == "true"
|
|
112
159
|
end
|
|
113
160
|
|
|
@@ -118,7 +165,7 @@ module ReveAI
|
|
|
118
165
|
# @example
|
|
119
166
|
# puts "This request used #{result.credits_used} credits"
|
|
120
167
|
def credits_used
|
|
121
|
-
|
|
168
|
+
body_value(:credits_used) || headers["x-reve-credits-used"]&.to_i
|
|
122
169
|
end
|
|
123
170
|
|
|
124
171
|
# Returns the number of credits remaining after this request.
|
|
@@ -130,7 +177,51 @@ module ReveAI
|
|
|
130
177
|
# puts "Warning: Low credit balance"
|
|
131
178
|
# end
|
|
132
179
|
def credits_remaining
|
|
133
|
-
|
|
180
|
+
body_value(:credits_remaining) || headers["x-reve-credits-remaining"]&.to_i
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Response wrapper for layout-only API responses.
|
|
185
|
+
#
|
|
186
|
+
# Returned by the v2 extract_layout and create_layout endpoints, which
|
|
187
|
+
# produce a layout object but no image. Accessors fall back to the
|
|
188
|
+
# X-Reve-* headers when the body carries no value.
|
|
189
|
+
#
|
|
190
|
+
# @example Inspecting a layout
|
|
191
|
+
# result = client.v2.layouts.extract(image: base64_image)
|
|
192
|
+
# result.layout # => { prompt: "...", regions: [...], width: 4096, height: 2560 }
|
|
193
|
+
#
|
|
194
|
+
# @see Response
|
|
195
|
+
# @see ImageResponse
|
|
196
|
+
class LayoutResponse < Response
|
|
197
|
+
# Returns the layout object.
|
|
198
|
+
#
|
|
199
|
+
# @return [Hash, nil] Layout Hash (e.g., +prompt+, +regions+, +width+,
|
|
200
|
+
# +height+), or nil when absent
|
|
201
|
+
def layout
|
|
202
|
+
body_value(:layout)
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Checks if the request violates content policy.
|
|
206
|
+
#
|
|
207
|
+
# @return [Boolean] true if content policy was violated
|
|
208
|
+
def content_violation?
|
|
209
|
+
body_value(:content_violation) == true ||
|
|
210
|
+
headers["x-reve-content-violation"] == "true"
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# Returns the number of credits used for this request.
|
|
214
|
+
#
|
|
215
|
+
# @return [Integer, nil] Credits consumed by this request
|
|
216
|
+
def credits_used
|
|
217
|
+
body_value(:credits_used) || headers["x-reve-credits-used"]&.to_i
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Returns the number of credits remaining after this request.
|
|
221
|
+
#
|
|
222
|
+
# @return [Integer, nil] Remaining credit balance
|
|
223
|
+
def credits_remaining
|
|
224
|
+
body_value(:credits_remaining) || headers["x-reve-credits-remaining"]&.to_i
|
|
134
225
|
end
|
|
135
226
|
end
|
|
136
227
|
end
|
data/lib/reve_ai/version.rb
CHANGED
data/lib/reve_ai.rb
CHANGED
|
@@ -7,6 +7,10 @@ require_relative "reve_ai/response"
|
|
|
7
7
|
require_relative "reve_ai/http/client"
|
|
8
8
|
require_relative "reve_ai/resources/base"
|
|
9
9
|
require_relative "reve_ai/resources/images"
|
|
10
|
+
require_relative "reve_ai/resources/effects"
|
|
11
|
+
require_relative "reve_ai/resources/v2"
|
|
12
|
+
require_relative "reve_ai/resources/v2/images"
|
|
13
|
+
require_relative "reve_ai/resources/v2/layouts"
|
|
10
14
|
require_relative "reve_ai/client"
|
|
11
15
|
|
|
12
16
|
# Ruby client for the Reve image generation API.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: reve_ai
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- dpaluy
|
|
@@ -9,6 +9,20 @@ bindir: exe
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: base64
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0.3'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0.3'
|
|
12
26
|
- !ruby/object:Gem::Dependency
|
|
13
27
|
name: faraday
|
|
14
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -37,8 +51,9 @@ dependencies:
|
|
|
37
51
|
- - "~>"
|
|
38
52
|
- !ruby/object:Gem::Version
|
|
39
53
|
version: '2.0'
|
|
40
|
-
description: ReveAI
|
|
41
|
-
|
|
54
|
+
description: ReveAI was a lightweight Faraday-based wrapper for the Reve image generation
|
|
55
|
+
API (create, edit, remix images). The upstream public API sunsets on August 14,
|
|
56
|
+
2026; this gem is deprecated and will be unmaintained after the shutdown.
|
|
42
57
|
email:
|
|
43
58
|
- dpaluy@users.noreply.github.com
|
|
44
59
|
executables: []
|
|
@@ -56,7 +71,11 @@ files:
|
|
|
56
71
|
- lib/reve_ai/errors.rb
|
|
57
72
|
- lib/reve_ai/http/client.rb
|
|
58
73
|
- lib/reve_ai/resources/base.rb
|
|
74
|
+
- lib/reve_ai/resources/effects.rb
|
|
59
75
|
- lib/reve_ai/resources/images.rb
|
|
76
|
+
- lib/reve_ai/resources/v2.rb
|
|
77
|
+
- lib/reve_ai/resources/v2/images.rb
|
|
78
|
+
- lib/reve_ai/resources/v2/layouts.rb
|
|
60
79
|
- lib/reve_ai/response.rb
|
|
61
80
|
- lib/reve_ai/version.rb
|
|
62
81
|
homepage: https://github.com/dpaluy/reve_ai
|
|
@@ -69,6 +88,13 @@ metadata:
|
|
|
69
88
|
source_code_uri: https://github.com/dpaluy/reve_ai
|
|
70
89
|
changelog_uri: https://github.com/dpaluy/reve_ai/blob/master/CHANGELOG.md
|
|
71
90
|
bug_tracker_uri: https://github.com/dpaluy/reve_ai/issues
|
|
91
|
+
deprecated: 'true'
|
|
92
|
+
post_install_message: |
|
|
93
|
+
WARNING: The upstream Reve public API sunsets Friday, August 14, 2026.
|
|
94
|
+
This gem is deprecated and will be unmaintained after the shutdown.
|
|
95
|
+
Existing approved API users retain access through the sunset window; all other users can no longer access it, and new API onboarding is closed.
|
|
96
|
+
Unused paid credits begin full-refund processing Monday, August 17, 2026.
|
|
97
|
+
See the repository README for details: https://github.com/dpaluy/reve_ai#api-sunset-notice
|
|
72
98
|
rdoc_options: []
|
|
73
99
|
require_paths:
|
|
74
100
|
- lib
|
|
@@ -85,5 +111,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
85
111
|
requirements: []
|
|
86
112
|
rubygems_version: 3.6.9
|
|
87
113
|
specification_version: 4
|
|
88
|
-
summary: Ruby client for
|
|
114
|
+
summary: Deprecated Ruby client for Reve's sunset image generation API.
|
|
89
115
|
test_files: []
|