Keys, billing and limits
Authentication, how you are charged, rate limits, file retention and errors.
Authentication
Send your key in the Authorization header on every request:
Authorization: Bearer sk-...Keys are created and deleted in the console under API keys. You can give a key its own spending limit, an expiry date and a list of allowed models. Delete a key straight away if it leaks.
Billing
- Prepaid. Each request is charged from your balance at the price on the Models page.
- Text is charged per token, after the reply.
- Media jobs reserve the expected cost plus 20% when they start, then settle at the real cost when they finish; the difference comes back to your balance. A failed job costs nothing.
- If a job turns out to cost more than it reserved, your balance can go below zero. New requests then wait until you top up.
- See your balance with
GET /v1/dashboard/billing/subscriptionand spending withGET /v1/dashboard/billing/usage, or in the console.
Rate limits
Each account may send 120 requests a minute, 60 of them successful. Over the limit you get HTTP 429; wait and retry. Need more? Contact us. Details and backoff code: Rate limits.
Files and results
- Pass input files (images, audio, video) as public
https://links. Files you upload in the Studio are kept for 1 day. - Result links stay available for 7 days, then the files are deleted. Download anything you want to keep.
Errors
Errors come back with an HTTP status and a JSON body: {"error": {"message": "...", "type": "...", "code": "..."}} (jobs: {"code": 400, "msg": "..."}).
| Status | Meaning | What to do |
|---|---|---|
| 400 | The request is invalid or breaks the content rules | Fix the request; content-rules refusals count against your account |
| 401 | Missing or wrong key | Check the Authorization header |
| 403 | Balance too low, or the key may not use this model | Top up, or check the key's settings |
| 429 | Rate limit | Wait and retry with backoff |
| 500, 502, 503 | The model failed, or we are briefly overloaded | Retry; a failed job is not charged |
Every status, both body shapes and retry rules: Errors.
Content rules
Our Terms apply. Safety filters are always on. Sexual content involving minors is refused, and repeated refusals disable an account automatically.
