Skip to main content
CrewAI is an agent framework for orchestrating role-playing, autonomous AI agents. Agents are assigned roles, goals, and backstories, then collaborate to complete multi-step tasks. By routing CrewAI’s LLM calls through the Portkey AI Gateway, you gain visibility into cost, token usage, and latency across every agent run.

Installation

1

Start the gateway

The gateway listens at http://localhost:8787/v1.
2

Install dependencies

Basic setup

CrewAI’s LLM class accepts base_url and extra_headers, making it straightforward to route through the gateway.
You can also use langchain_openai.ChatOpenAI with CrewAI if you prefer the LangChain integration. See the LangChain integration page for setup details.

Connecting via LangChain

If you are already using LangChain in your stack, pass a ChatOpenAI instance directly as the llm on each agent.

Using multiple LLMs across agents

Assign different models to different agents to balance cost and capability. All requests remain visible in the Portkey observability dashboard.

Real-world use case: web research crew

A two-agent crew that researches a topic and writes a report, with retry logic configured at the gateway.
The trace_id header groups all LLM calls from a single crew run in the Portkey dashboard, making it easy to debug individual runs and compare costs across executions.