Send OpenAI Agents SDK Traces to KloudMate
The OpenAI Agents SDK traces every run, but by default it sends those traces to the OpenAI dashboard. The OpenInference instrumentation for the Agents SDK turns them into OpenTelemetry spans instead, so you can send them to KloudMate and see each run in AI Observability.
Prerequisites
Section titled “Prerequisites”- A KloudMate API key, from Settings → Ingest Keys.
- Python 3.10 or later.
Install the packages
Section titled “Install the packages”Instrument the SDK
Section titled “Instrument the SDK”Set up a tracer provider and instrument the Agents SDK before you run an agent:
Call tracer_provider.shutdown() before a script exits, so the last spans are sent.
By default, the instrumentation replaces the SDK’s own trace export, so traces stop going to the OpenAI dashboard. To keep sending to both, pass exclusive_processor=False to instrument().
Point the exporter at KloudMate
Section titled “Point the exporter at KloudMate”OTLPSpanExporter() reads the standard OpenTelemetry variables. Set them in the environment that runs your app:
KloudMate expects the raw API key in the Authorization header, with no Bearer prefix. If the KloudMate agent runs on the same machine, set the endpoint to http://localhost:4318 and leave out the header.
Group a conversation
Section titled “Group a conversation”The Agents SDK’s group_id isn’t exported to OpenTelemetry. Wrap each run in using_session() instead:
Control what’s captured
Section titled “Control what’s captured”Prompts, responses, and tool arguments are recorded by default. To leave them out, set these variables before your app starts:
Token counts, models, and latency are still recorded.
Check the data
Section titled “Check the data”Run the agent once, then open AI Observability → Traces. The run appears as Agent workflow Turn, or under the name you set with RunConfig(workflow_name=...), with its model, steps, tokens, and estimated cost.