respan-instrumentation-crewai
First-party Respan instrumentation for CrewAI. It subscribes to CrewAI's official lifecycle events and emits canonical workflow, task, agent, tool, and LLM spans directly. LLM spans include model, prompt/completion, and provider-reported token usage, which allows Respan to calculate cost for models in its pricing catalog.
Configuration
1. Install
pip install respan-instrumentation-crewai
The package requires CrewAI 1.10.1 or newer. That version introduced the provider-neutral LLM lifecycle and usage hooks required for complete tracing.
2. Set Environment Variables
| Variable | Required | Description |
|---|---|---|
RESPAN_API_KEY |
Yes | Your Respan API key. Authenticates both proxy and tracing. |
RESPAN_BASE_URL |
No | Defaults to https://api.respan.ai/api. |
Quickstart
3. Run Script
import os
from dotenv import load_dotenv
load_dotenv()
# Route OpenAI traffic through the Respan gateway (no separate OpenAI key needed)
os.environ["OPENAI_API_KEY"] = os.environ["RESPAN_API_KEY"]
os.environ["OPENAI_BASE_URL"] = os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api")
from respan import Respan
from respan_instrumentation_crewai import CrewAIInstrumentor
respan = Respan(
api_key=os.environ["RESPAN_API_KEY"],
base_url=os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api"),
instrumentations=[CrewAIInstrumentor()],
)
from crewai import Agent, Task, Crew
agent = Agent(
role="Poet",
goal="Write a short haiku about recursion in programming",
backstory="You are a programmer who writes haikus.",
llm="gpt-4o-mini",
)
task = Task(
name="Write recursion haiku",
description="Write a haiku about recursion in programming.",
expected_output="A single haiku (3 lines: 5-7-5 syllables).",
agent=agent,
)
crew = Crew(name="crewai_haiku", agents=[agent], tasks=[task])
result = crew.kickoff()
print(result.raw)
respan.flush()
4. View Dashboard
After running the script, traces appear on your Respan dashboard.
Further Reading
See the Respan example projects for runnable scripts.
Metadata
Release files for respan-instrumentation-crewai 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| respan_instrumentation_crewai-0.1.1.tar.gz | 15.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| respan_instrumentation_crewai-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.2 kB
Release files / respan_instrumentation_crewai-0.1.1.tar.gz
| Download URL | respan_instrumentation_crewai-0.1.1.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8c892ebbb454478bfaa5d158e554ad81aa63de5735472eb11dac54ac384deee
|
|
BLAKE2b-256 checksum How to use checksums |
7f1800a2a8a41bb16ae30db23c3f0131dc31a037b32447ff93a725c17b5d6715
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / respan_instrumentation_crewai-0.1.1-py3-none-any.whl
| Download URL | respan_instrumentation_crewai-0.1.1-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e031b13d12f5f202fecd963bdff4b956015f8674886f6da66a8a7837031dbc80
|
|
BLAKE2b-256 checksum How to use checksums |
4b78387618b95d71a8e406fb1270bcd0528e43ce65d064d5bf7ffd78727c022c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|