/v1 request must carry a credential, normally in the Authorization: Bearer header. The gateway identifies the caller from it (team, workspace, user or service account) and applies that caller’s access rules, limits and budgets.
The gateway reads the credential from
Authorization: Bearer <token>. If that header is absent it falls back to x-api-key, which is what the Anthropic SDK sends by default, so the SDK’s api_key= works unchanged. Authorization wins when both are present. Neither header is forwarded to the provider.How the credential is recognised
The gateway checks the shape of the token to decide how to verify it:- No bearer token and no
x-api-key, but anml_sessioncookie goes to console session authentication (only when console sign-in is enabled). With neither, the request is refused. - A JWT-shaped token (three dot-separated parts, not starting with
ml-) is verified against your identity provider, when OIDC is configured: theauth.oidcprovider ingateway.yaml, and, on a console deployment, the identity providers your organizations register under Admin → Security, matched by the token’siss. - Anything else is looked up as a stored credential: an API key, a personal access token or a virtual account token.
Credential types
API keys (ml-)
API keys (ml-)
An API key belongs to a team and carries a role (Self-hosted installs can also seed keys under
member, editor or admin; default member). name is required, plus team (a team name), team_id or user_id (an owner, whose team the key joins). Optional fields are rpm_limit, tpm_limit, budget_usd_monthly, budget_reset_period (daily, weekly, monthly or never) and expires_at (RFC 3339). An owner must belong to the key’s team. Pass workspace_id to bind the key to a workspace: it then resolves chat models from that workspace’s console providers. Without it, the key is team-scoped and resolves from gateway.yaml. The plaintext key is returned once, in the creation response. A team that belongs to a different workspace than workspace_id is refused with 409 team_in_workspace (your organization’s default team is always allowed), and the organization’s key policy may require expires_at (400 expiry_required), cap it (400 expiry_too_far) or limit keys per person (409 key_limit_reached).Key management is a control-plane call on the console host, made by a signed-in person or a credential allowed to manage Gateway API keys:teams[].api_keys in gateway.yaml (name, key, role), with ${ENV_VAR} interpolation for the key value.Personal access tokens (ml_pat_)
Personal access tokens (ml_pat_)
A PAT authenticates as the person who created it, with their roles, in the one workspace it was issued for. If their access is revoked, so is the token’s. PATs created in the console (Gateway → Access → Personal Access Tokens) can be issued or rotated only from a signed-in session, never with another token, and must have an expiry. The legacy
POST /w/my/api-key still issues a workspace-less personal token with no expiry. The organization’s credential policy caps the lifetime and the number of PATs per person.Virtual account tokens (ml_vat_)
Virtual account tokens (ml_vat_)
A virtual account is a service identity in a workspace with
allowed_models and allowed_providers lists, both required when you create it (400 missing_allowlist); an empty list allows nothing. A request for a model outside the list is refused with 403 model_not_allowed. Its tokens can be rotated on a schedule with a grace period. See Credentials.OIDC JWTs
OIDC JWTs
The gateway verifies the token’s signature, issuer and audience, then maps a claim to a team by name. On a console deployment it also accepts JWTs from an organization’s own registered identity provider (Admin → Security), with no
gateway.yaml configuration; the team is resolved within that organization. A token whose team claim is missing or maps to no team is rejected. If the role claim matches admin_role, the caller is an admin; otherwise a member.Key expiry
API keys, PATs and VATs can carry anexpires_at timestamp. From that moment the credential is refused with 401 key_expired rather than invalid_api_key, so a client can tell “rotate your credential” apart from “your credential is wrong”. PATs created in the console always expire. A VAT may be set never to expire if the organization’s credential policy allows it. An expired OIDC JWT fails signature verification and returns invalid_api_key.
Acting as a PAT from the console
The id of one of your own PATs. Accepted only from a signed-in console session. The request is then authenticated and attributed as that PAT, so its limits, usage and traces match the snippet the Playground generates. The header is never forwarded upstream.
400 credential_header_not_allowed. Naming a PAT that is not yours, or is no longer usable, returns 401 invalid_api_key.
Configure OIDC
Self-hosted installs enable OIDC underauth.oidc in gateway.yaml. An empty issuer disables it, and audience is required when issuer is set.
gateway.yaml
Use the Anthropic SDK
Error responses
Authentication errors use the OpenAI error envelope (on/v1/messages they use the Anthropic envelope, with the same code):
Verified identities are cached for up to 30 seconds. Revoking a key or changing a role is announced to every process immediately, so the change applies without waiting for the cache to expire.
Next steps
Access control
Roles, permissions and model allow-lists.
Credentials
Manage PATs, virtual accounts and rotation.