> ## Documentation Index
> Fetch the complete documentation index at: https://agent-observability-docs.splunk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI Agents SDK

> Learn how to send traces from the OpenAI Agents SDK to Splunk Agent Observability for evaluation

The OpenAI Agents SDK uses has built in tracing to log agent runs, and this can be extended to log to platforms like Splunk Agent Observability. The Splunk Agent Observability Python SDK has a custom [OpenAI tracing processor](https://openai.github.io/openai-agents-python/tracing/#custom-tracing-processors) that logs all agent events, allowing you to evaluate your agentic apps using Splunk Agent Observability evaluators.

> **[SplunkAOTracingProcessor](https://agent-observability-docs.splunk.com/sdk-api/python/reference/handlers/openai_agents/handler.md)**
>
> The SplunkAOTracingProcessor SDK reference.

> **[Integrate Splunk Agent Observability into an OpenAI Agents SDK app](https://agent-observability-docs.splunk.com/sdk-api/logging/splunk-ao-logger.md)**
>
> Get hands on integrating Splunk Agent Observability into an agentic app using the OpenAI Agents SDK.

## Log an OpenAI Agent app

To log OpenAI Agent apps to Splunk Agent Observability, you need to create an instance of the [`SplunkAOTracingProcessor`](https://agent-observability-docs.splunk.com/sdk-api/python/reference/handlers/openai_agents#galileotracingprocessor-objects), and set this as the default tracing processor for your agent using the [`set_trace_processors`](https://openai.github.io/openai-agents-python/ref/tracing/#agents.tracing.set_trace_processors) function from the OpenAI Agents SDK.

```python Python theme={null}
from splunk_ao.handlers.openai_agents import SplunkAOTracingProcessor
from agents import set_trace_processors

# Create a Splunk Agent Observability tracing processor
# and set it as the OpenAI tracing processor
set_trace_processors([SplunkAOTracingProcessor()])
```

Once this is set, all agent events, such as tool calls, handoffs, and generations, will be logged to Splunk Agent Observability.

![A graph of an agent call in Splunk Agent Observability showing guardrails and response generation](https://mintcdn.com/agent-observability-docs/Y4gaVgpsSUs8MBdT/sdk-api/third-party-integrations/openai-agents/agent-graph.webp?fit=max\&auto=format\&n=Y4gaVgpsSUs8MBdT\&q=85\&s=55e8a94d2117c3c33afbaad22b40f51a)

![A set of spans in Splunk Agent Observability showing an OpenAI Agent running guardrails, handoffs, and generating responses](https://mintcdn.com/agent-observability-docs/Y4gaVgpsSUs8MBdT/sdk-api/third-party-integrations/openai-agents/agent-spans.webp?fit=max\&auto=format\&n=Y4gaVgpsSUs8MBdT\&q=85\&s=817b0057b9d0fe93ccec8e64b5f4cd9f)

By default the tracing processor using the current logger at the time it is created. For example, if you create this processor in a function that is decorated with the `@log` wrapper, then the processor will log to the same logger.

You can override this by passing a [SplunkAOLogger](https://agent-observability-docs.splunk.com/sdk-api/logging/splunk-ao-logger.md) into the `SplunkAOTracingProcessor` constructor.

```python Python theme={null}
from splunk_ao import SplunkAOLogger
from splunk_ao.handlers.openai_agents import SplunkAOTracingProcessor
from agents import set_trace_processors

# Create a logger
logger = SplunkAOLogger()

# Create a Splunk Agent Observability tracing processor using the existing logger
# and set it as the OpenAI tracing processor
set_trace_processors([SplunkAOTracingProcessor(splunk_ao_logger=logger)])
```

## Next steps

> **[Splunk Agent Observability logger](https://agent-observability-docs.splunk.com/sdk-api/logging/splunk-ao-logger.md)**
>
> Log with full control over sessions, traces, and spans using the Splunk Agent Observability logger.

> **[Log decorator](https://agent-observability-docs.splunk.com/sdk-api/logging/log-decorator/log-decorator.md)**
>
> Quickly add logging to your code with the log decorator and wrapper.

> **[Splunk Agent Observability context](https://agent-observability-docs.splunk.com/sdk-api/logging/splunk-ao-context.md)**
>
> Manage logging using the Splunk Agent Observability context manager.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.