Welcome! Before we dive into building AI applications with LangChain, let's get your development environment ready. This chapter walks you through setting up your development environment and getting your GitHub token for free AI model access (you can also use Microsoft Foundry.) By the end, you'll have everything you need to start building with LangChain.
- A GitHub account (free)
- Basic command line knowledge
- Text editor or IDE
Just like setting up a workshop before building furniture, you need to prepare your development environment before building AI applications.
You'll setup your development environment, get access to AI models, and configure your tools. This ensures you have a solid foundation and smooth development experience. Let's get your workshop ready—it takes just 15 minutes!
For this coures you can use GitHub Models or Microsoft Foundry to access LLMs. To get started we recommend using Github Models.
- ✅ Free: No credit card required
- ✅ Powerful: Access to GPT-5, GPT-5-mini, and other models
- ✅ Easy: Use your existing GitHub account
- ✅ Learning: Perfect for this course!
While GitHub Models is a great option for this course, if you have an Azure subscription, you can use Microsoft Foundry for production-grade AI applications with enterprise features. If you are new to Azure you can also get a FREE Azure account with USD$200, by signing up here.
Choose from one of the following options to set up your development environment. The easiest way to get started is GitHub Codespaces, since it will setup all the tools for you, but you can also set it up locally:
- GitHub Codespaces: Use a cloud-based development environment (recommended)
- Local Development: Set up your environment on your machine.
You can open this course in GitHub Codespaces. The button below will take you to a page that has a green button that says CREATE A CODESPACE. Click that button and wait for the codespace to load. A web-based VS Code instance will open in your browser when loaded.
The terminal should automatically open and in it you should see (.venv) in front of your username. This shows that a Python virtual enviroment has been activated. This environemnt already has all the python packages required for this course installed.
All of your environment variables are automatically setup for you in Codespaces.
GitHub Models is used by default and provides free access to AI models. To use Github Models you need a Personal Access Token. In Codespaces this token, the correct endpoint and model will automatically be added to your .env file.
Ensure that your .env file exists and examine it to make sure it has these required variables.
For GitHub Models (Free):
AI_API_KEY=your_personal_token_will_show_up_here
AI_ENDPOINT=https://models.inference.ai.azure.com
AI_MODEL=gpt-5-miniAlternative: Microsoft Foundry:
If you have an Azure subscription, you can use Microsoft Foundry for production-grade AI applications and more tokens. See the Azure Setup Appendix for detailed instructions on deploying models and configuring your environment.
Thats it🎉 You can now move on to testing your setup.
You'll need Python 3.10 or higher to run LangChain v1 applications.
python --version
# or
python3 --versionIf you see Python 3.10 or higher, you're good! Skip to Step 2. If not:
- Visit python.org
- Download Python 3.10+ for your operating system
- Follow the installation instructions (make sure to check "Add Python to PATH" on Windows)
- Verify installation:
python --version # Should show 3.10 or higher
pip --version # Should show pip version# Clone the course repository
git clone https://github.com/microsoft/langchain-for-beginners
# Navigate to the project
cd langchain-for-beginners
# Create a virtual environment
python -m venv venv
# Activate the virtual environment
# On Mac/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtThis will install all required packages including:
langchain-openai- OpenAI-compatible model integrationlangchain-core- Core LangChain functionalitylangchain- Main LangChain package with additional utilitieslangchain-azure-ai- Azure specific langchain integrationspython-dotenv- Environment variable management for API keys
GitHub Models provides free access to powerful AI models—you just need a Personal Access Token.
- Visit: https://github.com/settings/tokens/new
- Token name:
langchain-course(or any name you prefer) - Expiration: Choose your preference (90 days recommended for learning)
- Scopes/Permissions:
- ✅ No scopes needed for GitHub Models!
- You can leave all checkboxes unchecked
- Click: "Generate token"
⚠️ IMPORTANT: Copy your token now and save it to a text file temporarily! You'll need it in the next step.
Mac, Linux, WSL on Windows:
cp .env.example .envWindows Command Prompt:
# Windows Command Prompt
copy .env.example .env
# Windows PowerShell
Copy-Item .env.example .envOpen .env in your text editor and configure your AI provider.
For GitHub Models (Free):
AI_API_KEY=ghp_your_github_token_here
AI_ENDPOINT=https://models.inference.ai.azure.com
AI_MODEL=gpt-5-miniReplace ghp_your_github_token_here with your actual GitHub token!
Alternative: Microsoft Foundry:
If you have an Azure subscription, you can use Microsoft Foundry for production-grade AI applications. See the Azure Setup Appendix for detailed instructions on deploying models and configuring your environment.
Let's verify everything works!
Run the following command in your terminal from the root of the project:
python scripts/test_setup.pyExpected output:
🚀 Testing AI provider connection...
✅ SUCCESS! Your AI provider is working!
Provider: https://models.inference.ai.azure.com
Model: gpt-5-mini
Model response: Setup successful!
🎉 You're ready to start the course!If you see this, you're all set! If not, check the troubleshooting section below.
Before starting the course, make sure you have:
For Codespaces:
- The Codepsace and terminal open
- A
.envwith the expected variables - Test script runs successfully
For Local development:
- Python 3.10+ installed
- Project cloned and virtual environment created
- Dependencies installed (
pip install -r requirements.txt) - GitHub Personal Access Token created if you're using GitHub Models. If you're using Microsoft Foundry, ensure your models are deployed and you have your API key and endpoint.
-
.envfile configured with your token (or key if using Microsoft Foundry) and endpoint - Test script runs successfully
- VS Code installed (optional but recommended)
You're all set! Time to build your first AI application.
👉 Continue to Introduction to LangChain
Back to Main | Next: Introduction to LangChain →
If you get stuck or have any questions about building AI apps, join:
If you have product feedback or errors while building visit:
If you run into issues with the course materials, please open an issue in the GitHub repo: