Skip to main content

Lanternfish docs

Build from first trace to first briefing

Browse documentation
C
Integration

CrewAI

End-to-end tracing for CrewAI crews, tasks, and agent delegation. See how your role-based agents collaborate.

Prerequisites

  • CrewAI installed
  • Lanternfish SDK installed
1

Install the SDK

bash
pip install "lanternfish[crewai]"
2

Initialize with auto-instrument

python
import os
import lanternfish
from crewai import Crew, Agent, Task

# Simply call instrument() and CrewAI crew execution is auto-traced!
lanternfish.instrument(
    api_key=os.environ["LANTERNFISH_API_KEY"],
    endpoint=os.environ["LANTERNFISH_ENDPOINT"],
)

researcher = Agent(
    role="Senior Research Analyst",
    goal="Uncover cutting-edge AI developments",
    backstory="Expert in AI research...",
)

writer = Agent(
    role="Tech Content Strategist",
    goal="Craft compelling content on tech advancements",
    backstory="Seasoned content creator...",
)
3

Use as normal — tracing is automatic

python
# Define tasks
research_task = Task(
    description="Research the latest AI agent frameworks",
    agent=researcher,
    expected_output="A 4-paragraph report",
)

write_task = Task(
    description="Write an engaging article based on the research",
    agent=writer,
    expected_output="A 500-word article",
)

# Create and run the crew — all traced automatically
crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, write_task],
)

result = crew.kickoff()
# Lanternfish captures: crew structure, task execution, 
# agent delegation, tool usage, token costs

What Lanternfish captures

  • Complete trace timeline
  • Token usage and cost
  • Latency metrics
  • Tool and function calls
  • Error tracking
  • Model information

Next steps