Installation
Install the Portkey SDK from npm:API Key Setup
- Create a Portkey API key in your dashboard.
- Store your API key securely as an environment variable:
The SDK automatically detects your API key from the environment.
Quickstart
Here’s a minimal example to get you started: You can use either a Virtual Key or a Config object to select your AI provider. Find more info on different authentication mechanisms here.
Authentication & Configuration
The SDK requires:- Portkey API Key: Your Portkey API key (env var
PORTKEY_API_KEY
recommended) - Provider Authentication:
- Virtual Key: The Virtual Key of your chosen AI provider
- Config: The Config object or config slug for advanced routing
- Provider Slug + Auth Headers: Useful if you do not want to save your API keys to Portkey and make direct requests.
Adding Trace ID & Metadata
TypeScript Support
Portkey’s Node.js SDK is fully typed and works seamlessly with TypeScript:Parameters
List of All Headers
View the complete list of headers that can be used with Portkey API requests, including authentication, configuration, and custom headers.
Changelog
View Changelog
Stay updated with the latest features, improvements, and bug fixes in the Portkey Node.js SDK by checking the release tags on GitHub.
Troubleshooting & Support
- Having trouble? Email support or book a demo with our team.
- View the SDK on GitHub
- Report issues or request features
FAQ
Can I use Portkey with OpenAI-compatible code?
Can I use Portkey with OpenAI-compatible code?
Yes! Portkey’s APIs are OpenAI-compatible. You can use any OpenAI-compatible library by pointing it to the Portkey API endpoint and using your Portkey API key.
Where can I find more examples?
Where can I find more examples?
Check out our integration docs here.