APIs for AIFastAPI 0.141 · httpx2 2.13 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
19 small wins to finish your pathNext lesson

What you are going to build

You will finish this course with a web service that other programs send support tickets to. It asks a model API to sort each one, checks the answer, and replies.

An API, application programming interface, is a way for one program to ask another for something. On the web that request travels over HTTP, the same protocol your browser uses to load a page. Every model you will call, and every service you will build around one, is reached this way.

One ticket, from start to finish
A client sends the ticket. A POST request to your service, with the ticket as JSON and a key saying who is asking.Step 1 of 5
The four parts of the course
HTTPrequestsresponses and status codesa fake server for testingBuilding an APIFastAPI endpointsparameters and bodieserrorsa real serverCalling a model APIa stand-in model APIkeysrate limits and timeoutsasync and streamingYour AI servicethe triage endpointprotecting itteststhe finished serviceAPIs for AI

No API key, no bill

In lesson 9 you build a small model API of your own. It answers in the same JSON shape as OpenAI's Chat Completions API, checks an API key, and turns requests away when they come too fast. Everything after it calls that API, so the whole course runs on your computer for free.

What you need

  • Python 3.10 or later and a terminal.
  • Lists, dictionaries, functions, classes, Pydantic, async and pytest. The Python for AI course covers all of them, and this course uses its ticket examples.

Make a folder for the course, create a virtual environment in it, and install three packages:

Example
pip install "fastapi==0.141.1" "httpx2==2.13.0" "uvicorn==0.53.0" pytest

FastAPI builds APIs. httpx2 sends HTTP requests from Python. uvicorn is the server that runs a FastAPI app so other programs can reach it. Pinning the versions means your output matches the lessons.

Back toAll frameworks

Every expert started right here.