API Keys, Authentication and Credits: A Complete Guide
Two endpoints cost credits. Six are free. Credits are pooled across every key on your account and refunded automatically when a render fails. Understanding those three facts precisely is what keeps a video feature profitable and a batch job from dying halfway through.
Getting a Key
Open the API dashboard, choose a plan to activate API access, and generate a key from the API Keys tab. API access is gated behind an active plan, so the key and the credit allotment arrive together — there is no separate provisioning step to wait on.
Every request needs that key in a header. The API accepts two formats, and they are equivalent — use whichever fits your HTTP client:
Authorization: Bearer <API_KEY>
# or
x-api-key: <API_KEY>The Authorization: Bearer form is conventional and works well with most SDKs and HTTP libraries that already have first-class support for bearer tokens. The x-api-key form is convenient when a framework or gateway already reserves the Authorization header for its own session auth, which is common if you are calling from inside an application that authenticates its own users.
Keys are environment labels, not billing units
Every key on an account draws from the same credit pool. Issuing a second key does not partition your balance or give a customer their own allowance. If you need per-tenant limits, they belong in your application code.
Which Endpoints Actually Cost Anything
This table is the entire cost model. Two rows cost credits and six do not, which has real design implications: the operation you will perform most often — polling job status — is free, so your polling frequency is a UX and compute decision rather than a budget decision.
/api/v1/presigned-urlsReserve 1–20 signed upload URLs for input images.
/api/v1/videosTurn one property photo into a cinematic clip.
/api/v1/videos/:jobIdCheck status and fetch finished video URLs.
/api/v1/videosList this key's video jobs, newest first.
/api/v1/reelsMerge 2–20 completed clips into one branded reel.
/api/v1/reels/:jobIdCheck reel status and fetch merged output.
/api/v1/reelsList this key's reel jobs, newest first.
/api/v1/creditsRead total, used, and remaining credits.
A worked example makes the arithmetic concrete. An eight-photo listing rendered into one merged reel costs nine credits: eight video generations plus one reel merge. Uploading the eight photos, polling each of the nine jobs a dozen times, listing your recent jobs, and checking your balance all cost nothing. The number is nine regardless of how chatty your integration is.
When Credits Are Charged — and Refunded
Both paid endpoints are asynchronous, and the charge happens at acceptance rather than at completion. The create response tells you so explicitly:
POST /api/v1/videos
{ "jobId": "uuid", "status": "pending", "creditsCharged": 1 }That creditsCharged field is the authoritative record of what this call cost you, and the moment you receive it you have spent money on a job whose only identifier is in that response body. Persist it immediately. A process that crashes between the API call and the database write has paid for a render it can never retrieve.
If generation fails, the credit is refunded to your account automatically. No support ticket, no manual reconciliation. That is a meaningful simplification for anyone metering usage downstream, because it means a failed render never needs a compensating adjustment on a customer's invoice:
GET /api/v1/videos/:jobId
{
"job": {
"status": "completed",
"video_url": "https://...",
"download_url": "https://...?download",
"credit_cost": 1
}
}Retries cost the same as originals
Because a failed job refunds its credit, retrying is economically neutral — you are spending the same credit a second time, not paying twice. This makes an automatic single retry on failure a reasonable default in your worker rather than something you have to justify against a budget.
Monitoring the Balance
The balance endpoint is free, which means there is no reason not to poll it on a schedule and store the result somewhere your alerting can see:
GET /api/v1/credits
# Returns total, used, and remaining for the account.The failure mode to design against is not running out of credits — it is running out mid-batch. A twenty-photo listing that exhausts the pool at photo fourteen leaves you with fourteen orphaned clips, no reel, and a customer looking at a half-finished job. The fix is a preflight check: before starting a listing, confirm the remaining balance covers every clip plus the merge, and queue the listing rather than starting it if it does not.
Alert above zero, not at zero
By the time remaining credits hit zero, customer-facing jobs are already being refused. Set the threshold at whatever a busy day of generation consumes, so you always have time to top up before anything user-visible breaks.
Key Management Practices
Because a revoked key returns 401 immediately rather than failing gradually, rotation is safe but has to be sequenced correctly. These four decisions cover nearly every operational problem teams hit.
Key scope
One key per environment — production, staging, internal tooling — so you can revoke one without disrupting the others.
A single key pasted everywhere, so rotating it after a leak means simultaneous downtime across every system.
Storage
Server-side environment variables or a secrets manager, read at runtime and never sent to a browser.
A key embedded in client-side JavaScript or a mobile bundle, where anyone can extract it and spend your credits.
Rotation
Generate the replacement, deploy it, confirm traffic is flowing, then revoke the old key.
Revoking first and then deploying, which guarantees a window of 401s on live customer requests.
Failure handling
Treat a 401 as an alertable operational event, since a revoked or invalid key fails immediately rather than degrading.
Retrying a 401 in a loop, which will never succeed and can bury the real problem in noise.
The client-side storage warning is worth repeating because the consequence is unusual here. A leaked key does not just expose data — it lets a stranger spend your credit balance. Every call to the video endpoint from a stolen key is a real charge against your account, so keys must stay server-side without exception.
Per-Customer Accounting Rules
If you are reselling video inside your own product, the pooled credit model means all tenant boundaries are yours to enforce. These seven rules are the ones that keep a metered feature reconcilable.
- 1Persist the jobId and the creditsCharged value from every create response before doing anything else.
- 2Attribute each charge to a customer, a listing, and a user in a single reconcilable row.
- 3Never treat a status poll as billable — polling is free, so it should not appear in your cost model at all.
- 4Mark refunded credits when a job reaches failed, so your internal ledger matches the account balance.
- 5Enforce per-customer limits in your own code, because the credit pool has no built-in per-tenant boundary.
- 6Read the balance on a schedule and alert well above zero, not at zero.
- 7Refuse to start a multi-photo batch unless the remaining balance covers the whole listing plus the merge.
The job listing endpoints help here as a reconciliation backstop. Because GET /api/v1/videos and GET /api/v1/reels are free and return this key's jobs newest first, you can periodically compare what the API believes you created against what your own database recorded — and catch any job you paid for but failed to persist.
The short version: two paid endpoints, credits charged at acceptance, automatic refunds on failure, one pool across all keys, and a free balance endpoint you should be polling. Everything else is application design. Full schemas and error codes live in the API documentation.
Generate your first key
Activate a plan, create a key, and make your first authenticated call in a few minutes.
Related Articles
Async Jobs and Polling: Production Video Pipelines
Worker design, backoff strategy, and handling terminal states correctly.
Add AI Video as a Paid Product to Your SaaS
Packaging models, margin math, and metering rules that protect your margin.
PhotoAIVideo Developer API
Endpoint reference, camera effects, credit costs, and plan tiers.