Why 21YunBox Pricing Contact Log in
Talk to an expert Test your site in China

Does LangChain Work in China? Data Residency, ICP & Cross-Border Rules

LangChain is open-source orchestration code you embed and run yourself, so it is residency-neutral. The real China question is not LangChain — it is where the models and vector stores it calls live, and whether your prompts and RAG context cross the border to offshore inference under PIPL and the CAC generative-AI filing gate.

Does LangChain work in China?

LangChain is an open-source orchestration library you embed in your own application and run yourself, so the mainland question is not whether LangChain "works" — it is residency-neutral code. What decides it is where the models, vector stores, and tools it calls actually live.

Point a chain at an offshore inference endpoint and every prompt, every piece of retrieved RAG context, and every completion leaves the country — a cross-border transfer of personal information, and often your most sensitive internal corpus, under PIPL. Ship a public-facing generative feature to mainland users and the CAC generative-AI filing and an ICP filing apply on top. The compliant path keeps LangChain itself running in-country, pointed at CAC-filed domestic or sovereign models, with prompts and data kept resident.

What LangChain's own documentation says about China

FactPrimary source
LangChain's GitHub repository opens its README with "LangChain is a framework for building agents and LLM-powered applications," and the About panel labels the project "MIT license" — open-source code you embed and run yourself, with no hosted service and no region to select. LangChain GitHub repository, README and license label, retrieved 2026-10-14
LangChain's documentation describes building an agent by composing "exactly the agent your use case needs from model, tools, prompt, and middleware," and names LangSmith as the hosted service to "trace, debug, and evaluate" — so residency depends on the model and tools you choose, and the managed trace cloud runs offshore. LangChain documentation, overview page, retrieved 2026-10-14
Prompts, retrieved RAG context, and model outputs sent from the mainland to an offshore model are a cross-border transfer of personal information under PIPL Articles 38–40 (notice, a separate consent, and one transfer mechanism); Article 28 adds heightened duties for sensitive personal information. PRC Personal Information Protection Law, Articles 28 and 38–40
Using generative AI to provide content services "to the public" within mainland China requires a CAC filing plus content-safety measures and AI-content labeling; the duty sits on the public feature you build with LangChain, not on the upstream model provider. Interim Measures for the Management of Generative AI Services (生成式人工智能服务管理暂行办法), CAC

Sources verified by the 21YunBox compliance team on 2026-10-14.

For a mainland-China audience, the first thing to settle about LangChain is that the question is not whether it loads, and not really about LangChain at all. LangChain is an open-source orchestration library — you install it with a package manager and embed it inside your own application, where it runs wherever you run that application. By itself it is residency-neutral code: it holds no model and stores no data. What it does is wire together the pieces that do — the large language model you call, the vector store your retrieval reads from, the tools your agents invoke. So “does LangChain work in China” resolves into a different question: where do those pieces live, and does the data your chains move cross the border to reach them? Point a chain at an offshore inference endpoint and every prompt, every chunk of retrieved context, and every completion leaves the country. That border crossing is the compliance event — not the round-trip time, and not the library.

LangChain's GitHub repository, showing the README opening sentence describing it as a framework for building agents and LLM-powered applications, with an MIT license label in the About panel
"LangChain is a framework for building agents and LLM-powered applications." LangChain's own GitHub repository says so in the first line of its README, and the About panel labels the project "MIT license" — it is open-source code you embed and run yourself, with no hosted service and no in-country region to select. Residency is decided by what you point it at. Source: github.com/langchain-ai/langchain

LangChain in China at a glance

