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

# OpenAI Agents SDK

> Audit OpenAI Agents function calls, handoffs, and guardrails

<Note>
  **Prefer zero setup?** Use `plog run` or `import provenlog.auto` instead. See [Auto-Instrumentation](/integrations/auto-instrumentation).
</Note>

## Setup

```python theme={null}
from provenlog.integrations.openai_agents import Trail
from agents import add_trace_processor

add_trace_processor(Trail(agent_id="my-openai-agent"))
```

## What gets captured

| Event                 | Action Type                 | Details                          |
| --------------------- | --------------------------- | -------------------------------- |
| Function calls        | `TOOL_CALL` / `TOOL_RESULT` | Function name, arguments, output |
| LLM generations       | `LLM_CALL` / `LLM_RESPONSE` | Model, token counts              |
| Handoffs              | `CUSTOM`                    | Source agent, target agent       |
| Guardrail evaluations | `CUSTOM`                    | Guardrail name, pass/fail        |
| Agent spans           | `CUSTOM`                    | Agent lifecycle events           |

## How it works

The Trail registers as a trace processor via the OpenAI Agents SDK's `add_trace_processor` hook. It receives structured trace events for all agent activity.

## Configuration

```python theme={null}
# Simple — uses default embedded mode
trail = Trail(agent_id="my-openai-agent")

# With explicit client for custom configuration
from provenlog import ProvenLogClient

client = ProvenLogClient("http://localhost:7600", agent_id="my-agent")
trail = Trail(client=client, agent_id="my-openai-agent")
```
