TemprTempr
Docs
Gateway API

Authentication & virtual keys

Last updated

Every Gateway request is authenticated with a virtual key: a scoped credential you create in the Portal, never your raw provider key.

Send your virtual key as a standard bearer token:

Authorization: Bearer tvk_xxxxxxxxxxxxxxxxxxxxxxxx

On /v1/messages you can send the key in the x-api-key header instead, which is what clients built on Anthropic's SDK send.

Virtual keys are always prefixed tvk_, stored hashed (never recoverable after creation), and shown to you exactly once at creation time in the Portal.

Your own credentials: a plan login or a plan's key

You can also send the virtual key in its own header, x-tempr-key. Authorization (or x-api-key) is then left for a credential of your own, which Tempr forwards to the provider it belongs to instead of using a stored key:

x-tempr-key: tvk_xxxxxxxxxxxxxxxxxxxxxxxx
Authorization: Bearer <your Claude Code login, or a coding plan's key>
  • A Claude plan login. Claude Code signed in with a Claude Pro, Max, Team or Enterprise plan sends its login this way when you set only ANTHROPIC_BASE_URL and put the key in ANTHROPIC_CUSTOM_HEADERS (see the Claude Code guide). On /v1/messages, an Anthropic model goes to Anthropic on the login, so your plan pays rather than an API key, and you don't need an Anthropic key stored in Tempr.
  • Your own Anthropic API key (sk-ant-…) works the same way, and that key's account is billed.
  • A coding plan's key (Z.AI, Kimi, MiniMax and the others) goes to that plan for a model the plan serves, such as zai-coding/glm-5.3, on chat completions, /v1/messages and /v1/responses, and the plan pays.
  • A ChatGPT plan login works on Codex's own route, /backend-api/codex, not here; see the Codex CLI guide.
  • Other providers' models use your stored keys as usual. A credential only ever goes to the provider it belongs to.

Tempr forwards the credential with that one request and never stores or logs it. Your key's limits, guardrails, sessions and request logs still apply; the log records the tokens and, for a plan login, what they would have cost at API prices, with a cost of $0. The LLM guardrail check and response caching don't run on these requests. Personal keys accept your own credentials by default. Organization keys accept them once an owner or admin turns on Plan logins, since a plan login moves billing onto each member's own plan. Every plan, side by side: Your AI plans.

What a virtual key scopes

LimitWhat it controls
Model allowlistWhich provider/model values this key is allowed to call. A request naming a model outside the allowlist is rejected before it reaches a provider.
BudgetA maximum spend for the key, tracked against provider cost as computed from usage.
RPM / TPMRequests-per-minute and tokens-per-minute ceilings, enforced independently of your plan's overall rate limit.
Fallback chainsAn optional ordered list of provider/model candidates the key falls back to on error. See fallback chains.
ExpiryA date after which the key stops working, for a contractor's or a CI job's key. An expired key gets 401 key_expired; extend it in the Portal to keep using it.
IP allowlistThe addresses or CIDR ranges (for example 203.0.113.7 or 10.20.0.0/16) the key may be used from, up to 50. A request from anywhere else gets 403 ip_not_allowed. Leave it empty to allow any address.

Personal vs. organization keys

A key belongs to either your personal account or, if you're part of a Teams organization, a shared org pool with per-member limits set by an admin. Both kinds work identically against the API; ownership only affects who can see and manage the key in the Portal.

Revoking a key

Revoke a key from the Portal at any time. Revocation is immediate: in-flight requests already accepted may complete, but no new request will authenticate with a revoked key.

Auth errors

A missing, invalid, or revoked key returns 401 with an authentication_error before anything else about the request is checked. The full list of codes is in the error reference.

{
  "error": {
    "message": "This virtual key is invalid or has been revoked. Create one at https://portal.temprhq.io/gateway/keys, or sign up free at https://portal.temprhq.io/account/register if you don't have an account.",
    "type": "authentication_error",
    "code": "invalid_api_key",
    "doc_url": "https://temprhq.io/docs/gateway-errors#invalid_api_key"
  }
}