Skip to content

Credits API

Check the remaining credit balance for your AnyRouter workspace.

Return the credit balance for the workspace tied to your credential. Use it to surface budget state in dashboards, run low-balance alerts, or pre-flight a paid request before you send it.

GET/api/v1/credits

Authenticate with the same LLM key (sk-ar-v1-…) you already use for inference — no second credential needed. A Management key (ak_…) or a signed-in dashboard session also works. Each returns the balance for that credential's workspace.

The one restriction is per-key endpoint scoping: a key whose allowed_endpoints allow-list is non-empty and omits /api/v1/credits gets 403 insufficient_scope. Keys created in the dashboard start with the inference endpoints enabled and management endpoints — including /api/v1/credits — turned off; enable Management permissions when you create the key, or edit it later. Keys created through the API with no allow-list have full access.

Request

GET /api/v1/credits takes no request body and no query parameters. The balance is scoped to the credential in the Authorization header.

GET /api/v1/credits HTTP/1.1
Authorization: Bearer sk-ar-v1-your-key

Response

{
  "balance": 9.734035,
  "monthly_balance": 7.5,
  "topup_balance": 2.234035,
  "used": 0.265965,
  "today_cost": 0.042,
  "currency": "usd"
}
FieldTypeDescription
balancenumberTotal remaining credit (monthly_balance + topup_balance). When this hits zero, paid inference requests return 402 with error.code: "insufficient_balance".
monthly_balancenumberAnyRouter-issued credits (plan monthly credit, referral/admin grants). Spent before top-up credits. New signups do not receive a signup bonus.
topup_balancenumberCredits you purchased. Spent after monthly credits run out; never expire.
usednumberCumulative lifetime spend across every successful inference.
today_costnumberSpend recorded since the start of the current UTC day.
currencystringAlways "usd".

All values are in USD, accurate to six decimal places. One unit of credit equals one US dollar. Both managed and BYOK pricing are pass-through — you're charged the upstream provider's list price with no AnyRouter markup, whether the request is billed against your credit balance or served on your own key. (Card top-ups do carry a separate 5% + 50¢ Polar processing fee — see Credits & Billing — but that's a payment-provider fee, not a per-request charge.)

If you only use catalog models tagged :free, credits are not consumed — used stays at zero. The free tier has its own rate limits.

Examples

curl https://anyrouter.dev/api/v1/credits \
  -H "Authorization: Bearer sk-ar-v1-your-key"
import httpx

resp = httpx.get(
    "https://anyrouter.dev/api/v1/credits",
    headers={"Authorization": "Bearer sk-ar-v1-your-key"},
)
balance = resp.json()["balance"]
if balance < 1.0:
    print("Low balance — top up before your next big request")
const resp = await fetch("https://anyrouter.dev/api/v1/credits", {
  headers: { Authorization: "Bearer sk-ar-v1-your-key" },
})
const { balance } = await resp.json()
if (balance < 1.0) console.warn("Low balance")

Errors

StatusMeaningFix
401Missing or invalid bearer token (missing_api_key / invalid_api_key)Send a valid LLM key, Management key, or dashboard session.
403Key scoped to an endpoint allow-list that omits this route (insufficient_scope)Allow /api/v1/credits on the key, or use a key with no allow-list.
429Rate limited (rate_limit_exceeded, ip_rate_limit_exceeded, or free_tier_daily_limit_exceeded)Back off and honor Retry-After.
500Unexpected AnyRouter failure (internal_server_error)Retry; contact support if it persists.

See API Overview for the full error envelope.