Management API Keys

Programmatic credentials for managing your AnyRouter account — keys, presets, BYOK, and credits.

Management keys (ak_…) administer your account from scripts and CI without your dashboard password: LLM keys, presets, BYOK providers, credits and your own management keys.

Send a management key as a Bearer token (Authorization: Bearer ak_live_…). It is not for inference; to call /api/v1/chat/completions or /api/v1/messages, use an LLM key (sk-ar-…) from /dashboard/keys.

Two kinds of keys

Key typePrefixPurposeWhere to manage
LLM API keyssk-ar-Send chat, messages, embeddings, image, and responses requests/dashboard/keys
Management API keysak_Programmatically manage your account: list/create/revoke LLM keys, configure BYOK, read credits/dashboard/settings#keys

Request

Create a key in the dashboard (Create key, name, scopes; the secret is shown once), or with a session-authenticated request:

FieldTypeRequiredDescription
namestringYesHuman-readable key name.
descriptionstringNoFree-text note (e.g. what uses the key).
scopesstring[]YesThe scopes this key grants (see below).
expires_atstringNoISO 8601 expiration timestamp.

Scopes

Scopes are action:resource; write:X implies read:X. Grant the smallest set a key needs.

ScopeGrants access to
read:llm-keysGET /api/v1/keys, GET /api/v1/key
write:llm-keysPOST /api/v1/keys, PATCH /api/v1/keys/{hash}, DELETE /api/v1/keys/{hash}
read:presetsGET /api/v1/presets, GET /api/v1/presets/{slug}
write:presetsPOST /api/v1/presets, PATCH /api/v1/presets/{slug}, DELETE /api/v1/presets/{slug}
read:byokGET /api/v1/auth/byok/...
write:byokPOST/PATCH/DELETE /api/v1/auth/byok/...
read:creditsGET /api/v1/credits
read:analyticsGET /api/v1/analytics/* (read-only; there is no write scope)
read:management-keysGET /api/v1/management-keys
write:management-keysPOST /api/v1/management-keys, DELETE /api/v1/management-keys/{id}
read:artifactsGET /api/v1/artifacts, GET /api/v1/artifacts/{id} and its versions
write:artifactsPOST /api/v1/artifacts, POST /api/v1/artifacts/{id}/versions, PATCH and DELETE /api/v1/artifacts/{id}
read:securityGET /api/v1/security/keys, GET /api/v1/security/ip-allowlist
write:securityPOST /api/v1/security/ip-allowlist, DELETE /api/v1/security/ip-allowlist/{id}

Other routes

Method & pathPurpose
GET /api/v1/management-keysList your management keys. Pass ?include_invalid=true to include revoked/expired keys.
DELETE /api/v1/management-keys/{id}Revoke a key immediately (optional revocation_reason body).

Response

POST /api/v1/management-keys returns the plaintext secret once — store it immediately. Revocation is immediate: the next request with a revoked key returns 401.

Examples

curl -X POST https://anyrouter.dev/api/v1/management-keys \
  -H "Content-Type: application/json" \
  --cookie "__session=<your-session-cookie>" \
  -d '{
    "name": "CI deploy bot",
    "description": "Used by the GitHub Actions deploy workflow",
    "scopes": ["read:credits", "write:llm-keys"],
    "expires_at": "2027-01-01T00:00:00Z"
  }'

BYOK keys

read:byok lists your provider keys; write:byok adds, rotates, donates and removes them.

Method & pathScopePurpose
GET /api/v1/auth/byokread:byokList your keys, grouped by provider.
POST /api/v1/auth/byokwrite:byokAdd a key.
PATCH /api/v1/auth/byok/keys/{keyid}write:byokEdit or rotate one key in place, keeping its id and its pool donation.
POST /api/v1/byok/donatedwrite:byokDonate a key to the shared pool (requires explicit consent in the body).
DELETE /api/v1/byok/donated/{id}write:byokWithdraw a donation — the key goes back to serving only your own requests.

Every key object carries two fields beyond the id, provider, label, and quota:

FieldValuesMeaning
kindbyok, donateddonated while the key is shared with the community shared pool, including while it is temporarily paused; byok when it serves only your own requests. Read-only — it changes when you donate or withdraw, not by editing the key.
sourcecli, dashboard, apiWhich app added the key. api is the default when you don't pass one, and for keys added before the field existed. Set once, at creation.

Pass source when adding a key to tell scripts' keys apart later:

curl -X POST https://anyrouter.dev/api/v1/auth/byok \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{"provider_id": "openai", "api_key": "sk-proj-…", "label": "laptop", "source": "cli"}'

source accepts cli, dashboard, or api; any other value is rejected with 400 source must be 'cli', 'dashboard', or 'api'. The dashboard sends dashboard. The anyr binary doesn't send cli yet, so its keys report api.

{
  "id": "byok_01JQZ…",
  "provider_id": "openai",
  "label": "laptop",
  "key_preview": "sk-p****7c2",
  "enabled": true,
  "route_coverage": "all",
  "kind": "byok",
  "source": "cli"
}

key_preview is masked (first four characters, ****, last three). The key itself is never returned.

Organization-scoped keys

Keys you create while an organization is active are owned by the org: any member with access can use them and revocation is org-wide. Personal keys authenticate only you.

Keep secrets in a secret manager, never in source control. Use the narrowest scopes, set expires_at, and revoke any key you suspect is compromised.

Errors

StatusMeaningFix
401Key invalid, revoked, or expiredCreate a fresh key from the dashboard.
403Key valid but lacks the route's scopeAdd the required scope, or use a higher-scoped key.

AnyRouter routes requests to third-party models. Models and outputs are provided as is, with no warranty; you use them at your own risk. Disclaimer