POST /v1/run starts a job and GET /v1/generations/{id}?wait=45 returns the finished file. The code below uses the built-in fetch in Node.js 18 or newer, requests in Python, and plain cURL.
Before you start, create a key on the developer page (Scale and Ultra plans) and export it:
Generate a file and wait for it
Find a model’s inputs
Each model has its owninput fields. Read them from the public catalog, no key needed:
Handle errors
See Errors and rate limits for every message.
Good habits
- Keep the key on your server. Browsers on other websites cannot call the API, and client code exposes the key.
- Send an
Idempotency-Keyon everyPOST /v1/runthat might be retried. - Download the files in
output.urlsto your own storage when you need to keep them. - For jobs that take minutes, pass a webhook and skip the loop.
Related
Make a talking avatar video
A three-step pipeline built on these helpers.
Start a generation
Every field of POST /v1/run.
Authentication
Create, cap and revoke keys.
MCP server
Let an AI agent call Percify for you.