Configure JWT-based authentication for your organization in Portkey
This feature is available only on the Enterprise Plan of Portkey.
Portkey supports JWT-based authentication in addition to API Key authentication. Clients can authenticate API requests using a JWT token, which is validated against a configured JWKS (JSON Web Key Set). This guide explains the requirements and setup process for JWT authentication in Portkey.
Validate your JWT Token before making a LLM request using Portkey.
JWT authentication can be configured under Admin Settings → Organisation → Authentication.
To validate JWTs, you must configure one of the following:
Your JWT payload must contain the following claims:
Claim Key | Description |
---|---|
portkey_oid / organisation_id | Unique identifier for the organization. |
portkey_workspace / workspace_slug | Identifier for the workspace. |
scope / scopes | Permissions granted by the token. |
Portkey identifies users in the following order of precedence for logging and metrics:
email_id
sub
uid
The client sends an HTTP request with the JWT in the x-portkey-api-key
header:
The server validates the JWT:
If valid, the request is authenticated, and user details are extracted for authorization and logging.
If invalid, the request is rejected with an HTTP 401 Unauthorized response.
Once the JWT is validated, the server checks for the required scope. Scopes can be provided in the JWT as either a single string or an array of strings using the scope
or scopes
claim.
Scopes can also be prefixed with portkey.
(e.g., portkey.completions.write
).
JWT tokens with appropriate scopes function identically to workspace API keys, providing access to workspace-specific operations. They cannot be used as organization API keys, which have broader administrative permissions across all workspaces.
Once you have a valid JWT token, you can use it to authenticate your API calls to Portkey. Below are examples showing how to use JWT authentication with different SDKs.
Install the Portkey SDK with npm