Working recipes for the LivePair AI API — image and video generation, chat completions, and x402 agent payments.
livepair.py is a dependency-free client (standard library only) that
handles the full async lifecycle: submit → poll → media URL, with typed
errors, timeouts, and one network retry. Drop it into any project.
from livepair import LivePair
client = LivePair() # reads LP_KEY from env
url = client.generate_image("a cat astronaut, cinematic")
clip = client.generate_video("slow wave crash, aerial")Get a key at https://livepairai.com/settings — lp_…, prepaid credits,
per-result billing. Wallet-carrying agents can skip the key entirely and
pay per call with x402 (USDC on Base) — see x402-payment.md.
| File | What it does |
|---|---|
examples/generate_image.py |
Generate an image, download it before the 48h TTL |
examples/generate_video.py |
Generate a clip with a longer poll timeout |
examples/list_models.py |
Print the live catalog — free, no key needed |
mobile-proxy.mjs |
Backend proxy for mobile apps — key stays server-side |
export LP_KEY=lp_...
python examples/generate_image.py "a cat astronaut, cinematic"
python examples/generate_video.py "aerial drone shot of a coastline"
python examples/list_models.py imagecurl -X POST https://livepairai.com/v1/agent/generate \
-H "x-api-key: $LP_KEY" -H "Content-Type: application/json" \
-d '{"model":"qwen-image-3","prompt":"a cat astronaut"}'
# → {"jobId": "..."}
curl https://livepairai.com/v1/agent/jobs/<jobId> -H "x-api-key: $LP_KEY"
# → {"status":"done","url":"https://…"} — media auto-deletes after 48hErrors you should handle: 401/403 (bad key), 402 (insufficient credit
or an x402 quote), 5xx (retryable). livepair.py maps these to typed
exceptions.
If your app already speaks OpenAI, skip the job protocol and point it at
https://livepairai.com/v1/agent — three spec-shaped endpoints:
| Endpoint | Spec | Notes |
|---|---|---|
POST /v1/agent/chat/completions |
OpenAI chat | model ids from GET /v1/agent/models |
POST /v1/agent/images/generations |
OpenAI Images | {prompt, model, size, response_format} → {created, data:[{url}]} |
POST /v1/agent/videos |
OpenAI Videos (Sora) | returns a job; GET /v1/agent/videos/{id} polls, …/content fetches the mp4 |
GET /v1/agent/models also serves the OpenAI {object:"list"} shape so
client model pickers populate automatically. Same lp_ key (Bearer or
x-api-key), same prepaid-credit billing.
- livepair-cli —
npm i -g livepair - livepair-bots — Telegram/Discord/X templates
- n8n-nodes-livepair — n8n community node
- ComfyUI-LivePair — ComfyUI nodes
- livepair-skills — agent SKILL.md
- OpenAPI:
https://livepairai.com/v1/agent/openapi.json· MCP:https://livepairai.com/mcp
MIT