Skip to content
Opod

Endpoints

API keys

Mint and revoke endpoint API keys, require them, bound the age of the auth snapshot, and revoke a key with the control plane down.

An endpoint API key (sk-orc-…) is the right to call one endpoint. The control plane mints it, keeps only its hash, and pushes the hashes to the endpoint's leader in an auth snapshot: a file in the endpoint's Secret, mounted in the leader pod. The leader checks keys from that file. No request waits on the control plane.

A key is an identity, not a budget. It carries no rate limit, quota or model allowlist. Per-user and per-team limits are the job of the gateway in front of the endpoint. See Gateways in front.

In short

An endpoint key is the password a client sends to call one endpoint. You mint it once, store it, and give it to one app or one gateway. Until you turn on Require keys, the endpoint takes calls with no key at all. The leader checks keys itself, so keys keep working, and a revoke still lands, while the control plane is down.

When you need it

  • Before anyone outside your team can reach the endpoint: mint a key, then require keys.
  • When a key leaks or an app is retired: revoke it.
  • When the control plane is down and a key must stop now: revoke it with --direct.
  • When a batch must yield to live traffic: give its key class: sheddable (see Routing → Admission).

Do it

  1. Mint a key

    opodcp key create --endpoint chat --expires-in 720h --cp https://cp.example.com --token <token> ci-bot > ci-bot.key

    stderr shows the key's id (k_…) and its expiry. stdout, here the file, holds only the key (sk-orc-…). The control plane never shows it again.

  2. Require keys on the endpoint

    curl -s -H "$H" -H 'Content-Type: application/json' -X PUT \
      https://cp.example.com/api/v1/endpoints/<id>/auth -d '{"requireKeys": true}'
  3. Give the key to the client

    The client sends Authorization: Bearer sk-orc-<key>. In the OpenAI SDK, that is api_key="sk-orc-<key>".

  4. Revoke it when it is no longer needed

    opodcp key revoke --endpoint chat k_3f9a1c2b7d4e

    The leader refuses the key within about a minute.

Check it worked

curl -s -H "$H" https://cp.example.com/api/v1/endpoints/<id>/auth | jq '{requireKeys, activeKeys, stale: .snapshot.stale}'
# {"requireKeys": true, "activeKeys": 1, "stale": false}

Then call the endpoint twice from a pod in the cluster: with the key it answers 200, without it 401. The console's API keys page lists the key as active, and a revoked one as revoked.

If it fails

SymptomCauseFix
PUT …/auth answers 400the endpoint has no active key (an endpoint key, or a route key that lists it)mint a key first
PUT …/auth refused E-VERTEX-KEYSthe plan serves the keyless Vertex AI routesturn exposure.vertex off first
A minted key gets 401it expired, it was revoked, or it belongs to another endpointread GET …/keys; mint a new key
A revoked key still worksthe leader has not synced its snapshot yetwait about a minute; check snapshot.revision in GET …/auth
Keyed calls get refused after a long control-plane outageauth.maxSnapshotAgeSec is set and the snapshot passed itbring the control plane back; it re-issues the snapshot
400 on create naming rpmLimit or another limit fieldkeys carry no limits (0.3.0)set limits in your gateway
opodcp key revoke fails with the control plane downthe API cannot be reachedadd --direct and a kubeconfig. From the release after 0.3.6 the error ends with the exact --direct command; 0.3.6 printed only the dial error

Mint a key

opodcp key create --endpoint chat --expires-in 720h --cp https://cp.example.com --token <token> ci-bot
opodcp key create --endpoint chat --no-expiry litellm

The CLI prints the key id and expiry on stderr and the key alone on stdout. It sets a name and an expiry; for class or team, use the API.

The answer is 201 and carries the plaintext key once, beside the key record. You need the operator role. In 0.3.0, a machine token with scope tokens:write may mint and revoke keys too.

{ "id": "k_3f9a1c2b7d4e", "endpointId": "…", "name": "ci-bot", "prefix": "sk-orc-XXXXX…",
  "expiresAt": "2026-12-31T00:00:00Z", "createdAt": "…", "createdBy": "…",
  "class": "standard", "team": "search", "state": "active", "key": "sk-orc-<printed once>" }
FieldDefaultMeaning
name—required: a label for people, at most 64 characters
expiresAt90 days from nowan RFC 3339 time in the future; the leader enforces it locally
noExpiryfalsea key that never expires, as an explicit choice recorded on key.created; not with expiresAt
classstandardcritical, standard or sheddable: how the key's requests rank when the endpoint is full
teamnoneat most 64 characters; makes the key one flow with every other key of that team, for fair share and cache isolation

In 0.3.0 any other field is refused 400, and a limit field (rpmLimit, tpmLimit, quotaDailyTokens, allowedModels) gets a message that says keys carry none; 0.2.1 ignores unknown fields. Class and team are set at creation; to change them, mint a new key.

Require keys

A new endpoint accepts any caller until you require keys. Turn it on with the Require keys switch on the Connect card, or:

curl -s -H "$H" -H 'Content-Type: application/json' -X PUT \
  https://cp.example.com/api/v1/endpoints/<id>/auth -d '{"requireKeys": true}'

