LangChain

Route LangChain chat models, embeddings, and rerankers through Ingate by changing the base URL, no adapter or callback handler required.

What it is

LangChain is a framework for building LLM-backed applications and agents in Python or JavaScript. Its chat model classes (ChatOpenAI, ChatAnthropic, …) accept a custom base URL, which is all that's needed to route them through Ingate instead of calling a provider directly.

Point it at Ingate

python
import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="https://api.ingateai.com/v1",
    api_key=os.environ["INGATE_KEY"],
    default_headers={"X-Ingate-Provider": "openai"},
)

INGATE_KEY is a gateway API key (X-Ingate-Key auth). LangChain's api_key parameter carries it as a standard Authorization: Bearer header, which Ingate accepts alongside X-Ingate-Key. X-Ingate-Provider tells Ingate which upstream provider config to route to; swap it (and the LangChain chat class) to point the same code at Anthropic, Azure OpenAI, a self-hosted model, or any other configured provider, Ingate's passthrough mode forwards whatever shape the client sends, so no LangChain-side adapter or translation step is needed.

This works the same way for any LangChain component built on an OpenAI-compatible client, embeddings, rerankers, streaming chat, since Ingate's proxy doesn't inspect or require a particular request shape in passthrough mode.

Observability

LangChain ships a callback-handler system for tracing (LangSmith, custom callbacks, etc.). You don't need one for Ingate: every request that passes through the gateway is already logged, and if your org has an export config configured, it's also streamed out as OTLP GenAI-semconv spans in near-real-time, no LangChain-side instrumentation required. Point that export at Arize Phoenix or Langfuse to see LangChain's calls alongside every other proxied trace.

Reference

  • Proxy API: headers, streaming, error responses
  • Providers: configuring the upstream provider(s) X-Ingate-Provider routes to
  • Trace Exports: streaming traces to an observability backend