Turning AI capabilities into usable product interfaces
Week 30 • Day 1 • 3 hoursA model is only useful when something can call it. APIs are the contract between your ML system and every product, client, and teammate that depends on it. API-first design is how you ship MVPs that don't collapse the first time someone integrates with them.
Grab the starter code and go. Every command below is copy-paste ready.
1. Download & unzip the starter:
curl -LO https://class.wize73.com/W30D1/starter.zip unzip starter.zip -d week30_product_lab cd week30_product_lab
2. Install deps and run:
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r api/requirements.txt
uvicorn api.main:app --reload
3. Confirm it works:
curl http://localhost:8000/health
# {"status":"ok","uptime_seconds":3,"model_loaded":true}
Every AI product — whether it's a chatbot, a vision system, or a recommendation engine — shares this shape. Your job tonight is the second layer: the stable contract every client and downstream system talks to.
api/api_design.mdapi/main.py with /health and /predict.api/api_spec.md with versioning + examples.You'll extend this in the lab. Every endpoint you add should have a clear purpose, a typed request, a predictable response, and a documented error condition.
from fastapi import FastAPI from pydantic import BaseModel app = FastAPI(title="AI Product MVP API", version="1.0.0") class PredictRequest(BaseModel): text: str class PredictResponse(BaseModel): prediction: str confidence: float @app.get("/health") def health(): return {"status": "ok"} @app.post("/predict", response_model=PredictResponse) def predict(req: PredictRequest): # TODO: wire to your ML inference function return PredictResponse(prediction="example", confidence=0.85)
/docs.
Two pieces of infrastructure, for free, the moment you describe your contract.
api/api_design.md. Define POST /predict, GET /health, GET /metadata. For each: purpose, request schema, response schema, error conditions.
api/main.py. Run with uvicorn api.main:app --reload.
curl http://localhost:8000/health. Open http://localhost:8000/docs. Try the playground page.
api/api_spec.md — endpoint descriptions, example requests/responses, versioning approach.
Resource naming, HTTP methods, request & response design.
restfulapi.net →Submit under week30_product_lab/api/:
api_design.md — endpoint specs with "why" sectionsapi_spec.md — full documentation + versioning strategymain.py — running FastAPI servicerequest_examples.md — curl / httpie examples for each endpoint