A publishable key can limit how many questions each of your users asks a minute, an hour, a day and a month, and how many all of them ask together. Limits count questions, not credits, and sit inside your organization's credits: a user limit never raises them. Limits need a verified user, so they apply to publishable keys only; with a secret key, apply your own in your route.
What a new publishable key starts with depends on where you create it:
| Created in | Each user may ask |
|---|---|
| Setup | At most 10 questions a minute, 50 a day and 300 a month. One rule, for every user |
| API keys | No per-user limit. Only your organization's credits apply |
In Setup, Create another key copies the first key's settings, limits included. Either way you can change the limits at any time.
Owners and admins open Auth and limits, choose the key, and edit Limits. Members can read them. Choose Save limits: the change applies from the next question, and counts already made in the current minute, hour, day or month stay.
Each user holds rules, checked from the top. The first rule that matches a user sets that user's limits; a rule is a limit for each matching user, not one shared allowance. Limit every user adds a rule with no condition. Once you have conditional rules, it becomes Limit everyone else, the catch-all at the end. Without a catch-all, users no rule matches have no per-user limit. You can save up to 50 rules.
| Field | Meaning |
|---|---|
| Per minute, Per hour, Per day | Questions in the current UTC minute, hour or day. Empty means no limit; otherwise a whole number of at least 1 |
| Per month | Questions in the current UTC calendar month. This is not your billing period |
| Per month, from a claim (optional) | A claim holding the user's monthly allowance, such as ai_quota. A whole number of 0 or more replaces Per month for that user; anything else falls back to it |
| Message to the user (optional) | Up to 300 characters, shown in place of ours when the user reaches any of this rule's limits, for example to point at your upgrade page |
Add a rule with a condition tests one claim: from the token with JWT and OIDC, or from the attributes your server sent with session tokens or the identity webhook. Dots reach nested claims, as in subscription.plan.
| Test | Matches when the claim | Example Value |
|---|---|---|
| is | equals the value | pro |
| is one of | equals one of the values | pro, team |
| starts with | starts with the value, ignoring case | team_ |
| ends with | ends with the value, ignoring case | @example.com |
| is at least | is a number at least the value | 10 |
| is at most | is a number at most the value | 100 |
| is present | exists | |
| is absent | does not exist |
is and is one of compare text, numbers and true or false as typed: 10 matches the number 10, and true the value true; put quotes around a value, as in "10", to match text. On a claim named email, or ending in .email, they ignore case.
All users together is one more allowance shared by everyone using the key, on top of each user's.
The minute and hour counts are kept per server and start again if it restarts; the day and month counts are stored.
A publishable key answers only questions sent from its Allowed origins, which you set when you create the key or with Edit on API keys. The browser's Origin header must match one entry exactly; with no entries, the key refuses everything.
https://app.example.com matches that origin only.http://localhost:3000 matches that development origin and port only.https://*.example.com matches any subdomain of example.com, at any depth, over https, but not https://example.com itself.https://*.example.com:8443 matches the same, on port 8443 only.Enter the scheme and any port, with no path. From any other site, your user sees "The assistant is not available on this site." (403 origin_not_allowed).
The question is refused before it reaches the assistant, with status 429 and code rate_limited, a Retry-After header and retryAfter in seconds. It is not charged and does not count. The user reads your rule's message if it has one, or ours:
| Window | Our message |
|---|---|
| Minute or hour | The assistant is busy. Try again in N seconds. |
| Day | The assistant has reached today's limit. Try again tomorrow. |
| Month | The assistant has reached this month's limit. Try again next month. |
An All users together limit always shows our message. The response's detail names the limit that was reached:
{ "ok": false, "statusCode": 429, "code": "rate_limited", "message": "The assistant has reached today's limit. Try again tomorrow.", "detail": "The user day limit (50) was reached. Retry after 3600 seconds, or change limits at /app/auth. Refused before the model; no Usage log row.", "retryAfter": 3600}A question counts once it passes your limits, and stays counted when the assistant was called, even if the answer then fails and is not charged. Your organization's credits can stop a question too, with 402: see Limits.