# Credits

> What each call costs, how the monthly limit works, and how to check your balance.

Source: https://openpipe.health/docs/credits/

Every metered call spends credits from a monthly allowance. The allowance belongs to the [workspace](https://openpipe.health/docs/workspaces.md), not to a person or a key: every key and every member of a workspace draws on the same balance. A new workspace, personal or organization, is on the `free` plan with 100 credits a month.

## Prices

| Action | Endpoints | Credits |
|---|---|---|
| Search | `GET /api/providers`, `/api/facilities`, `/api/groups`, `/api/procedures` | 1 |
| Lookup | `GET /api/providers/:npi`, `/api/facilities/:ccn`, `/api/groups/:id` | 1 |
| [Hospitals and systems](https://openpipe.health/docs/api/hospital-intel.md) | `GET /api/hospital-intel`, `/api/health-systems`, `/api/health-systems/:id`, `/api/facilities/:ccn/intel`, `/api/facilities/:ccn/clinicians`, `/api/facilities/:ccn/measures`, `/api/facilities/:ccn/drgs`, `/api/providers/:npi/facilities` | 1 each |
| [Care sites](https://openpipe.health/docs/api/care-sites.md) | `GET /api/care-sites`, `/api/care-sites/types`, `/api/care-sites/:id`, `/api/care-sites/:id/owners` | 1 each |
| [Drug markets](https://openpipe.health/docs/api/drug-markets.md) | `GET /api/market/drugs`, `/api/market/drugs/spending` | 1 each |
| [Payers and ACOs](https://openpipe.health/docs/api/payers-acos.md) | `GET /api/market/payers`, `/api/market/payers/counties/:fips`, `/api/market/plans`, `/api/market/acos`, `/api/market/acos/:id` | 1 each |
| [Experts](https://openpipe.health/docs/api/experts.md) | `GET /api/market/experts`, `/api/market/experts/:npi` | 1 each |
| Export | `POST /api/exports` | 10 |
| Ask | `POST /api/ask` | 25 |
| [Ask (instant)](https://openpipe.health/docs/api/ask2.md), answered from a recipe | `POST /api/ask2/ask`, `/api/ask2/edit` | 5 |
| Ask (instant), answered by the planner | `POST /api/ask2/ask`, `/api/ask2/edit` | 25 |
| Open a predicted dashboard | `POST /api/ask2/open` | 5 |

[MCP tools](https://openpipe.health/docs/mcp.md#tools) cost the same as the endpoint they match: 1 credit for the `search_*` and `get_*` tools and for `list_hospital_clinicians` and `list_care_site_types`, 25 for `ask`. `list_datasets` and `describe_data` are free.

Not metered: `/api/health`, `/api/config`, `/api/meta`, `/api/me`, `/api/usage`, `/api/keys`, `GET /api/exports`, `GET /api/ask2/preview`, `POST /api/ask2/predict`, `GET /api/ask2/d/:id`, `GET /api/ask2/about` and everything under `/api/auth/`. Three more groups are free and have their own rate limits in place of a price:

- [`/api/dashboards`](https://openpipe.health/docs/api/saved.md): listing, opening, saving, renaming and deleting, and also refreshing. A refresh runs the stored SQL again at no charge, up to 20 refreshes a minute per workspace and 2 at a time.
- [`/api/catalog`](https://openpipe.health/docs/data/catalog.md): the dataset list, column descriptions and statistics, sample rows and search.
- [`/api/profile`](https://openpipe.health/docs/api/profile.md): the onboarding profile. Session tokens only.

## When you are charged

- **Search** on providers, facilities, groups and procedures is charged when the request arrives.
- **Lookup** is charged only if the record exists. A `404` is free.
- **Hospitals and systems, care sites, drug markets, payers, ACOs and experts** are charged only when the call succeeds. A `400` or a `404` is free. A search that returns no rows is a success and is charged.
- **Exports** run first. An export that is rejected, fails or times out is free.
- **Ask** is charged once, when the model has produced a plan and before any tile runs. If the model cannot plan an answer, nothing is charged. If a tile fails afterwards, the call is still charged, and [refreshing](https://openpipe.health/docs/api/saved.md#refresh-a-dashboard) the stored dashboard retries the tile for free.
- **Ask (instant)** is charged 5 credits when a recipe answers, once, when the first tile has a result and before any row is sent. If every tile fails, or you disconnect before that point, nothing is charged. When the planner answers it is charged 25, the same way as Ask. A retry with the same `rid` and a second open of the same prediction are free. See [when you are charged](https://openpipe.health/docs/api/ask2.md#when-you-are-charged-and-what-is-stored).

## The usage object

Every metered response carries what the call cost and where the workspace stands:

```json
"usage": { "credits": 1, "creditsUsed": 42, "creditsLimit": 100, "txid": "81240" }
```

| Field | Meaning |
|---|---|
| `credits` | Cost of this call |
| `creditsUsed` | Total the workspace has spent this calendar month, including this call |
| `creditsLimit` | The workspace's monthly allowance |
| `txid` | Postgres transaction id of the usage record. The app uses it to know when its live usage feed has caught up. You can ignore it. |

## Running out

The balance is checked twice, and both checks answer `402`.

**Before any work.** Every metered endpoint first checks whether the workspace can cover the price of the call. If it cannot, the request stops there: no query runs, and nothing else about the request is looked at. A malformed request or an unknown id gets `402` too, not `400` or `404`.

```json
{ "error": "Out of credits: 92 of 100 used this month, this call costs 10." }
```

The message is the same whether the allowance is spent or there is only too little left for this call. In the example, eight credits remain: a 1-credit search still works, a 10-credit export does not.

**At the moment of charging.** The same check runs again, together with the usage record, and answers with the same message. It matters when several calls arrive at once: a call that passed the first check can still be refused here if others spent the balance in between. It is not charged. For an export the statement has already run by then; its result is discarded and no file is written. For Ask the plan is discarded and no tile runs.

Charging is atomic. The balance check and the usage record happen together under one lock per workspace, so concurrent calls cannot spend past the limit between them. The limit is read fresh on every call, so a plan change applies to the next request.

Over [MCP](https://openpipe.health/docs/mcp.md#errors), both cases come back as a tool error with the same message, not as an HTTP `402`.

The count resets at the start of each calendar month, by the database clock. Check the balance any time with [`GET /api/me`](https://openpipe.health/docs/api/account.md#get-your-account).

## Older usage records

`POST /api/sql` (5 credits) was removed. Calls made before that still appear in [`GET /api/usage`](https://openpipe.health/docs/api/account.md#list-usage) with `kind` set to `sql`, and still count toward the month they were made in.
