> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI Agents Instantiation Performance Evaluation

> Benchmark 1000 OpenAI Agents SDK agent constructions with a function tool using Agno's PerformanceEval.

Demonstrates agent instantiation benchmarking with OpenAI Agents SDK.

```python openai_agents_instantiation.py theme={null}
"""
OpenAI Agents Instantiation Performance Evaluation
==================================================

Demonstrates agent instantiation benchmarking with OpenAI Agents SDK.
"""

from typing import Literal

from agno.eval.performance import PerformanceEval

try:
    from agents import Agent, function_tool
except ImportError:
    raise ImportError(
        "OpenAI agents not installed. Please install it using `uv pip install openai-agents`."
    )


# ---------------------------------------------------------------------------
# Create Benchmark Tool
# ---------------------------------------------------------------------------
def get_weather(city: Literal["nyc", "sf"]):
    """Use this to get weather information."""
    if city == "nyc":
        return "It might be cloudy in nyc"
    elif city == "sf":
        return "It's always sunny in sf"
    else:
        raise AssertionError("Unknown city")


# ---------------------------------------------------------------------------
# Create Benchmark Function
# ---------------------------------------------------------------------------
def instantiate_agent():
    return Agent(
        name="Haiku agent",
        instructions="Always respond in haiku form",
        model="o3-mini",
        tools=[function_tool(get_weather)],
    )


# ---------------------------------------------------------------------------
# Create Evaluation
# ---------------------------------------------------------------------------
openai_agents_instantiation = PerformanceEval(
    func=instantiate_agent, num_iterations=1000
)

# ---------------------------------------------------------------------------
# Run Evaluation
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    openai_agents_instantiation.run(print_results=True, print_summary=True)
```

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno memory-profiler openai-agents
```

**2. Run the example**

Save the code above as `openai_agents_instantiation.py`, then run:

```bash theme={null}
python openai_agents_instantiation.py
```

Full source: [cookbook/09\_evals/performance/comparison/openai\_agents\_instantiation.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/09_evals/performance/comparison/openai_agents_instantiation.py)


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