API reference
Credits & balance
Check the balance#
/api/v1/meget_balance.curl https://<your-host>/api/v1/me -H "Authorization: Bearer $AIO_KEY"{
"object": "account",
"team": { "id": "…", "name": "Studio", "plan": "pro" },
"role": "owner",
"credits": {
"balance": 42,
"low": true,
"low_threshold": 50,
"top_up_url": "https://<your-host>/pricing"
}
}lowistrueonce the balance drops underlow_threshold. Team owners and admins also get an email the first time that happens.top_up_urlis where a team member buys more credits. Show it to your users rather than hard-coding a link.
Before you generate#
POST /api/v1/estimate (MCP: estimate_cost) returns the exact cost of a model or template with your settings, the current balance and whether it is sufficient. Nothing is created or charged. See Generations.
After every charge#
POST /api/v1/generations reports the balance after the charge, in the body and in headers, so you never need a second request:
X-Credits-Remaining: 42
X-Credits-Low: true
{
"id": "…",
"status": "queued",
"credits": 8,
"credits_remaining": 42,
"low_balance": true
}X-Credits-Low is only sent when the balance is low. MCP's create_generation returns the same credits_remaining and low_balance fields, and its summary tells the agent to ask the user to top up.
In webhooks#
Each generation.updated webhook carries the balance at delivery time — after any refund for a failed or blocked generation:
{
"type": "generation.updated",
"data": { "id": "…", "status": "failed", "credits": 8, "…": "…" },
"account": { "credits_remaining": 50, "low_balance": false }
}When there isn't enough#
A generation that costs more than the balance is rejected before anything runs, with 402 and the numbers you need to tell the user:
{
"code": "INSUFFICIENT_CREDITS",
"message": "This costs 24 credits but your team has 10.",
"hint": "Top up credits or upgrade your plan.",
"details": { "required": 24, "balance": 10, "shortfall": 14, "top_up_url": "https://<your-host>/pricing" }
}Member limits#
Workspace owners and admins can cap what each member spends — daily, monthly (UTC) and in total — from Settings → Members. Generations made with an API key count against the key creator's limit. Going over returns 402 with MEMBER_LIMIT_REACHED:
{
"code": "MEMBER_LIMIT_REACHED",
"message": "This costs 24 credits, but your monthly limit in this workspace has 10 left (490 of 500 used).",
"hint": "It resets at the start of next month (UTC), or ask a workspace owner or admin to raise it.",
"details": { "period": "monthly", "limit": 500, "used": 490, "remaining": 10, "cost": 24, "resets_at": "2026-12-01T00:00:00.000Z" }
}Failed and blocked generations are refunded and don't count toward a limit.
Refunds#
Credits are charged when a generation is created. If it fails or is blocked by moderation, they are returned to the team automatically and the generation shows refunded in its error. Idempotent replays (same Idempotency-Key) are never charged twice.
Who can top up
Credit packs are available to teams with an active subscription. Keys can read the balance but cannot buy credits — a team owner or admin does that from the app.