Get started ยท 3 min read

Installation

Install LangChain and wire up your first model provider.


LangChain ships as a small core package plus provider integrations you install on demand. Start with the core and add only the providers your application talks to.

Install the core packages

bash
pip install langchain langchain-core
pip install langchain-openai  # or any other provider

For JavaScript and TypeScript projects the equivalent packages are published on npm.

bash
npm install langchain @langchain/core @langchain/openai

Set your provider credentials

Model providers are configured with environment variables so keys never end up in source control.

bash
export OPENAI_API_KEY="sk-..."

Note

Keep credentials in an environment file or secret manager. LangChain reads them lazily, the first time a model is invoked.

Verify the install

python
from langchain.chat_models import init_chat_model

model = init_chat_model("gpt-4o-mini", model_provider="openai")
print(model.invoke("Say hello in five words.").content)