需自行准备模型厂商的 API Key 与网络访问;示例中的模型名需替换为实际可用的模型;复杂智能体编排需另装 LangGraph
langchain
langchain-aiMIT活跃维护用 Python 搭建 LLM 应用和智能体的开发框架,把模型调用、工具、检索和记忆串成可组合的链路,省去自己拼装底层胶水代码。
The agent engineering platform.
构建智能体与 LLM 应用的框架,用统一接口串联模型、工具与第三方集成
用 Python 搭建 LLM 应用和智能体的开发框架,把模型调用、工具、检索和记忆串成可组合的链路,省去自己拼装底层胶水代码。
核心能力
- 用 init_chat_model 统一初始化各家聊天模型
- 提供模型、嵌入、向量库的标准接口
- 内置大量模型厂商、工具与检索器集成
- 模块化组件架构支持快速原型迭代
- 可配合 LangGraph 做可控智能体编排
容易踩的坑
- langchain-typesafe==0.0.2最新正式版2026-11-05 · 2026-11-05 22:56 UTC
Changes since langchain-typesafe==0.0.1
release(typesafe): 0.0.2 (#41720) feat(typesafe): accept a
classifierin experimental middleware (#41657) - langchain-core==1.7.62026-11-05 · 2026-11-05 00:22 UTC
查看更新说明
Changes since langchain-core==1.7.5
release(core): 1.7.6 (#41698) perf(core): merge streamed
AIMessageChunks once when accumulating runnable streams (#41697) perf(core): stopparse_partial_jsonfrom retrying one character at a time (#41467) - langchain==1.4.92026-11-04 · 2026-11-04 17:07 UTC
查看更新说明
Changes since langchain==1.4.8
release(langchain): 1.4.9 (#41684) chore(deps): require
langchain-core>=1.7.5for refusal handling (#41682) feat(core): standardize model refusal content blocks (#41582) - langchain-openai==1.7.42026-11-04 · 2026-11-04 16:55 UTC
查看更新说明
Changes since langchain-openai==1.7.3
release(openai): 1.7.4 (#41683) chore(deps): require
langchain-core>=1.7.5for refusal handling (#41682) feat(core): standardize model refusal content blocks (#41582) chore(model-profiles): refresh model profile data (#41556) - langchain-typesafe==0.0.12026-11-04 · 2026-11-04 00:11 UTC
查看更新说明
Initial release
release(typesafe): 0.0.1 (#41650) chore(infra): relax third-party dependency upper bounds (#41407) chore(deps): bump certifi from 2026.7.22 to 2026.10.19 in /libs/partners/typesafe (#41375) fix: fix dependencies in some partner packages (#41266) release(typesafe): 0.0.1a3 (#40693) feat(typesafe): make classifier questions invocation-scoped (#40659) release(typesafe): bump to 0.0.1a2 (#40576) feat(typesafe): experimental
AutoModeMiddleware(#40545) feat(typesafe): experimentalModelRouterMiddleware(#40543) fix(typesafe): trace usage metadata (#40570) feat(typesafe):TypeSafeClassifier(#40542)
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
LangChain is a framework for building agents and LLM-powered applications. It helps you chain together interoperable components and third-party integrations to simplify AI application development — all while future-proofing decisions as the underlying technology evolves.
[!TIP] Just getting started? Check out Deep Agents — a higher-level package built on LangChain for agents that have built-in capabilities for common usage patterns such as planning, subagents, file system usage, and more.
Quickstart
uv add langchain
from langchain.chat_models import init_chat_model
model = init_chat_model("openai:gpt-5.5")
result = model.invoke("Hello, world!")
If you're looking for more advanced customization or agent orchestration, check out LangGraph, our framework for building controllable agent workflows.
For an equivalent JS/TS library, check out LangChain.js.
[!TIP] For developing, debugging, and deploying AI agents and LLM applications, see LangSmith.
LangChain ecosystem
While the LangChain framework can be used standalone, it also integrates seamlessly with any LangChain product, giving developers a full suite of tools when building LLM applications.
- Deep Agents — Build agents that can plan, use subagents, and leverage file systems for complex tasks
- LangGraph — Build agents that can reliably handle complex tasks with our low-level agent orchestration framework
- Integrations — Chat & embedding models, tools & toolkits, and more
- LangSmith — Agent evals, observability, and debugging for LLM apps
- LangSmith Deployment — Deploy and scale agents with a purpose-built platform for long-running, stateful workflows
Why use LangChain?
LangChain helps developers build applications powered by LLMs through a standard interface for models, embeddings, vector stores, and more.
- Real-time data augmentation — Easily connect LLMs to diverse data sources and external/internal systems, drawing from LangChain's vast library of integrations with model providers, tools, vector stores, retrievers, and more
- Model interoperability — Swap models in and out as your engineering team experiments to find the best choice for your application's needs. As the industry frontier evolves, adapt quickly — LangChain's abstractions keep you moving without losing momentum
- Rapid prototyping — Quickly build and iterate on LLM applications with LangChain's modular, component-based architecture. Test different approaches and workflows without rebuilding from scratch, accelerating your development cycle
- Production-ready features — Deploy reliable applications with built-in support for monitoring, evaluation, and debugging through integrations like LangSmith. Scale with confidence using battle-tested patterns and best practices
- Vibrant community and ecosystem — Leverage a rich ecosystem of integrations, templates, and community-contributed components. Benefit from continuous improvements and stay up-to-date with the latest AI developments through an active open-source community
- Flexible abstraction layers — Work at the level of abstraction that suits your needs — from high-level chains for quick starts to low-level components for fine-grained control. LangChain grows with your application's complexity
Resources
- Documentation — conceptual overviews and guides
- LangChain ecosystem overview — how LangChain, LangGraph, and Deep Agents fit together
- API reference — complete reference for all public classes, functions, and types
- Discussions — community forum for technical questions, ideas, and feedback
- LangChain Academy — comprehensive, free courses on LangChain libraries and products, made by the LangChain team
- Contributing Guide — how to contribute and find good first issues
- Code of Conduct — community guidelines and standards