Skip to main content

AI Gateway

Overview

LangChain is a framework for building LLM-powered applications through composable chains, agents, and integrations with external data sources. Connecting LangChain to Orq.ai’s AI Gateway provides access to 300+ models through a single base URL change.

Key Benefits

Orq.ai’s AI Gateway enhances LangChain applications with:

Complete Observability

Track every chain step, tool use, and LLM call with detailed traces

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 LangChain with Orq.ai, ensure the following are in place:
  • An Orq.ai account and API Key
  • Python 3.9 or higher
To set up an API key, see API keys & Endpoints.

Installation

Configuration

Configure LangChain to use Orq.ai’s AI Gateway via ChatOpenAI with a custom base_url:
Python
base_url: https://api.orq.ai/v3/router

Basic Example

Python

Chains

Build composable chains using LangChain’s pipe operator:
Python

Streaming

Python

Model Selection

With Orq.ai, any supported model from 20+ providers can be used:
Python