Skip to content

Integration / Developer framework

LangChain, routed by jurisdiction.

Keep your LangChain chains, agents and LangGraph workflows as they are: point ChatOpenAI or ChatAnthropic at a YTT Secunet regional base URL with the policy headers, and every model call inside the framework is checked, routed and receipted.

LangChain logo

LangChain

Developer framework

Regions documented
4
Setup steps
6

How YTT Secunet works with LangChain

LangChain is an open-source framework, in Python and JavaScript, for building applications on language models: prompt templates, retrievers, tools and agents, with LangGraph as its library for stateful, multi-step agent workflows. Provider support ships as separate integration packages. In Python, ChatOpenAI from langchain-openai and ChatAnthropic from langchain-anthropic both accept a base_url and a default_headers mapping, which is all a gateway needs.

Because YTT Secunet speaks the OpenAI and Anthropic wire formats, there is no YTT Secunet-specific LangChain class to install. You construct the chat model with base_url set to your regional data plane, such as https://eu.yttsecunet.com/v1 for ChatOpenAI, and pass X-YTT-Policy and X-YTT-Tenant as default headers. Streaming, tool calling and structured output pass through unchanged. An agent that loops ten times makes ten model calls, and each gets its own policy decision, PII masking pass and signed receipt, so a single agent run can be reconstructed call by call. The same applies to OpenAIEmbeddings, which matters for retrieval: documents you embed while building a vector store leave your network too.

YTT Secunet governs the model calls, not everything a chain does. Tools that call third-party APIs, document loaders that fetch from the web and vector databases sit outside the gateway's path and need their own residency review. So does tracing: with LangSmith tracing switched on, LangChain sends the inputs and outputs of each run to LangSmith. LangSmith offers a US region, an EU region (eu.api.smith.langchain.com, hosted on Google Cloud in the Netherlands) and self-hosting, so set the tracing endpoint deliberately, or turn tracing off for regulated tenants.

LangChain regions and jurisdictions

Region or deploymentLocationJurisdiction
EU data plane (eu.yttsecunet.com)Frankfurt am Main, GermanyEU / European Union
UK data plane (uk.yttsecunet.com)United KingdomUK / United Kingdom
Swiss data plane (ch.yttsecunet.com)SwitzerlandCH / Switzerland
US data plane (us.yttsecunet.com)United StatesUS / United States

Connect LangChain: setup steps

  1. 01

    Install the provider packages you already use, for example pip install langchain-openai langchain-anthropic. No YTT Secunet package is required.

  2. 02

    Create a YTT Secunet API key for the application in the console, and decide which policy pack and tenant identifier each LangChain model instance should send.

  3. 03

    Construct ChatOpenAI with base_url set to the regional data plane (https://eu.yttsecunet.com/v1) and the two YTT Secunet headers in default_headers. Construct ChatAnthropic the same way, with base_url https://eu.yttsecunet.com.

  4. 04

    Point OpenAIEmbeddings at the same base URL, so documents embedded for retrieval are routed and receipted like chat calls.

  5. 05

    Decide where traces go: set LANGSMITH_ENDPOINT to LangSmith's EU endpoint or to your self-hosted instance, or set LANGSMITH_TRACING to false for tenants whose policy forbids it.

  6. 06

    Set include_response_headers=True on ChatOpenAI to read the X-YTT-Proof-Signature receipt from the message's response_metadata, and verify a few receipts offline with ytt-verify before moving production traffic.

Configuration

pythonLangChain through YTT Secunet
import os
from langchain_anthropic import ChatAnthropic
from langchain_openai import ChatOpenAI, OpenAIEmbeddings

headers = {
    "X-YTT-Policy": "eu-gdpr-strict",
    "X-YTT-Tenant": "tenant-nl-0219",
}
key = os.environ["YTT_SECUNET_API_KEY"]

gpt = ChatOpenAI(
    model="gpt-4.1",
    base_url="https://eu.yttsecunet.com/v1",
    api_key=key,
    default_headers=headers,
    include_response_headers=True,
)

claude = ChatAnthropic(
    model="claude-sonnet",
    base_url="https://eu.yttsecunet.com",
    api_key=key,
    default_headers=headers,
)

embeddings = OpenAIEmbeddings(
    model="text-embedding-3-small",
    base_url="https://eu.yttsecunet.com/v1",
    api_key=key,
    default_headers=headers,
)

msg = gpt.invoke("Summarise the termination clause in plain language.")
print(msg.response_metadata["headers"]["x-ytt-proof-signature"][:48])

Policy notes

  • Create one chat model instance per policy and tenant combination. Instances are cheap, and binding the headers at construction stops a request for one tenant from travelling under another tenant's policy.
  • Each model call in an agent loop is evaluated on its own, so a tool result that brings personal data into the next turn is masked before that turn reaches the model.
  • Embedding calls run under the same policy pack as chat calls: a document that would be refused in a prompt is also refused for embedding.
  • Do not use with_fallbacks to fall back to a model instance that calls a provider directly. That path bypasses residency enforcement; configure in-jurisdiction failover in YTT Secunet instead.
  • Tools, retrievers and vector stores are not on the gateway path. Record them separately in your RoPA and DPIA; YTT Secunet receipts cover the model calls only.

LangChain questions

Do I need a YTT Secunet package for LangChain?

No. LangChain's own ChatOpenAI and ChatAnthropic classes work against YTT Secunet because the gateway speaks the OpenAI and Anthropic APIs. You change the base URL and add two headers.

Does this work with LangGraph agents?

Yes. LangGraph nodes call the same chat model objects, so every model call in the graph goes through YTT Secunet with its own policy decision and receipt. Tools the graph calls directly are outside the gateway's path.

Will LangSmith tracing undo the residency controls?

It can, because tracing sends run inputs and outputs to LangSmith. Use LangSmith's EU region or a self-hosted instance for EU tenants, or switch tracing off for policies that forbid it. YTT Secunet receipts give you per-call evidence without sending prompt content anywhere.

What about LangChain.js?

The same approach works. With @langchain/openai, pass baseURL and defaultHeaders inside the configuration object when you construct ChatOpenAI.

Related integrations

Sovereign route ready

Stop risking 4% global turnover GDPR fines on AI inference.

Deploy sovereign, cryptographically proven AI routing in 15 minutes.