Requires
openai-agents >=0.13.Prerequisites
Install
Use ArbytraAsyncOpenAI (experimental)
ArbytraAsyncOpenAI (experimental) is an AsyncOpenAI subclass that captures routing metadata from every successful response. Pass it to OpenAIChatCompletionsModel via the openai_client= parameter:
Runner.run_sync() works the same way.
Configure routing
Pass routing options throughModelSettings.extra_body, not through the client.chat.completions.create() call:
ModelSettings.extra_body to the API call. RoutingOptions.to_extra_body() returns a dict the Arbytra API accepts.
Access routing metadata
Readclient.last_routing_metadata after a run completes:
on_response callback:
TypeError.
Handle errors
ArbytraAsyncOpenAI raises errors catchable as both Arbytra and OpenAI error types:
openai.RateLimitError.
Network-layer exceptions (openai.APITimeoutError, openai.APIConnectionError) propagate unchanged.
Mid-stream SSE errors (raised after the HTTP 200 during
stream=True) remain unmapped openai.APIError. ArbytraAsyncOpenAI maps HTTP-level status errors only.ArbytraAsyncOpenAI.
Configure manually
Alternative: configure OpenAI Agents SDK manually
Alternative: configure OpenAI Agents SDK manually
If you prefer to configure the SDK’s client directly, without the Arbytra integration:
set_default_openai_api("chat_completions") is the default for the Agents SDK. Both Chat Completions and Response API streaming include routing_metadata.