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

# Pricing and limits

> Pricing, rate limits, budget enforcement, and usage tracking for Model APIs

Model APIs bill by token and enforce request and token rate limits. You can also set a workspace budget and query usage by API key or model.

## Rate limits

Baseten applies two rate limits:

* **Requests per minute (RPM):** The maximum number of API requests per minute.
* **Tokens per minute (TPM):** The maximum number of input and output tokens processed per minute. Cached and uncached input tokens count equally toward this limit, even though cached tokens cost less.

To monitor token and request consumption by API key or model, see [Usage](#usage).

Default limits vary by account status.

| Account                |                                         RPM |                                         TPM |
| :--------------------- | ------------------------------------------: | ------------------------------------------: |
| **Basic** (unverified) |                                          15 |                                     100,000 |
| **Basic** (verified)   |                                         120 |                                     500,000 |
| **Pro**                |                                         120 |                                     500,000 |
| **Enterprise**         | [Custom](https://www.baseten.co/talk-to-us) | [Custom](https://www.baseten.co/talk-to-us) |

To raise a Basic account's limits, [request email verification](https://www.baseten.co/talk-to-us/increase-rate-limits/). You can also use that form to move to Pro or Enterprise.

<Warning>
  If you exceed these limits, the API returns a `429 Too Many Requests` error. See [Inference errors](/inference/errors#429-too-many-requests) for how to respond.
</Warning>

## Pricing

Model APIs bill per million tokens. For current per-model rates, see the [Model APIs pricing page](https://www.baseten.co/pricing). Fast tier variants have their own per-model pricing and rate limits; see [Supported models](/inference/model-apis/overview#supported-models) for details.

### Cached input tokens

Cached input tokens are prompt tokens served from the KV cache at a discounted rate. Caching is automatic and requires no request flags.

For coding-agent requests, Baseten uses recognized session IDs to pin related requests to the same replica. Claude Code, Codex, and OpenCode include these IDs without additional configuration. Baseten checks the following header:

* `x-session-affinity`: generic session ID

The following headers are recognized as best-effort fallbacks:

* `x-claude-code-session-id`: Claude Code's root session
* `x-claude-code-agent-id`: Claude Code's subagent
* `session-id`: Codex
* `x-opencode-session`: OpenCode
* `x-session-id`: generic session ID

For other integrations, send a consistent `x-session-affinity` value to pin related requests to the same region or replica. Use one ID for a single conversation or agent task, including its subagents. Do not reuse an ID across unrelated tasks because doing so concentrates traffic on one replica.
The ID should remain stable within a task and differ across tasks. For example, hash your internal conversation or session ID with SHA-256 and use the first 16 hexadecimal characters:

```python x-session.py theme={"system"}
import hashlib

conversation_id = "conv-or-agent-task"  # your existing conversation or session identifier, trace-id
affinity = hashlib.sha256(conversation_id.encode()).hexdigest()[:16]
```

Send the resulting value in the `x-session-affinity` header on every request in the conversation:

<CodeGroup>
  ```bash Request theme={"system"}
  curl -X POST https://inference.baseten.co/v1/chat/completions \
    -H "Authorization: Bearer $BASETEN_API_KEY" \
    -H "Content-Type: application/json" \
    -H "x-session-affinity: 8f9ff769f61b13e1" \
    -d '{
      "model": "zai-org/GLM-5.2",
      "messages": [
        {"role": "system", "content": "You are a concise technical writer."},
        {"role": "user", "content": "What is gradient descent?"},
        {"role": "assistant", "content": "An optimization algorithm that iteratively adjusts model parameters by moving in the direction of steepest decrease in the loss function."},
        {"role": "user", "content": "How does the learning rate affect it?"}
      ]
    }'
  ```

  ```json Response theme={"system"}
  {
    "id": "chatcmpl-4a7e03f0b97e453fa5b8eeeac78b3d13",
    "object": "chat.completion",
    "model": "zai-org/GLM-5.2",
    "choices": [
      {
        "index": 0,
        "message": {
          "content": "The learning rate determines the step size of each update. Too high, and the model overshoots the minimum or diverges; too low, and convergence becomes prohibitively slow or risks getting stuck in local minima.",
          "role": "assistant"
        },
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 56,
      "completion_tokens": 44,
      "total_tokens": 100,
      "prompt_tokens_details": {
        "cached_tokens": 32
      }
    }
  }
  ```
</CodeGroup>

## Budgets

Set a [monthly budget](/organization/billing#monthly-budget) to receive email notifications as workspace spend approaches the configured amount. If you enforce the budget, Baseten rejects Model API requests after the workspace reaches it. Budget enforcement does not affect dedicated inference or training.

## Usage

Track Model APIs usage with [`GET /v1/model_apis/usage`](/reference/management-api/model-apis/gets-model-apis-token-usage). The endpoint returns input, cached input, uncached input, and output token counts, plus request counts, in `1m`, `1h`, or `1d` buckets. Group or filter results by API key, user, or model. Personal API keys and OAuth credentials are attributed to a user; usage from credentials that are not user-scoped has a `null` user ID.

<CodeGroup>
  ```bash Request theme={"system"}
  curl --get "https://api.baseten.co/v1/model_apis/usage" \
    --header "Authorization: Bearer $BASETEN_API_KEY" \
    --data-urlencode "start_time=2026-08-06T12:00:00Z" \
    --data-urlencode "end_time=2026-08-06T13:00:00Z" \
    --data-urlencode "bucket_width=1h" \
    --data-urlencode "group_by=api_key" \
    --data-urlencode "group_by=user" \
    --data-urlencode "group_by=model"
  ```

  ```json Response theme={"system"}
  {
    "items": [
      {
        "start_time": "2026-08-06T12:00:00Z",
        "end_time": "2026-08-06T13:00:00Z",
        "results": [
          {
            "api_key_prefix": "<API_KEY_PREFIX>",
            "user_id": "<USER_ID>",
            "model": "zai-org/GLM-5.2",
            "input_tokens": 14820,
            "cached_input_tokens": 9200,
            "uncached_input_tokens": 5620,
            "output_tokens": 3200,
            "request_count": 24
          }
        ]
      }
    ],
    "pagination": {
      "has_more": false,
      "cursor": null
    }
  }
  ```
</CodeGroup>

<Note>
  Usage data is available from August 5, 2026 at 20:45 UTC (`2026-08-05T20:45:00Z`). Baseten did not backfill earlier Model APIs usage.
</Note>

You can also track usage as Prometheus metrics in your own observability stack through the [metrics export endpoint](/observability/export-metrics/overview): `baseten_model_api_tokens_total` splits token counts by `token_type` (`uncached_input`, `cached_input`, `output`), and `baseten_model_api_inference_requests_total` counts requests by `status_code`. See [Model API metrics](/observability/export-metrics/supported-metrics#model-api-metrics) for the full label set.

## Next steps

<CardGroup cols={2}>
  <Card title="Inference errors" icon="triangle-exclamation" href="/inference/errors#429-too-many-requests">
    Handle `429 Too Many Requests` and other status codes.
  </Card>

  <Card title="Model APIs overview" icon="layer-group" href="/inference/model-apis/overview">
    Review supported models and features.
  </Card>
</CardGroup>
