Working with OpenAI Agents SDK
Trace OpenAI Agents SDK workflows end-to-end with LangDB—monitor model calls, tool invocations, and runner sessions via one-line init().
LangDB helps you add full tracing and observability to your OpenAI Agents SDK workflows—without changing your core logic. With a one-line initialization, LangDB captures model calls, tool invocations, and intermediate steps, giving you a complete view of how your agent operates.
Installation
Enable end-to-end tracing for your OpenAI Agents SDK agents by installing the pylangdb client with the openai feature flag:
Quick Start
Export Environment Variables
Set your LangDB credentials:
Initialize Tracing
Import and run the initialize before configuring your OpenAI client:
Configure OpenAI Client and Agent Runner
Once executed, LangDB links all steps—model calls, intermediate tool usage, and runner orchestration—into a single session trace.
Complete OpenAI Agents SDK Example
Here is a full example based on OpenAI Agents SDK Quickstart which uses LangDB Tracing.
Example code
Check out the full sample on GitHub: https://github.com/langdb/langdb-samples/tree/main/examples/openai/openai-agents-tracing
Setup Environment
Export Environment Variables
main.py
Running Your Agent
Navigate to the parent directory of your agent project and use one of the following commands:
Output:
Traces on LangDB
When you run queries against your agent, LangDB automatically captures detailed traces of all agent interactions:

Next Steps: Advanced OpenAI Agents SDK Integration
This guide covered the basics of integrating LangDB with OpenAI Agents SDK using a history and maths agent example. For more complex scenarios and advanced use cases, check out our comprehensive resources in Guides Section.
Last updated
Was this helpful?
