Chapter 1 · Your Developer Toolbox
Git, APIs and Backends: Why AI Engineers Need Them
- Page 1 of 22
- 10 min read
You have trained a model, called an LLM from Python and stored data in a database. Now comes the question every AI engineer meets sooner or later: how does any of this become something other people can use? A notebook on your laptop is not a product. A product is code that lives in a repository where a team can work on it together, is reachable over the network through an API, runs on a server that is not your laptop, and keeps working when you are asleep.
This tutorial teaches the skills that connect your AI work to the real world: Git to keep and share your code safely, HTTP and web APIs to talk to other systems (including LLM providers), and a backend you build yourself with FastAPI. This first page is the map: how the pieces fit together, what each later page builds, and how to set up your machine.
What you will learn
- How a real AI product is put together: repository, API, backend, model or LLM, deployment
- Why Git, APIs and backends matter even if you "only want to do AI"
- The tools you will use, and what each of them is for
- What the 22 pages of this tutorial build, and the project you will finish with
- How to follow along on Windows, macOS or Linux
How an AI product fits together
Picture a small product: a service that reads a customer review and answers with its sentiment, or a chat assistant for your university's courses. Behind the screen there are always the same five layers:
1. Repository your code, prompts and settings, versioned with Git
|
v
2. Backend a program that runs all the time and waits for requests (FastAPI)
|
v
3. API the agreed "menu" of requests it understands (HTTP + JSON)
|
v
4. Model / LLM a scikit-learn model in the backend, or a call to an LLM provider
|
v
5. Deployment a server or cloud service that keeps it running for everyoneA user's app, a website or another program sends an HTTP request to your API. Your backend checks it, runs the model (or calls an LLM provider's API, which is itself just another HTTP API), and sends back a response, usually JSON. All of that code is kept in a repository, and deployment copies it to a machine that stays on.
| Layer | Question it answers | Tool in this tutorial |
|---|---|---|
| Repository | Which version is this? Who changed it, and why? Can I go back? | Git, GitHub |
| Backend | What program answers requests, and how does it check them? | Python, FastAPI, Pydantic |
| API | How do other programs talk to mine, and I to theirs? | HTTP, JSON, curl, requests |
| Model / LLM | Where does the intelligence come from? | Your Python code, an LLM API |
| Deployment | How does it run for real users, safely? | Covered in the Advanced tutorial |
Why an AI engineer needs this
- Almost every AI product is an API. A model only becomes useful to others when something calls it. The "AI" part is often one function inside a backend.
- You already use APIs. Every call to an LLM provider is an HTTP request with a key, a JSON body and a JSON answer. Understanding that makes errors such as 401, 422, 429 and timeouts readable instead of mysterious.
- Prompts, code and configuration change constantly. Without Git you cannot tell which change made the answers worse, and you cannot work with a team.
- Secrets and cost. A leaked API key or an endpoint without limits turns into a bill. Handling keys, validation and errors properly is part of the job.
- Jobs ask for it. AI engineer roles list Git, REST APIs and a Python web framework next to machine learning.
The tools
| Tool | What it is | Where you meet it |
|---|---|---|
| Terminal and shell | The text interface where you type commands | The Terminal: Files, Paths and Commands |
Python, venv, pip, uv | The language and its environment and package tools | Environment Variables, .env Files and Virtual Environments |
| Git | Version control on your own machine | Pages 4 to 8 |
| GitHub | A website that hosts Git repositories for sharing and review | Pages 9 and 10 |
curl | A command-line HTTP client for trying APIs by hand | Pages 11 to 13 |
requests | The Python library for calling APIs from code | Pages 14 and 15 |
| FastAPI and Pydantic | A Python framework for building APIs, and data validation | Pages 16 to 18 |
| pytest | Automated tests for your code | Page 19 |
What the tutorial builds
There are four chapters, and each one ends with something you can run:
- The terminal, environments and Git (pages 2 to 10): move around with confidence, keep projects tidy, make commits, ignore secrets, undo mistakes, branch, merge, and publish your first project through GitHub.
- HTTP and web APIs (pages 11 to 15): see what really travels over the network, read API documentation, call APIs with
curland Python, and make those calls reliable with timeouts, retries and pagination, including a chat-style LLM API. - Your own backend (pages 16 to 19): build an API with FastAPI, validate input with Pydantic, return correct errors, and test it with pytest.
- The project (pages 20 to 22): the BitByte Data Explorer API, a FastAPI service that calls another API, reshapes its data and handles failures properly. You build it on a Git branch, test it, document it and merge it. Then a cheat sheet closes the tutorial.
The Advanced tutorial continues with Docker, authentication, databases, serving a model, an LLM backend with streaming, GitHub Actions and deployment.
Practising without the internet
Real APIs change, need accounts and cost money, which is a poor way to learn. So this tutorial comes with the BitByte Practice API, a small server that runs on your own computer at http://localhost:8800 and behaves like a real one: pagination, API keys, tokens, rate limits, flaky failures and even a fake chat model. Every example answers the same way for everyone. You will start it on the page Web APIs and REST: Reading Docs and Testing with curl; for now, just look at what it says when asked (until you start it, your own curl will report that the connection was refused):
curl -s http://localhost:8800/ | python -m json.tool{
"name": "BitByte Practice API",
"version": "1.0.0",
"docs": "/docs"
}localhost means "this computer", and 8800 is the port the server listens on. The response is JSON, the format you already know from Python.
Setting up your machine
You need four things: a terminal, Python 3.12 or newer (the tutorial uses 3.14), Git, and curl. An editor such as VS Code is recommended. Commands in this tutorial are for a bash shell, which is what you get on macOS and Linux:
| System | What to use |
|---|---|
| Linux | Your normal terminal. Install Git and Python with your package manager, for example sudo apt install git python3 python3-venv curl on Ubuntu or Debian. |
| macOS | The Terminal app. Run xcode-select --install or install Git with Homebrew (brew install git python). curl is already there. |
| Windows | Best: WSL (Windows Subsystem for Linux), which gives you a real Linux shell, then follow the Linux column. Also fine: install Git for Windows, which includes Git Bash, and use that. Plain PowerShell works for most of Git, but the bash commands (pipes, export, cat) differ, so where it matters the pages show the PowerShell form in a small table. |
Check that everything is installed. This loop asks the shell where each tool is, and the last line checks the Python version (on some systems the command is python3; use whichever works):
for tool in git python curl; do
command -v $tool > /dev/null && echo "$tool: found" || echo "$tool: MISSING"
done
python -c "import sys; print('Python OK' if sys.version_info >= (3, 12) else 'Python is older than 3.12')"git: found
python: found
curl: found
Python OKAnything reported as MISSING needs installing before the next pages. To see exact versions run git --version, python --version and curl --version | head -n1; the numbers will differ from machine to machine, and that is fine. The page Environment Variables, .env Files and Virtual Environments goes through installing and checking each tool in detail.
How to study this tutorial
- Type the commands. Reading Git is like reading about swimming. Every output on these pages was produced by really running the commands.
- Do the exercises. Each page ends with Easy, Medium and Hard tasks with answers. Try before you look.
- Break things on purpose. A repository or server on your laptop is a safe place to make a mistake and see what happens.
- Keep one project folder. Use
~/projectsand a folder per exercise, so you can always find your work. - Expect different hashes and dates. Your commit hashes and times will not match the pages, because they depend on who you are and when you ran the command.
Common mistakes
- Skipping the "boring" tools. The terminal and Git feel like detours from AI. They are the part that stops you losing work, and every later page assumes them.
- Copying commands without reading the output. The output tells you whether it worked. Read it, and compare with the page.
- Installing packages into the system Python. It works until two projects need different versions. Use a virtual environment per project, as you will see in the next chapter.
- Using Windows PowerShell with bash commands. Many fail with confusing errors. Use WSL or Git Bash, or the PowerShell form where the pages give it.
Try it yourself
- Easy: Run the check loop on your own machine. Is anything missing? Write down how you will install it.
- Medium: Draw the five layers for a product you would like to build (for example "answer questions about my notes"). Name one real tool or file for each layer.
- Hard: Ask the Practice API's
/healthendpoint whether it is alive, and print only the HTTP status code that comes back, usingcurl -s -o /dev/null -w "%{http_code}\n".
Answers
1. Install what is missing with the commands in the table above, then run the loop again until nothing says MISSING.
2. One possible answer: repository = a GitHub repository with app.py and prompts/; backend = a FastAPI app; API = a POST /ask endpoint that takes and returns JSON; model = an LLM provider called with requests; deployment = a small cloud service with the API key kept in an environment variable.
3. -o /dev/null throws the body away and -w prints just the status code (on Windows PowerShell use NUL instead of /dev/null):
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8800/health200Summary
- A deployed AI product is a chain: repository, backend, API, model or LLM, deployment.
- Git keeps your code safe and shareable; APIs and HTTP let programs talk; a backend is the program that answers.
- This tutorial teaches the terminal, Git and GitHub, HTTP and
requests, FastAPI with Pydantic, and testing, and ends with the BitByte Data Explorer API. - The offline Practice API gives every learner the same answers, on
http://localhost:8800. - Use bash on macOS and Linux, or WSL or Git Bash on Windows, and check your tools before starting.
Next: The Terminal: Files, Paths and Commands. You will learn to move around your computer, create and search files, and chain commands, the skill all the later pages stand on.

