# OpenAI Agents SDK

Source: https://staging-docs.aiand.com/integrations/openai-agents/

The [OpenAI Agents SDK](https://github.com/openai/openai-agents-python) (Python) and its JS counterpart work against ai& by configuring a custom `OpenAI` client.

## Setup

```bash
pip install openai-agents
```

```python
from agents import Agent, Runner, ModelSettings
from agents.models.openai_chatcompletions import OpenAIChatCompletionsModel
from openai import AsyncOpenAI

client = AsyncOpenAI(
    base_url="https://api.aiand.com/v1",
    api_key="sk-your-api-key",
)

model = OpenAIChatCompletionsModel(
    model="openai/gpt-oss-120b",
    openai_client=client,
)
```

## A simple agent

```python
agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant. Always reply concisely.",
    model=model,
)

result = await Runner.run(agent, "What is the capital of France?")
print(result.final_output)
```

## Agent with tools

```python
from agents import function_tool

@function_tool
def get_weather(city: str) -> str:
    """Get current weather for a city."""
    return f"Sunny in {city}, 22°C"

agent = Agent(
    name="WeatherBot",
    instructions="Help the user with weather questions.",
    model=model,
    tools=[get_weather],
)

result = await Runner.run(agent, "What's the weather in Tokyo?")
print(result.final_output)
```

## Handoffs and multi-agent

The Agents SDK's handoff pattern works the same way — pass `handoffs=[other_agent]` on `Agent(...)`. No ai&-specific configuration needed.

<Aside type="note">
  The Agents SDK uses `chat.completions` under the hood, so every ai& capability (tool calling, structured outputs, vision via `file_id`) is available.
</Aside>
