Back to Guides

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

FieldDescription
ModelAI model used by agents
TemperatureSampling temperature
Agent RoleThe role of the agent making the call
Task DescriptionDescription of the task being executed
Prompt HashHash of the agent's prompt
Response TimeTime for each agent interaction
Token UsageTokens consumed per agent
CostTotal 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.

Next Steps