LangChain 1 cheatsheet

LangChain 1: Setup

4 common LangChain 1 tasks.

Install LangChain

Install the core package. Add a provider package for the model you use.

pip install -U langchain

Install a model provider

Install the integration package for Anthropic. Other providers have packages such as langchain-openai.

pip install -U langchain-anthropic

Set the provider API key

The integration reads the key from an environment variable. Use your own key and keep it out of source control.

export ANTHROPIC_API_KEY="your-api-key"

Turn on LangSmith tracing

Send traces of every run to LangSmith to inspect prompts, tool calls and latency.

export LANGSMITH_TRACING=true
export LANGSMITH_API_KEY="your-api-key"

Was this page helpful?