Use Portkey With Fireworks
Portkey + Fireworks Integration
Portkey + Fireworks Integration
Portkey provides a robust gateway to integrate Fireworks models into your applications with features like:
- Fast AI gateway access
- Comprehensive observability
- Semantic caching
- Automated retries & fallbacks
- Custom metadata & logging dashboard
This cookbook demonstrates how to effectively use Fireworks models through Portkey's AI Gateway.
Setup & Installation
Install Portkey Python SDK and intialise the LLM client.
Portkey's Virtual keys is an alias to your real Firworks API key, this allows you to manage your API keys more effectively and add budget limits and rate limits to it
1. Basic Chat Completion
Let's start with a simple chat completion using Fireworks' Llama model:
Advanced Routing Features
2.1 Load Balancing
Portkey allows you to distribute traffic across multiple models or API keys:
2.2 Fallbacks & Retries
Configure automatic retries and fallbacks for improved reliability:
Portkey has powerful routing strategies beyond what we've covered. You can use conditional routing to direct requests based on custom rules, implement advanced retry mechanisms, conduct A/B testing between models, and much more. Check out Portkey docs to explore these advanced routing capabilities in detail.
Enhanced Observability
Request Tracing
Add metadata and trace IDs to track requests:


6.3 Prompt Library
The Portkey Prompt Library is a powerful tool for managing your prompts efficiently:
- Create, edit, and organize prompts in a central location
- Version control your prompts without needing to redeploy your application
- Collaborate with team members on prompt development
- Test prompts directly in the interface
- Organize prompts into collections for better management

Next Steps
- Visit Portkey Documentation for detailed API reference
- Join the Portkey Discord for community support
This cookbook demonstrates the key features of using Fireworks models through Portkey's AI Gateway.