# API keys and authentication (https://inference.net/docs/api-keys)

## Manage API keys

Create and revoke keys on the [API keys](/dashboard/api-keys/) page of the
dashboard.

1. Open [API keys](/dashboard/api-keys/) and choose **Create key**.
2. Give the key a recognizable name.
3. If you hold an active Inference Pass plan in the selected team, the dialog
   defaults to creating a [plan key](#plan-keys). Team owners and admins can
   switch **Uses** to the team's **API credits** option (`<Team> API credits`)
   to create a credit-billing key instead (required for async, Group, Batch,
   Files, gateway passthrough, and platform/MCP write routes). Other members
   with an active plan can create plan keys only; ask an owner or admin for a
   credit-billing key if you need those routes.
4. Copy the key. The dashboard shows the plaintext key once; store it in your
   password manager or secret store before closing the dialog.

To revoke a key, use its action in the keys table. Requests using a revoked key
stop working immediately.

### Per-key spend limits

Team owners and admins can set or clear an optional USD inference spend cap on
any API key via `PUT /api-keys/{apiKeyId}/spend-limit`, tRPC
`apiKey.setSpendLimit`, or the MCP tool `api_key_set_spend_limit` (all require
a Better Auth user-session token with `team:update` permission; header API keys
and MCP OAuth project grants are not accepted):

- Send `{ teamId, spendLimitUsd, window }` with a minimum cap of `$0.01` and
  `window` set to `"day"` or `"month"` (UTC).
- Send `null` for both `spendLimitUsd` and `window` to remove the limit.
- API key responses include `spendLimitUsd` and `spendLimitWindow` (`null` when
  uncapped).
- Enforcement is soft: spend is read from usage rolled up approximately every 10
  minutes plus several minutes of edge verdict caching, so a key can overshoot
  its cap by whatever it spends within that combined lag. Other keys on the team
  keep working.

### API key spend-limit errors

When an API key's spend in its current UTC window reaches its cap, new
proxy-routed synchronous and asynchronous inference requests with that key fail
with HTTP `402` and `error.type: "ApiKeySpendLimitExceeded"`. Requests succeed
again when the UTC day or month resets, or after a team admin raises or clears
the cap via `PUT /api-keys/{apiKeyId}/spend-limit`. Enforcement is soft
(approximately 10 minutes of usage rollup lag plus several minutes of edge
verdict caching), completed requests are always billed, and Batch API
submissions are not currently gated by per-key spend limits.

The [`fast` CLI](/docs/cli/) creates its own project-scoped key, named for your
machine, the first time you connect a coding agent.

## Project scoping

API keys are scoped to a project. Select a team and project using the pickers at
the top of the dashboard before creating a key. The key you use determines which
project's resources you interact with — custom models, deployments, datasets,
evals, batch jobs and batch files, and observability metrics — and usage made
with it is reported for that project. Batch jobs and batch files created before
project scoping are not assigned to a project and remain visible to all keys in
the team. If no valid project selection is saved for that team in this browser,
the dashboard selects its first available project. See
[Getting started](/docs/getting-started/#understand-project-scope).

## Permissions

When creating an API key, you can grant **read** access, **write** access, or
both (for example, a read-only key for pulling metrics, or a key with write
access for uploading datasets and running evals). Keys created through the
quick-create flow on [API keys](/dashboard/api-keys/) receive **read** and
**write** access by default; use the platform key settings when you need to
restrict a key to read-only or write-only permissions.

## Authentication

Pass the key as a Bearer token in the `Authorization` header (or as `x-api-key`
for Anthropic-compatible clients when `Authorization` is not set; `Authorization`
takes precedence if both are sent), or set it as the API key in whichever SDK you use:

```bash
curl https://api.inference.net/v1/chat/completions \
  -H "Authorization: Bearer $INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.2",
    "messages": [{ "role": "user", "content": "Hello" }]
  }'
```

A key that bills API credits works across every endpoint:

- **Synchronous API:** `https://api.inference.net/v1`, including the
  Anthropic-compatible `/v1/messages` endpoint
- **Asynchronous API:** [`/v1/slow`](/docs/api/async/overview/) and the
  [Group API](/docs/api/async/group/)
- **Batch API:** [`https://batch.inference.net/v1`](/docs/api/async/batch/)
- **Generation results:** `/v1/generation/{id}`
- **Webhooks:** asynchronous requests that reference a
  [webhook](/docs/api/async/webhooks/) registered for your team

### Plan keys

If you have an Inference Pass plan, a key created for the plan draws from the
plan's usage allowance first (and only draws from prepaid API credits if your
team enables prepaid overage and the allowance is used up). Plan keys work only
on interactive requests to models included in your plan:

- `POST /v1/chat/completions`, `/v1/completions`, `/v1/embeddings`,
  `/v1/responses`, and `/v1/messages` (plus `/v1/messages/count_tokens`)
- `GET /v1/models`, `/v1/generation/{id}` (or `/v1/generations/{id}`), and
  `/v1/usage`

`GET /v1/usage` returns the plan's usage without using the allowance. It is
rate-limited to 60 requests per minute per API key (exceeding the limit returns
`429` with `error.code` `usage_rate_limit` and a `Retry-After` header) and
responds with `Cache-Control: private, max-age=5`:

```json
{
  "object": "plan_usage",
  "plan": { "plan": "pro" },
  "allowances": [
    {
      "id": "usage",
      "window": "week",
      "used_percent": 42.5,
      "status": "ok",
      "resets_at": "2026-12-01T00:00:00.000Z",
      "period_start": "2026-11-24T00:00:00.000Z"
    }
  ],
  "overage": {
    "enabled": true,
    "spent_usd": 12.5,
    "cap_usd": 100,
    "cap_used_percent": 12.5,
    "hosted_mode": "full_speed"
  },
  "alert_thresholds_percent": [80, 100],
  "in_flight": { "limit": 2, "in_use": null },
  "lane": "full_speed",
  "dashboard_url": "https://inference.net/plans"
}
```

- `window`: `week` or `month`.
- `status`: `ok`, `warning` (80% or more used), or `exhausted`.
- `overage`: `null` when overage is disabled; otherwise an object with
  `enabled`, optional `paused` (`true` alongside `enabled: false` when prepaid
  overage is temporarily paused platform-wide), `spent_usd` (current UTC
  month), `cap_usd`, `cap_used_percent`, and `hosted_mode` (`slow_lane` or
  `full_speed`).
- `alert_thresholds_percent`: the usage alert thresholds (in percent) active for
  the plan.
- `in_flight.limit`: how many full-speed requests can run at once.
  `in_use` is always `null`.
- `lane`: the lane a new request to an Inference.net-hosted model would get,
  with open requests left out: `full_speed`, `slow`, or `refused` (including
  full-speed prepaid overage when enabled, funded, and within cap). Requests
  already in flight can still send it to the slow lane or refuse it with
  `concurrency_limit`, and partner-served models follow their own limits.

Model responses to a plan key carry these headers. Browsers can read them (they
are listed in `Access-Control-Expose-Headers`):

| Header                                 | Value                                                                                                                                                                      |
| -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `x-inference-plan`                     | The plan: `starter`, `pro`, or `fleet`.                                                                                                                                    |
| `x-inference-plan-lane`                | The lane the request ran in: `full_speed` or `slow`. `refused` or `rejected` when the request did not run.                                                                 |
| `x-inference-plan-funding`             | How the request was funded when admitted: `plan` (included plan allowance) or `overage` (prepaid API credits).                                                             |
| `x-inference-plan-used-percent`        | Allowance used this period, `0` to `100`, to one decimal place.                                                                                                            |
| `x-inference-plan-resets-at`           | When the allowance resets, as an ISO 8601 UTC timestamp.                                                                                                                   |
| `x-inference-inflight-limit`           | How many full-speed requests can run at once.                                                                                                                              |
| `x-inference-inflight-remaining`       | Full-speed capacity still free, when an in-flight count is available (can be omitted for hosted slow-lane responses and included for successful partner-served responses). |
| `x-inference-overage-spent-usd`        | Included on overage-funded responses and overage `402` refusals (omitted on plan-funded responses and when overage is paused): your monthly prepaid overage spend in USD (e.g. `12.50`) for the current UTC month. |
| `x-inference-overage-cap-used-percent` | Included on overage-funded responses and overage `402` refusals (omitted on plan-funded responses and when overage is paused): percentage of your monthly overage cap used (`0` to `100`, one decimal place). |

When streaming usage reporting is enabled, final usage SSE events on
streaming `/v1/chat/completions`, `/v1/responses`, and `/v1/messages` responses
also include an additive `inference_plan` object:

```json
{
  "inference_plan": {
    "used_percent": 42.9,
    "resets_at": "2026-12-01T00:00:00.000Z"
  }
}
```

- `inference_plan.used_percent`: provisional cumulative allowance percentage
  used after this request (`0` to `100`, one decimal place).
- `inference_plan.resets_at`: when the allowance resets (ISO 8601 UTC).
- On `/v1/chat/completions`, `inference_plan` appears on the terminal chunk (or
  usage-only final chunk when `stream_options.include_usage: true` is sent). On
  `/v1/responses`, it appears on `response.completed` and `response.incomplete`.
  On `/v1/messages`, it appears on `message_delta`. Values are provisional
  estimates computed at the edge; authoritative settled usage is shown on
  `GET /v1/usage` and the Plan usage page.

Requests to Inference.net-hosted models run at full speed while the allowance
lasts and full-speed capacity is free. Once the allowance is used up, they run in
the slow lane at lower priority by default — or stay at full speed billed to
prepaid API credits if your team enables overage, allows full-speed hosted
overage, you choose **Full speed** in your overage preferences, and both cap
headroom and prepaid credit balance remain. Partner-served models have no slow
lane: when the allowance is used up, they continue at full speed on prepaid API
credits if overage is enabled with remaining cap and credit balance, and
otherwise stop with `402`. Plan keys also count against your team's
[rate limits](/docs/rate-limits/).

Plan key errors carry a machine-readable `error.code`:

| Status | `error.code`                     | Retry                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ------ | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `402`  | `usage_limit`                    | No while exhausted. Partner-served models only: settled usage has reached the plan's allowance or partner-model limit and prepaid overage is not enabled. `error.type` is `usage_limit_reached`, there is no `Retry-After`, and `x-should-retry` is `false`. Requests work again at `x-inference-plan-resets-at`, or once overage is enabled. Inference.net-hosted models keep running in the slow lane. |
| `402`  | `overage_cap_reached`            | No until next UTC month or cap increase (`error.type` is `usage_limit_reached`, `x-should-retry` is `false`, no `Retry-After`). Your monthly member overage cap or the team's monthly overage cap has been reached.                                                                                                                                                                                                                                                                                                                                                                   |
| `402`  | `overage_no_credit`              | No until prepaid credits are added (`error.type` is `usage_limit_reached`, `x-should-retry` is `false`, no `Retry-After`). Prepaid overage is enabled, but the team has no available prepaid credit balance.                                                                                                                                                                                                                                                                                                                                                                            |
| `429`  | `usage_rate_limit`               | Yes, after `Retry-After`. `GET /v1/usage` exceeded 60 requests per minute for this API key.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `429`  | `concurrency_limit`              | Yes, after `Retry-After`. Too many requests in flight, or for partner-served models while remaining allowance is temporarily held by concurrent or recently finished unmeasured requests (for up to 60 seconds while usage settles). |
| `429`  | `slow_lane_paused`               | Yes, after `Retry-After`. Inference.net-hosted models only: the request needed the slow lane (allowance used up, full-speed capacity busy, or the plan is limited to the slow lane), and the slow lane is paused.                                                                                                                                                                                                                                                                                                                                                                       |
| `429`  | `slow_lane_busy`                 | Yes, after `Retry-After`. The slow lane has no spare capacity.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `403`  | `plan_restricted`                | No (`x-should-retry` is `false`, no `Retry-After`). The plan is limited to the slow lane, which partner-served models do not have; switch to an Inference.net-hosted model.                                                                                                                                                                                                                                                                                                                                                                                                             |
| `402`  | `payment_past_due`               | No (`x-should-retry` is `false`, no `Retry-After`). Partner-served models only: the team's Inference Pass payment is past due and its grace period ended. Pay in billing settings or switch to an Inference.net-hosted model, which keeps working at reduced speed.                                                                                                                                                                                                                                                                                                                   |
| `403`  | `plan_inactive`                  | No. The plan ended or is paused, or the key's plan is no longer active in the team.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `403`  | `model_not_in_plan`              | No. Your plan does not include the model.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `403`  | `plan_route_not_supported`       | No. The asynchronous, Group, Batch, and Files APIs. Use a key that bills API credits.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `403`  | `plan_passthrough_not_supported` | No. Requests that bring your own provider credentials or route to an external provider.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `403`  | `plan_feature_not_supported`     | No. Auto-train requests.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `404`  | `no_plan`                        | No. `GET /v1/usage` with a key that has no active plan.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `500`  | `plan_model_mismatch`            | No. The request's model changed after it was admitted.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

The `429` errors in this table have `error.type` `rate_limit_error`. Other
`429` errors a plan key can get, such as `capacity_exceeded` from a busy model,
keep their own type.

If the team's Inference Pass payment is past due, plan keys keep full service
for a short grace period. After that, requests to partner-served models return
`402` with `payment_past_due` (`x-should-retry: false`, no `Retry-After`), and
Inference.net-hosted models keep working at reduced speed. If the payment is
still not made, the plan is suspended: model requests return `403` with
`plan_inactive`, `GET /v1/usage` returns `404` with `no_plan`, and
`POST /v1/messages/count_tokens` still answers because it uses none of the
allowance. A team owner or admin can update the payment method in the team's
billing settings.

Clients built for the Anthropic API can send the key via `x-api-key`
(`ANTHROPIC_API_KEY`) or as `Authorization: Bearer` (`ANTHROPIC_AUTH_TOKEN`). If
both headers are sent, `Authorization` takes precedence for Inference auth;
`x-api-key` is stripped on Inference.net-hosted requests, and on
external-provider (BYOK) gateway requests it is forwarded unchanged unless a
provider credential replaces it.

### My plans

Open [My plans](/plans/) to see each plan you hold: usage,
reset and end dates, lane, and its keys. Personal and team plans are separate
allowances.

To buy a plan for yourself:

1. Open [My plans](/plans/) and pick a plan.
2. If you manage a company team, choose **For me (billed to you personally)**.
3. Confirm the price and pay. The plan is billed to your Personal team.

To change your personal plan, pick another plan in **Change plan** on the plan.
You can upgrade each plan once per usage-reset period (weekly or monthly,
depending on the plan). An eligible upgrade starts at once and charges the
difference for the rest of the billing period. A downgrade starts at the next
renewal.

To cancel your personal plan, click **Cancel plan** and confirm. The plan stays
active until the end of the paid period, with no refund. Until then,
**Undo cancel** keeps it.

To create a plan key:

1. Open [My plans](/plans/).
2. On the plan, click **Create key**.
3. Copy the key. It is shown once.

A plan key uses the plan's allowance. Any other key in the team bills API
credits. Use a credits key for requests a plan key does not support.

If you leave a team or are removed from it, your plan in that team ends and
your keys for that team stop working.

#### Plan usage and overage preferences

Open **Plan usage** from [My plans](/plans/) to inspect your
allowance meter, browse past billing periods, view a by-model breakdown, and
page through your recent request history (timestamps, models, lanes, billing
source, and overage USD when applicable).

When your team enables prepaid overage, the **Overage preferences** panel on
**Plan usage** shows your monthly spend against your monthly overage cap and
lets you choose how Inference.net-hosted models behave after your included
allowance runs out: **Slow lane** (stay at $0 extra cost) or **Full speed**
(continue at full speed billed to the team's prepaid credits, when your team
allows full-speed hosted overage).

### Manage team plans

Owners and admins see each member's plan and its usage in
**Settings → Members**. Each member's row has a **Plan** select:

- **Give a plan**: pick a plan for a member without one and confirm. The
  team reuses a plan it already paid for this period when it has one;
  otherwise the team is charged for a new plan.
- **Change a plan**: pick another plan. You can upgrade each plan once per
  usage-reset period (weekly or monthly, depending on the plan). An eligible
  upgrade starts at once and charges the difference; a downgrade starts at the
  next renewal.
- **Take a plan away**: pick **No plan** and confirm. The member's plan keys
  stop using the plan at once. The plan itself runs to the end of the current
  billing period.

An owner's plan can be changed or taken away only by that owner. A pending
change shows on the row with **Undo** until it starts.

To invite someone with a plan, click **Invite**, enter the email, and pick a
plan in **Plan**. When the team has no reusable plan, the invitation is sent
after payment.

#### Team overage and monthly statements

Only team owners and admins can configure team overage or open monthly
statements:

- **Team overage controls** (open **My plans → Team statements**, then use
  **Team overage controls**): turn prepaid overage on or off for the team, set a
  monthly team overage cap and default per-member monthly cap, set optional
  per-member cap overrides, and choose whether members may opt into full-speed
  overage on Inference.net-hosted models. Overage charges are deducted from the
  team's prepaid credit balance and reset on the 1st of each UTC month.
- **Team statements & overage**: open **My plans → Team statements** to review
  an itemized monthly statement combining prorated member plan subscriptions and
  per-member overage spend, and download the statement as **CSV** or **PDF**.

To buy plans for several people with one payment, add a row per person, each
with a plan, when you create a team. On inference.net you can do the same for
an existing team: open [My plans](/plans/), pick a plan,
and choose **For people in** your team. On platform.inference.net, give each
member a plan from their row in **Settings → Members**.

If sales are sold out or paused, you cannot buy a new plan. When the waitlist
is available, join it for your team. If fewer plans are available than you
request, you can buy the available plans and join the team waitlist for the
rest. People added beyond the available plans during team creation receive
invitations without a plan. Joining the waitlist holds your team's place in
line; it does not buy, reserve, or give anyone a plan. Give those people plans
after your team buys them.

During the limited sale a team can hold up to 5 plans. Members and Billing show
how many the team holds (for example, "3 of 5 plans"). At the limit, buying,
inviting with a new plan, and giving a plan that is not reusable are off.
[Contact sales](/sales/) for more.

Plan billing actions (buying, giving, inviting with a plan, changing plans, and
previewing prices) are rate-limited to 30 requests per user per action per
minute. If you receive `Too many plan billing requests`, wait up to a minute and
retry. See [Plan billing rate limits](/docs/rate-limits/#plan-billing-rate-limits).

## Best practices

- Keep API keys out of source control.
- Rotate keys periodically.
- Store keys in environment variables in your application.