On this page
Block 1 · Week 2 · The second interface: APIs · Practice lab
Request Builder
Ten short steps, all in this browser tab. Each one ends with a checkpoint. Do them in order, then do the practice set.
Where you are
In the Round Three exercise in the notes, the machine taught you that every request carries four things, address action key package, and every reply carries two, code and package. Now you send real requests with those parts, to real machines, and finally to a model.
01The parts: your Round Three message, translated
This is the winning message from Round Three. Below it is the same request written the way HTTP writes it. Tap a coloured part to find its twin.
| In the game | On the wire | Its name |
|---|---|---|
| CREATE | POST | Method. The CRUD action is what you want; the method is how HTTP spells it. |
| …/aarav/diagnoses | https:// + host + /aarav/diagnoses | URL, or endpoint. The host names the machine, the path names the door. |
| key: | Authorization: Bearer … | A header. Written on the envelope, read without opening the letter. |
| {"workflow": …} | Content-Type + body | The body, in JSON. The header says which format it is in. |
| 201 | HTTP/1.1 201 Created | Status code, plus a reply package. |
02Read: your first request
A Read fetches something that already exists. httpbin.org is a public echo machine: it sends back whatever it receives, so you can see exactly what you sent.
- Look at the four bands. Address is filled in for you. Action is Read · GET. Key: none needed. Package: none, because a Read sends no package.
- Press Send. You should see a large 200, and under The part you want, your text.
- Type a sentence with a space in the text box, like
hello world, and watch the address. The space turns into%20before anything is sent. An address cannot hold a space, so it is translated. Your code and your tools will not always do this for you; a raw space in an address is a classic 400. - Click Show the raw request. This is the request as text: the action, the address, and nothing else.
The same request in Python
Use the folder and terminal you set up in Block 1 · Week 1 · The first interface: building UI. Install the library once with pip install requests (Mac: pip3), save this as step2.py, and run python step2.py.
params builds the address for you, %20 included.
03Create: send a package
Same echo machine, a different door, a different action. This time you send something: Aarav's Friday workflow, as JSON.
- Check the package band. It holds
{"text": "…"}and says ✓ valid JSON. Try deleting a quote: it turns red. Put it back. - Press Send. Look for 200, then find your text at
json.textin the reply. - Click Show the raw request. A package needs one more header,
Content-Type: application/json, so the machine knows which format to read. Machines do not guess.
The same request in Python
json= turns the dictionary into JSON and adds the Content-Type header for you.
04Round Three, for real
The machine from Round Three is real. It lives at __SITE__/aarav and checks the parts in the order you learned them: address, action, key, package. It needs a key, and it issues its own.
Part A · Create a key
- Replace
your namein the package with your name. - Press Send. Expect 201: something new was created, your key. It is copied into Part B's key box for you.
Part B · Create a diagnosis
- Check the key band holds your
aarav_…key. Press Show to check it pasted fully. - Press Send. Expect 201 and a diagnosis of Aarav's Friday report.
- Press Send the same request again. The two replies sit side by side. They are identical: this machine follows rules. Remember that for step 8.
- For the practice set: take a screenshot of the reply. The reply shows only the start of your key.
Both requests in Python
05Break it on purpose
Every failed request comes back with a code, and the code points at one part. Learn the codes by causing them, one part at a time.
- Pick a button below. It changes one part of the Part B request above.
- Before you press Send, write down the code you expect.
- Press Send in Part B. The red box names the part and what to change.
- Press Put it right, then try the next button. Fill in the practice set table as you go: what you changed, the code you got, the part it points to.
| Code | Means | Whose fault |
|---|---|---|
| 400 | Package unreadable, or a part is missing | Yours |
| 401 | Key missing or wrong | Yours |
| 404 | Nothing at that address | Yours |
| 405 | That door does not take that action | Yours |
Then: Read what you created
In Part B, switch the action to Read · GET and press Send. You created diagnoses a few minutes ago. The reply is 200 and an empty list. Where did they go? This machine has no database, so nothing it creates is kept. Where data should live is Block 1 · Week 3 · Databases and domain modelling.
Break it in Python
Change one thing at a time in your step 4 script (the address, the method, the key, the field name) and print what comes back:
06Whose fault? Every code
Each card sends one real request. Before you press Send, pick whose fault the reply will be. 2xx worked. 4xx you sent something wrong. 5xx their machine broke.
07Read real traffic
Every request you sent here is visible in your browser's own tools. Real products work the same way. Reading this is how you check what an app actually sends.
- Open DevTools. Mac: Cmd Option I. Windows: F12 or Ctrl Shift I. Or right click anywhere, Inspect.
- Click the Network tab, then the Fetch/XHR filter. Click the clear button (a circle with a line).
- Scroll up to step 4, Part B, and press Send. A row named
diagnosesappears. - Click it and find each part:
Address Headers → Request URL Action Headers → Request Method Key Request Headers → authorization Package Payload (what you sent) and Response (what came back) Code Headers → Status Code - Optional, a real product: do the same on ChatGPT. Reading the Network tab walks through it, including the one header you must never expand or paste.
08Put a model behind it
Aarav's UI has a face. It needs a brain: a model that reads his workflow and writes a plan. Groq runs open-weight models on its own chips, and you reach them with the same four parts. That is Groq with a q, not Grok.
Part A · Get a free Groq key (one time, about 3 minutes)
- Open console.groq.com/keys in a new tab. It is a website, not a download.
- Sign in with Google. No card needed.
- Click Create API Key, name it
fde-apis, and click Submit. - Copy the key now. Groq shows it once. Do not paste it anywhere except the box below.
Part B · Send your first request to a model
- Paste the key into the key band. Wait a second: the model list loads from Groq itself. That load was a Read with your key, your first keyed request. If it says 401, the key was not copied fully.
- Keep the model
openai/gpt-oss-120band the message as it is. - Press Send. Expect 200. The answer is at
choices[0].message.content. The reply also carries areasoningfield, the model's scratchpad. Ignore it. - Press Send the same request again. Same address, action, key and package. Different words. Compare that with Aarav's service in step 4.
Your key stays in this tab's memory. It is not saved and is gone when you reload. Free tier: 30 requests a minute, counted per Groq account, so use your own account, not a friend's key.
The door is deterministic. What comes through it is probabilistic.
Two answers to the same request. Which one is right, and who decides? Write one line on which you would trust, and why. That line is the start of a verifier.
The same request in Python
Put the key in an environment variable, never in the file. In the same terminal:
Then save and run:
This file becomes the body of your FastAPI route in the next lesson, Building APIs and the backend.
09Find your key, and where it should live
- With DevTools open on Network, press Send in step 8.
- Click the
completionsrow, then Request Headers. Your Groq key is there in plain text. - Think it through. This page is your private tool, so that is fine here. If Aarav's product worked like this, every visitor could open DevTools, read his key, and spend his money. So where should the key live?
Box 1
UIwhat the user sees · no keysBox 2
Backendholds the key · keeps the dataBox 3
Groqthe modelThe UI calls your backend. Only the backend calls Groq, with the key kept on the server. The backend is also where data can be kept, which step 5 showed the page and Aarav's machine cannot do. Building that backend is the next lesson, Building APIs and the backend. More in Keys.
When you are done practising, you can delete the key at console.groq.com/keys and create a new one for the next lesson.
10Design your API
You have sent every kind of request. Now design the ones your own app needs. Here is Aarav's, as the example:
| CRUD | Method | Address | Package in | Reply |
|---|---|---|---|---|
| Create | POST | /workflows | {"description": "..."} | 201 + workflow id |
| Read | GET | /workflows/{id} | none | 200 + the workflow |
| Create | POST | /workflows/{id}/diagnoses | none; the backend sends the workflow to Groq | 201 + diagnosis |
| Read | GET | /workflows/{id}/diagnoses | none | 200 + past diagnoses |
Your version, with a blank template and what to produce, is in the practice set.
Next: the practice set.Stuck? Troubleshooting · Curious why each part exists? The Wire, optional