OpenPixels Python SDK
Project description
OpenPixels Python SDK
A Python SDK for accessing the OpenPixels API.
Installation
pip install openpixels
# or with uv
uv pip install openpixels
Usage
from openpixels import OpenPixels
client = OpenPixels(
api_key="sk-op-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)
# Generate an image
def generate_image():
result = client.run(
model="flux-dev",
prompt="a cat"
)
print(result)
generate_image()
The SDK provides both synchronous and asynchronous clients. The asynchronous client is preferable for most applications, especially those handling multiple requests or running in async environments like FastAPI.
Async Client Usage
from openpixels import AsyncOpenPixels
import asyncio
client = AsyncOpenPixels(
api_key="sk-op-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)
async def generate_image_async():
result = await client.run(
model="flux-dev",
prompt="a cat"
)
print(result)
# Run the async function
asyncio.run(generate_image_async())
API Reference
OpenPixels
The synchronous client for making calls to the OpenPixels API.
client = OpenPixels(
api_key="YOUR_API_KEY",
base_url="https://worker.openpixels.ai" # Optional, defaults to production API
)
AsyncOpenPixels
The asynchronous client for making calls to the OpenPixels API. This is generally preferred for better performance and responsiveness.
client = AsyncOpenPixels(
api_key="YOUR_API_KEY",
base_url="https://worker.openpixels.ai" # Optional, defaults to production API
)
Methods
Both clients provide the following methods:
run(payload)
: Submits a job and waits for the result.
Development
Building the Package
This project uses uv for package management and building:
# Install development dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Build the package
uv build
Deploying a New Version
- Update the version in
pyproject.toml
- Remove the dists folder:
rm -rf dist
- Build the distribution packages:
uv build
- Upload to PyPI using twine:
python3 -m twine upload dist/*
git tag vX.Y.Z
git push origin vX.Y.Z
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file openpixels-0.3.1.tar.gz
.
File metadata
- Download URL: openpixels-0.3.1.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
e12f6bfa15b6757105c68ddd8ddfe78338699b2d5b5fd8fc9588266b47c3210e
|
|
MD5 |
e53ced5b1d4e813e4e2d9d42837bb856
|
|
BLAKE2b-256 |
8d1efa5715a8dc9eb7bb7561bc1952ea53807c152a6a8f8a1bd6bf32fbcdb610
|
File details
Details for the file openpixels-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: openpixels-0.3.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
9fa9d93a9690fabb7e4fe68673867c7cb85a39891c78b8cf0da7ecbab78f4fcd
|
|
MD5 |
6b257c16014170d1b1670e19a58803cd
|
|
BLAKE2b-256 |
1224151b5bc287e3ba777f1d0969a3f476c228b6b2462e3ff73c71bb1bde59c6
|