Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portkey integration #130

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Disclaimer: Examples contributed by the community and partners do not represent
| [Panel Integration - Chat with PDF](third_party/panel/README.md) | UI chat, demo, RAG | Panel |
| [phospho integration](third_party/phospho/cookbook_phospho_mistral_integration.ipynb) | Evaluation, Analytics | phospho |
| [pinecone_rag.ipynb](third_party/Pinecone/pinecone_rag.ipynb) | RAG | Pinecone |
| [portkey_with_mistral.ipynb](third_party/Portkey/portkey_with_mistral.ipynb) | LLM Observability, Prompt Management & Governance | Portkey |
| [RAG.ipynb](third_party/LlamaIndex/RAG.ipynb) | RAG | LLamaIndex |
| [RouterQueryEngine.ipynb](third_party/LlamaIndex/RouterQueryEngine.ipynb) | agent | LLamaIndex |
| [self_rag_mistral.ipynb](third_party/langchain/self_rag_mistral.ipynb) | RAG | Langchain |
Expand Down
84 changes: 84 additions & 0 deletions third_party/Portkey/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Portkey + Mistral Integration

This cookbook demonstrates how to effectively use Mistral models through Portkey's AI Gateway. Learn how to integrate Mistral AI with enterprise-grade reliability, observability, and performance features.

<img width="400" src="https://raw.githubusercontent.com/siddharthsambharia-portkey/Portkey-Product-Images/main/full-white-text.png" alt="portkey">

[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/16Z1AlAsW_d_mB5UK1EbailGt4laUU7E9?usp=sharing)



## Features

- 🚀 Unified API Gateway for Mistral models
- 📊 Full-stack observability with 40+ metrics
- 💾 Semantic & simple caching strategies
- 🔄 Automated retries & model fallbacks
- 🛡️ AI Guardrails & content safety controls

## Getting Started

1. Install the required packages:
```bash
pip install portkey-ai
```

2. Set up your API keys in environment variables:
```python
export PORTKEY_API_KEY="your_portkey_key"
export MISTRAL_VIRTUAL_KEY="your_mistral_key" # Get from Portkey dashboard
```

## Examples

The cookook in the same folder contains several examples demonstrating different features:

- Simple chat completion setup
- Load balancing and Fallback deployments
- Metadata tracking and request tracing
- Semantic caching implementation


## Usage

Basic chat completion with Mistral:
```python
from portkey_ai import Portkey

portkey = Portkey(
api_key="your_portkey_key",
virtual_key="your_mistral_key"
)

completion = portkey.chat.completions.create(
messages=[{"role": "user", "content": "Hello!"}],
model="mistral-large-latest"
)
print(completion.choices[0].message.content)
```

## Features Overview

### Production-Grade Controls
- **Load Balancing**: Distribute traffic between Mistral models/versions
- **Semantic Retries**: Auto-rewrite failed prompts for better results
- **Guardrails**: Prevent PII leaks, block prompt injections
- **Virtual Keys**: Secure API key management with budget controls

### Enterprise Observability
- Real-time cost tracking
- Custom metadata tagging
- Request tracing with Trace IDs
- Audit logs with full history

### Team Collaboration
- Version-controlled prompt library
- Shared routing configurations
- RBAC permissions
- Central monitoring dashboard

## Support

- [Portkey AI Mistral Documentation](https://portkey.sh/mistral)
- [Portkey Wesbite](https://portkey.ai/)
- [Join Portkey Discord](https://discord.gg/SqX9epQKNR)
Loading