Skip to main content
Integrate Portkey with Phidata to build production-ready AI assistants with access to 250+ LLMs, automatic fallbacks, and complete observability.

Overview

Portkey enhances Phidata applications with:
  • Multi-Provider Support: Connect to 250+ LLMs for your AI assistants
  • Reliability: Automatic fallbacks and retries for assistant interactions
  • Observability: Full logging and tracing for assistant conversations
  • Performance: Smart caching to improve response times
  • Cost Optimization: Track and reduce token usage

Installation

Quick Start

Phidata integrates with Portkey through OpenAI-compatible configuration:
1

Import Libraries

2

Configure Portkey

3

Create LLM with Portkey

4

Create Assistant

5

Use the Assistant

Complete Assistant Example

Build a comprehensive AI assistant:

Using Different Providers

Switch between LLM providers easily:

Advanced Routing

Fallback Configuration

Automatically fallback to backup providers:

Load Balancing

Distribute requests across multiple models:

Retry Configuration

Assistant with Memory

Create assistants with persistent memory:

Knowledge Base Integration

Build assistants with knowledge bases:

Using Phidata Tools

Integrate various tools with your assistant:

Caching for Assistants

Enable caching to reduce costs:

Streaming Responses

Stream assistant responses:

Team of Assistants

Create multiple specialized assistants:

Observability and Tracking

Add detailed tracking to your assistants:
View metrics in Portkey dashboard:
  • Conversation flows
  • Token usage per session
  • Response latency
  • Tool usage patterns
  • Cache hit rates
  • Error tracking

Best Practices

Configure fallback providers for reliability:
Use semantic caching for FAQ-style assistants:
Track user sessions with metadata:
Use the Portkey dashboard to track and optimize token consumption.
Integrate knowledge bases for domain-specific assistants to reduce hallucinations.

Example: Customer Support Assistant

Complete customer support assistant:

Error Handling

Implement robust error handling:

Resources

Need help? Join our Discord community for support with Phidata implementations.