---
title: "OpenAI Agents (gateway)"
description: "Set up OpenAI Agents SDK with the Respan gateway."
---

Route LLM calls through the Respan gateway to use 1000+ models from different providers. Only your Respan API key is needed. No separate provider keys are required.

Paste this into your coding agent:

```text
Help me set up the Respan gateway with the OpenAI Agents integration.
Follow https://www.respan.ai/docs/integrations/gateway/open-ai-agents.md
```

## Setup

<Steps>
<Step title="Install packages">

<Tabs>
<Tab title={"Python"}>

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

</Tab>
<Tab title={"TypeScript"}>

```bash
npm install @openai/agents openai
```

</Tab>
</Tabs>

</Step>

<Step title="Set environment variables">

```bash
export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
```

No `OPENAI_API_KEY` needed. The Respan gateway handles provider authentication.

</Step>

<Step title="Point to the Respan gateway">

<Tabs>
<Tab title={"Python"}>

```python
import os
import asyncio
from openai import AsyncOpenAI
from agents import (
    Agent,
    Runner,
    set_default_openai_api,
    set_default_openai_client,
    set_tracing_disabled,
)

client = AsyncOpenAI(
    api_key=os.environ["RESPAN_API_KEY"],
    base_url="https://gateway.respan.ai",
)
set_default_openai_client(client)
set_default_openai_api("chat_completions")
set_tracing_disabled(True)

agent = Agent(
    name="Assistant",
    model="gpt-5.5",
    instructions="You only respond in haikus.",
)

async def main():
    result = await Runner.run(agent, "Tell me about recursion.")
    print(result.final_output)

asyncio.run(main())
```

</Tab>
<Tab title={"TypeScript"}>

```typescript
import {
  Agent,
  OpenAIProvider,
  run,
  setDefaultModelProvider,
  setOpenAIAPI,
  setTracingDisabled,
} from "@openai/agents";

setDefaultModelProvider(
  new OpenAIProvider({
    apiKey: process.env.RESPAN_API_KEY,
    baseURL: "https://gateway.respan.ai",
  })
);
setOpenAIAPI("chat_completions");
setTracingDisabled(true);

const agent = new Agent({
  name: "Assistant",
  model: "gpt-5.5",
  instructions: "You only respond in haikus.",
});

const result = await run(agent, "Tell me about recursion.");
console.log(result.finalOutput);
```

</Tab>
</Tabs>

<Note>
OpenAI Agents defaults to the Responses API, which the gateway serves for OpenAI models only. Set the SDK to `chat_completions` so the same agent can also run non-OpenAI models, such as the Claude example below.
</Note>

</Step>
</Steps>

## Switch models

Change the `model` parameter on any agent to use 1000+ models from different providers through the same gateway.

```python
agent = Agent(
    name="Assistant",
    model="claude-sonnet-4-5-20250929",  # Use Anthropic via gateway
    instructions="You are a helpful assistant.",
)
```

See the [full model list](https://platform.respan.ai/platform/models).
