# API keys with a spend limit and an expiry date on Tchavi

> Every Tchavi API key can now have an expiry date and a spend limit in credits: how it works, the 403 error and what to watch for.

- Published: 2026-10-20
- Author: Gael — Tchavi founder
- Canonical: https://tchavi.com/en/blog/api-keys-spend-limit-expiry

---


Every Tchavi API key can now have an expiry date and a spend limit in credits. You hand a key to an intern, a demo or a CI job, and it stops on its own, on the planned date or when the cap is reached.

## In short

- Tchavi, an OpenAI-compatible AI API gateway you pay for with mobile money, adds two settings per key: an expiry and a spend limit.
- Expiry: never, 1 hour, 1 day, 3 days, 7 days, 1 month, or a custom date.
- Limit: the maximum number of credits the key can spend over its whole lifetime.
- At the cap, the request gets a 403 `key_spend_limit_reached` error.

## Expiry

In the key creation form, the **Expiration** field offers: _Never_, _1 hour_, _1 day_, _3 days_, _7 days_, _1 month_ and _Custom date_. A date in the past is refused. With _Never_, the key works until you revoke it.

Past the date, the key returns `403 key_inactive` with `details.status: "EXPIRED"`. In your key list it shows as _Expired_, even before its next use, and it no longer counts toward the maximum number of keys for your tier.

## Spend limit

The **Spend limit** field is a number of credits. Leave it empty for no limit. It accepts up to 3 decimals. As a rough guide at October 2026 rates, a limit of 3,000 credits is about KES 227.

How it works: each request first reserves its estimated cost. If that reservation does not fit in what the key has left, the request is refused with a 403 error:

```json
{
  "error": "key_spend_limit_reached",
  "message": "…",
  "statusCode": 403
}
```

It is a 403 and not a 402, because a top-up would change nothing: the key is capped, not your balance. The error also shows the limit, what the key has already spent, what is left and what the request asked for.

## Changing the limit

The key list shows each key's spend against its limit (for example "120 of 3,000") and its expiry. When a key reaches its limit, it is marked _Limit reached_. You can raise the limit, lower it or remove it from the dashboard; what the key has already spent is kept.

## What to watch

**Streaming can overshoot a little.** A streaming request reserves its estimated cost at the start. If the final cost is higher, the difference is still billed: a key can end slightly above its limit. Conversely, because each request holds its estimate until it finishes, a key can stop a little before its cap. Leave a small margin.

**The cap is cumulative.** It covers the whole lifetime of the key, not a day or a month.

## Three concrete uses

- **An intern or a contractor:** a key with 1,500 credits (about KES 114), expiring in 7 days.
- **A client demo:** a 1-hour key, capped at a few hundred credits.
- **A CI job:** a long-lived but capped key, so the job cannot drain your balance.

I give these figures as starting points to adjust. To see a real case, read [how to use Claude Code with a capped key](https://tchavi.com/en/blog/claude-code-without-credit-card-mobile-money).

## How to try it

1. Open the [API keys](https://tchavi.com/en/dashboard/api-keys) page of your dashboard.
2. Create a key: choose the expiry and enter the limit.
3. Read the [Expiry and spend limit](https://tchavi.com/en/docs/authentication) section of the documentation.

## FAQ

### Is a refused request billed?

No: the request is not served, so nothing is charged.

### What do I do when a key reaches its limit?

Raise the limit from the key list, or create a new key. The key works again right after the change.

### Can I cap a key that already exists?

Yes: the key list offers _Spend limit_ for an active key.

[create your account and top up KES 250](https://tchavi.com/en/register?next=%2Fdashboard%2Fbilling%3Famount%3D250%26currency%3DKES%26from%3Dblog-spend-keys-en)

> _This article is part of the series "Building an AI product from Africa". Tchavi is an OpenAI-compatible AI API gateway: one key gives access to over 100 text, image, audio and video models, and you pay for it with mobile money, no bank card ([countries and operators](https://tchavi.com/en/docs/payments)). More guides on [the blog](https://tchavi.com/en/blog). Follow us: [LinkedIn](https://www.linkedin.com/company/tchavi) and [X](https://x.com/tchaviai)._

