Guide · Open source
How to use LangChain: install, first model call and key concepts
Updated · written with AI from the project's own documentation and checked against our catalogue data
LangChain is an open-source Python framework for building applications and agents powered by large language models (LLMs). This guide shows you how to add it to a Python project with uv, make your first model call, and understand what the library is for. By the end you will know where LangChain fits, when it is the right tool, and when a different library is a better choice.
Quick start
- 1Install uv. Install uv, the package manager LangChain's quickstart uses, along with Python.
- 2Add LangChain to your project. Run uv add langchain from your project folder to add the library as a dependency.
- 3Choose a model. Pick a provider and model string, such as openai:gpt-5.5, and confirm you have access to that provider.
- 4Create the model. Import init_chat_model from langchain.chat_models and pass your provider-and-model string to it.
- 5Send a prompt. Call model.invoke with a prompt and read the result.
- 6Check the right tool. If you need low-level agent orchestration, look at LangGraph; for JavaScript or TypeScript, look at LangChain.js.
What LangChain is and who it is for
LangChain provides a standard interface for models, embeddings, and vector stores, along with a library of integrations with model providers and tools. The goal is to let you connect LLMs to your own data and systems and swap models without rewriting your application.
It is a library you code against, not a finished end-user app. It suits Python developers building LLM-powered applications, teams that want to switch between model providers, and anyone prototyping LLM workflows with reusable components.
- Good fit: Python developers, teams switching model providers, developers connecting LLMs to external data and tools, rapid prototyping.
- Not a fit: people who want a ready-made app, developers who need low-level control over agent orchestration (the README points to LangGraph for that), and JavaScript or TypeScript projects (the README points to LangChain.js).
Install LangChain with uv
LangChain is installed as a package. The prerequisites listed for the project are Python and uv, a package manager. Run the command below inside your project to add LangChain as a dependency.
- Prerequisites: Python and uv.
- Run the install command from your project folder so the dependency is recorded there.
uv add langchainMake your first model call
The quickstart in the README uses init_chat_model to create a chat model from a provider-and-model string, then calls invoke with a prompt. Changing the string is how you point the same code at a different model.
The example uses the model identifier openai:gpt-5.5. Using it requires access to that provider, which the source does not cover, so check your provider's setup before running the code.
from langchain.chat_models import init_chat_model
model = init_chat_model("openai:gpt-5.5")
result = model.invoke("Hello, world!")Understand the main building blocks
LangChain's value is its shared interfaces. Models, embeddings, and vector stores each have a standard way to be used, so the code around them stays the same when you change providers.
The library also offers integrations for connecting models to external data sources and tools, and retrievers for pulling in your own content. The README describes these as a library of integrations covering model providers, tools, vector stores, and retrievers.
- Models: chat models accessed through a common interface, such as init_chat_model.
- Embeddings and vector stores: a standard interface for both.
- Integrations: model providers, tools and toolkits, vector stores, and retrievers.
- Components: modular pieces you combine, from high-level chains to low-level parts.
Know when to use LangGraph, LangChain.js or LangSmith
LangChain is one part of a wider set of products. The README names LangGraph as the framework for controllable, low-level agent orchestration, and LangChain.js as the equivalent library for JavaScript and TypeScript.
LangSmith is described as the tool for developing, debugging, and deploying agents and LLM applications, including evals and observability. Deep Agents is a higher-level package built on LangChain for agents with built-in planning, subagents, and file system use.
- Need fine-grained agent orchestration: LangGraph.
- Working in JavaScript or TypeScript: LangChain.js.
- Need evals, observability, and debugging: LangSmith.
- Want higher-level agent capabilities out of the box: Deep Agents.
Where to learn more
The README links to the official documentation, an API reference covering all public classes, functions, and types, and a community discussion forum for technical questions. LangChain Academy offers free courses on the LangChain libraries and products.
If you want to contribute, the contributing guide explains how and points to good first issues.
- Documentation: conceptual overviews and guides.
- API reference: complete reference for public classes, functions, and types.
- Discussions: community forum for technical questions.
- LangChain Academy: free courses made by the LangChain team.
What people use it for
- Connecting an LLM to your own documents or internal systems through its integrations.
- Switching between model providers without rewriting application code.
- Prototyping an LLM workflow by combining reusable components and iterating on approaches.
- Building an agent with a higher-level package such as Deep Agents, which is built on LangChain.
Frequently asked questions
Is LangChain free to use?
LangChain is released under the MIT licence, as listed on the project page. The licence covers the open-source code; any model provider you connect to may charge for its own API use, which the source does not cover.
What do I need to install LangChain?
The listed prerequisites are Python and uv, a package manager. Install LangChain by running uv add langchain in your project.
Is LangChain a Python or JavaScript library?
The main project is a Python library. The README directs JavaScript and TypeScript projects to the separate LangChain.js library.
What is the difference between LangChain and LangGraph?
LangChain provides standard interfaces, integrations, and reusable components. The README describes LangGraph as the framework for more advanced customization and low-level agent orchestration.
Can I switch model providers without rewriting my code?
That is one of the stated goals. LangChain offers a standard interface for models, so you can change the provider-and-model string passed to init_chat_model to swap models.
What are the alternatives to LangChain?
Comparable projects include LlamaIndex, Haystack, Semantic Kernel, and CrewAI. The source does not compare them in detail, so review each one against your project's needs.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
LangChain suits Python developers who want a standard interface for models, embeddings, and integrations, and who need to switch providers or connect LLMs to their own data. Pick LangGraph if you need low-level control over agent orchestration, LangChain.js if your project is in JavaScript or TypeScript, or a finished app if you do not want to write code.
Install options & downloads