Getting Started
Queue your first run and fetch its outputs — complete starter code in Python and TypeScript.
Five minutes from zero to a finished run. You need two things:
- An API key — create one on the API Keys page
- A deployment ID — deploy any workflow (how), then copy its ID from the deployment page
Keep the key in an environment variable (PIXIO_API_KEY) — never hardcode it.
TypeScript
npm i pixio-apiimport { PixioAPI, collectOutputs } from "pixio-api";
const pixio = new PixioAPI({ apiKey: process.env.PIXIO_API_KEY! });
// 1. Queue the run — returns immediately with a run id
const { runId } = await pixio.run.queue({
deploymentId: "<your-deployment-id>",
inputs: {
// keys = the input names you exposed with external input nodes
prompt: "A cinematic photo of a lighthouse in a storm",
},
// recommended for production — push instead of poll:
// webhook: "https://yourapp.com/api/webhook",
});
// 2. Wait for a terminal state (polls every 3s; use webhooks in production)
const run = await pixio.run.wait(runId, {
onProgress: (r) => console.log(r.status, Math.round(r.progress * 100) + "%"),
});
if (run.status === "success") {
for (const img of collectOutputs(run, "images")) console.log("→", img.url);
} else {
console.error("Run ended:", run.status);
}Python
pip install pixio-apiimport os
from pixio_api import PixioAPI
pixio = PixioAPI(api_key=os.environ["PIXIO_API_KEY"])
# 1. Queue the run — returns immediately with a run id
run_id = pixio.queue_run(
deployment_id="<your-deployment-id>",
inputs={
# keys = the input names you exposed with external input nodes
"prompt": "A cinematic photo of a lighthouse in a storm",
},
# recommended for production — push instead of poll:
# webhook="https://yourapp.com/api/webhook",
)
# 2. Wait for a terminal state (polls every 3s; use webhooks in production)
run = pixio.wait_for_run(run_id, on_progress=lambda r: print(r["status"], r["progress"]))
if run["status"] == "success":
for img in pixio.collect_outputs(run, "images"):
print("→", img["url"])
else:
print("Run ended:", run["status"])Prefer raw HTTP? (no SDK)
pip install requestsimport os, time, requests
API = "https://pixio-api-workers-production.up.railway.app/api"
HEADERS = {"Authorization": f"Bearer {os.environ['PIXIO_API_KEY']}"}
# 1. Queue the run — returns immediately with a run id
resp = requests.post(
f"{API}/run/deployment/queue",
headers=HEADERS,
json={
"deployment_id": "<your-deployment-id>",
"inputs": {
# keys = the input names you exposed with external input nodes
"prompt": "A cinematic photo of a lighthouse in a storm",
},
# recommended for production — push instead of poll:
# "webhook": "https://yourapp.com/api/webhook",
},
)
resp.raise_for_status()
run_id = resp.json()["run_id"]
print("queued:", run_id)
# 2. Poll until it reaches a terminal state
TERMINAL = {"success", "failed", "timeout", "cancelled"}
while True:
run = requests.get(f"{API}/run/{run_id}", headers=HEADERS).json()
print(f'{run["status"]} {round((run.get("progress") or 0) * 100)}%')
if run["status"] in TERMINAL:
if run["status"] == "success":
for output in run.get("outputs") or []:
for img in (output.get("data") or {}).get("images") or []:
print("→", img["url"])
else:
print("Run ended:", run["status"])
break
time.sleep(3)What you'll see
queued: 5e9f8a…
not-started 0%
queued 0%
started 0% ← cold start: machine + model loading (unbilled queue, then billed)
running 35%
running 80%
uploading 100%
success 100%
→ https://…/output_00001.pngHandling the errors that matter
| Response | Cause | Fix |
|---|---|---|
401 | bad/revoked key | check PIXIO_API_KEY |
402 | out of credits or plan required | top up / subscribe |
422 | wrong input names/types | match the inputs you exposed in the workflow |
Full status/error reference: Run Lifecycle & Errors.
Outputs are keyed by type: images, files, gifs, or mesh — the snippets above walk images; video workflows typically emit under files or gifs.