Skip to main content
Prerequisite: Complete the Quickstart to get an access key. All requests go to https://gateway.ngrok.ai.
LangChain is a framework for building applications with LLMs. The ngrok AI Gateway works with LangChain’s OpenAI-compatible integrations, adding automatic failover and key rotation.

Installation

Basic usage

Configure LangChain to use your AI Gateway. Pass your access key (ng-xxxxx-g1-xxxxx) as the API key—the AI Gateway injects upstream provider credentials from your access key configuration.

Streaming

Stream responses for real-time output:

Using different providers

Route to different providers with model prefixes:

Chains

Build chains that route through the gateway:

Embeddings

Generate embeddings through the gateway:

RAG applications

Build RAG applications with automatic failover:

Agents

Build agents that use the gateway:

Next steps