Skip to main content

Prerequisites

Before you begin, ensure you have the following:
  • Chrome browser (recommended for the best experience)
  • Python 3.12 or 3.13 - See Python version management below
  • Package manager: uv (recommended) or pip

Installation

1

Clone the repository

Download the course repository using a shallow clone to get only the latest code:
git clone --depth 1 https://github.com/langchain-ai/lca-reliable-agents.git
cd lca-reliable-agents/python
2

Create environment file

Make a copy of the example environment file:
cp example.env .env
3

Configure API keys

Edit the .env file to include your API keys:
# Required
OPENAI_API_KEY='your_openai_api_key_here'

# Optional, used by the question generator
ANTHROPIC_API_KEY='your_anthropic_api_key_here'

# Required for evaluation and tracing
LANGSMITH_API_KEY='your_langsmith_api_key_here'
LANGSMITH_TRACING=true
LANGSMITH_PROJECT=lca-reliable-agents

# Uncomment the following if you are on the EU instance:
#LANGSMITH_ENDPOINT=https://eu.api.smith.langchain.com
Where to get API keys:
4

Install dependencies

Create a virtual environment and install dependencies:
uv sync
Using uv is recommended as it automatically manages Python versions and creates optimized virtual environments. It will install a compatible Python version (3.12 or 3.13) in the .venv directory when running uv sync.
5

Verify setup

Run the verification script to ensure everything is configured correctly:
uv run python env_utils.py
The verification script checks:
  • ✅ Python executable location and version (must be 3.12 or 3.13)
  • ✅ Virtual environment is properly activated
  • ✅ Required packages are installed with correct versions
  • ✅ Packages are in the correct Python version’s site-packages
  • ✅ Environment variables (API keys) are properly configured
If the script flags any issues, see the troubleshooting section below.

Running Scripts

This course uses Python scripts (not notebooks). Here’s how to run them:
# Example: run the agent interactively
uv run python officeflow-agent/agent_v5.py

# Example: run an experiment
uv run python module-2/lesson-3/run_experiment.py
When using uv, you don’t need to manually activate the virtual environment. The uv run command automatically uses the correct Python version and environment.

Python Version Management

Managing your Python version is best done with virtual environments. This allows you to select a Python version for the course independent of the system Python version. uv will automatically install a version of Python compatible with the versions specified in the pyproject.toml file. When you run uv sync, it installs the correct Python version in the .venv directory and uses it automatically with uv run. For more information, see the uv documentation.

Using pyenv + pip

If you’re using pip instead of uv, you can use pyenv to manage your Python versions:
pyenv install 3.13
pyenv local 3.13
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Environment Variables

This course uses the dotenv module to read key-value pairs from the .env file and set them in the environment. They do not need to be set globally in your system environment.
If you have API keys already set in your system environment, they may conflict with the ones in your .env file. The env_utils.py verification script will detect and warn you about such conflicts. By default, load_dotenv() does not override existing environment variables.

LangSmith Configuration

LangSmith is required for evaluation and tracing in this course:
1

Create account

Sign up for a free LangSmith account
2

Generate API key

Navigate to Settings → API Keys and create a new API key
3

Update .env file

Add your LangSmith API key to the .env file:
LANGSMITH_API_KEY='your_langsmith_api_key_here'
LANGSMITH_TRACING=true
LANGSMITH_PROJECT=lca-reliable-agents
If you’re on the EU instance of LangSmith, uncomment and use LANGSMITH_ENDPOINT=https://eu.api.smith.langchain.com in your .env file.

Troubleshooting

ImportError when running env_utils.py

If you see an error like ModuleNotFoundError: No module named 'dotenv', you’re likely running Python outside the virtual environment. Solution:
  • Use uv run python xxx.py (recommended), or
  • Activate the virtual environment first:
    • macOS/Linux: source .venv/bin/activate
    • Windows: .venv\Scripts\activate

Environment Variable Conflicts

If you see a warning about “ENVIRONMENT VARIABLE CONFLICTS DETECTED”, you have API keys set in your system environment that differ from your .env file. Solutions:
  1. Unset the conflicting system environment variables (commands provided in warning)
  2. Use load_dotenv(override=True) in your scripts to force .env values to take precedence
  3. Update your .env file to match your system environment

LangSmith Tracing Errors

If you see “LANGSMITH_TRACING is enabled but LANGSMITH_API_KEY still has the example/placeholder value”, you need to set a valid LangSmith API key in your .env file. Solution: Replace the placeholder value in .env with your actual LangSmith API key from smith.langchain.com.

Wrong Python Version

If you see a warning about Python version not satisfying requirements (must be 3.12 or 3.13): Solutions:
  • If using uv: Run uv sync which will automatically install the correct Python version
  • If using pip: Install Python 3.12 or 3.13 using pyenv or from python.org

Model Providers

The course primarily uses OpenAI’s gpt-5-nano model, which is very inexpensive. If you don’t have an OpenAI API key, sign up here. You can optionally obtain an Anthropic API key here for the question generator.
This course has been created using particular models and model providers. You can use other providers, but you’ll need to update the API keys in the .env file and make necessary code changes. LangChain supports many chat model providers - see the full list here.

Development Environment

This course uses Python scripts that you can edit and run in any editor, including:
  • VSCode
  • Cursor
  • Windsurf
  • Any text editor with a terminal

Using Coding Agents

If you’re using coding agents during the course, you can provide your agent access to the LangSmith documentation. Instructions are available here.

Build docs developers (and LLMs) love