OpenAI Agents (gateway)

Route LLM calls through the Respan gateway to use 250+ 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

1import os
2import asyncio
3from openai import AsyncOpenAI
4from agents import (
5 Agent,
6 Runner,
7 set_default_openai_api,
8 set_default_openai_client,
9 set_tracing_disabled,
10)
11
12client = AsyncOpenAI(
13 api_key=os.environ["RESPAN_API_KEY"],
14 base_url="https://api.respan.ai/api",
15)
16set_default_openai_client(client)
17set_default_openai_api("chat_completions")
18set_tracing_disabled(True)
19
20agent = Agent(
21 name="Assistant",
22 model="gpt-5.5",
23 instructions="You only respond in haikus.",
24)
25
26async def main():
27 result = await Runner.run(agent, "Tell me about recursion.")
28 print(result.final_output)
29
30asyncio.run(main())

OpenAI Agents defaults to the Responses API. Live verification with a Respan gateway key returned a provider-credential error on /api/responses, while Chat Completions succeeded, so set the SDK to chat_completions for this gateway setup.

Switch models

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

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

See the full model list.