Skip to main content
Integrate Portkey with CrewAI to build production-ready multi-agent systems with access to 250+ LLMs, automatic fallbacks, and complete observability.

Overview

Portkey enhances CrewAI applications with:
  • Multi-Provider Support: Route crew agents to 250+ different LLMs
  • Crew Observability: Full logging and tracing for all agent interactions
  • Reliability: Automatic fallbacks and retries for mission-critical tasks
  • Cost Optimization: Track and optimize token usage across your crew
  • Performance: Smart caching for repeated tasks

Installation

Quick Start

CrewAI integrates seamlessly with Portkey through OpenAI-compatible configuration:
1

Import Libraries

2

Configure Portkey

3

Create LLM Instance

4

Create Agent

5

Create and Run Crew

Complete Crew Example

Build a complete content creation crew:

Using Different Providers

Assign different LLM providers to different agents:

Advanced Routing

Fallback Configuration

Automatically fallback to backup providers:

Load Balancing

Distribute crew workload across multiple providers:

Retry Configuration

Handle transient failures:

Crew Observability

Track individual agents with custom metadata:

Caching for Crews

Reduce costs for repeated tasks:

Sequential vs Hierarchical Crews

Sequential Crew with Portkey

Hierarchical Crew with Portkey

Using CrewAI Tools

Integrate tools with Portkey-powered agents:

Memory and Context

Use CrewAI’s memory features with Portkey:

Best Practices

Add agent-specific metadata for better debugging:
Configure fallbacks for critical crews:
Use caching for crews with repeated tasks:
Track token usage per agent to optimize costs in the Portkey dashboard.
Use GPT-4 for complex tasks, GPT-3.5 for simpler ones to optimize costs.

Example: Market Research Crew

Complete market research crew with Portkey:

Monitoring Crew Performance

View detailed crew metrics in the Portkey dashboard:
  • Per-agent token usage and costs
  • Task completion times
  • Error rates by agent
  • Cache hit rates
  • Conversation flows between agents
  • Custom metadata filtering

Resources

Questions? Join our Discord community for help with CrewAI implementations.