Endpoints
List and search return 10 keys per page, with
p starting at 0. The key in those results is masked; call the reveal endpoint to get the full key used for model calls.
Fields for a new key
billing_type decides which models the key can call. Usage-based keys call only usage-based models, Per-call keys call only per-call models, and Usage first keys call both. Billing explains the three modes.
Create a key and reveal it
This script creates a key with a 5 USD limit, a 30-day expiry, and two allowed models, then reveals the full key. It needsrequests (python -m pip install requests).
Authorization: Bearer <key>), with or without an sk- prefix. Store it in your secret manager before you hand it out. Avoid calling the reveal endpoint repeatedly; it is strictly rate limited.
Update, disable, and delete
An update replaces the whole key object. Read it withGET /api/token/{id}, change the fields you need, and PUT the full object back. Sending only a few fields can reset the others.
- A disabled or deleted key gets HTTP 401
Invalid token.on model calls. - A model outside the allowlist gets HTTP 403 with a message that the token may not use that model.
Errors
FAQ
Whose balance pays for a customer’s key?
Yours. Setremain_quota on each key as its spending cap. When a key reaches its cap it stops working and cannot draw on the rest of your balance.
How do I see how much each key has used?
used_quota in the list and detail responses is the key’s total usage. To break it down by time or model, use the log query API with token_name.
I set model_limits. Why is it ignored?
The model allowlist is read only from models. Put the allowed model IDs there as a comma-separated string.
Related documentation
- Get an AccessToken and check your balance: Balance API
- Export a key’s call records: Log query API
- Create keys and set IP allowlists in the console: Create, store, rotate, and revoke API keys