Skip to main content

Python SDK for PixelAPI — AI image generation, editing & audio API

Project description

PixelAPI Python SDK

Official Python client for PixelAPI — the cheapest AI image generation, background removal, upscaling, and audio API.

10 AI models, one API key, from $0.002/image.

PyPI Python 3.8+ License: MIT

Installation

pip install pixelapi

Quick Start

from pixelapi import PixelAPI

api = PixelAPI("your_api_key")

# Generate an image ($0.003)
result = api.image.generate("a cat astronaut, digital art", model="flux-schnell")
print(result.url)

Image Generation

# FLUX Schnell — fast, photorealistic (~3s, 3 credits)
result = api.image.generate("product on marble table", model="flux-schnell")

# SDXL — versatile, great for illustrations (~13s, 3 credits)
result = api.image.generate("watercolor mountains", model="sdxl")

print(result.url)

Background Removal — $0.002/image

result = api.image.remove_background("https://example.com/product.jpg")
print(result.url)  # Transparent PNG

Background Replacement — $0.005/image

result = api.image.replace_background(
    "https://example.com/product.jpg",
    prompt="product on marble countertop, soft studio lighting"
)

4x Upscaling — $0.02/image

result = api.image.upscale("https://example.com/low-res.jpg")
print(result.url)

Face Restoration — $0.003/image

result = api.image.restore_face("https://example.com/blurry-portrait.jpg")

Object Removal — $0.005/image

result = api.image.remove_object(
    "https://example.com/photo.jpg",
    mask_url="https://example.com/mask.png"
)

🎵 AI Music Generation — $0.005/track (NEW in v0.2.0)

result = api.audio.generate("upbeat electronic music for a product video", duration=15)
print(result.url)  # Audio URL

Non-blocking Usage

# Don't wait for completion
result = api.image.generate("hello world", wait=False)
print(result.id, result.status)  # generation_id, "pending"

# Check later
status = api.image.get(result.id)
if status.status == "completed":
    print(status.url)

Error Handling

from pixelapi import PixelAPI, AuthError, InsufficientCredits, RateLimitError

api = PixelAPI("your_api_key")

try:
    result = api.image.generate("hello world")
except AuthError:
    print("Invalid API key")
except RateLimitError:
    print("Too many requests — slow down")
except InsufficientCredits:
    print("Top up at pixelapi.dev/app")

API Reference

Method Endpoint Credits
api.image.generate() POST /v1/image/generate 3
api.image.remove_background() POST /v1/image/remove-background 2
api.image.upscale() POST /v1/image/upscale 20
api.image.restore_face() POST /v1/image/restore-face 3
api.image.remove_object() POST /v1/image/remove-object 5
api.image.replace_background() POST /v1/image/replace-background 5
api.audio.generate() POST /v1/audio/generate 5
api.image.get() GET /v1/image/{id} 0
api.account.balance() GET /v1/account/balance 0
api.models.list() GET /v1/models 0

What's New in v0.2.0

  • 🎵 Audio generation via api.audio.generate()
  • ✂️ Background removal via api.image.remove_background()
  • 🎨 Background replacement via api.image.replace_background()
  • 👤 Face restoration via api.image.restore_face()
  • 🧹 Object removal via api.image.remove_object()
  • Resource-based API (api.image.*, api.audio.*, api.account.*)
  • Full backward compatibility with v0.1.0 flat API

Links

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

pixelapi-0.2.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pixelapi-0.2.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file pixelapi-0.2.0.tar.gz.

File metadata

  • Download URL: pixelapi-0.2.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pixelapi-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d332bdd5cfbcb91a3fe15314ff08b962b04b6abac3fe1b17a54500cb3534f56d
MD5 64bd3aae8a3fc56cdff98013d8cb200c
BLAKE2b-256 ee6886caea30f0715e50254bfb2a9d7e16ad465bd601f02b84f7d86a730872d5

See more details on using hashes here.

File details

Details for the file pixelapi-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pixelapi-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pixelapi-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3c6efae323585e6ea28b506791c06bdeb78dd84e61f3cec3868fbf474430f78
MD5 e9a66ec41160956bd0c10621b9411bb8
BLAKE2b-256 10c2f8199e58c01e06dd80b603d5b105f5b93484eb9fa5a0eda4d2795950ec0e

See more details on using hashes here.

Supported by

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