CrewAI

Trace a CrewAI crew with Neatlogs (Python).

Wrap your crew with neatlogs.wrap(crew) and the whole run is traced — agents, tasks, and their LLM calls all appear in the span tree.

Prerequisites

pip install -U "neatlogs[crewai]" crewai

Usage

import os
import neatlogs

neatlogs.init(
    api_key=os.environ["NEATLOGS_API_KEY"],
    workflow_name="crewai-demo",
    # CrewAI dispatches LLM calls via LiteLLM — add the provider key that
    # matches your crewai.LLM(model=...): openai / azure_ai_inference /
    # google_genai / anthropic.
    instrumentations=["crewai", "openai"],
)

from crewai import Agent, Task, Crew

crew = neatlogs.wrap(Crew(agents=[...], tasks=[...]))
result = crew.kickoff()
print(result)

neatlogs.flush()
neatlogs.shutdown()

CrewAI routes LLM calls internally through LiteLLM, so "crewai" alone isn't enough — also add the provider key matching your crewai.LLM(model=...): "openai" for gpt-*, "azure_ai_inference" for azure/*, "google_genai" for gemini/*, "anthropic" for claude-*. Without it the LLM call runs but produces no LLM span.

Prompt templates

To attach prompt templates to CrewAI work (the framework owns the LLM call, so you can't wrap it with trace()), two helpers complement wrap():

  • neatlogs.bind_templates(llm, system_tpl) — attach a system prompt template to an LLM before passing it to an agent
  • neatlogs.register_crewai_task(task, user_tpl) — associate a user prompt template with a task after creating it

See the CrewAI Multi-Agent Crew guide for an end-to-end example.

On this page