AI Gateway
Overview
OpenAI Agents SDK enables powerful AI-driven automation through structured conversations and tool calling. Connecting the Agents SDK to Orq.ai’s AI Gateway transforms experimental agents into production-ready systems with enterprise-grade capabilities.Key Benefits
Orq.ai’s AI Gateway enhances OpenAI Agents with:Complete Observability
Track every agent step, tool use, and interaction with detailed traces and analytics
Built-in Reliability
Automatic fallbacks, retries, and load balancing for production resilience
Cost Optimization
Real-time cost tracking and spend management across all AI operations
Multi-Provider Access
Access 300+ LLMs and 20+ providers through a single, unified integration
Prerequisites
Before integrating OpenAI Agents SDK with Orq.ai, ensure the following are in place:- An Orq.ai account and API Key
- Python 3.9 or higher
- OpenAI Agents SDK installed
To set up an API key, see API keys & Endpoints.
Installation
Install the OpenAI Agents SDK:Configuration
Configure OpenAI Agents SDK to use Orq.ai’s AI Gateway by setting a custom AsyncOpenAI client:Python
base_url: https://api.orq.ai/v3/router
Built-in OpenAI Tracing
Do not setOPENAI_API_KEY only to silence this warning. That sends SDK traces to OpenAI’s dashboard instead of Orq.ai. Disable the SDK’s built-in OpenAI tracing for gateway-only use when agent traces in Orq.ai are not needed.
Basic Agent Example
Here’s a complete example of creating and running an OpenAI agent through Orq.ai:Python
Agent with Tools
OpenAI Agents can use tools while routing through Orq.ai:Python
Model Selection
With Orq.ai, any supported model from 20+ providers can be used:Python