pixio-api
Official Python client for Pixio API — run ComfyUI workflows in the cloud on GPUs from T4 to B300.
- Light — one dependency (
requests); Python 3.8+ - Batteries included — polling helper, output collector, billing-aware errors, automatic retries
- Async optional —
AsyncPixioAPIon httpx viapip install pixio-api[async] - ~300 lines you can actually read
Install
pip install pixio-api # sync client
pip install "pixio-api[async]" # + async client (httpx)
Quickstart
import os
from pixio_api import PixioAPI
pixio = PixioAPI(api_key=os.environ["PIXIO_API_KEY"])
# 1. Queue a run — returns immediately
run_id = pixio.queue_run(
deployment_id="<your-deployment-id>",
inputs={"prompt": "A cinematic photo of a lighthouse in a storm"},
)
# 2. Wait for it (polls every 3s, stops at a terminal state)
run = pixio.wait_for_run(run_id, on_progress=lambda r: print(r["status"], r["progress"]))
# 3. Collect the outputs
if run["status"] == "success":
for img in pixio.collect_outputs(run, "images"):
print(img["url"])
You need:
- An API key → api.myapps.ai/api-keys
- A deployment ID → deploy any workflow (guide) and copy its ID
API
PixioAPI(api_key, base_url=…, timeout=30.0, session=None, retries=3)
| arg | default | notes |
|---|---|---|
api_key |
— | required |
base_url |
Pixio production | self-hosted / staging override |
retries |
3 |
automatic retries for GET requests |
session |
new requests.Session |
bring your own (proxies, testing) |
queue_run(deployment_id, inputs=None, webhook=None, webhook_intermediate_status=None) → str
Queue a deployment run; returns the run id immediately. inputs keys are the input names you exposed with external input nodes. Pass webhook for production — push beats polling.
get_run(run_id) → dict
Current state: status, progress (0–1), live_status, outputs, timings, GPU.
wait_for_run(run_id, interval=3.0, timeout=None, on_progress=None) → dict
Polls until a terminal state (success / failed / timeout / cancelled). Raises TimeoutError if the optional client-side timeout (seconds) elapses.
cancel_run(run_id)
Cancels a queued/running run. Billed only for time already used.
collect_outputs(run, kind="images") → list[dict]
Flattens a run's outputs. kind is "images", "files", "gifs", or "mesh" — video workflows typically emit under files/gifs.
Async
from pixio_api import AsyncPixioAPI # pip install "pixio-api[async]"
async with AsyncPixioAPI(api_key=os.environ["PIXIO_API_KEY"]) as pixio:
run_id = await pixio.queue_run("<deployment-id>", inputs={"prompt": "..."})
run = await pixio.wait_for_run(run_id)
Same surface as the sync client; context manager closes the connection pool.
Error handling
Every non-2xx response raises PixioAPIError:
from pixio_api import PixioAPIError
try:
pixio.queue_run(deployment_id, inputs=inputs)
except PixioAPIError as e:
if e.is_billing_error: # 402: out of credits or plan required
... # send the user to top up
else:
print(e.status, e.detail)
status |
meaning |
|---|---|
401 |
bad / revoked API key |
402 |
out of credits / plan required (is_billing_error == True) |
404 |
unknown run or deployment id |
422 |
invalid inputs — e.body has field details |
Retries: GET requests auto-retry on network errors and 429/502/503/504 with exponential backoff + jitter (default 3 attempts, retries= arg). POSTs (queue/cancel) are never auto-retried — an ambiguous failure retried could queue and bill the same run twice. Handle queue failures explicitly.
Run lifecycle
not-started → queued → started → running → uploading → success
↘ failed / timeout / cancelled
TERMINAL_STATUSES is exported. A failed/timeout run is not an HTTP error — the request succeeded; check the run's logs in the dashboard. Full reference: Run Lifecycle & Errors.
Links
- Docs: docs.myapps.ai — Getting Started · GPU pricing · Billing
- Dashboard: api.myapps.ai
- TypeScript client:
npm i pixio-api
MIT © Pixio
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pixio_api-0.2.1.tar.gz.
File metadata
- Download URL: pixio_api-0.2.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da8f3f18c17194bdecf909724530a9782b4c77e375b5df9005e78263e1f994cd
|
|
| MD5 |
a8e4d3accb8d9aabe696508098628128
|
|
| BLAKE2b-256 |
56af60794a11e1f6dceb783c8928fa6ef1efe909bb978adacb655eb99fd922c8
|
File details
Details for the file pixio_api-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pixio_api-0.2.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14ab0a8fe0eaa0636148802f45a2dd7fdef5711a2dabdd85b155852a7a8f18bd
|
|
| MD5 |
2346c57a675ea8ea00b148132db08ac1
|
|
| BLAKE2b-256 |
2fce01df22d58a3d0a84909f75f21a66d5b98f44eafde01ea5f1e208cad562ad
|