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

# Credits

> Two wallets — data credits for API calls and AI credits for model usage — plus auto-reload, trials, and balance checks.

agntdata bills usage in cents against two separate wallets:

| Wallet          | What it pays for                                                                                       | Where credits come from                                                       |
| --------------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------- |
| **Data wallet** | Data API calls, connection proxy calls, webhook events, workspace database usage.                      | Monthly plan allowance + purchased data credits + signup bonus + trial grant. |
| **AI wallet**   | Anthropic model calls for deployed agents — input + output tokens, cache reads, cache writes, runtime. | Monthly plan allowance + purchased AI credits + trial grant.                  |

The split exists so that an agent runaway on AI tokens doesn't drain the wallet you use for data lookups, and vice versa. Both wallets are **organization-scoped**: every workspace in the org draws from the same balance.

## Data credits

Data credits are deducted on every successful API request to `/v1/data/*`, `/v1/connections/*`, `/v1/db/*`, and webhook-event consumption.

<Steps>
  <Step title="Make a request">
    The endpoint has a base cost in cents. Each request consumes that amount, possibly discounted by your plan tier.
  </Step>

  <Step title="Plan discount applies">
    If you hold an active credit package, the discount lowers the effective cost.

    ```
    Effective cost = Base cost × (100 − Discount %) / 100
    ```
  </Step>

  <Step title="Wallets drain in order">
    Subscription allowance first, then purchased balance, then trial credits. The response tells you how much of each is left.
  </Step>
</Steps>

Every response on a billable endpoint includes the live balance:

```json theme={null}
{
  "success": true,
  "data": { },
  "meta": {
    "costCents": 1,
    "purchasedBalanceCents": 949,
    "subscriptionRemainingCents": 500,
    "cached": false,
    "latencyMs": 245
  }
}
```

| Field                        | Meaning                                      |
| ---------------------------- | -------------------------------------------- |
| `costCents`                  | Data credits charged for this request        |
| `purchasedBalanceCents`      | Remaining purchased data credits             |
| `subscriptionRemainingCents` | Remaining subscription allowance this period |

## AI credits

AI credits fund Anthropic model calls for deployed agents — every turn the agent takes, every cache read/write, and the managed-runtime compute time. The wallet is debited per session: each session writes one or more `agent_compute_usage` rows that aggregate token + runtime cost and deduct against the AI balance.

What's billed to the AI wallet:

* Input tokens sent to the model
* Output tokens generated by the model
* Cache reads and cache writes
* Managed-agent runtime usage
* Any other model I/O Anthropic charges for the agent run

Agent **builder** model calls and the **support widget** are also billed to the AI wallet so all model usage rolls up in one place.

## Checking your balance

### From the dashboard

The Billing page shows both wallets — subscription allowance, purchased balance, and any trial credits still available — with a usage chart on top.

### From the API

```bash theme={null}
curl -X GET "https://api.agntdata.dev/v1/credits" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

A deployed agent can also call `agnt_credits_balance` as an MCP tool to check before doing something expensive.

## Buying credits

Add to either wallet from the dashboard:

1. Open **Billing**.
2. Choose **Buy data credits** or **Buy AI credits**.
3. Pick an amount and complete Stripe checkout.
4. Credits land in the chosen wallet immediately.

Purchased credits never expire. Trial credits are bound to the trial window and aren't refunded after conversion.

## Auto-reload

Auto-reload tops a wallet up automatically when the balance drops below a threshold. The wallets are configured independently — you can enable auto-reload on data credits and leave AI credits manual, or vice versa.

| Setting             | Meaning                                            |
| ------------------- | -------------------------------------------------- |
| `enabled`           | Whether auto-reload fires for this wallet.         |
| `thresholdCents`    | The balance at or below which we attempt a reload. |
| `reloadAmountCents` | How much we charge the card on reload.             |

Auto-reload requires a saved payment method on the org. The dashboard's Billing tab walks through the Stripe setup intent flow.

## Subscription vs. purchased vs. trial

| Source                     | Behavior                                                                  |
| -------------------------- | ------------------------------------------------------------------------- |
| **Subscription allowance** | Monthly bucket that resets at billing period rollover. Use it or lose it. |
| **Purchased balance**      | One-time top-up. Doesn't expire. Drained after subscription.              |
| **Trial grant**            | One-time grant during the trial window (see [Trial](/billing/trial)).     |
| **Signup bonus**           | Added once when you first activate a credit package. Doesn't expire.      |

Across all sources, drain order is: subscription → purchased → trial.

## Workspace credit sharing

Credits live at the organization level, not on individual workspaces or users:

* Every API key in any workspace in the org draws from the same wallets.
* Members see the same balance regardless of which workspace they're viewing.
* The Billing tab is identical across workspaces in the same org.

If you need separate billing per project, use separate organizations.

## Insufficient credits

When the data wallet is empty, billable API calls return:

```json theme={null}
{
  "success": false,
  "error": {
    "code": "INSUFFICIENT_CREDITS",
    "message": "Insufficient credits to complete this request"
  }
}
```

When the AI wallet is empty, deployed agent runs are paused (the model call returns the same error) and the dashboard surfaces a banner with a one-click top-up.

## Next steps

<CardGroup cols={2}>
  <Card title="Usage" icon="chart-line" href="/billing/usage">
    Per-call drill-down on data credit consumption and per-session AI credit burn.
  </Card>

  <Card title="Trial" icon="rocket" href="/billing/trial">
    How trial credits land in each wallet and how the deploy gate works.
  </Card>

  <Card title="Rate limits" icon="gauge" href="/concepts/rate-limits">
    Per-plan RPM caps and backoff guidance.
  </Card>

  <Card title="Errors" icon="triangle-exclamation" href="/concepts/errors">
    Error codes you might see when a wallet is empty.
  </Card>
</CardGroup>
