LangChain

Route LangChain chat models, embeddings, and rerankers through Ingate using a gateway base URL and separate gateway authentication.

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 and headers. Configure both gateway authentication and a compatible upstream provider.

Point it at Ingate

python
import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="https://api.ingateai.com/v1",
    api_key="unused", # Configured Ingate provider injects its API key.
    default_headers={"X-Ingate-Key": os.environ["INGATE_KEY"], "X-Ingate-Provider": "openai"},
)

INGATE_KEY goes in X-Ingate-Key, not the provider Bearer credential. For upstream credential passthrough, configure no provider credential injection and useapi_key=os.environ["OPENAI_API_KEY"], retaining the gateway header. Choose a compatible provider config with X-Ingate-Provider; changing that header alone does not translate every framework request or establish subscription routing.

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.). Gateway logging covers recorded proxy exchanges according to capture policy and asynchronous pipeline capacity, not every internal chain step. Configured exports can deliver supported traces to Phoenix or Langfuse; this is not durable delivery or automatic evaluation.

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