Skip to Content

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, plus gateway routing through the OpenAI-compatible Respan endpoint.

Set up Respan

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

Paste this into your coding agent:

Help me set up Respan tracing with the BeeAI integration. Follow https://www.respan.ai/docs/integrations/bee-ai.md

Setup

Install packages

Terminal
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.

Set environment variables

Terminal
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.

Initialize and run

Python
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())

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.

Python
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.

Python
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.