---
title: "Set a Budget"
description: "Use prepaid credits as the team-wide boundary, add resettable budgets to workload keys, and account for auto top-up, provider billing, and BYOK fallback in the spend policy."
canonical_url: "https://vercel.com/academy/ai-gateway/set-a-budget"
md_url: "https://vercel.com/academy/ai-gateway/set-a-budget.md"
docset_id: "vercel-academy"
doc_version: "1.0"
last_updated: "2026-08-08T23:27:13.415Z"
content_type: "lesson"
course: "ai-gateway"
course_title: "Using AI Gateway in Production"
prerequisites:  []
---

<agent-instructions>
Vercel Academy — structured learning, not reference docs.
Lessons are sequenced.
Adapt commands to the human's actual environment (OS, package manager, shell, editor) — detect from project context or ask, don't assume.
The lesson shows one path; if the human's project diverges, adapt concepts to their setup.
Preserve the learning goal over literal steps.
Quizzes are pedagogical — engage, don't spoil.
Quiz answers are included for your reference.
</agent-instructions>

# Set a Budget

# How Do I Set a Budget So I Don't Get a Surprise Bill?

A runaway loop can drain a credit balance before anyone notices. Gateway credits put a boundary around team spend, while API key budgets keep one workload from consuming the entire balance.

\*\*Note: Quick Answer\*\*

AI Gateway Credits are prepaid, so requests stop when the team balance reaches zero. Add a budget to each API key to limit a feature, service, or developer tool, and choose when that budget resets. Key budgets are soft caps: the request that crosses the limit can finish, then later requests are rejected.

## Outcome

Give one workload its own API key budget, then document every setting that can refill the balance or move charges to a provider account.

## Fast Track

1. Create or edit a dedicated API key for one workload
2. Set its budget and reset period
3. Review auto top-up, BYOK billing, and system-credential fallback

## Hands-on exercise

Open **API Keys** in the AI Gateway dashboard and choose a key used by one workload. Avoid a shared key with five unrelated jobs attached. That key cannot tell you which job spent the money.

Set a limit and choose the reset period that matches how your team reviews spend. The key row shows current spend against the limit, which makes it useful for both control and attribution.

\*\*Warning: The crossing request completes\*\*

A key budget is checked when a request starts. If that request pushes spend past the limit, it still finishes. Requests that start after the limit has been reached are rejected until the budget resets or changes.

Now review the settings that sit outside the key budget:

- **Auto top-up:** Can refill the team balance automatically
- **BYOK provider billing:** Sends successful BYOK charges to the provider account
- **BYOK fallback:** Can use Gateway system credentials and Gateway credits when your provider credential fails

Record the decision in the demo README:

```markdown
## Spend policy

- Workload: order assistant
- Gateway key: dedicated key with a monthly reset
- Auto top-up: off
- BYOK: none configured
- Reviewed: <date>, by <owner>
```

Use the states your team chose. The example keeps one spending path active and gives the order assistant a budget of its own.

## Try It

Confirm three pieces of evidence:

1. The workload key shows spend against its limit
2. The key's edit view shows the intended limit and reset period
3. The README matches the current auto top-up and BYOK settings

If requests continue after the limit, confirm that the application is using the budgeted key rather than another team key. If a single request carries the total slightly over the limit, that is the documented soft-cap behavior.

## Commit

```bash
git commit -m "docs(spend): record the order assistant budget policy"
```

## Done-When

- [ ] One workload has a dedicated API key with a budget and reset period
- [ ] You can explain the soft-cap behavior
- [ ] Auto top-up, BYOK billing, and fallback are documented
- [ ] The README names an owner and review date

## Solution

The solution is a budgeted workload key plus the written spend policy. The dashboard enforces the limit, while the README records the billing paths that the limit does not cover.

## Related Questions

- [How do I use AI credits I already bought?](/ai-gateway/save-money/use-ai-credits)
- [How do I bring my own provider keys?](/ai-gateway/save-money/bring-your-own-keys)
- [How do I see where my money is going?](/ai-gateway/stay-aware/see-your-spend)


---

[Full course index](/academy/llms.txt) · [Sitemap](/academy/sitemap.md)
