Gateway: OpenAI Agents SDK

Platform

Custom AsyncOpenAI client plus chat_completions. The Agents SDK defaults to the Responses API, which this Gateway does not implement.

The OpenAI Agents SDK uses the Responses API by default. This Gateway only implements POST /openai/v1/chat/completions. Build an AsyncOpenAI client with base_url https://gateway.traccia.ai/openai/v1 and both Traccia headers, then force Chat Completions.

What this Gateway accepts

OpenAI: POST /openai/v1/chat/completions and GET /openai/v1/models. Anthropic: POST /anthropic/v1/messages. Gemini Developer API: POST /google/{v1beta|v1}/models/{model}:generateContent and :streamGenerateContent. Embeddings, the OpenAI Responses API, Assistants, Azure OpenAI paths, Vertex AI paths, and Anthropic Batches are not this Gateway. Those requests 404.

Headers

HeaderValue
X-Traccia-Api-KeyWorkspace key from Settings → API Keys
X-Traccia-Agent-IdSame Agent ID you would pass to init

Keep the provider API key on the client. The Gateway forwards it and does not store it. Missing Traccia key returns 401. Missing agent ID returns 400.

Global Client

Official pattern: set_default_openai_client plus set_default_openai_api("chat_completions"). Pass use_for_tracing=False so the Gateway client is not reused for OpenAI tracing export.

python
import os
from openai import AsyncOpenAI
from agents import Agent, Runner, set_default_openai_api, set_default_openai_client
client = AsyncOpenAI(
api_key=os.environ["OPENAI_API_KEY"],
base_url="https://gateway.traccia.ai/openai/v1",
default_headers={
"X-Traccia-Api-Key": os.environ["TRACCIA_API_KEY"],
"X-Traccia-Agent-Id": "billing-bot",
},
)
set_default_openai_client(client, use_for_tracing=False)
set_default_openai_api("chat_completions")
agent = Agent(
name="Assistant",
instructions="Be concise.",
model="gpt-4o-mini",
)
result = await Runner.run(agent, "hello")

Per-Agent Model

Equivalent official path: wrap the same client in OpenAIChatCompletionsModel.

python
import os
from openai import AsyncOpenAI
from agents import Agent, OpenAIChatCompletionsModel
client = AsyncOpenAI(
api_key=os.environ["OPENAI_API_KEY"],
base_url="https://gateway.traccia.ai/openai/v1",
default_headers={
"X-Traccia-Api-Key": os.environ["TRACCIA_API_KEY"],
"X-Traccia-Agent-Id": "billing-bot",
},
)
agent = Agent(
name="Assistant",
instructions="Be concise.",
model=OpenAIChatCompletionsModel(
model="gpt-4o-mini",
openai_client=client,
),
)

Responses API 404s

If you only set OPENAI_BASE_URL and leave the default API, the SDK posts to /v1/responses. That is not this Gateway.

Next Steps

© 2026 Traccia.