Rate limiting
Breign applies two independent sets of limits. They do not share counters.
- Agent chat β messages sent to an agent, new conversations, and turns running at the same time. Configured by an organization admin under Agent limits in the sidebar. Off by default.
- AI Gateway β requests per minute on the OpenAI-compatible API, and token quotas and euro budgets per user, which also apply to agent chat. Configured under AI Gateway, on AI Gateway limits. Unlimited until an admin sets a value.
A refused call returns 429 with a Retry-After header (seconds). Wait at least that long before retrying the same call. A 429 does not consume an extra slot of the limit that refused it.
Who is countedβ
Limits follow the caller, in this order:
- The owner of the conversation, when the call continues an existing conversation.
- The authenticated user (JWT or user API key).
- The application, and its instance when the call comes from an app instance.
- A shared bucket for a platform key that is not tied to a user.
Two users never share a bucket. The same user shares one bucket across the organization's agents for conversation creation and concurrent turns. The message quota is per user and per agent.
Agent chatβ
Turn the limits on with Enable limits. The three caps are positive integers. The window and the concurrency lease are fixed by the platform: a sliding window of 60 seconds, and a concurrency slot that expires after 15 minutes if the process never releases it.
| Setting | Default | What it counts |
|---|---|---|
| Concurrent turns / user | 3 | Agent turns in progress for this user, across the organization's agents. |
| New conversations / minute / user | 5 | Conversations created in the sliding window, across the organization's agents. |
| Messages / minute / user / agent | 30 | Messages sent to one agent in the sliding window. |
While the switch is off, calls are not refused. GET /agents/:agentId/prompts/rate-limit still answers, with used at 0 and remaining equal to the configured message cap.
Calls that consume a quotaβ
| Call | Quotas |
|---|---|
POST /agents/:agentId/prompts | Concurrent turn, then message, then new conversation. |
POST /conversations/:conversationId/prompts | Concurrent turn, then message. |
POST /agents/:agentId/prompts/flows | New conversation. |
POST /agents/:agentId/conversations | New conversation. |
POST /apps/:appId/chats and POST /agents/:appId/chats | Concurrent turn, then message, then new conversation. A dry create only counts a new conversation. |
POST /apps/:appId/chats/:chatId and POST /agents/:appId/chats/:chatId | Concurrent turn, then message. A dry submit counts nothing. |
POST /apps/:appId/flows | New conversation. |
Creating a conversation checks the turn first. If the conversation cap then refuses the call, the concurrency slot is released. The message just sent still counts toward the message cap.
Sending the result of a client tool call (POST /conversations/:conversationId/messages/:messageId/tool-calls/:callId) continues the turn already in progress. It does not take a new slot.
Reading the remaining quotaβ
GET /agents/:agentId/prompts/rate-limit returns the message quota for the caller on that agent. It does not consume a slot.
{
"limit": 30,
"used": 4,
"remaining": 26,
"resetSeconds": 42
}
The same figures are repeated on response headers, including on a successful prompt:
| Header | Meaning |
|---|---|
X-RateLimit-Limit-Prompts | Cap for the window. |
X-RateLimit-Remaining-Prompts | Slots left. |
X-RateLimit-Reset-Prompts | Seconds until the oldest event leaves the window. |
Conversation creates use the suffix Conversations, concurrent turns use Concurrent.
429 bodyβ
{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"kind": "PROMPT_RATE",
"message": "Too many requests to this agent. Please retry in a minute.",
"retryAfterSeconds": 42,
"limit": 30,
"used": 30,
"remaining": 0
}
}
kind is one of:
kind | Meaning |
|---|---|
PROMPT_ | Message cap reached for this user on this agent. |
CONVERSATION_ | Too many conversations created in the window. |
CONCURRENT_ | Too many turns already in progress. retryAfterSeconds is 5: retry shortly, the slot frees when a turn ends. |
App chat routes (/apps/β¦/chats) return this body and Retry-After. The prompt routes also set the X-RateLimit-* headers.
Rejections are counted on the agent Metrics tab, under Rate limiting.
Settings APIβ
Organization admins only.
GET /organizations/:organizationId/agents/rate-limit/settings
PUT /organizations/:organizationId/agents/rate-limit/settings
PUT accepts any subset of enabled, maxConcurrentTurnsPerSubject, maxConversationCreatesPerSubjectPerMinute, and maxPromptsPerSubjectPerAgentPerMinute. Each cap must be an integer β₯ 1. windowMs and concurrencyLeaseMs are returned on GET and stay at the platform values (60000 and 900000).
AI Gatewayβ
These limits apply to chat completions and embeddings:
POST /organizations/:organizationId/ai-gateway/chat/completionsandβ¦/ai-gateway/v1/chat/completionsPOST /organizations/:organizationId/ai-gateway/embeddingsandβ¦/ai-gateway/v1/embeddingsPOST /organizations/:organizationId/openai/chat/completionsandβ¦/openai/v1/chat/completions
They do not apply to listing models.
Token quotas and euro budgets also apply to agent chat: before each turn, Breign checks them for the user and the agent's model, and the usage of both chat and gateway counts toward them. They only cover engines that use the organization's own API key. Breign models (platform engines) have their own caps, set by the platform superadmin.
Requests per minuteβ
gatewayRpm is the maximum number of those calls per subject in a sliding window of 60 seconds. null means unlimited. The subject is the authenticated user, or the application when the call has no user id.
Token quotasβ
Each quota is a cap of input + output + reasoning tokens for one user on one model, over a calendar day or month in UTC. The model can be a bare id or providerId/modelId. Breign matches a qualified id first, then the same provider and model, then a bare model id.
The check uses tokens already recorded. The call in flight is not reserved, so one request can finish slightly above the cap.
Euro budgetsβ
A budget caps what one user spends in euros over a calendar day or month in UTC, across all the organization's own-key models.
- The cost of each call is computed when it is recorded, from the model's price per million tokens, and kept with it. Changing a price later does not change past spending.
- Only prices in
EURcount. A model with no price, or a price in another currency, is not counted in budgets; it still counts in token quotas. - Like token quotas, the budget is a soft cap: the call in flight is not reserved.
- A user can have a token quota and a budget: the first one reached refuses the call.
Rules for all usersβ
In a quota or a budget, userId: "*" means all users. The rule applies to each user separately: it is not a cap shared by the organization. A rule on a specific user replaces the * rule for that user (for a quota, on the same model).
Calls without a userβ
Quotas and budgets cap users. A call with no user id (an application with its appId:appSecret pair, an ephemeral instance token) is not checked against them. Requests per minute still apply.
429 bodyβ
The gateway keeps an OpenAI-shaped error. Retry-After and the limit headers are set as well, with a suffix for the limit that refused the call: gateway for requests per minute, gateway-tokens for a token quota, gateway-budget for a budget (for example X-RateLimit-Limit-Gateway-Budget, X-RateLimit-Remaining-Gateway-Budget, X-RateLimit-Reset-Gateway-Budget). For a budget, Limit and Remaining are in euros, and Reset is the number of seconds until the period ends.
{
"error": {
"message": "Too many requests for this model. Please retry in a minute.",
"type": "rate_limit_error",
"code": "RATE_LIMIT_EXCEEDED",
"param": null
}
}
A token quota uses "type": "insufficient_quota" and the message Token quota reached for this model. A budget uses "type": "insufficient_quota" and the message Budget reached for this period.
In agent chat, the turn fails with the code RATE_, and the message shown to the user says that the quota or the budget is reached.
Settings APIβ
Organization admins only.
GET /organizations/:organizationId/ai-gateway/settings
PUT /organizations/:organizationId/ai-gateway/settings
PUT accepts gatewayRpm (null or an integer β₯ 1), modelTokenQuotas and userBudgets. A field left out is not changed; an empty array removes every rule of that kind.
{
"gatewayRpm": 60,
"modelTokenQuotas": [
{
"userId": "*",
"model": "openai/gpt-4o",
"providerId": "openai",
"limit": 100000,
"period": "month"
},
{
"userId": "7c1eβ¦",
"model": "openai/gpt-4o",
"providerId": "openai",
"limit": 500000,
"period": "month"
}
],
"userBudgets": [
{ "userId": "*", "amount": 10, "period": "month" },
{ "userId": "7c1eβ¦", "amount": 50, "period": "month" }
]
}
Validation, with a 400 otherwise:
- a quota needs a
userId, amodel, alimitβ₯ 1 and aperiodofdayormonth; only one quota per user (or*) and model; - a budget needs a
userId, anamount> 0 (rounded to the cent) and aperiodofdayormonth; only one budget per user (or*).
The response returns the settings. Each budget on a specific user also carries used, the euros already spent in the current period. A * budget has no used, since each user spends their own.