BeeAI (tracing)

BeeAI is an open-source framework for building production-ready AI agents with memory, tools, and LLM integrations. Respan gives you visibility into BeeAI workflow spans, agent runs, LLM calls, and tool calls — and gateway routing through the OpenAI-compatible Respan endpoint.

Create an account at platform.respan.ai and grab an API key.

Run npx @respan/cli setup to set up with your coding agent.

See BeeAI gateway setup to route this integration through the Respan gateway.

Setup

1

Install packages

$pip install respan-ai respan-instrumentation-beeai beeai-framework

@arizeai/openinference-instrumentation-beeai currently instruments beeai-framework >=0.1.9 <0.1.14. Use beeai-framework@0.1.13 for compatible TypeScript tracing.

2

Set environment variables

$export OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"

Python uses OPENAI_API_KEY for LLM requests and RESPAN_API_KEY for trace export. TypeScript can route LLM calls through the Respan gateway with RESPAN_API_KEY, or you can set RESPAN_GATEWAY_API_KEY separately.

3

Initialize and run

1import asyncio
2import os
3from dotenv import load_dotenv
4
5load_dotenv()
6
7from beeai_framework.agents.requirement import RequirementAgent
8from beeai_framework.backend import ChatModel
9from respan import Respan
10from respan_instrumentation_beeai import BeeAIInstrumentor
11
12respan = Respan(
13 app_name="beeai-python-example",
14 instrumentations=[BeeAIInstrumentor()],
15)
16
17
18async def main() -> None:
19 agent = RequirementAgent(
20 llm=ChatModel.from_name(os.getenv("BEEAI_MODEL", "openai:gpt-4.1-nano")),
21 role="observability assistant",
22 instructions="Answer clearly and concisely.",
23 )
24 response = await agent.run(
25 "Explain why traces help agent debugging in one sentence."
26 )
27 print(response.last_message.text)
28 respan.flush()
29
30
31asyncio.run(main())
4

View your trace

Open the Traces page to see your BeeAI workflow with agent, chat, and tool spans.

Configuration

ParameterTypeDefaultDescription
api_key / apiKeystr | None / string | undefinedRESPAN_API_KEYRespan API key for trace export.
base_url / baseURLstr | None / string | undefinedRESPAN_BASE_URLRespan trace export base URL.
instrumentationslist / RespanInstrumentation[][]Plugin instrumentations to activate, such as BeeAIInstrumentor() or new BeeAIInstrumentor({ sdkModule }).
app_name / appNamestr | None / string | undefinedNone / undefinedService name shown on exported spans.
metadatadict | None / Record<string, unknown>None / undefinedDefault metadata attached to exported spans.
environmentstr | None / string | undefinedNone / undefinedEnvironment tag, such as "production".

Attributes

In Respan()

Set defaults at initialization — these apply to exported spans.

1from respan import Respan
2from respan_instrumentation_beeai import BeeAIInstrumentor
3
4respan = Respan(
5 app_name="beeai-agent-api",
6 instrumentations=[BeeAIInstrumentor()],
7 customer_identifier="user_123",
8 metadata={"service": "beeai-api", "version": "1.0.0"},
9)

With propagate_attributes

Override per-request using a context scope.

1from respan import Respan, propagate_attributes
2from respan_instrumentation_beeai import BeeAIInstrumentor
3
4respan = Respan(instrumentations=[BeeAIInstrumentor()])
5
6
7async def handle_request(user_id: str, message: str):
8 with propagate_attributes(
9 customer_identifier=user_id,
10 thread_identifier="conv_abc_123",
11 metadata={"plan": "pro"},
12 ):
13 response = await agent.run(message)
14 print(response.last_message.text)
AttributeTypeDescription
customer_identifierstrIdentifies the end user in Respan analytics.
thread_identifierstrGroups related messages into a conversation.
metadatadictCustom key-value pairs. Merged with default metadata.