What decides it In LangChain's own terms — and China's law
Where it actually runs LangChain is open-source code, distributed under an MIT license, that you embed in your own application and run wherever you deploy it. There is no LangChain "service" with a region to select — so the library itself is residency-neutral. What is not neutral is the endpoints you configure: the model, the vector store, and the tools your chains and agents call.
What you send it, and why it is personal information To answer a request, LangChain assembles a prompt, retrieves context from your corpus (RAG), passes inputs to tools, and returns a completion. That stream routinely carries names, contact details, customer records, and the internal documents you retrieve over — personal information, and sensitive personal information under PIPL Article 28 where IDs, financial, or health data appear. Your RAG corpus is often the most confidential data your company holds.
Data crossing the border to an offshore model When a user in the mainland triggers a chain pointed at an offshore model or managed vector store, that prompt and retrieved context leave the country. Under the Personal Information Protection Law that is a cross-border transfer (Articles 38–40): notice, a separate consent, and one transfer mechanism — a CAC security assessment, the CAC standard contract, or certification.
Does the generative-AI filing gate apply? Only if you ship a public-facing generative feature. The CAC Interim Measures for the Management of Generative AI Services govern services that generate content "to the public" within China; a build-time library used inside your app is not that. But the chatbot, assistant, or content feature you build with LangChain and offer to mainland users is — and it owes a filing, content-safety measures, and AI-content labeling.
Reachability is not the axis There is no LangChain server to ping, so this is not a block and speed is not the deciding factor. The decision turns on residency — whether your prompts, RAG context, and data may lawfully leave the country to reach the model you chose. Any China-facing surface you then ship still carries an ICP filing (备案) duty and needs compliant, in-country delivery. This page publishes no first-party latency figure; speed is the wrong axis.

The library runs where you run it — so what it calls decides residency

Start with where LangChain runs, because the whole question rests on it. LangChain is a framework you add to your own codebase: its README opens by calling it “a framework for building agents and LLM-powered applications,” and the project ships under an MIT license. There is no hosted LangChain to connect to and no in-country region to select — the library executes inside whatever application you deploy, which can just as easily sit on a mainland server as anywhere else. In that sense LangChain is reachable and usable from China in a way a blocked consumer service is not, and it can run entirely in-country.

What that also means is that LangChain never sets your residency posture — your configuration does. A chain is a pipeline of components you choose: the model endpoint, the embedding and vector store, the retriever, the tools. If those point offshore, the library faithfully ships your data offshore to reach them; if they point to in-country infrastructure, the data stays. So the compliance question is not answered by looking at LangChain. It is answered by looking at the list of endpoints your chains and agents are wired to, and where each one lives.

What you send it is personal information — and often your most sensitive corpus

A LangChain request is not neutral text. To produce an answer, the library assembles a prompt, retrieves supporting context from your own corpus, passes inputs and outputs through tools, and returns a completion — and that corpus is frequently the most confidential material a company holds: internal wikis, support tickets, contracts, HR records, source documents. The moment a user in China triggers a chain that reaches a model hosted outside the mainland, that prompt and retrieved context are a cross-border transfer of personal information under China’s Personal Information Protection Law. PIPL puts the duty on the handler — you: Articles 38–40 require notice, a separate consent, and one transfer mechanism (a CAC security assessment, the CAC standard contract, or certification), and Article 28 adds heightened duties where the data is sensitive — government IDs, financial, health, biometric, or minors’ information that so often turns up in retrieved documents.

Before it is a compliance question it is a confidentiality one: a representation of your proprietary knowledge base leaving the country on every retrieval. And if any of that data is “important data,” or your organization operates critical information infrastructure, the Cybersecurity Law adds a data-localization duty — Article 39 (formerly Article 37; renumbered by the 2025 amendment in force January 1, 2026, substance unchanged) requires personal information and important data collected and generated in-country by such operators to be stored in-country, with a security assessment before any export.

LangSmith and LangGraph Platform add an offshore hosted path

The open-source runtime is one thing; LangChain’s managed cloud is another, and it is worth being plain about it. LangSmith is LangChain’s hosted service to trace, debug, and evaluate what your agents do, and LangGraph Platform is its hosted way to deploy them. Both are managed clouds that run offshore, with no mainland-China region. Tracing is the sharp edge here: a trace captures the full prompt, the retrieved context, the intermediate steps, and the model output — exactly the sensitive stream discussed above. Sending traces or deployments to that cloud is therefore a second cross-border transfer to assess, separate from the model call itself, even if your inference endpoint is otherwise in-country. The lever is to keep orchestration and observability resident — run the open-source runtime inside your own in-country environment rather than routing traces and deploys to the offshore managed cloud.

The generative-AI filing gate — only if you ship to the public

