Getting Started· 15 min

Set up your machine

What you'll learn
  • Install Python and create a virtual environment
  • Configure a .env file with your API keys
  • Verify the OpenAI API is reachable before the first session

This page sets up everything you need before Session 1. Finish it once and every session in the course will work. The stack is deliberately tiny: Python 3.10+, a virtual environment, and a .env file with your API keys.

On Windows?
The commands below use macOS/Linux syntax. For the Windows (PowerShell) equivalent, see the Windows Setup page in the sidebar.

Step 1 — Check your Python version

You need Python 3.10 or newer (3.12+ recommended for Session 6). Verify yours:

$ python3 --version

If it prints 3.10 or higher, you are good. Otherwise install Python from python.org or via Homebrew (`brew install python@3.12`).

Step 2 — Clone the course material

Grab the course folder your instructor shared with you (Session1, Session5, Session6, etc.). Open a terminal and `cd` into it:

$ cd ~/Documents/AICourse

Step 3 — Create a virtual environment

Each session folder has its own requirements. Create a venv inside the session folder you are starting with. Example for Session 1:

$ cd Session1 && python3 -m venv .venv && source .venv/bin/activate
How do I know the venv is active?
Your terminal prompt will show (.venv) at the start. When you open a new terminal you have to activate it again.

Step 4 — Install dependencies

$ pip install -r requirements.txt

This installs openai, python-dotenv, and any other libraries the session needs. Repeat this step once per session folder.

Step 5 — Create your .env file

Copy the example and open it in your editor:

$ cp .env.example .env

Paste your OpenAI API key (and, for Session 6, your Anthropic and Google keys). The file should look like this:

.env
OPENAI_API_KEY=sk-...your-key-here...
# Session 6 only
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_API_KEY=AIza...

# Optional overrides
OPENAI_MODEL=gpt-4o-mini
ANTHROPIC_MODEL=claude-sonnet-4-5
GEMINI_MODEL=gemini-2.0-flash
Never commit .env to git
It contains real API keys. The .gitignore in each session folder already excludes it — leave it that way.

See "Get Your API Keys" in the sidebar if you do not have keys yet.

Step 6 — Verify your setup

Run this tiny Python snippet to confirm the key is loaded and the API reachable:

verify.py
from dotenv import load_dotenv
import os
from openai import OpenAI

load_dotenv()
assert os.getenv("OPENAI_API_KEY"), "OPENAI_API_KEY not set"

client = OpenAI()
resp = client.responses.create(
    model="gpt-4o-mini",
    input="Say 'setup working' in 3 words.",
)
print(resp.output_text)
$ python verify.py
You are ready
If you saw any short response, setup is done. Head to Session 1 from the sidebar.