API reference
Account
GET /v1/agents/account
View as MarkdownReturns the plan and spendable credit of the account behind the key. Use it to decide whether to start a task, or to explain a task that stopped for lack of credits.
Request
bash
curl -s "$SAI_API_URL/v1/agents/account" \
-H "Authorization: Bearer $SAI_API_KEY"Response
json
{
"userId": "3fA9kQ2xYz",
"userState": "active",
"plan": {
"id": "sai_subscription",
"title": "Sai Subscription",
"free": false,
"unlimited": false
},
"credits": { "usd": 12.4 },
"authType": "apiKey"
}A free account:
json
{
"userId": "3fA9kQ2xYz",
"userState": "active_free",
"plan": { "id": null, "title": "Free", "free": true, "unlimited": false },
"credits": { "usd": 0.35 },
"authType": "apiKey"
}Gotchas
- The call never fails because Billing is down. Check
creditsfornullbefore readingcredits.usd. - Credit is what a task can spend now. A free account's daily grant refills it; the portal shows when.
- The Billing lookup has a five-second timeout, so this call can take a moment. Do not put it inside the poll loop.