It is refused 400 while the endpoint has no active key (an endpoint key, or a route key of an auto route that lists it), and, from 0.3.0, while the plan serves the keyless Vertex AI routes (E-VERTEX-KEYS). The control plane's own calls and the console's proxy use the endpoint's admin token, so requiring keys never locks an operator out.

Clients send the key as Authorization: Bearer sk-orc-<key> (or X-Api-Key).

Revoke a key

opodcp key revoke --endpoint chat k_3f9a1c2b7d4e
curl -s -H "$H" -X DELETE https://cp.example.com/api/v1/endpoints/<id>/keys/<kid>

Revoke by the key's id (k_…), never by the plaintext key. The route answers 200 with the record, now state: revoked. The leader refuses the key on its next snapshot sync, within about a minute. The revocation is written as a tombstone (revokedKeys in the snapshot) as well as by dropping the key, so no later writer can bring it back.

Revoke a key with the control plane down

Revocation is delivered by the cluster, not by the control plane. With only a kubeconfig:

opodcp key revoke --direct --endpoint chat --kubeconfig ~/.kube/config --namespace opodcp k_3f9a1c2b7d4e

--direct takes the key's id or its name. It finds the endpoint's auth Secret by its labels (opod.io/endpoint=<name>,opod.io/role=auth), appends the tombstone, stamps a new snapshot revision and keeps every other field. A key already revoked there writes nothing. --endpoint-id picks one endpoint when two of one name have a Secret; --secret <name> names the Secret directly. When the control plane returns it keeps the tombstone, marks the key revoked and publishes key.revoked.

The same edit with kubectl and jq:

S=$(kubectl -n opodcp get secret -l opod.io/endpoint=chat,opod.io/role=auth -o name)
kubectl -n opodcp get "$S" -o jsonpath='{.data.auth\.json}' | base64 -d \
  | jq -c --arg k <key-id> '.revokedKeys = ((.revokedKeys // []) + [$k] | unique)' > auth.json
kubectl -n opodcp patch "$S" --type merge -p "{\"data\":{\"auth.json\":\"$(base64 < auth.json | tr -d '\n')\"}}"

The RBAC either path needs:

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata: { name: opodcp-key-revoker, namespace: opodcp }
rules:
  - apiGroups: [""]
    resources: [secrets]
    verbs: [list, get, update, patch]

A tighter grant names the endpoint's Secret with resourceNames and drops list; then use --secret.

The snapshot's age

By default a leader serves from whatever snapshot it holds, for as long as it holds it (fail-static). The control plane re-issues an unchanged snapshot hourly. If revocation matters more than availability during a control-plane outage, set a bound in the endpoint's policy:

curl -s -H "$H" https://cp.example.com/api/v1/endpoints/<id>/policy > policy.json   # read it first
jq '.auth.maxSnapshotAgeSec = 3600' policy.json > new.json
curl -s -H "$H" -H 'Content-Type: application/json' -X PUT \
  https://cp.example.com/api/v1/endpoints/<id>/policy -d @new.json

Send the whole policy back: a PUT that leaves out routing.fallbackUrl clears the fallback. See Routing policy.

maxSnapshotAgeSec is 0 (fail-static) or 600 to 2,592,000 (30 days). Past it, the leader refuses keyed traffic and says why. The control plane then re-issues every third of the bound.

GET /api/v1/endpoints/{id}/auth shows the gate:

{ "requireKeys": true, "activeKeys": 2, "routeKeys": 1,
  "snapshot": { "revision": "…", "issuedAt": "…", "ageSec": 1260, "maxSnapshotAgeSec": 3600,
                "keys": 3, "revokedKeys": 1, "stale": false, "readAt": "…" } }

routeKeys counts the usable route keys that open the endpoint; it is new in 0.3.0. stale is true when a bound is set and the snapshot is past it. snapshot.error is the last write that failed; snapshotError says why the Secret could not be read. The doctor row auth-snapshots names every endpoint whose snapshot is past its bound.

List keys

RouteAnswers
GET /api/v1/keysevery key of the cell the caller may see; a team-scoped caller sees its team's endpoints' keys
GET /api/v1/endpoints/{id}/keysone endpoint's keys: id, name, prefix (the first 12 characters), expiresAt, createdAt, createdBy, revokedAt, state (active, revoked, expired), class, team

Hashes are never returned.

Keys for the cell door's auto routes

Route keys are new in 0.3.0. An auto route on the cell door lists several endpoints. A route key is accepted by every endpoint the route lists, so a fallback is not a 401: POST /api/v1/door/auto-routes/{name}/keys (admin, the same body as an endpoint key), GET to list, DELETE …/keys/{kid} (operator) to revoke. A route key's record carries autoRoute and no endpointId. Usage stays with the endpoint that served. Removing a route revokes its keys. See Routing policy.

Test a key through the control plane

The proxy route POST /api/v1/endpoints/{id}/gateway/{path} sends the endpoint's admin token by default. To test what a customer sees, add X-Opod-Endpoint-Key: sk-orc-<key> (forwards that key) or X-Opod-Endpoint-Key: - (forwards none). The Playground offers the same choice.

Last updated · Source: content/docs/control-plane-endpoints/api-keys.mdx · View as Markdown