# Budgets per case and per person

> Keep one use case, or one person of your app, from spending what belongs to everyone, and set a ceiling on a single call.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://ai.docs.sypnia.com/usage/budgets-per-case-and-user/

For agents: Patterns: cap each case (limits.cases.<id>.credits_per_day) so one feature cannot starve others; cap each end user (route limits.end_user, required for browser routes) to stop abuse; cap a single call with Sypnia-Budget / SDK budget (refused before calling with 402 budget_exceeded if the estimate exceeds it; output cut at the budget with finish_reason budget); map errors to the case's failure (e.g. TooManyQuestions) in your app. Agents' tasks: Sypnia Agent passes its task budget as Sypnia-Budget.

## A ceiling for each case

The bakery's search, `find-products`, makes many cheap calls; answering questions, `ask-about-a-product`, makes fewer, longer ones. A daily cap per case keeps a sudden rush on one from using up the other:

`sypnia.toml`

```toml
[ai.limits.cases]
ask-about-a-product = { credits_per_day = 400 }
find-products = { credits_per_day = 150 }
```

## A ceiling for each person

Without one, a single visitor, or a script pretending to be one, could ask questions all day on your credits. A route that browsers may call **must** have one:

`sypnia.toml`

```toml
[ai.tasks.allergen-answer]
browser = true
limits = { end_user = { requests_per_day = 40, credits_per_day = 10 } }
```

When a person reaches it, the call answers `429 end_user_limit`. In your app that is a failure of the use case, with a message you wrote: «You asked a lot today. You can ask us at the counter, or again tomorrow.» (`TooManyQuestions` in the case file).

## A ceiling for one call

```ts
await ai.chat({ task: 'summarize', case: 'summarize-reviews', budget: 3, messages });
```

or `Sypnia-Budget: 3`. If the call could cost more than that before it starts, it is refused with `402 budget_exceeded`; if the answer reaches the budget while it is written, it stops there with `finish_reason: "budget"`.

[Sypnia Agent](https://agent.docs.sypnia.com/) sends each coding task's remaining budget this way, so no step can spend past it.
