API keys: making, keeping and limiting them
A key isn't just a secret; it's the best tool you have for keeping spend under control.
An API key is a string starting with ir- that lets a tool or program talk to models on your behalf. Think of a house key: whoever holds it can walk in.
But a key here is more than a password. Each one has its own spending cap, expiry and billing source.
Rule one: one key per tool. If one gets out of hand, you close only that one.
Making a key
A key for this course0 of 5 steps
- Go to API keys and press New key.
- Give it a name that says what it's for, such as "course practice".
- Set Expires to 30 days. For automated tools, an expiry is safer.
- Fill in Monthly cap.
- Copy the key, keep it somewhere safe and tick the box.
Where the key spends from
One choice matters when you make a key:
| Option | Spends | Reaches |
|---|---|---|
| Account plan | The plan's token allowance | That plan's models |
| Credit (pay as you go) | The wallet balance | Every active model |
This is per key and can be changed later. So you can hold a plan and still make one credit key to try a model outside it, leaving your allowance untouched.
Caps
Caps stop unwanted spending. A cap is hard: a request that would cross it doesn't run.
- Monthly cap: in rials, over the Jalali month. It resets at the start of each month, Tehran time.
- Daily spend cap: under More limits; resets at midnight Tehran time.
- Daily token cap: for when you think in tokens.
- Requests per minute: you can only lower this below your plan's limit.
If a key leaks
Do one of these three, all from that key's menu:
| Action | What happens |
|---|---|
| Rotate key | A new secret; the old one stops at once. The name, cap and reports stay |
| Disable | Requests are refused immediately, but you can turn it back on |
| Delete key | Gone for good |
Where not to put a key
A key can spend from your wallet. Never put it in browser code, a mobile app or a public repository. Keep it on your own server or in an environment variable.
A quick check
Just for you: your answers aren't sent anywhere.
What you learned
- One key per tool, with its own cap.
- A plan key reaches the plan's models; a credit key reaches every model.
- Next: your first request with this key.
Keep your place
Sign in to the panel and each lesson and your path are saved, so you continue from the same spot on any device.