Environment

For this module, all you need is Python with Jupyter.

Prerequisites

You need the following:

  • Python (3.14 or later)
  • An OpenAI account (or an OpenAI-compatible provider like Groq, Gemini, or Ollama)
  • Basic familiarity with Python and the command line

Creating the project

We'll start from scratch with no cloning needed - you'll create the project yourself, step by step, either locally or on GitHub Codespaces.

Creating the project locally

First, install uv - it's a Python package manager, and I switched all my projects to it because it's fast and convenient. Once I started using it, I never wanted to go back.

On Mac or Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh

On Windows:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

(You can also use pip install uv if you prefer.)

Create an empty folder for the project and initialize it:

mkdir llm-zoomcamp-2026-code
cd llm-zoomcamp-2026-code
uv init

This creates a pyproject.toml and a basic project structure.

Creating the project on GitHub Codespaces

We suggest using Codespaces because everyone gets the same Ubuntu, Python, and Docker. That makes it easier to help each other when problems come up.

Setup:

  • Create a new repo on GitHub. Name it whatever you want, for example llm-zoomcamp-2026-code or introduction-to-rag, and add a README.
  • Open the repo, click the green <> Code button, switch to the Codespaces tab, and create a codespace.

You now have a remote environment running in Codespaces. By default it opens an in-browser editor, but you can connect VS Code on your desktop for a better experience. Click Codespaces in the bottom-left corner and pick "Open in Visual Studio Code Desktop" from the dropdown.

Once VS Code opens, press ctrl+` to bring up the terminal and initialize the project the same way as locally:

pip install uv
uv init

Adding dependencies

Now add the dependencies we'll need:

uv add requests minsearch openai jupyter python-dotenv

This installs:

  • requests - to fetch the FAQ dataset from the internet
  • minsearch - a simple in-memory search engine for indexing and searching text
  • openai - the OpenAI API client for calling the LLM
  • jupyter - the notebook environment where we'll write and run code
  • python-dotenv - to load API keys from a .env file

Setting up API keys

We need an API key to talk to the LLM. If you're using OpenAI, you'll need to deposit some money first. The minimum is $5 (as of June 2026). This lesson costs well under 10 cents to run, so that $5 goes a long way.

I also recommend creating a separate OpenAI project for the course. Then you can open the usage page and see exactly how much you spent here, apart from your other work.

The safest way to store the key is in a .env file that never gets committed to git.

Create a .env file in your project folder and put your API key in it:

OPENAI_API_KEY=sk-YOUR_KEY_HERE

Now add .env to .gitignore to make sure you never accidentally commit your key:

.env

Never commit .env to git. Treat the API key like a password. If it leaks, someone else can run up charges on your account.

Starting Jupyter

Start Jupyter:

uv run jupyter notebook

Create a new notebook. Throughout the course, you'll copy code from the section notes into notebook cells.

Check that the OpenAI client works:

from dotenv import load_dotenv
load_dotenv()

from openai import OpenAI
openai_client = OpenAI()

If you see an error, make sure the key in your .env file is correct.

For Groq or other OpenAI-compatible providers, add the key to .env:

GROQ_API_KEY=your_key_here

And configure the client:

from openai import OpenAI
import os

openai_client = OpenAI(
    api_key=os.getenv("GROQ_API_KEY"),
    base_url="https://api.groq.com/openai/v1"
)

(Optional) Auto-loading .env with dirdotenv

If you don't want to call load_dotenv() in every notebook, use dirdotenv.

It loads .env files automatically when you cd into a directory:

uv tool install dirdotenv
echo 'eval "$(dirdotenv hook bash)"' >> ~/.bashrc

Restart your terminal, and now whenever you enter the project directory, the variables from .env are loaded automatically. No load_dotenv() needed.

← Previous: Introduction · Next: RAG →

Optional analytics

Optional analytics are off unless you allow them. Your choice does not affect access to DataTalks.Club, Slack, events, or courses.

Current choice: not chosen.

Privacy Policy

If you allow analytics, self-hosted Umami counts anonymous public pageviews without analytics cookies. Private account and learning pages are excluded. Read the Privacy Policy for the complete data boundary.