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.
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:
[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:
[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
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 sends each coding task’s remaining budget this way, so no step can spend past it.