Skip to main content
Portkey is an AI Gateway that provides a unified interface to access multiple AI providers with advanced features like routing, load balancing, retries, and observability. Use Portkey to build production-ready AI applications with better reliability and cost optimization. With Portkey, you can:
  • Route requests across multiple AI providers
  • Implement fallback mechanisms for better reliability
  • Monitor and analyze your AI usage
  • Cache responses for cost optimization
  • Apply rate limiting and usage controls

Authentication

You need both a Portkey API key and a virtual key for model routing. Get them from Portkey here.

Example

Use Portkey with your Agent:

Advanced Configuration

You can configure Portkey with custom routing and retry policies:
View more examples here.

Params

Portkey also supports the params of OpenAI.
The base_url parameter is the endpoint for the Portkey AI Gateway. Default value is “https://api.portkey.ai/v1” for the standard managed Portkey service.You only need to specify this if you are using a self-hosted instance of Portkey or a specific enterprise endpoint.