# Limits

Two kinds of limit keep your AI bill under control. Both refuse a call **before** it reaches the model, so a refused call costs nothing.

| Limit | Applies to | Set in | Error your app gets |
|---|---|---|---|
| Monthly spending limit | The whole project | **Settings** | 429 `budget_exceeded` |
| Daily limit per user | One Feature, per end user, optionally per plan | The Feature's **Limits** tab | 429 `quota_exceeded` |

## Monthly spending limit

A maximum for the project's **estimated** spend in a calendar month (UTC). Once the month's spend reaches it, every call of the project is refused until the next month, or until you raise the limit.

- Set it in **Settings**, **Monthly spending limit**: between $0.01 and $10,000. FeatWire may ask for your password again before saving it.
- Leave it empty for no limit. A new project has none.
- Every call counts, tests from the dashboard included, and tests are refused too once the limit is reached.
- **Overview** and **Settings** show the month's spend against the limit, with a warning from 80% and a banner at 100%.
- A change applies to calls within 30 seconds.

Good to know:

- The spend is an [estimate](/docs/costs-and-requests#why-the-cost-is-an-estimate), not your provider's bill. Set a limit at your provider too: see [AI provider keys](/docs/ai-provider-keys#set-a-spending-limit-at-the-provider).
- The check happens before each call. A call that starts under the limit is answered in full, so the month can end slightly above it.

## Daily limits per user

How many times a day each user of your app may call one Feature. It protects you from one user (or one bug) running up the bill.

Open the Feature, tab **Limits**:

- **Calls a day per user**: the limit for every user, from 1 to 100,000. Leave it empty for no limit.
- **By plan**: a different limit for each plan of your app, up to 20 plans. For example 5 calls a day on `free` and 100 on `premium`. A plan without a row gets the limit above.

Click **Save limits**. They apply to calls within 30 seconds. You do not need to publish a new version.

### How FeatWire knows the user and the plan

From the body of each call:

- `userId` names the user: a stable, non-personal id, such as the user's id in your database. **A call without `userId` is never limited.**
- `metadata.plan` names the plan, such as `{ "plan": "free" }`. It must be written exactly as in the Limits tab (`free` is not `Free`). A call without a plan, or with a plan that has no row, gets the limit for every user.

The prompt from **Connect** already tells your coding assistant to send both.

### How the days are counted

- Days start at midnight UTC.
- A call is counted when it starts. If the user gets nothing back (the provider failed, the model took too long, the answer had the wrong format), the call is given back.
- Tests from the dashboard are not counted.

### What your app gets

Every answer to a call counted against a limit tells your app what is left, in two response headers, so that it can show "3 messages left today" without another call:

```
X-FeatWire-Quota-Limit: 5
X-FeatWire-Quota-Remaining: 3
```

- `X-FeatWire-Quota-Limit`: the user's limit today, the one of their plan when it has its own.
- `X-FeatWire-Quota-Remaining`: the calls they have left after this one, never below 0.

They come with successful answers, streamed ones included, and with the 429 below. They are not sent when the call has no `userId`, when no limit applies to it, or when FeatWire could not count the call: show no count then. The details, including calls that fail: [What is left of a user's daily limit](/docs/api-reference#what-is-left-of-a-user-s-daily-limit).

Once a user has reached their limit, their next calls to that Feature get a 429 error with `used` (their calls today) and `limit`:

```json
{
  "error": {
    "type": "quota_exceeded",
    "message": "...",
    "used": 30,
    "limit": 30
  }
}
```

Its headers say the same: `X-FeatWire-Quota-Remaining` is 0. Your app can show what is left (`limit - used`) in a friendly message, or offer an upgrade if it has paid plans.
