Lab 1 of 8 · Python, APIs and secrets
Set up the project and call your first API
Create the Docs Assistant repository, install everything the roadmap needs, call a public API from Python, and set up safe secret handling.
- Time
- 45–60 minutes
- Cost
- Free.
What you learn
AI engineering is mostly software engineering: calling web APIs, handling JSON, and keeping keys out of your code. This lab sets up the project and those habits.
- Virtual environments and pinned dependencies
- Calling a web API and reading JSON
- Keeping secrets in a .env file that never reaches Git
- Committing and pushing to GitHub
In the AI era: Every AI model you will use is behind a web API with a secret key. Leaking that key costs real money within minutes, so the .env habit comes first.
Before you start
Windows: install WSL (Ubuntu) and use its terminal. Mac and Linux: use Terminal.
Install Git and Python 3.11 or newer, and create a free GitHub account.
Step by step
1 Create and clone the repository
On github.com/new create a public repository called
docs-assistantwith a README, then clone it. Replace YOUR-USERNAME with yours.git clone https://github.com/YOUR-USERNAME/docs-assistant.git cd docs-assistant python3 -m venv .venv source .venv/bin/activateYou should see:Your prompt starts with
(.venv).2 List the dependencies for the whole roadmap
Installing once now saves time later. The versions are pinned so the labs keep working.
anthropic==2.14.0 python-dotenv==1.2.4 requests==2.34.2 pydantic==2.14.4 fastembed==0.9.1 mcp[cli]==2.3.0 fastapi==0.115.6 uvicorn==0.34.0 httpx==0.28.1 pytest==8.3.43 Install them
This takes a minute or two.
pip install -r requirements.txtYou should see:The last line starts with
Successfully installed.4 Keep secrets and junk out of Git
Your API key will live in
.env. This file makes sure Git never uploads it..venv/ __pycache__/ .pytest_cache/ .env5 Call a public API
This asks GitHub's public API about the Python repository and prints two fields from the JSON answer. Run it with
python github_stars.py.import requests response = requests.get("https://api.github.com/repos/python/cpython", timeout=10) response.raise_for_status() data = response.json() print(f"{data['full_name']} has {data['stargazers_count']:,} stars")You should see:A line like
python/cpython has 70,000 stars(the number changes).6 Read a setting from .env
Create
.envwith one line,GREETING=hello from .env, then run this. Later, your Claude key goes into this file in exactly the same way.import os from dotenv import load_dotenv load_dotenv() print(os.getenv("GREETING", "GREETING is not set"))You should see:hello from .env.7 Check that .env stays private, then push
git statusmust not list.env. If it does, fix.gitignorebefore committing.git status --short git add . git commit -m "Set up the Docs Assistant project" git pushYou should see:.envis not in the list, and GitHub shows your files.
You are done when
Both scripts run.
.envexists on your computer but not on GitHub.Your repository has
requirements.txtand.gitignore.
We check your public GitHub repository and give you a page to share with recruiters, and can add the project to your resume.