API reference

Credits & balance

Every generation is paid for in credits from the team the key belongs to. The balance comes back with every charge, so your app can warn its users before they run out instead of failing on the next request.

Check the balance#

GET/api/v1/me
The key's team, role and credit status. MCP: get_balance.
bash
curl https://<your-host>/api/v1/me -H "Authorization: Bearer $AIO_KEY"
200 OK
{
  "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"
  }
}
  • low is true once the balance drops under low_threshold. Team owners and admins also get an email the first time that happens.
  • top_up_url is 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:

201 Created
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:

json
{
  "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:

402 Payment Required
{
  "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:

402 Payment Required
{
  "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.