Get 6% back at Conifer with an ernd card
SectionsAPI keys and teams

Gateway

API keys and teams

Give each client a key of its own, hold it to what it needs, and share a workspace with your team.

An API key is how a request proves it may use a workspace’s models and balance. This page covers making, limiting, rolling and revoking keys, the headers a key is sent in, and the people who share a workspace.

Create a key

In the console, open API keys and choose Create key. Only the workspace’s owner and its editors can make keys. The key is shown once, in full; the gateway keeps only a fingerprint of it, so it can’t show it again. Keep it in an environment variable, out of your code.

terminal
export CONIFER_API_KEY="sk-cg-…"

A key starts with sk-cg- and is 55 characters long. Keys made before that shape, starting cr_live_ or cr_test_, still work. The dialog asks for these:

FieldWhat it sets
NameWhat you call the key.
KindLive or Test. The kind is a label: both reach the same models and spend the same balance.
AccessFull, Restricted or Read only, below.
Routers, ModelsFor a restricted key, the routers and models it may call.
Allowed addressesThe IP ranges a request may come from, up to 100.
Spend limitDollars a calendar month, in UTC, up to $1,000,000, past which no new request starts.
At the limitBlock requests, or Cheapest models only.
Rate limitRequests a minute, a million at most. None means no limit.
ExpiresWhen the key stops working.

Access

AccessIn the console’s wordsWhat it means
FullEvery router and model.The key can call anything the workspace can.
RestrictedOnly the routers and models listed.Up to 100 routers and 100 models, by id or alias. Anything else answers 403 forbidden.
Read onlyNo model: it reads.Any route that sends to a model answers 403 forbidden, “This key only reads: it can’t send requests to models.” GET /v1/balance takes only a key like this.

A router a restricted key lists serves its whole pool, and with manual-router the key may send only the models it lists. A read-only key reads the whole workspace’s usage and requests (GET /v1/usage, GET /v1/requests); a key that sends requests reads only its own.

Limits

Each limit answers in a way a client can act on. The errors page lists every code.

  • Allowed addresses. A request from outside the key’s ranges answers 403 forbidden, naming the address the gateway saw.
  • Spend limit. A new request starts only where what is left of the month covers what the key’s requests already running usually cost, this one with them, as the balance does. One already running when the limit is reached runs to its end and is charged in full, so a month can end a little past its limit. With Block requests, a request the month can’t take answers 429 spend_limit_reached with x-should-retry: false, until the month ends or the limit is raised; where what is left is set aside for the key’s requests already running, it answers 429 with retry-after: 1 instead. With Cheapest models only, a request through a router goes on past the limit, to the cheapest model the router allows, as far as the balance goes, and its answer says moved_for_spend_limit; one that names a model still answers 429.
  • Rate limit. A limit of L requests a minute lets L through at once, then one every 60/L seconds. Past it a request answers 429 rate_limited, with retry-after saying how many seconds to wait.
  • Expires. After it, the key answers 401 invalid_api_key, as a revoked or mistyped key does.

A change to a key reaches every server within a second.

Send the key

OpenAI’s SDKs send the key as Authorization: Bearer sk-cg-…, and Anthropic’s as x-api-key: sk-cg-…. An api-key header is also read. When a request sends more than one, Authorization wins, then x-api-key.

A missing or wrong key answers 401 invalid_api_key, “The API key is missing or isn’t valid.”

Roll or revoke a key

On the API keys page, Roll key issues a new key in place of the old one, shown once, as a new key is. The old key goes on working for a grace period, so whatever uses it can move to the new one: under Old key stops working, choose Now, 1 hour (the default), 24 hours or 7 days. Rolling again while an older key is still in its grace period stops that one at once.

Revoking a key stops it on every server within a second; a request that sends it then answers 401. Owners and editors can change and revoke keys.

Workspaces and people

A workspace has its own API keys, balance and people. A new account has none: you make one in the console, or open a link to join one you were sent.

Each person in a workspace has one role. These are the console’s own words:

RoleWhat it may do
OwnerEverything, including billing, people, handing the workspace over and deleting it. One per workspace.
EditorMakes and deploys routers, makes, changes and revokes API keys, manages billing, and reads all a viewer does.
ViewerRead only.

The owner invites people from the Team page, with Invite. The workspace’s name, its ID, handing it over and deleting it are under Settings.

A key’s spend limit holds one key. What the workspace spends is paid from its balance, which Billing covers, along with the workspace’s own provider keys. To read what Conifer Gateway itself is, see its page.