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

# OpenAI Agents

> How to integrate OpenAI Agents with Quraite.

## Overview

Quraite provides a built-in adapter for OpenAI Agents. This adapter allows you to integrate OpenAI Agents with Quraite and run evaluations on them.

This adapter uses OpenInference instrumentation to capture the trajectory of the agent.

## Prerequisites

* Agent dependencies: `openai-agents` package, OpenAI API key, and any tools you want to use.
* Quraite dependencies: `quraite[openai-agents-oi]` package.

## Define Your OpenAI Agent

You create a normal OpenAI `Agent` first, exactly as you would in any OpenAI Agents project.

```python theme={null}
from agents import Agent
from dotenv import load_dotenv
from prompts import SYSTEM_PROMPT
from tools import (
    book_flight,
    cancel_ticket,
    fetch_user_flight_information,
    lookup_policy,
    search_flights,
    update_ticket_to_new_flight,
)


load_dotenv(override=True)


flight_booking_agent = Agent(
    name="Flight Booking Agent",
    instructions=SYSTEM_PROMPT,
    tools=[
        book_flight,
        cancel_ticket,
        fetch_user_flight_information,
        lookup_policy,
        search_flights,
        update_ticket_to_new_flight,
    ],
    model="gpt-4o-mini",
)
```

## Set up Tracing

Quraite provides a tracing setup helper. For OpenAI Agents, pass the `Framework.OPENAI_AGENTS` enum:

```python theme={null}
from quraite.tracing import Framework, setup_tracing


tracer_provider = setup_tracing([Framework.OPENAI_AGENTS])
```

## Wrap the OpenAI Agent

Inject the `tracer_provider` into the `OpenaiAgentsAdapter` so Quraite can capture spans and metrics from the agent.

```python theme={null}
from quraite.adapters import OpenaiAgentsAdapter


openai_agents_adapter = OpenaiAgentsAdapter(
    agent=flight_booking_agent,
    agent_name="Flight Booking Agent",
    tracer_provider=tracer_provider,
)
```

## Run the Agent

Once wrapped, you expose the adapter using Quraite's `run_agent` helper.

```python theme={null}
if __name__ == "__main__":
    from dotenv import load_dotenv
    from quraite import run_agent

    load_dotenv(override=True)

    run_agent(
        openai_agents_adapter,
        port=8080,
        host="0.0.0.0",
        tunnel="cloudflare",
    )
```

## End-to-End Examples

* [OpenAI flight booking agent example](https://github.com/innowhyte/quraite-python/tree/main/examples/openai_flight_booking_agent)
