> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usehasp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Budget Controls & Billing Transparency

> Monthly spend caps, spend alerts, BUDGET_EXCEEDED handling, and per-request billing telemetry in API responses.

Every HASP organization has a configurable AI credit budget. Credits are consumed on each successful inference request based on token usage. Budget controls let you cap spend, receive alerts before you hit the cap, and handle exhaustion gracefully.

## Credit model

AI usage is billed in credits. The conversion rate depends on the model:

| Model             | Credits per 1M input tokens | Credits per 1M output tokens |
| ----------------- | --------------------------- | ---------------------------- |
| claude-haiku-4-5  | 80                          | 400                          |
| claude-sonnet-4-6 | 300                         | 1,500                        |
| claude-opus-4     | 1,500                       | 7,500                        |

Credits are not currency — they are a normalized unit that maps to a dollar value on your invoice. The exact rate per credit is shown in your billing dashboard.

## Monthly budget cap

Each organization has a monthly credit allotment. When credits are exhausted, inference requests fail. On the native surface, the error code is `CONSUMPTION_BLOCKED` with HTTP status 402:

```json theme={null}
{
  "success": false,
  "error": {
    "type": "payment_required",
    "code": "CONSUMPTION_BLOCKED",
    "message": "Org has used its full credit allotment this cycle.",
    "retryable": false
  }
}
```

On the Anthropic-compat and OpenAI-compat surfaces, the same condition maps to `BUDGET_EXCEEDED` with status 429 (to match those SDKs' rate-limit status convention) instead of a 402, since neither wire format has a payment-required concept. See the [Error Reference](/ai-api/reference/errors) for the full catalog.

## Configuring a spend cap

Set a hard cap below your plan's allotment via `PATCH /v1/usage/budget`:

```bash theme={null}
curl -X PATCH https://api.usehasp.com/v1/usage/budget \
  -H "Authorization: Bearer hasp_api_live_<key>" \
  -H "Content-Type: application/json" \
  -d '{"spend_cap": 50000}'
```

Once the cap is reached, requests fail with `CONSUMPTION_BLOCKED` (native surface) or `BUDGET_EXCEEDED` (compat surfaces) until the billing period resets or the cap is raised.

## Spend alerts

Configure alert thresholds via the dashboard (**Settings → AI Workspace → Budget Alerts**). HASP sends email alerts when usage crosses 50%, 80%, and 100% of your configured cap. Budget thresholds do not emit webhook events.

## Per-request usage in responses

Every non-streaming response includes token usage in the `usage` field:

```json theme={null}
{
  "usage": {
    "input_tokens": 120,
    "output_tokens": 85
  }
}
```

For streaming responses, usage appears in the `message_delta` SSE event with `usage.output_tokens` and in a final `UsageUpdate` event.

## Checking current usage

```bash theme={null}
curl https://api.usehasp.com/v1/usage \
  -H "Authorization: Bearer hasp_api_live_<key>"
```

The response includes `credits_used`, `credits_allotment`, `credits_remaining`, and a per-model breakdown for the current billing period.
