Python SDK
pip install framera: sync and async clients with retries, idempotency, waiting for jobs and webhook checks, and type hints throughout.
Install
pip install frameraPython 3.9 or newer, built on httpx. The client reads FRAMERA_API_KEY from the environment when you don't pass api_key. Keep it on your server.
Sync and async clients
Framera is the everyday client. AsyncFramera has the same resources and methods, each awaitable, for asyncio apps such as FastAPI. Create one client and reuse it.
| Resource | Methods |
|---|---|
models | list() |
quotes | create(product=…, operation=…, …); a UGC quote passes body={…} |
videos · avatars · ugc · images · swap | create(…) |
tools | upscale(), remove_background(), inpaint() |
audio | speech(), voice_change(), translate() |
uploads | create(), upload(file) |
jobs | get(), list(), wait(), cancel() |
balance | get() |
webhook_endpoints | create(), get(), update(), list(), delete(), roll_secret() |
events | list(), get() |
webhooks | verify(body, header, secret, tolerance=300), secret() |
Arguments are snake_case (duration_seconds, aspect_ratio, webhook_url); the SDK sends them to the API in its camelCase. Responses are plain dicts with the API's own keys, so you read job["price"]["amount"] and job["createdAt"] exactly as the API reference shows them.
Retries and idempotency
Rate limits (429), server errors (5xx) and network failures are retried with backoff, honouring Retry-After. Every create gets an idempotency key automatically, reused across those retries, so a retry never makes or charges for a second job. Pass idempotency_key= to use your own.
Waiting for jobs
framera.jobs.wait(job["id"]) polls until the job finishes and returns it; pass timeout (seconds) and on_update to follow it. jobs.list() returns a page: page.data is this page, and iterating over it fetches the next pages for you. In web apps, webhooks save you the polling.
Verifying webhooks
framera.webhooks.verify(body, header, secret, tolerance=300) checks the Framera-Signature header (an HMAC-SHA256 of "{t}.{body}" with your signing secret), refuses events more than tolerance seconds old, and returns the event. Pass the raw request body. It raises if the signature does not match.
Type hints
Every argument is typed, and responses are typed dicts (Job, Price, Event, Balance and more in framera.types), so editors complete field names and type checkers such as mypy and pyright catch mistakes before you run. Failed requests raise FrameraError, or a subclass per code, with status, code, message and details.