Skip to main content

AI Gateway

Overview

The OpenAI SDK provides powerful tools for building AI applications with GPT models. Connecting the SDK to Orq.ai’s AI Gateway transforms any OpenAI integration into a production-ready system with enterprise-grade capabilities, complete observability, and access to 300+ models across 20+ providers.

Key Benefits

Orq.ai’s AI Gateway enhances the OpenAI SDK with:

Complete Observability

Track every API call, token usage, and model 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 the OpenAI SDK with Orq.ai, ensure the following are in place:
  • An Orq.ai account and API Key
  • Python 3.8+ or Node.js 18+ with TypeScript support
  • OpenAI SDK installed
To set up an API key, see API keys & Endpoints.
To use libraries with private models, see Onboarding Private Models.

Installation

Configuration

Set the Base URL to the AI Gateway to route calls through the API without changing any other part of the code. The Orq.ai AI Gateway provides Platform Traces, keeping full compatibility and a unified API with all models while using the OpenAI SDK.
base_url: https://api.orq.ai/v3/router

Text Generation

Basic text generation with the OpenAI SDK through Orq.ai:

Streaming Responses

Stream responses for real-time output:

Model Selection

With Orq.ai, you can use any supported model from 20+ providers: