> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.fabricgateway.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.fabricgateway.ai/_mcp/server.

# LLM Rate Limit plugin

> Reference for the LLM Rate Limit plugin, which limits the LLM tokens a caller can use in a time window.

The LLM Rate Limit plugin gives each caller a token budget: at most `max_tokens` LLM tokens in a sliding window. It checks the budget before the call and charges the tokens the model used after it. When the budget is used up, the plugin refuses the request with `429` and a `Retry-After` header, and the provider isn't called.

The plugin doesn't estimate what a request will cost. A request under the budget goes through however large it is, so the request that crosses the budget is always let through.

## Where it runs

|             |                                                                       |
| ----------- | --------------------------------------------------------------------- |
| Protocols   | LLM routes. Other requests pass through unchecked and aren't charged. |
| Scope kinds | `service`, `route`, `consumer`                                        |
| Phase       | Request (check) and after the response (charge)                       |

The plugin charges the tokens that the [LLM Observability](/reference/plugins/llm-observability) plugin records, so it needs that plugin's global instance. The control plane doesn't create one for you. After an Adaptive Model Router cascade, it charges the total of every attempt, whether or not LLM Observability is present. Otherwise, without it, or when no tokens were recorded, nothing is charged and the budget never refuses a request.

## Configuration

| Field        | Type   | Default  | Description                                                                 |
| ------------ | ------ | -------- | --------------------------------------------------------------------------- |
| `max_tokens` | number | `100000` | The token budget for the window. The console labels this **Max tokens**.    |
| `window`     | number | `60`     | The window length in seconds. The console labels this **Window (seconds)**. |

A counter belongs to one consumer on one route. All anonymous callers of a route share one budget. A budget attached to a consumer or a connection is still counted separately on each route.

## Example

```json
{
  "name": "token-budget",
  "plugin_id": "llm-rate-limit",
  "scope": { "kind": "route", "name": "openai-route" },
  "config": { "max_tokens": 200000, "window": 3600 }
}
```

## Related guides

* [Set rate limits](/configure/access-and-limits/rate-limits)
* [Set budgets](/configure/access-and-limits/budgets)