CrewAI
Instrument CrewAI tasks and agents with a one-line patch.
CrewAI instruments through a single patch call. It wraps the framework’s Task and Agent classes, so each task run and each agent turn becomes a TokenJam span without touching your crew definition.
Setup
from tokenjam.sdk.integrations.crewai import patch_crewai
patch_crewai()
Call it once at startup, before you kick off a crew.
What gets captured
Every Task execution and every Agent turn emits a span with token usage, timing, and the underlying model. Spans nest along the crew’s own structure. A CrewAI task that calls a tool backed by an LLM produces a parent-child tree, with the API call as a leaf.
The patch is framework-agnostic and composes with the provider patches. If a CrewAI agent reaches an API client tj already patches, inner spans are de-duplicated so nothing is counted twice. See the Frameworks overview for the provider patches and how the tiers fit together.