# Credits API

> Check the remaining credit balance for your AnyRouter workspace.


# Credits API

Get the credit balance for the workspace tied to your credential, for dashboards and low-balance alerts.

::endpoint{method="GET" path="/api/v1/credits"}

:::note
Authenticate with your **LLM key** (`sk-ar-v1-…`), a **Management key** (`ak_…`) or a dashboard session. Each returns the balance for that credential's workspace.

A key whose `allowed_endpoints` list is non-empty and omits `/api/v1/credits` gets `403 insufficient_scope`. Dashboard-created keys start with management endpoints (including this one) off; enable **Management permissions** when creating the key, or edit it later. Keys created through the API with no allow-list have full access.
:::

## Request

No body or query parameters. The balance is scoped to the credential in `Authorization`.

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

## Response

```json
{
  "balance": 9.734035,
  "monthly_balance": 7.5,
  "topup_balance": 2.234035,
  "plan_credit": 7.5,
  "bought_credit": 2.234035,
  "used": 0.265965,
  "today_cost": 0.042,
  "currency": "usd"
}
```

| Field | Type | Description |
|---|---|---|
| `balance` | number | Total remaining credit (`monthly_balance + topup_balance`). When this hits zero, paid inference requests return `402` with `error.code: "insufficient_balance"`. |
| `monthly_balance` | number | Plan credit: credit from your plan, plus referral bonuses and pool rewards. **Spent before** bought credit. Unspent plan credit carries over to the next month, and is removed when a Go plan ends. New signups do not receive a signup bonus. |
| `topup_balance` | number | Bought credit: credit you purchased, and credit granted by AnyRouter support. Spent after plan credit runs out; never expires. |
| `plan_credit` | number | Same value as `monthly_balance`. |
| `bought_credit` | number | Same value as `topup_balance`. |
| `used` | number | Cumulative lifetime spend across every successful inference. With an API key, only that key's lifetime spend; signed in or with a management key, the whole workspace's. |
| `today_cost` | number | Spend recorded since the start of the current UTC day. With an API key, only that key's spend; signed in or with a management key, the whole workspace's. |
| `currency` | string | Always `"usd"`. |

All values are **USD** to six decimal places; one credit is one dollar. Managed and BYOK pricing are pass-through at the provider's list price, with no AnyRouter markup. Card top-ups carry a separate 5% + 50¢ Polar processing fee (see [Credits & Billing](/features/credits#topping-up)), not a per-request charge.

:::tip
Models tagged `:free` consume no credits, so `used` stays at zero. The free tier has its own rate limits.
:::

## Examples

::::tabs

:::tab{label="curl"}
```bash
curl https://anyrouter.dev/api/v1/credits \
  -H "Authorization: Bearer sk-ar-v1-your-key"
```
:::

:::tab{label="Python"}
```python
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")
```
:::

:::tab{label="TypeScript"}
```typescript
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

| Status | Meaning | Fix |
|---|---|---|
| 401 | Missing or invalid bearer token (`missing_api_key` / `invalid_api_key`) | Send a valid LLM key, Management key, or dashboard session. |
| 403 | Key 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. |
| 429 | Rate limited (`rate_limit_exceeded` or `ip_rate_limit_exceeded`) | Back off and honor `Retry-After`. |
| 500 | Unexpected AnyRouter failure (`internal_server_error`) | Retry; contact support if it persists. |

See [API Overview](/api-reference/overview) for the full error envelope.



## Related

- [Pricing & Plans](/docs/features/pricing.md)
- [Rate Limits](/docs/features/rate-limits.md)
- [Management API Keys](/docs/api-reference/management-keys.md)
