Portkey + DeepInfra
Portkey is the Control Panel for AI apps. With it’s popular AI Gateway and Observability Suite, hundreds of teams ship reliable, cost-efficient, and fast apps.
With Portkey, you can
- Connect to 150+ models through a unified API,
- View 40+ metrics & logs for all requests,
- Enable semantic cache to reduce latency & costs,
- Implement automatic retries & fallbacks for failed requests,
- Add custom tags to requests for better tracking and analysis and more.
Quickstart
Since Portkey is fully compatible with the OpenAI signature, you can connect to the Portkey AI Gateway through OpenAI Client.
- Set the
base_url as PORTKEY_GATEWAY_URL
- Add
default_headers to consume the headers needed by Portkey using the createHeaders helper method.
You will need Portkey and Deepinfra API keys to run this notebook.
- Sign up for Portkey and generate your API key here.
- Get your Deepinfra key here
With OpenAI Client
Observability with Portkey
By routing requests through Portkey you can track a number of metrics like - tokens used, latency, cost, etc.
Here’s a screenshot of the dashboard you get with Portkey:
Last modified on April 8, 2026