Skip to main content

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

  1. Update the version in pyproject.toml
  2. Remove the dists folder: rm -rf dist
  3. Build the distribution packages:
    uv build
    
  4. Upload to PyPI using twine:
    python3 -m twine upload dist/*
    
  5. git tag vX.Y.Z
  6. git push origin vX.Y.Z

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openpixels-0.3.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

openpixels-0.3.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

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

Hashes for openpixels-0.3.1.tar.gz
Algorithm Hash digest
SHA256 e12f6bfa15b6757105c68ddd8ddfe78338699b2d5b5fd8fc9588266b47c3210e
MD5 e53ced5b1d4e813e4e2d9d42837bb856
BLAKE2b-256 8d1efa5715a8dc9eb7bb7561bc1952ea53807c152a6a8f8a1bd6bf32fbcdb610

See more details on using hashes here.

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

Hashes for openpixels-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9fa9d93a9690fabb7e4fe68673867c7cb85a39891c78b8cf0da7ecbab78f4fcd
MD5 6b257c16014170d1b1670e19a58803cd
BLAKE2b-256 1224151b5bc287e3ba777f1d0969a3f476c228b6b2462e3ff73c71bb1bde59c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page