wavespeed 0.0.1__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.
- wavespeed-0.0.1/LICENSE +21 -0
- wavespeed-0.0.1/PKG-INFO +270 -0
- wavespeed-0.0.1/README.md +233 -0
- wavespeed-0.0.1/pyproject.toml +93 -0
- wavespeed-0.0.1/setup.cfg +4 -0
- wavespeed-0.0.1/tests/test_client.py +316 -0
- wavespeed-0.0.1/wavespeed/__init__.py +18 -0
- wavespeed-0.0.1/wavespeed/client.py +150 -0
- wavespeed-0.0.1/wavespeed.egg-info/PKG-INFO +270 -0
- wavespeed-0.0.1/wavespeed.egg-info/SOURCES.txt +11 -0
- wavespeed-0.0.1/wavespeed.egg-info/dependency_links.txt +1 -0
- wavespeed-0.0.1/wavespeed.egg-info/requires.txt +4 -0
- wavespeed-0.0.1/wavespeed.egg-info/top_level.txt +1 -0
wavespeed-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Wavespeed AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
wavespeed-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wavespeed
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Python client for Wavespeed
|
|
5
|
+
Author: Wavespeed, Inc.
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 Wavespeed AI
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
Project-URL: homepage, https://wavespeed.ai
|
|
28
|
+
Project-URL: repository, https://github.com/wavespeed-ai/wavespeed-python
|
|
29
|
+
Requires-Python: >=3.8
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Requires-Dist: httpx<1,>=0.21.0
|
|
33
|
+
Requires-Dist: packaging
|
|
34
|
+
Requires-Dist: pydantic>1.10.7
|
|
35
|
+
Requires-Dist: typing_extensions>=4.5.0
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# Wavespeed Python Client
|
|
39
|
+
|
|
40
|
+
A Python client for interacting with the Wavespeed AI API.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install wavespeed
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
### Synchronous Image Generation
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from wavespeed import Wavespeed
|
|
54
|
+
|
|
55
|
+
# Initialize the client with your API key (or set WAVESPEED_API_KEY environment variable)
|
|
56
|
+
client = Wavespeed(api_key="YOUR_API_KEY")
|
|
57
|
+
|
|
58
|
+
# Generate an image and wait for the result
|
|
59
|
+
prediction = client.run(
|
|
60
|
+
modelId="wavespeed-ai/flux-dev",
|
|
61
|
+
input={
|
|
62
|
+
"prompt": "A futuristic cityscape with flying cars and neon lights",
|
|
63
|
+
"size": "1024*1024",
|
|
64
|
+
"num_inference_steps": 28,
|
|
65
|
+
"guidance_scale": 5.0,
|
|
66
|
+
"num_images": 1,
|
|
67
|
+
"seed": -1,
|
|
68
|
+
"enable_safety_checker": True
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# Print the generated image URLs
|
|
73
|
+
for i, img_url in enumerate(prediction.outputs):
|
|
74
|
+
print(f"Image {i+1}: {img_url}")
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Asynchronous Image Generation
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
import asyncio
|
|
81
|
+
from wavespeed import Wavespeed
|
|
82
|
+
|
|
83
|
+
async def generate_image():
|
|
84
|
+
# Initialize the client with your API key (or set WAVESPEED_API_KEY environment variable)
|
|
85
|
+
client = Wavespeed(api_key="YOUR_API_KEY")
|
|
86
|
+
|
|
87
|
+
try:
|
|
88
|
+
# Generate an image and wait for the result
|
|
89
|
+
prediction = await client.async_run(
|
|
90
|
+
modelId="wavespeed-ai/flux-dev",
|
|
91
|
+
input={
|
|
92
|
+
"prompt": "A futuristic cityscape with flying cars and neon lights",
|
|
93
|
+
"size": "1024*1024",
|
|
94
|
+
"num_inference_steps": 28,
|
|
95
|
+
"guidance_scale": 5.0,
|
|
96
|
+
"num_images": 1,
|
|
97
|
+
"seed": -1,
|
|
98
|
+
"enable_safety_checker": True
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# Print the generated image URLs
|
|
103
|
+
for i, img_url in enumerate(prediction.outputs):
|
|
104
|
+
print(f"Image {i+1}: {img_url}")
|
|
105
|
+
finally:
|
|
106
|
+
# Always close the client when done
|
|
107
|
+
await client.close()
|
|
108
|
+
|
|
109
|
+
# Run the async function
|
|
110
|
+
asyncio.run(generate_image())
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Non-blocking Image Generation
|
|
114
|
+
|
|
115
|
+
You can also create a prediction without waiting for it to complete:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from wavespeed import Wavespeed
|
|
119
|
+
|
|
120
|
+
# Initialize the client with your API key (or set WAVESPEED_API_KEY environment variable)
|
|
121
|
+
client = Wavespeed(api_key="YOUR_API_KEY")
|
|
122
|
+
|
|
123
|
+
# Create a prediction without waiting
|
|
124
|
+
prediction = client.create(
|
|
125
|
+
modelId="wavespeed-ai/flux-dev",
|
|
126
|
+
input={
|
|
127
|
+
"prompt": "A futuristic cityscape with flying cars and neon lights",
|
|
128
|
+
"size": "1024*1024",
|
|
129
|
+
"num_inference_steps": 28,
|
|
130
|
+
"guidance_scale": 5.0,
|
|
131
|
+
"num_images": 1,
|
|
132
|
+
"seed": -1,
|
|
133
|
+
"enable_safety_checker": True
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
print(f"Prediction created with ID: {prediction.id}")
|
|
138
|
+
print(f"Initial status: {prediction.status}")
|
|
139
|
+
|
|
140
|
+
# Later, you can wait for the prediction to complete
|
|
141
|
+
result = prediction.wait()
|
|
142
|
+
print(f"Final status: {result.status}")
|
|
143
|
+
|
|
144
|
+
# Print the generated image URLs
|
|
145
|
+
for i, img_url in enumerate(result.outputs):
|
|
146
|
+
print(f"Image {i+1}: {img_url}")
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Command Line Examples
|
|
150
|
+
|
|
151
|
+
The package includes several example scripts that you can use to generate images:
|
|
152
|
+
|
|
153
|
+
### Basic Image Generation
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Set your API key as an environment variable
|
|
157
|
+
export WAVESPEED_API_KEY="your_api_key_here"
|
|
158
|
+
|
|
159
|
+
# Run the example script
|
|
160
|
+
python examples/generate_image.py --prompt "A futuristic cityscape with flying cars and neon lights"
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Asynchronous Image Generation
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Run the async example script
|
|
167
|
+
python examples/async_generate_image.py --prompt "A futuristic cityscape with flying cars and neon lights"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Non-blocking Image Generation
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Create a prediction and poll for status
|
|
174
|
+
python examples/create_generate_image.py --prompt "A futuristic cityscape with flying cars and neon lights"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Command Line Options
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
--prompt TEXT Text description of the desired image (required)
|
|
181
|
+
--strength FLOAT How much to transform the input image (0.0 to 1.0)
|
|
182
|
+
--size WIDTHxHEIGHT Image dimensions (default: 1024*1024)
|
|
183
|
+
--steps INT Number of inference steps (default: 28)
|
|
184
|
+
--guidance FLOAT How closely to follow the prompt (default: 5.0)
|
|
185
|
+
--num-images INT Number of images to generate (default: 1)
|
|
186
|
+
--seed INT Random seed (-1 for random)
|
|
187
|
+
--safety Enable content safety filtering
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## API Reference
|
|
191
|
+
|
|
192
|
+
### Wavespeed Client
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
Wavespeed(api_key)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### Parameters:
|
|
199
|
+
|
|
200
|
+
- `api_key` (str): Your Wavespeed API key
|
|
201
|
+
|
|
202
|
+
### Methods
|
|
203
|
+
|
|
204
|
+
#### run
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
run(modelId, input, **kwargs) -> Prediction
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Generate an image and wait for the result.
|
|
211
|
+
|
|
212
|
+
#### async_run
|
|
213
|
+
|
|
214
|
+
```python
|
|
215
|
+
async_run(modelId, input, **kwargs) -> Prediction
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Asynchronously generate an image and wait for the result.
|
|
219
|
+
|
|
220
|
+
#### create
|
|
221
|
+
|
|
222
|
+
```python
|
|
223
|
+
create(modelId, input, **kwargs) -> Prediction
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Create a prediction without waiting for it to complete.
|
|
227
|
+
|
|
228
|
+
#### async_create
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
async_create(modelId, input, **kwargs) -> Prediction
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Asynchronously create a prediction without waiting for it to complete.
|
|
235
|
+
|
|
236
|
+
### Prediction Model
|
|
237
|
+
|
|
238
|
+
The `Prediction` object contains information about an image generation job:
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
prediction.id # Unique ID of the prediction
|
|
242
|
+
prediction.model # Model ID used for the prediction
|
|
243
|
+
prediction.status # Status of the prediction (processing, completed, failed)
|
|
244
|
+
prediction.outputs # List of output image URLs
|
|
245
|
+
prediction.input # Input parameters used for the prediction
|
|
246
|
+
prediction.created_at # Creation timestamp
|
|
247
|
+
prediction.error # Error message (if any)
|
|
248
|
+
prediction.executionTime # Time taken to execute the prediction in milliseconds
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
#### Methods
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
prediction.wait() -> Prediction # Wait for the prediction to complete
|
|
255
|
+
prediction.reload() -> Prediction # Reload the prediction status
|
|
256
|
+
|
|
257
|
+
# Async versions
|
|
258
|
+
await prediction.async_wait() -> Prediction
|
|
259
|
+
await prediction.async_reload() -> Prediction
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Environment Variables
|
|
263
|
+
|
|
264
|
+
- `WAVESPEED_API_KEY`: Your Wavespeed API key
|
|
265
|
+
- `WAVESPEED_POLL_INTERVAL`: Interval in seconds for polling prediction status (default: 1)
|
|
266
|
+
- `WAVESPEED_TIMEOUT`: Timeout in seconds for API requests (default: 60)
|
|
267
|
+
|
|
268
|
+
## License
|
|
269
|
+
|
|
270
|
+
MIT
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# Wavespeed Python Client
|
|
2
|
+
|
|
3
|
+
A Python client for interacting with the Wavespeed AI API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install wavespeed
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Synchronous Image Generation
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from wavespeed import Wavespeed
|
|
17
|
+
|
|
18
|
+
# Initialize the client with your API key (or set WAVESPEED_API_KEY environment variable)
|
|
19
|
+
client = Wavespeed(api_key="YOUR_API_KEY")
|
|
20
|
+
|
|
21
|
+
# Generate an image and wait for the result
|
|
22
|
+
prediction = client.run(
|
|
23
|
+
modelId="wavespeed-ai/flux-dev",
|
|
24
|
+
input={
|
|
25
|
+
"prompt": "A futuristic cityscape with flying cars and neon lights",
|
|
26
|
+
"size": "1024*1024",
|
|
27
|
+
"num_inference_steps": 28,
|
|
28
|
+
"guidance_scale": 5.0,
|
|
29
|
+
"num_images": 1,
|
|
30
|
+
"seed": -1,
|
|
31
|
+
"enable_safety_checker": True
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
# Print the generated image URLs
|
|
36
|
+
for i, img_url in enumerate(prediction.outputs):
|
|
37
|
+
print(f"Image {i+1}: {img_url}")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Asynchronous Image Generation
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import asyncio
|
|
44
|
+
from wavespeed import Wavespeed
|
|
45
|
+
|
|
46
|
+
async def generate_image():
|
|
47
|
+
# Initialize the client with your API key (or set WAVESPEED_API_KEY environment variable)
|
|
48
|
+
client = Wavespeed(api_key="YOUR_API_KEY")
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
# Generate an image and wait for the result
|
|
52
|
+
prediction = await client.async_run(
|
|
53
|
+
modelId="wavespeed-ai/flux-dev",
|
|
54
|
+
input={
|
|
55
|
+
"prompt": "A futuristic cityscape with flying cars and neon lights",
|
|
56
|
+
"size": "1024*1024",
|
|
57
|
+
"num_inference_steps": 28,
|
|
58
|
+
"guidance_scale": 5.0,
|
|
59
|
+
"num_images": 1,
|
|
60
|
+
"seed": -1,
|
|
61
|
+
"enable_safety_checker": True
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# Print the generated image URLs
|
|
66
|
+
for i, img_url in enumerate(prediction.outputs):
|
|
67
|
+
print(f"Image {i+1}: {img_url}")
|
|
68
|
+
finally:
|
|
69
|
+
# Always close the client when done
|
|
70
|
+
await client.close()
|
|
71
|
+
|
|
72
|
+
# Run the async function
|
|
73
|
+
asyncio.run(generate_image())
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Non-blocking Image Generation
|
|
77
|
+
|
|
78
|
+
You can also create a prediction without waiting for it to complete:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from wavespeed import Wavespeed
|
|
82
|
+
|
|
83
|
+
# Initialize the client with your API key (or set WAVESPEED_API_KEY environment variable)
|
|
84
|
+
client = Wavespeed(api_key="YOUR_API_KEY")
|
|
85
|
+
|
|
86
|
+
# Create a prediction without waiting
|
|
87
|
+
prediction = client.create(
|
|
88
|
+
modelId="wavespeed-ai/flux-dev",
|
|
89
|
+
input={
|
|
90
|
+
"prompt": "A futuristic cityscape with flying cars and neon lights",
|
|
91
|
+
"size": "1024*1024",
|
|
92
|
+
"num_inference_steps": 28,
|
|
93
|
+
"guidance_scale": 5.0,
|
|
94
|
+
"num_images": 1,
|
|
95
|
+
"seed": -1,
|
|
96
|
+
"enable_safety_checker": True
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
print(f"Prediction created with ID: {prediction.id}")
|
|
101
|
+
print(f"Initial status: {prediction.status}")
|
|
102
|
+
|
|
103
|
+
# Later, you can wait for the prediction to complete
|
|
104
|
+
result = prediction.wait()
|
|
105
|
+
print(f"Final status: {result.status}")
|
|
106
|
+
|
|
107
|
+
# Print the generated image URLs
|
|
108
|
+
for i, img_url in enumerate(result.outputs):
|
|
109
|
+
print(f"Image {i+1}: {img_url}")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Command Line Examples
|
|
113
|
+
|
|
114
|
+
The package includes several example scripts that you can use to generate images:
|
|
115
|
+
|
|
116
|
+
### Basic Image Generation
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Set your API key as an environment variable
|
|
120
|
+
export WAVESPEED_API_KEY="your_api_key_here"
|
|
121
|
+
|
|
122
|
+
# Run the example script
|
|
123
|
+
python examples/generate_image.py --prompt "A futuristic cityscape with flying cars and neon lights"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Asynchronous Image Generation
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Run the async example script
|
|
130
|
+
python examples/async_generate_image.py --prompt "A futuristic cityscape with flying cars and neon lights"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Non-blocking Image Generation
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Create a prediction and poll for status
|
|
137
|
+
python examples/create_generate_image.py --prompt "A futuristic cityscape with flying cars and neon lights"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Command Line Options
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
--prompt TEXT Text description of the desired image (required)
|
|
144
|
+
--strength FLOAT How much to transform the input image (0.0 to 1.0)
|
|
145
|
+
--size WIDTHxHEIGHT Image dimensions (default: 1024*1024)
|
|
146
|
+
--steps INT Number of inference steps (default: 28)
|
|
147
|
+
--guidance FLOAT How closely to follow the prompt (default: 5.0)
|
|
148
|
+
--num-images INT Number of images to generate (default: 1)
|
|
149
|
+
--seed INT Random seed (-1 for random)
|
|
150
|
+
--safety Enable content safety filtering
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## API Reference
|
|
154
|
+
|
|
155
|
+
### Wavespeed Client
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
Wavespeed(api_key)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
#### Parameters:
|
|
162
|
+
|
|
163
|
+
- `api_key` (str): Your Wavespeed API key
|
|
164
|
+
|
|
165
|
+
### Methods
|
|
166
|
+
|
|
167
|
+
#### run
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
run(modelId, input, **kwargs) -> Prediction
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Generate an image and wait for the result.
|
|
174
|
+
|
|
175
|
+
#### async_run
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
async_run(modelId, input, **kwargs) -> Prediction
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Asynchronously generate an image and wait for the result.
|
|
182
|
+
|
|
183
|
+
#### create
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
create(modelId, input, **kwargs) -> Prediction
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Create a prediction without waiting for it to complete.
|
|
190
|
+
|
|
191
|
+
#### async_create
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
async_create(modelId, input, **kwargs) -> Prediction
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Asynchronously create a prediction without waiting for it to complete.
|
|
198
|
+
|
|
199
|
+
### Prediction Model
|
|
200
|
+
|
|
201
|
+
The `Prediction` object contains information about an image generation job:
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
prediction.id # Unique ID of the prediction
|
|
205
|
+
prediction.model # Model ID used for the prediction
|
|
206
|
+
prediction.status # Status of the prediction (processing, completed, failed)
|
|
207
|
+
prediction.outputs # List of output image URLs
|
|
208
|
+
prediction.input # Input parameters used for the prediction
|
|
209
|
+
prediction.created_at # Creation timestamp
|
|
210
|
+
prediction.error # Error message (if any)
|
|
211
|
+
prediction.executionTime # Time taken to execute the prediction in milliseconds
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### Methods
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
prediction.wait() -> Prediction # Wait for the prediction to complete
|
|
218
|
+
prediction.reload() -> Prediction # Reload the prediction status
|
|
219
|
+
|
|
220
|
+
# Async versions
|
|
221
|
+
await prediction.async_wait() -> Prediction
|
|
222
|
+
await prediction.async_reload() -> Prediction
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Environment Variables
|
|
226
|
+
|
|
227
|
+
- `WAVESPEED_API_KEY`: Your Wavespeed API key
|
|
228
|
+
- `WAVESPEED_POLL_INTERVAL`: Interval in seconds for polling prediction status (default: 1)
|
|
229
|
+
- `WAVESPEED_TIMEOUT`: Timeout in seconds for API requests (default: 60)
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
MIT
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "wavespeed"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
description = "Python client for Wavespeed"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
authors = [{ name = "Wavespeed, Inc." }]
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"httpx>=0.21.0,<1",
|
|
15
|
+
"packaging",
|
|
16
|
+
"pydantic>1.10.7",
|
|
17
|
+
"typing_extensions>=4.5.0",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[dependency-groups]
|
|
21
|
+
dev = [
|
|
22
|
+
"pytest>=8.1.1,<9",
|
|
23
|
+
"pylint>=3.1.0,<4",
|
|
24
|
+
"pyright>=1.1.358,<2",
|
|
25
|
+
"pytest-asyncio>=0.23.6,<1",
|
|
26
|
+
"pytest-recording>=0.13.1,<1",
|
|
27
|
+
"respx>=0.21.1,<1",
|
|
28
|
+
"ruff>=0.3.7,<1",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
homepage = "https://wavespeed.ai"
|
|
33
|
+
repository = "https://github.com/wavespeed-ai/wavespeed-python"
|
|
34
|
+
|
|
35
|
+
[tool.pytest.ini_options]
|
|
36
|
+
asyncio_mode = "auto"
|
|
37
|
+
testpaths = "tests/"
|
|
38
|
+
|
|
39
|
+
[tool.setuptools]
|
|
40
|
+
packages = ["wavespeed"]
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.package-data]
|
|
43
|
+
"wavespeed" = ["py.typed"]
|
|
44
|
+
|
|
45
|
+
[tool.pylint.main]
|
|
46
|
+
disable = [
|
|
47
|
+
"C0301", # Line too long
|
|
48
|
+
"C0413", # Import should be placed at the top of the module
|
|
49
|
+
"C0114", # Missing module docstring
|
|
50
|
+
"R0801", # Similar lines in N files
|
|
51
|
+
"W0212", # Access to a protected member
|
|
52
|
+
"W0622", # Redefining built-in
|
|
53
|
+
"R0903", # Too few public methods
|
|
54
|
+
]
|
|
55
|
+
good-names = ["id"]
|
|
56
|
+
|
|
57
|
+
[tool.ruff.lint]
|
|
58
|
+
select = [
|
|
59
|
+
"E", # pycodestyle error
|
|
60
|
+
"F", # Pyflakes
|
|
61
|
+
"I", # isort
|
|
62
|
+
"W", # pycodestyle warning
|
|
63
|
+
"UP", # pyupgrade
|
|
64
|
+
"S", # flake8-bandit
|
|
65
|
+
"BLE", # flake8-blind-except
|
|
66
|
+
"FBT", # flake8-boolean-trap
|
|
67
|
+
"B", # flake8-bugbear
|
|
68
|
+
"ANN", # flake8-annotations
|
|
69
|
+
]
|
|
70
|
+
ignore = [
|
|
71
|
+
"E501", # Line too long
|
|
72
|
+
"S113", # Probable use of requests call without timeout
|
|
73
|
+
"ANN001", # Missing type annotation for function argument
|
|
74
|
+
"ANN002", # Missing type annotation for `*args`
|
|
75
|
+
"ANN003", # Missing type annotation for `**kwargs`
|
|
76
|
+
"ANN101", # Missing type annotation for self in method
|
|
77
|
+
"ANN102", # Missing type annotation for cls in classmethod
|
|
78
|
+
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in {name}
|
|
79
|
+
"W191", # Indentation contains tabs
|
|
80
|
+
"UP037", # Remove quotes from type annotation
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
[tool.ruff.lint.per-file-ignores]
|
|
84
|
+
"tests/*" = [
|
|
85
|
+
"S101", # Use of assert
|
|
86
|
+
"S106", # Possible use of hard-coded password function arguments
|
|
87
|
+
"ANN201", # Missing return type annotation for public function
|
|
88
|
+
"ANN202", # Missing return type annotation for private function
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
[tool.pyright]
|
|
92
|
+
venvPath = "."
|
|
93
|
+
venv = ".venv"
|