CrewAI is a framework for easily building multi-agent applications. Crew has comprehensive documentation available as well as a great quickstart guide.

1

Install the AgentOps SDK

pip install agentops crewai
2

Add AgentOps to your code

Make sure to call agentops.init before calling any openai, cohere, crew, etc models.

import agentops
from crewai import Agent, Task, Crew, LLM
import os
from dotenv import load_dotenv

# Load environment variables
load_dotenv()
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") or "YOUR_OPENAI_API_KEY"
AGENTOPS_API_KEY = os.getenv("AGENTOPS_API_KEY") or "YOUR_AGENTOPS_API_KEY"

# Initialize AgentOps at the start of your application
agentops.init(AGENTOPS_API_KEY)

# Set up your CrewAI elements as you normally would
# AgentOps will automatically track all interactions
llm = LLM(model="openai/gpt-4o", api_key=OPENAI_API_KEY)

researcher = Agent(
    role="Researcher",
    goal="Find accurate information about a topic",
    backstory="You're an expert researcher with keen attention to detail",
    llm=llm
)

research_task = Task(
    description="Research the latest developments in quantum computing",
    expected_output="A comprehensive report on the latest breakthroughs in quantum computing, including advancements in quantum algorithms, hardware, and potential applications.",
    agent=researcher
)

crew = Crew(
    agents=[researcher],
    tasks=[research_task],
    verbose=True
)

# Run the crew - AgentOps will track everything
result = crew.kickoff()

Set your API key as an .env variable for easy access.

AGENTOPS_API_KEY=<YOUR API KEY>

Read more about environment variables in Advanced Configuration

3

Run your crew

Execute your program and visit app.agentops.ai/traces to observe your Crew! 🕵️

After your run, AgentOps prints a clickable url to console linking directly to your session in the Dashboard

Clickable link to session

Crew + AgentOps Examples