AI Gateway
Route your LLM calls through the AI Gateway with a single base URL change. Zero vendor lock-in: always run on the best model at the lowest cost for your use case.
Observability
Use OpenInference and OpenTelemetry to capture LangChain and LangGraph traces.
AI Gateway
Overview
LangChain is a framework for building LLM-powered applications through composable chains, agents, and integrations with external data sources. By connecting LangChain to Toqan Router’s AI Gateway, you access 500+ models through a single base URL change.Key Benefits
Toqan Router’s AI Gateway enhances your 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 your AI operations
Multi-Provider Access
Access 500+ LLMs and 30+ providers through a single, unified integration
Prerequisites
Before integrating LangChain with Toqan Router, ensure you have:- A Toqan Router account and API Key
- Python 3.8 or higher
To set up your API key, see API keys & Endpoints.
Installation
Configuration
Configure LangChain to use Toqan Router’s AI Gateway viaChatOpenAI with a custom base_url:
Python
base_url: https://router.toqan.ai/eu/v3/router
Basic Example
Python
Chains
Build composable chains using LangChain’s pipe operator:Python
Streaming
Python
Model Selection
With Toqan Router, you can use any supported model from 30+ providers:Python
Observability
Model calls through the AI Gateway appear in Traces. To capture the surrounding application workflow, use OpenTelemetry with a framework instrumentor and the regional OTLP endpoint. For Python, installopeninference-instrumentation-langchain and follow the OpenInference LangChain setup. It supports LangChain and LangGraph. For Node.js, use OpenInference LangChain.js.
Configure the exporter using the Observability quickstart:

