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

import asyncio
import os
from dotenv import load_dotenv
load_dotenv()
from beeai_framework.agents.requirement import RequirementAgent
from beeai_framework.backend import ChatModel
from respan import Respan
from respan_instrumentation_beeai import BeeAIInstrumentor
respan = Respan(
app_name="beeai-python-example",
instrumentations=[BeeAIInstrumentor()],
)
async def main() -> None:
agent = RequirementAgent(
llm=ChatModel.from_name(os.getenv("BEEAI_MODEL", "openai:gpt-4.1-nano")),
role="observability assistant",
instructions="Answer clearly and concisely.",
)
response = await agent.run(
"Explain why traces help agent debugging in one sentence."
)
print(response.last_message.text)
asyncio.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.

from respan import Respan
from respan_instrumentation_beeai import BeeAIInstrumentor
respan = Respan(
app_name="beeai-agent-api",
instrumentations=[BeeAIInstrumentor()],
customer_identifier="user_123",
metadata={"service": "beeai-api", "version": "1.0.0"},
)

With propagate_attributes

Override per-request using a context scope.

from respan import Respan, propagate_attributes
from respan_instrumentation_beeai import BeeAIInstrumentor
respan = Respan(instrumentations=[BeeAIInstrumentor()])
async def handle_request(user_id: str, message: str):
with propagate_attributes(
customer_identifier=user_id,
thread_identifier="conv_abc_123",
metadata={"plan": "pro"},
):
response = await agent.run(message)
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.