Skip to main content

Portkey + Groq

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:
  • Connect to 1,600+ 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.

Use Groq API with OpenAI Compatibility

Portkey is fully compatible with the OpenAI signature. Connect to the Portkey AI Gateway through the OpenAI Client:
  • Set base_url to PORTKEY_GATEWAY_URL
  • Add default_headers using the createHeaders helper method
Prerequisites:

With OpenAI Client

OpenAI Python

With Portkey Client

Note: Add your Groq API key in Model Catalog and access models using your provider slug
Python
Output

Advanced Routing - Load Balancing

Load balancing distributes traffic across multiple API keys or providers based on custom weights for high availability and optimal performance. Example: Split traffic between Groq’s llama-3-70b (70%) and OpenAI’s gpt-3.5 (30%):
Python
OpenAI Python
Output

Observability with Portkey

Route requests through Portkey to track metrics like tokens used, latency, and cost.
Last modified on April 8, 2026