Command Palette

Search for a command to run...

Authentication

How the bearer header is formed, why a key is only shown once, and how to rotate one without taking your own traffic down.

The header

Every request carries exactly one credential: an `Authorization` header with the `Bearer` scheme, one space, and the key as it was issued — no quotes, no trailing whitespace, no JSON wrapping.

Header
Authorization: Bearer sk-bf-...

The scheme is matched case-insensitively, and the key must match the shape `sk-bf-` followed by letters, digits and dashes. A key sent as a query parameter, a cookie or a custom header is ignored, and the request is refused as unauthenticated.

There is no login call and no token exchange. The key authenticates every request until it is revoked; nothing about it expires on its own.

What a key is, and what it is not

A key identifies two things at once: the account whose balance pays, and the key row that can be revoked. It is not a provider credential — the upstream provider is called with the gateway's own credential, never yours — and it is not a token you can decode. It is an opaque string, matched against a hash.

  • A request without a valid key is refused before a model, a balance or a provider is looked at.
  • Revoking a key takes effect at the next request; there is no grace period and no cached session to expire.
  • A key reaches the inference paths only. The gateway's own management API is never forwarded to, whatever path you send.

Why the key is shown once

The portal stores a hash of the key, and a hash cannot be turned back into the string it came from. That is the whole reason the key appears once, at the moment it is created: after that the site can show you a prefix and nothing more. A database dump is then far less useful than a leaked key.

  • Copy the key while the dialog is open. The list keeps only a prefix, which identifies the key but cannot authenticate.
  • Label keys by where they run — `laptop`, `ci`, `production` — so you revoke the one you meant to.
  • A lost key is revoked and replaced, never recovered. Treat the dialog as the only copy.

One key for work, one for what ships

Routebase keeps two key grades so your own traffic is easy to reason about. Both are the same credential and bill the same, but keeping them apart is what keeps an experiment off a live bill — and what keeps a runaway script out of the traffic your users depend on.

Development — A development key is for work in progress. Point your scripts, tests and local builds at it so production traffic is never mixed in.

Production — A production key is for what ships. It gets the same stable routing and the same per-token billing — the difference is the discipline around it.

Both grades bill the same rate from the same balance. Separate them to keep an experiment off a live bill, not to get a cheaper one.

Two variables, two keys
# .env.local — the development key, safe to rotate oftenIDROUTEBASE_API_KEY=sk-bf-...
# the deployment's secret store — the production keyIDROUTEBASE_API_KEY=sk-bf-...

The point of the split is what a leak costs. If the development key appears in a screenshot or a log, you revoke it and nothing your users depend on goes dark. If the same key were serving production, the same leak would take the product down for as long as a redeploy takes. The values differ; the variable name does not, so code does not change between the two.

Rotation, in order

Two requirements pull against each other: a key must not live forever, and no request may fail because of the change. Creating the new key before revoking the old one resolves both.

  • Create the new key and label it by date, so the pair is identifiable — `production-2026-11`.
  • Deploy it. Both keys are valid at once, which is the only window in which a mistake is free.
  • Watch the old key's **last used** go quiet. When it stays empty, nothing is still calling it.
  • Revoke the old key. Anything still holding it gets `401 invalid_api_key` at its next request.

Rotate on a schedule, not only after an incident: a key that has never been rotated is a key whose age nobody knows. Rotate a development key on any suspicion at all, because doing so costs nothing — that is what makes the habit cheap enough to keep.