CrewAI Integration
Route all CrewAI agent LLM calls through the Curate-Me gateway for cost tracking, rate limiting, and governance. CrewAI uses LiteLLM under the hood, so you can configure the gateway via environment variables or per-agent config.
Before and after
Environment variable approach (easiest)
# Before — direct to OpenAI
export OPENAI_API_KEY=sk-your-openai-key
# After — through Curate-Me gateway
export OPENAI_API_BASE=https://api.curate-me.ai/v1/openai # ← added
export OPENAI_API_KEY=sk-your-openai-keyYour existing CrewAI code needs zero changes:
from crewai import Agent, Task, Crew
researcher = Agent(
role="Research Analyst",
goal="Find key facts about AI governance",
backstory="You are a senior analyst.",
llm="gpt-4o",
)
task = Task(
description="List 3 reasons teams need an LLM gateway.",
expected_output="A bullet-point list with explanations.",
agent=researcher,
)
crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff() # ← governed by Curate-MePer-agent configuration (more control)
For per-agent cost tagging and explicit gateway auth, use llm_config:
from crewai import Agent, Task, Crew
researcher = Agent(
role="Research Analyst",
goal="Find key facts about AI governance",
backstory="You are a senior analyst.",
llm="gpt-4o",
llm_config={
"api_key": "sk-your-openai-key",
"base_url": "https://api.curate-me.ai/v1/openai",
"extra_headers": {
"X-CM-API-Key": "cm_sk_YOUR_KEY",
"X-CM-Tags": "project=crewai-app,team=research",
},
},
)
writer = Agent(
role="Technical Writer",
goal="Summarize the research findings",
backstory="You are an experienced technical writer.",
llm="gpt-4o",
llm_config={
"api_key": "sk-your-openai-key",
"base_url": "https://api.curate-me.ai/v1/openai",
"extra_headers": {
"X-CM-API-Key": "cm_sk_YOUR_KEY",
"X-CM-Tags": "project=crewai-app,team=writing",
},
},
)
research_task = Task(
description="List 3 reasons teams need an LLM gateway.",
expected_output="A bullet-point list with explanations.",
agent=researcher,
)
writing_task = Task(
description="Write a 2-paragraph summary of the research.",
expected_output="A concise summary suitable for a blog post.",
agent=writer,
)
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, writing_task],
)
result = crew.kickoff()With per-agent X-CM-Tags, you can see exactly how much each agent spent in the
Cost Tracking dashboard.
Prerequisites
pip install crewaiWhat you get
Every CrewAI agent call through the gateway automatically receives:
| Feature | Description |
|---|---|
| Cost tracking | Per-agent token and dollar cost via X-CM-Tags |
| Rate limiting | Per-org, per-key request throttling |
| PII scanning | Regex scan for secrets and PII before hitting the provider |
| Model allowlists | Only approved models per your org policy |
| Budget caps | Daily and monthly spend limits enforced |
| Audit trail | Full request metadata logged for compliance |
Per-agent cost attribution
Use X-CM-Tags to break down costs by agent, team, or project:
X-CM-Tags: project=crewai-app,agent=researcher,team=data
X-CM-Tags: project=crewai-app,agent=writer,team=contentView tagged costs in the dashboard under Gateway > Cost Tracking > Breakdown.
Working example
- Python example — multi-agent crew with per-agent cost tags
Next steps
- Gateway Quickstart — full setup walkthrough
- LangChain Integration — LangChain chains and agents
- Cost Tracking — budget alerts and cost attribution