To ensure secure access to Portkeyβs APIs, authentication is required for all requests. This guide provides the necessary steps to authenticate your requests using the Portkey API key, regardless of whether you are using the SDKs for Python and JavaScript, the OpenAI SDK, or making REST API calls directly.Documentation Index
Fetch the complete documentation index at: https://docs.portkey.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Obtaining Your API Key
Create or log in to your Portkey account. Grab your accountβs API key from the βSettingsβ page.
JWT-based Authentication
You can also authenticate Portkey using JWT Tokens. Learn more here
Authentication with SDKs
Portkey SDKs
- NodeJS SDK
- Python SDK
- cURL
OpenAI SDK
When integrating Portkey through the OpenAI SDK, modify the base URL and add thex-portkey-api-key header for authentication. Hereβs an example of how to do it:
We use the
createHeaders helper function from the Portkey SDK here to easily create Portkey headers.You can pass the raw headers (x-portkey-api-key, x-portkey-provider) directly in the defaultHeaders param as well.- NodeJS
- Python
JWT-based Authentication
Portkey supports JWT-based authentication as a secure alternative to API Key authentication. With JWT authentication, clients can authenticate API requests using a JWT token that is validated against a configured JWKS (JSON Web Key Set). This enterprise-grade authentication method is available as an add-on to any Portkey plan. JWT authentication provides enhanced security through:- Temporary, expiring tokens
- Fine-grained permission scopes
- User identity tracking
- Centralized authentication management
JWT Token Authentication
Learn how to implement JWT-based authentication with Portkey
Interested in adding JWT authentication to your Portkey plan?Contact our sales team to discuss pricing and implementation details.

