reve 0.1.0__tar.gz

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.
reve-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,276 @@
1
+ Metadata-Version: 2.4
2
+ Name: reve
3
+ Version: 0.1.0
4
+ Summary: Python SDK for the Reve image generation API
5
+ License-Expression: CC-BY-SA-4.0
6
+ Requires-Python: >=3.7
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: requests>=2.20.0
9
+ Requires-Dist: Pillow>=8.0.0
10
+ Requires-Dist: pydantic>=1.10.0
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
13
+ Requires-Dist: responses>=0.20.0; extra == "dev"
14
+
15
+ # Reve Python SDK
16
+
17
+ A Pythonic interface to the [Reve](https://reve.art) image-generation API.
18
+ Generate, remix, and edit images with a handful of function calls.
19
+
20
+ ## Installation
21
+
22
+ From PyPI:
23
+
24
+ ```bash
25
+ pip install reve
26
+ ```
27
+
28
+ From source:
29
+
30
+ ```bash
31
+ git clone https://github.com/reve-ai/reve-core.git
32
+ cd reve-core/sdk/python
33
+ pip install -e .
34
+ ```
35
+
36
+ ## Quick Start
37
+
38
+ ```python
39
+ from reve.v1.image import create
40
+
41
+ img = create(prompt="A beautiful sunset over the ocean")
42
+ img.save("sunset.jpg")
43
+ print(img.credits_remaining)
44
+ ```
45
+
46
+ > Set the `REVE_API_TOKEN` environment variable before running,
47
+ > or pass `api_token=` directly to any function.
48
+
49
+ ## Authentication
50
+
51
+ The SDK reads credentials from environment variables by default:
52
+
53
+ | Variable | Description | Default |
54
+ |----------|-------------|---------|
55
+ | `REVE_API_TOKEN` | Bearer token (required) | — |
56
+ | `REVE_MONOLITH_LOCATION` | API base URL | `https://api.reve.com` |
57
+ | `REVE_PROXY_AUTHORIZATION` | Proxy-authorization header | — |
58
+
59
+ ```bash
60
+ export REVE_API_TOKEN="papi.your-token-here"
61
+ ```
62
+
63
+ You can also pass them per-call:
64
+
65
+ ```python
66
+ img = create(
67
+ prompt="A sunset",
68
+ api_token="papi.your-token-here",
69
+ api_url="https://custom-endpoint.example.com",
70
+ )
71
+ ```
72
+
73
+ ## API Reference
74
+
75
+ All image functions live in `reve.v1.image`.
76
+
77
+ ### `create(prompt, *, aspect_ratio, version, test_time_scaling, postprocessing, ...)`
78
+
79
+ Generate an image from a text prompt.
80
+
81
+ ```python
82
+ from reve.v1.image import create
83
+ from reve.v1.postprocessing import upscale, remove_background
84
+
85
+ img = create(
86
+ prompt="A red dragon flying over mountains",
87
+ aspect_ratio="16:9",
88
+ version="latest",
89
+ test_time_scaling=3,
90
+ postprocessing=[upscale(factor=2), remove_background()],
91
+ )
92
+ img.save("dragon.png")
93
+ ```
94
+
95
+ | Parameter | Type | Description |
96
+ |-----------|------|-------------|
97
+ | `prompt` | `str` | Text description of the image (positional). |
98
+ | `aspect_ratio` | `str \| None` | One of `"16:9"`, `"3:2"`, `"4:3"`, `"1:1"`, `"3:4"`, `"2:3"`, `"9:16"`, `"auto"`. Default `"auto"`. |
99
+ | `version` | `str \| None` | Model version identifier or `"latest"`. |
100
+ | `test_time_scaling` | `int \| None` | Quality factor 1–5. Higher = better quality, more credits. |
101
+ | `postprocessing` | `list[dict] \| None` | Postprocessing pipeline (see below). |
102
+
103
+ ### `remix(prompt, reference_images, *, ...)`
104
+
105
+ Remix reference images into a new image guided by a prompt.
106
+ Use `<ref>0</ref>`, `<ref>1</ref>`, … to refer to each reference image.
107
+
108
+ ```python
109
+ from reve.v1.image import remix
110
+
111
+ img = remix(
112
+ prompt="The subject from <ref>0</ref> standing in a magical forest",
113
+ reference_images=["photo.jpg"],
114
+ aspect_ratio="1:1",
115
+ )
116
+ ```
117
+
118
+ | Parameter | Type | Description |
119
+ |-----------|------|-------------|
120
+ | `prompt` | `str` | Text prompt with optional `<ref>N</ref>` tags (positional). |
121
+ | `reference_images` | `Sequence[str \| bytes \| PIL.Image]` | Reference images — file paths, raw bytes, or PIL Images (positional). |
122
+ | `aspect_ratio` | `str \| None` | Aspect ratio (see `create`). |
123
+ | `version` | `str \| None` | Model version. |
124
+ | `test_time_scaling` | `int \| None` | Quality factor 1–5. |
125
+ | `postprocessing` | `list[dict] \| None` | Postprocessing pipeline. |
126
+
127
+ ### `edit(edit_instruction, reference_image, *, ...)`
128
+
129
+ Edit an existing image with a natural-language instruction.
130
+
131
+ ```python
132
+ from reve.v1.image import edit
133
+
134
+ img = edit(
135
+ edit_instruction="Make the sky more dramatic with storm clouds",
136
+ reference_image="original.jpg",
137
+ )
138
+ ```
139
+
140
+ | Parameter | Type | Description |
141
+ |-----------|------|-------------|
142
+ | `edit_instruction` | `str` | Description of the edit (positional). |
143
+ | `reference_image` | `str \| bytes \| PIL.Image` | Source image (positional). |
144
+ | `aspect_ratio` | `str \| None` | Aspect ratio (see `create`). |
145
+ | `version` | `str \| None` | Model version. |
146
+ | `test_time_scaling` | `int \| None` | Quality factor 1–5. |
147
+ | `postprocessing` | `list[dict] \| None` | Postprocessing pipeline. |
148
+
149
+ ### `get_balance(*, ...)`
150
+
151
+ Return the current credit balance.
152
+
153
+ ```python
154
+ from reve.v1.image import get_balance
155
+
156
+ balance = get_balance()
157
+ print(balance) # {"budget_id": "abc123", "new_balance": 500}
158
+ ```
159
+
160
+ Returns a `dict` with keys `budget_id` (str) and `new_balance` (number).
161
+
162
+ ### `list_effects(source=None, *, ...)`
163
+
164
+ List available effects for postprocessing.
165
+
166
+ ```python
167
+ from reve.v1.image import list_effects
168
+
169
+ effects = list_effects(source="preset")
170
+ for e in effects:
171
+ print(e["name"], "-", e["description"])
172
+ ```
173
+
174
+ | Parameter | Type | Description |
175
+ |-----------|------|-------------|
176
+ | `source` | `str \| None` | Filter by source: `"all"`, `"project"`, or `"preset"`. |
177
+
178
+ Returns a list of dicts with `name`, `description`, `source`, and `category` keys.
179
+
180
+ ## Postprocessing
181
+
182
+ Build postprocessing pipelines with helpers from `reve.v1.postprocessing`:
183
+
184
+ ```python
185
+ from reve.v1.postprocessing import upscale, remove_background, fit_image, effect
186
+ ```
187
+
188
+ | Helper | Description |
189
+ |--------|-------------|
190
+ | `upscale(factor=2)` | Upscale the image by the given factor. |
191
+ | `remove_background()` | Remove the background (produces transparent PNG). |
192
+ | `fit_image(max_width=None, max_height=None, max_dim=None)` | Constrain dimensions (pixels, 1–1024). |
193
+ | `effect(name, parameters=None)` | Apply a named effect. Use `list_effects()` for available names. |
194
+
195
+ Pass them as a list to the `postprocessing` parameter:
196
+
197
+ ```python
198
+ img = create(
199
+ prompt="A cat astronaut",
200
+ postprocessing=[upscale(factor=2), remove_background()],
201
+ )
202
+ ```
203
+
204
+ ## Response Object
205
+
206
+ `create()`, `remix()`, and `edit()` return an `ImageResponse` (a Pydantic BaseModel):
207
+
208
+ | Field | Type | Description |
209
+ |-------|------|-------------|
210
+ | `image` | `PIL.Image.Image` | The generated image. |
211
+ | `request_id` | `str \| None` | Unique request identifier. |
212
+ | `credits_used` | `int \| None` | Credits consumed by this request. |
213
+ | `credits_remaining` | `int \| None` | Credits remaining in the budget. |
214
+ | `version` | `str \| None` | Model version used. |
215
+ | `content_violation` | `bool` | Whether a content violation was flagged. |
216
+
217
+ ```python
218
+ img = create(prompt="A sunset")
219
+ img.image # PIL.Image.Image
220
+ img.request_id # "req_abc123"
221
+ img.credits_used # 10
222
+ img.credits_remaining # 490
223
+ img.version # "v1.2"
224
+ img.save("out.jpg") # delegates to PIL.Image.save()
225
+ ```
226
+
227
+ ## Error Handling
228
+
229
+ All exceptions inherit from `ReveAPIError`:
230
+
231
+ ```
232
+ ReveAPIError # Base — any API error
233
+ ├── ReveAuthenticationError # HTTP 401 — bad or missing token
234
+ ├── ReveBudgetExhaustedError # HTTP 402 — out of credits
235
+ ├── ReveRateLimitError # HTTP 429 — rate limited (has .retry_after)
236
+ ├── ReveValidationError # HTTP 400 — invalid parameters
237
+ └── ReveContentViolationError # Content policy violation
238
+ ```
239
+
240
+ ```python
241
+ from reve.exceptions import ReveAPIError, ReveRateLimitError
242
+ from reve.v1.image import create
243
+
244
+ try:
245
+ img = create(prompt="A sunset")
246
+ except ReveRateLimitError as exc:
247
+ print(f"Rate limited — retry after {exc.retry_after}s")
248
+ except ReveAPIError as exc:
249
+ print(f"API error (status {exc.status_code}): {exc.message}")
250
+ ```
251
+
252
+ ## Examples
253
+
254
+ Working example scripts are in the [`examples/`](examples/) directory:
255
+
256
+ - [`create_image.py`](examples/create_image.py) — Generate images with optional postprocessing.
257
+ - [`remix_image.py`](examples/remix_image.py) — Remix a reference image with a prompt.
258
+ - [`edit_image.py`](examples/edit_image.py) — Edit an existing image.
259
+
260
+ ## Development
261
+
262
+ Install development dependencies:
263
+
264
+ ```bash
265
+ pip install -e ".[dev]"
266
+ ```
267
+
268
+ Run the test suite:
269
+
270
+ ```bash
271
+ pytest
272
+ ```
273
+
274
+ ## License
275
+
276
+ This SDK is released under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/).
reve-0.1.0/README.md ADDED
@@ -0,0 +1,262 @@
1
+ # Reve Python SDK
2
+
3
+ A Pythonic interface to the [Reve](https://reve.art) image-generation API.
4
+ Generate, remix, and edit images with a handful of function calls.
5
+
6
+ ## Installation
7
+
8
+ From PyPI:
9
+
10
+ ```bash
11
+ pip install reve
12
+ ```
13
+
14
+ From source:
15
+
16
+ ```bash
17
+ git clone https://github.com/reve-ai/reve-core.git
18
+ cd reve-core/sdk/python
19
+ pip install -e .
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ```python
25
+ from reve.v1.image import create
26
+
27
+ img = create(prompt="A beautiful sunset over the ocean")
28
+ img.save("sunset.jpg")
29
+ print(img.credits_remaining)
30
+ ```
31
+
32
+ > Set the `REVE_API_TOKEN` environment variable before running,
33
+ > or pass `api_token=` directly to any function.
34
+
35
+ ## Authentication
36
+
37
+ The SDK reads credentials from environment variables by default:
38
+
39
+ | Variable | Description | Default |
40
+ |----------|-------------|---------|
41
+ | `REVE_API_TOKEN` | Bearer token (required) | — |
42
+ | `REVE_MONOLITH_LOCATION` | API base URL | `https://api.reve.com` |
43
+ | `REVE_PROXY_AUTHORIZATION` | Proxy-authorization header | — |
44
+
45
+ ```bash
46
+ export REVE_API_TOKEN="papi.your-token-here"
47
+ ```
48
+
49
+ You can also pass them per-call:
50
+
51
+ ```python
52
+ img = create(
53
+ prompt="A sunset",
54
+ api_token="papi.your-token-here",
55
+ api_url="https://custom-endpoint.example.com",
56
+ )
57
+ ```
58
+
59
+ ## API Reference
60
+
61
+ All image functions live in `reve.v1.image`.
62
+
63
+ ### `create(prompt, *, aspect_ratio, version, test_time_scaling, postprocessing, ...)`
64
+
65
+ Generate an image from a text prompt.
66
+
67
+ ```python
68
+ from reve.v1.image import create
69
+ from reve.v1.postprocessing import upscale, remove_background
70
+
71
+ img = create(
72
+ prompt="A red dragon flying over mountains",
73
+ aspect_ratio="16:9",
74
+ version="latest",
75
+ test_time_scaling=3,
76
+ postprocessing=[upscale(factor=2), remove_background()],
77
+ )
78
+ img.save("dragon.png")
79
+ ```
80
+
81
+ | Parameter | Type | Description |
82
+ |-----------|------|-------------|
83
+ | `prompt` | `str` | Text description of the image (positional). |
84
+ | `aspect_ratio` | `str \| None` | One of `"16:9"`, `"3:2"`, `"4:3"`, `"1:1"`, `"3:4"`, `"2:3"`, `"9:16"`, `"auto"`. Default `"auto"`. |
85
+ | `version` | `str \| None` | Model version identifier or `"latest"`. |
86
+ | `test_time_scaling` | `int \| None` | Quality factor 1–5. Higher = better quality, more credits. |
87
+ | `postprocessing` | `list[dict] \| None` | Postprocessing pipeline (see below). |
88
+
89
+ ### `remix(prompt, reference_images, *, ...)`
90
+
91
+ Remix reference images into a new image guided by a prompt.
92
+ Use `<ref>0</ref>`, `<ref>1</ref>`, … to refer to each reference image.
93
+
94
+ ```python
95
+ from reve.v1.image import remix
96
+
97
+ img = remix(
98
+ prompt="The subject from <ref>0</ref> standing in a magical forest",
99
+ reference_images=["photo.jpg"],
100
+ aspect_ratio="1:1",
101
+ )
102
+ ```
103
+
104
+ | Parameter | Type | Description |
105
+ |-----------|------|-------------|
106
+ | `prompt` | `str` | Text prompt with optional `<ref>N</ref>` tags (positional). |
107
+ | `reference_images` | `Sequence[str \| bytes \| PIL.Image]` | Reference images — file paths, raw bytes, or PIL Images (positional). |
108
+ | `aspect_ratio` | `str \| None` | Aspect ratio (see `create`). |
109
+ | `version` | `str \| None` | Model version. |
110
+ | `test_time_scaling` | `int \| None` | Quality factor 1–5. |
111
+ | `postprocessing` | `list[dict] \| None` | Postprocessing pipeline. |
112
+
113
+ ### `edit(edit_instruction, reference_image, *, ...)`
114
+
115
+ Edit an existing image with a natural-language instruction.
116
+
117
+ ```python
118
+ from reve.v1.image import edit
119
+
120
+ img = edit(
121
+ edit_instruction="Make the sky more dramatic with storm clouds",
122
+ reference_image="original.jpg",
123
+ )
124
+ ```
125
+
126
+ | Parameter | Type | Description |
127
+ |-----------|------|-------------|
128
+ | `edit_instruction` | `str` | Description of the edit (positional). |
129
+ | `reference_image` | `str \| bytes \| PIL.Image` | Source image (positional). |
130
+ | `aspect_ratio` | `str \| None` | Aspect ratio (see `create`). |
131
+ | `version` | `str \| None` | Model version. |
132
+ | `test_time_scaling` | `int \| None` | Quality factor 1–5. |
133
+ | `postprocessing` | `list[dict] \| None` | Postprocessing pipeline. |
134
+
135
+ ### `get_balance(*, ...)`
136
+
137
+ Return the current credit balance.
138
+
139
+ ```python
140
+ from reve.v1.image import get_balance
141
+
142
+ balance = get_balance()
143
+ print(balance) # {"budget_id": "abc123", "new_balance": 500}
144
+ ```
145
+
146
+ Returns a `dict` with keys `budget_id` (str) and `new_balance` (number).
147
+
148
+ ### `list_effects(source=None, *, ...)`
149
+
150
+ List available effects for postprocessing.
151
+
152
+ ```python
153
+ from reve.v1.image import list_effects
154
+
155
+ effects = list_effects(source="preset")
156
+ for e in effects:
157
+ print(e["name"], "-", e["description"])
158
+ ```
159
+
160
+ | Parameter | Type | Description |
161
+ |-----------|------|-------------|
162
+ | `source` | `str \| None` | Filter by source: `"all"`, `"project"`, or `"preset"`. |
163
+
164
+ Returns a list of dicts with `name`, `description`, `source`, and `category` keys.
165
+
166
+ ## Postprocessing
167
+
168
+ Build postprocessing pipelines with helpers from `reve.v1.postprocessing`:
169
+
170
+ ```python
171
+ from reve.v1.postprocessing import upscale, remove_background, fit_image, effect
172
+ ```
173
+
174
+ | Helper | Description |
175
+ |--------|-------------|
176
+ | `upscale(factor=2)` | Upscale the image by the given factor. |
177
+ | `remove_background()` | Remove the background (produces transparent PNG). |
178
+ | `fit_image(max_width=None, max_height=None, max_dim=None)` | Constrain dimensions (pixels, 1–1024). |
179
+ | `effect(name, parameters=None)` | Apply a named effect. Use `list_effects()` for available names. |
180
+
181
+ Pass them as a list to the `postprocessing` parameter:
182
+
183
+ ```python
184
+ img = create(
185
+ prompt="A cat astronaut",
186
+ postprocessing=[upscale(factor=2), remove_background()],
187
+ )
188
+ ```
189
+
190
+ ## Response Object
191
+
192
+ `create()`, `remix()`, and `edit()` return an `ImageResponse` (a Pydantic BaseModel):
193
+
194
+ | Field | Type | Description |
195
+ |-------|------|-------------|
196
+ | `image` | `PIL.Image.Image` | The generated image. |
197
+ | `request_id` | `str \| None` | Unique request identifier. |
198
+ | `credits_used` | `int \| None` | Credits consumed by this request. |
199
+ | `credits_remaining` | `int \| None` | Credits remaining in the budget. |
200
+ | `version` | `str \| None` | Model version used. |
201
+ | `content_violation` | `bool` | Whether a content violation was flagged. |
202
+
203
+ ```python
204
+ img = create(prompt="A sunset")
205
+ img.image # PIL.Image.Image
206
+ img.request_id # "req_abc123"
207
+ img.credits_used # 10
208
+ img.credits_remaining # 490
209
+ img.version # "v1.2"
210
+ img.save("out.jpg") # delegates to PIL.Image.save()
211
+ ```
212
+
213
+ ## Error Handling
214
+
215
+ All exceptions inherit from `ReveAPIError`:
216
+
217
+ ```
218
+ ReveAPIError # Base — any API error
219
+ ├── ReveAuthenticationError # HTTP 401 — bad or missing token
220
+ ├── ReveBudgetExhaustedError # HTTP 402 — out of credits
221
+ ├── ReveRateLimitError # HTTP 429 — rate limited (has .retry_after)
222
+ ├── ReveValidationError # HTTP 400 — invalid parameters
223
+ └── ReveContentViolationError # Content policy violation
224
+ ```
225
+
226
+ ```python
227
+ from reve.exceptions import ReveAPIError, ReveRateLimitError
228
+ from reve.v1.image import create
229
+
230
+ try:
231
+ img = create(prompt="A sunset")
232
+ except ReveRateLimitError as exc:
233
+ print(f"Rate limited — retry after {exc.retry_after}s")
234
+ except ReveAPIError as exc:
235
+ print(f"API error (status {exc.status_code}): {exc.message}")
236
+ ```
237
+
238
+ ## Examples
239
+
240
+ Working example scripts are in the [`examples/`](examples/) directory:
241
+
242
+ - [`create_image.py`](examples/create_image.py) — Generate images with optional postprocessing.
243
+ - [`remix_image.py`](examples/remix_image.py) — Remix a reference image with a prompt.
244
+ - [`edit_image.py`](examples/edit_image.py) — Edit an existing image.
245
+
246
+ ## Development
247
+
248
+ Install development dependencies:
249
+
250
+ ```bash
251
+ pip install -e ".[dev]"
252
+ ```
253
+
254
+ Run the test suite:
255
+
256
+ ```bash
257
+ pytest
258
+ ```
259
+
260
+ ## License
261
+
262
+ This SDK is released under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/).
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=45", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "reve"
7
+ version = "0.1.0"
8
+ description = "Python SDK for the Reve image generation API"
9
+ readme = "README.md"
10
+ license = "CC-BY-SA-4.0"
11
+ requires-python = ">=3.7"
12
+ dependencies = [
13
+ "requests>=2.20.0",
14
+ "Pillow>=8.0.0",
15
+ "pydantic>=1.10.0",
16
+ ]
17
+
18
+ [project.optional-dependencies]
19
+ dev = [
20
+ "pytest>=7.0.0",
21
+ "responses>=0.20.0",
22
+ ]
23
+
24
+ [tool.setuptools.packages.find]
25
+ include = ["reve*"]
26
+
@@ -0,0 +1,4 @@
1
+ """Reve Python SDK — A Pythonic interface to the Reve image generation API."""
2
+
3
+ __version__ = "0.1.0"
4
+