- 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
UsePortkey
with your Agent
:
Advanced Configuration
You can configure Portkey with custom routing and retry policies: View more examples here.
Params
Parameter | Type | Default | Description |
---|---|---|---|
id | str | "gpt-4o-mini" | The id of the model to use through Portkey |
name | str | "Portkey" | The name of the model |
provider | str | "Portkey" | The provider of the model |
portkey_api_key | Optional[str] | None | The Portkey API key for authentication |
virtual_key | Optional[str] | None | The virtual key for model routing in Portkey |
config | Optional[Dict[str, Any]] | None | Portkey configuration for routing, retries, and policies |
base_url | str | PORTKEY_GATEWAY_URL | The Portkey gateway URL |
Portkey
also supports the params of OpenAI.