> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langdock.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Limits and usage

> How spend limits, rate limits and cached tokens apply to Model Gateway keys, Platform API keys and agent runs, and where to see your usage.

Two kinds of limits apply to API keys:

* **Spend limits** cap how much money can be spent in a period. They are the main control for Model Gateway keys.
* **Rate limits** cap requests and tokens per minute so one key or workspace cannot crowd out others. They protect fairness, not your budget.

A request has to pass both. When a limit is reached, Langdock refuses the request with `429` before it reaches the model. It never switches an API request to a cheaper model.

## Spend limits

| Key | Spend counts toward | Who sets it |
| - | - | - |
| Personal key on Langdock Cloud | Your extra usage limit and the workspace's extra usage total, shared with your chat and agent usage. Extra usage has to be enabled | Admin, in **Model Gateway > Limits** or **Extra usage** |
| Personal key on BYOK or dedicated | Your monthly usage limit and the workspace spend limit, shared with chat and agents | Admin, in **Usage limits** |
| Workspace key | The workspace's monthly spend limit for workspace API keys | Admin, on the **API** or **Platform API** page |
| Any key running a saved agent | Also the agent's own budget, when the agent has one | The agent's owner or an admin |

Your personal limit is the higher of your seat default and your group limit, unless an admin set a personal limit for you. On BYOK and dedicated deployments a personal limit adds to the seat or group limit instead. Your keys page shows whether your keys can spend right now and, if not, which step is missing and who can fix it.

> [!NOTE]
>
> Model Gateway spend uses the same budget as your chat and agent usage. A busy coding session can use up the budget you also need in chat, so ask your admin for a limit that fits both.

## Rate limits

| Limit | Counted per | Default |
| - | - | - |
| Requests per minute | API key and model | 500 |
| Tokens per minute | Workspace and model, shared by every key in the workspace | 500,000. 1,000,000 for models published by OpenAI |
| Requests in progress at the same time (Model Gateway only) | Person, and workspace | 16 per person, 64 per workspace |
| Requests per minute on Platform API endpoints | API key | 500 |

Admins see each model's limit and its busiest minute in the last 7 days under **Model Gateway > Limits > Quotas & limits** (or **API > Model quotas** before the Model Gateway), and can request more there. A higher limit does not change the price per token. For your own models on a BYOK workspace, the token limit caps the estimated size of a single request instead of a per minute total.

### Cached tokens

Uncached input, cache writes and output always count toward the token limit. Cache reads count the way the provider that served the request counts them:

| Provider serving the request | Cache reads count toward tokens per minute |
| - | - |
| Anthropic, Amazon Bedrock, Claude on Google Vertex AI | No |
| OpenAI, Azure OpenAI, Google Gemini, Mistral, all others | Yes, in full |

This is why OpenAI models have a higher default token limit. Cache reads are still billed at the provider's cache read price.

### Agent runs

Running an agent through the API, with `POST https://api.langdock.com/agent/v1/chat/completions` or the `ask_agent` tool of the Agent MCP server, goes through the same checks before the run starts: requests and tokens per minute for the agent's model, the spend limit of the key, and the agent's budget. Spend limits are checked again between steps, so a run that reaches a limit stops with `429` instead of continuing on another model. An agent run's cost appears under **Agent runs** in the key's spend, not per model.

## Response headers

Both hosts send `Retry-After` (in seconds) on a `429` where waiting helps. A request that is too large for the token limit on its own, or a spend limit, has no `Retry-After`, because waiting does not help. The classic endpoints also send `x-ratelimit-limit-requests`, `x-ratelimit-remaining-requests`, `x-ratelimit-limit-tokens` and `x-ratelimit-remaining-tokens`.

Retry `429` and `5xx` responses with exponential backoff and honor `Retry-After`. Do not retry `400`, `401`, `403` or `404`, they fail again.

## Cost in each response

Responses from `gateway.langdock.com` carry the request's estimated cost in US dollars in their final usage object (`usage.cost`, `usage.is_byok`, `usage.cost_details`). See [the quickstart](https://docs.langdock.com/en/developer/model-gateway/quickstart.md#3-check-the-cost). The settled cost, which your spend limit and invoice use, can differ slightly and is billed in your workspace currency.

## See your usage

| Who | Where | What |
| - | - | - |
| You | [Settings > Account > API keys](https://app.langdock.com/settings/account/api-keys), **Keys** tab | Spend this month and last use per key |
| You | Same page, **Usage** tab | Your spend, requests and tokens over time, by model and by key, including agent runs |
| Admins | **Model Gateway > Analytics** | Spend, model calls, active people, tokens and failed requests, by model, person and key, plus a CSV export |
| Admins | **Model Gateway > Manage** | Every key with model access, its owner, last use and spend this month |
| Admins | **Platform API > Analytics** | Requests, error rate and response time per endpoint and key |
| Integrations | [Usage Export API](https://docs.langdock.com/en/developer/usage-export-api/intro-to-usage-export-api.md) | Usage per key for your own reporting, with a workspace key |

**Last used** counts every API request of a key on both hosts, not only model calls. Per person figures are hidden when your workspace turns off user level data.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.