On the filing gate, the honest answer for a build-time library is lighter than for a consumer AI service — and it is worth saying so. China’s Interim Measures for the Management of Generative AI Services (生成式人工智能服务管理暂行办法) apply to using generative AI “to provide services for generating text, images, audio, video, and other content to the public within the territory of the People’s Republic of China.” LangChain sitting inside your codebase is not a public content service, so the measure does not attach to the library. The caveat is about what you build with it: take a LangChain-powered chatbot, assistant, or content feature to the Chinese public and that downstream service is exactly what the measure governs — needing its own filing, content-safety measures, and AI-content labeling, and, where it ranks or recommends, the Algorithm Recommendation Provisions as well. Any China-facing surface you ship also carries an ICP filing (备案) duty. This page maps exposure; it does not rule on your facts — settle the specifics with your counsel against the real product and data you handle.

Why a reachability check misses this

A reachability or latency test pings an endpoint and reports whether it answers and how fast. For LangChain that test answers the wrong question twice over. First, there is no LangChain endpoint to ping — the library runs inside your app, so a green light tells you nothing about where your prompts and RAG context end up. Second, what actually decides compliance is invisible to a probe: which model and vector store each chain is wired to, whether the data crossing to them is personal or sensitive, and whether the public feature you built owes a CAC filing. Those are configuration and legal facts, not network facts. That is the half a pure speed-or-reachability view cannot supply — and the half we lead with.

The lawful path — map, localize, deliver

For an open-source library, 21YunBox’s role is focused, and we will say so plainly: there is no “domestic LangChain” to sell you — the library is already yours to run, including in-country. Our value is in three moves.

First, we map the exposure: the actual list of endpoints your chains and agents call — models, vector stores, retrievers, tools, and any LangSmith or LangGraph Platform cloud — which of them sit offshore, whether the prompts and retrieved context crossing to them are personal, sensitive, or “important data,” and how that lands against PIPL’s cross-border rules, Article 28, and the Cybersecurity Law, so you and your counsel can set the guardrails. Second, we help you localize the calls that cannot lawfully be served offshore: run LangChain itself in-country and point those chains at a CAC-filed domestic large model or an in-country sovereign model, with an in-country vector store and consented, resident processing for what must stay on mainland soil. This is a China-legal alternative, never a route to an offshore model. Third, we deliver any China-facing surface your team ships — the app, assistant, or API edge your mainland users hit — over ICP-filed, in-country infrastructure (the 21YunBox Optimizer), in front of the stack you already run, with no rebuild and no second codebase.

21YunBox is a compliant overlay, not a migration, and a partner to the tools you use, not a competitor to them. 21YunBox never uses or suggests circumvention of any kind. The result is a setup that runs legally and compliantly for your users in China.

Get a compliance assessment →


Related reading:

Frequently Asked Questions

Is LangChain blocked in China?
No. LangChain is an open-source Python and JavaScript library you install and run inside your own application, so there is nothing to block and reachability is not the issue. The compliance question is where the models, vector stores, and tools it orchestrates live, and whether your prompts and RAG context cross the border to reach them.
If I self-host LangChain in China, am I compliant?
Running the library in-country is the right first move, but it is not automatic compliance — it depends on what you point it at. A chain that calls an offshore model still makes a PIPL cross-border transfer, and a public-facing generative feature still owes the CAC filing and an ICP filing. The lever is to pair in-country LangChain with CAC-filed domestic or sovereign models and keep prompts and RAG data resident.
Does using LangSmith or LangGraph Platform change the picture?
Yes. LangSmith and LangGraph Platform are LangChain's hosted managed cloud, which runs offshore with no mainland region. Sending traces or deployments there moves your prompts, retrieved context, and outputs across the border — a separate transfer to assess, even if your inference endpoint is in-country. Keeping orchestration and observability in-country avoids that exposure.

ARTICLES RELATED TO LANGCHAIN

Make Your Site Work inside the Great Firewall of China

Enter your information, and our staff will assist you in getting a 21YunBox account for China.

Make Your Site Work Within the Great Firewall of China
Make Your Site Work Within the Great Firewall of China

By clicking 'Get Started', I also agree to 21YunBox's Terms of Service and Privacy Policy.