Skip to navigation

OpenAI Agents (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 required.

Setup

1

Install packages

pip install openai-agents
2

Set environment variables

export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"

No OPENAI_API_KEY needed — the Respan gateway handles provider authentication.

3

Point to the Respan gateway

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://api.respan.ai/api",
)
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())

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.

Switch models

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

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.