CrewAI
Create multi-agent systems with role-based agents
Pythonmedium
CrewAI enables building multi-agent systems where agents collaborate to solve complex tasks. Decyra captures all agent interactions, providing visibility into your crew's decision-making process.
Prerequisites
- Decyra account with API key
- Python 3.10+ installed
- CrewAI package installed
Installation
pip install crewai decyra-sdk
Integration
Set the OpenAI API base URL as an environment variable:
import os
os.environ['OPENAI_API_BASE'] = 'https://proxy.decyra.com/v1'
os.environ['OPENAI_API_KEY'] = os.getenv('DECYRA_API_KEY')
os.environ['X-Decyra-API-Key'] = os.getenv('DECYRA_API_KEY')
Create agents and a crew:
from crewai import Agent, Task, Crew
researcher = Agent(
role='Research Analyst',
goal='Research and analyze information',
backstory='You are an expert researcher',
verbose=True
)
writer = Agent(
role='Content Writer',
goal='Write compelling content',
backstory='You are a skilled writer',
verbose=True
)
task1 = Task(
description='Research the latest AI trends',
agent=researcher
)
task2 = Task(
description='Write a blog post about AI trends',
agent=writer
)
crew = Crew(
agents=[researcher, writer],
tasks=[task1, task2]
)
result = crew.kickoff()
What Gets Captured
| Field | Description |
|---|---|
| Model | AI model used by agents |
| Temperature | Sampling temperature |
| Agent Role | The role of the agent making the call |
| Task Description | Description of the task being executed |
| Prompt Hash | Hash of the agent's prompt |
| Response Time | Time for each agent interaction |
| Token Usage | Tokens consumed per agent |
| Cost | Total cost across all agents |
Verify
Check your Decyra dashboard to see traces for each agent interaction. You can track how agents collaborate and which models they use.