Computing Foundations for AI / Software & Data
How programs talk to each other.
Reviewed by Yuvaraj
Every time an app fetches data, signs you in, or calls an AI model, the same thing happens under the hood: one machine sends a carefully formatted message across a network and waits for a reply. Understanding that exchange, how a name becomes an address, how a connection is opened and secured, and how a request and response are shaped, is the foundation for almost everything you will build with AI. This lesson walks through the layers that carry your data, and shows you precisely what an API is.
No single piece of software does all the work. Networking is built from layers, each solving one problem and handing the rest down to the layer beneath it.
Application HTTP request / response, headers, JSON body
Security TLS encryption and server identity (the s in https)
Transport TCP reliable, ordered bytes; ports (443 for https)
Network IP machine addresses and routing
Ask about this lesson, or about anything in AI. Answers cite the lessons they draw on.
Finished this lesson?
Mark it complete to earn XP, keep your streak, and schedule a review.
An HTTP request has three parts: a request line (a method such as GET or POST, plus the path), a set of headers (key-value metadata like Host and Accept), and an optional body. A response mirrors this shape: a status line (a numeric status code and reason phrase), headers, and a body, very often JSON.
Suppose your program requests https://api.example.com/status. Here is what actually happens, step by step.
Those first three steps are pure setup. The fixed cost before your request even leaves is roughly , which is why reusing a connection (step 6) makes later requests noticeably faster.
The request the client sends is small and plain text:
GET /status HTTP/1.1
Host: api.example.com
Accept: application/json
The server responds with a status line, headers, and a JSON body:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 36
{"status":"ok","region":"us-east-1"}
Two small vocabularies do most of the work. The method states your intent; the status code reports the outcome.
| Method | Intent | Typical body | Idempotent |
|---|---|---|---|
| GET | Read a resource | None | Yes |
| POST | Create a resource or trigger an action | Yes | No |
| PUT | Replace a resource | Yes | Yes |
| DELETE | Remove a resource | None | Yes |
Status codes are grouped into classes by their first digit. Beyond the three below, 1xx (informational) and 3xx (redirection) also exist, but these are the ones you will handle most.
| Class | Meaning | Common examples |
|---|---|---|
| 2xx | Success | 200 OK, 201 Created |
| 4xx | Client error, the request was wrong | 400 Bad Request, 404 Not Found, 429 Too Many Requests |
| 5xx | Server error, the server failed | 500 Internal Server Error, 503 Service Unavailable |
An API is a documented contract for programmatic access to a service: which endpoints exist, which methods they accept, and the exact shape of the data going in and coming out. A UI, by contrast, is built for humans, pages and buttons rendered as HTML that may be redesigned at any time. The API is the stable, machine-readable door into the same service.
This is exactly how you call an AI model
Calling a hosted model is not special. Your program makes an HTTP POST to an endpoint such as /v1/messages, sends a JSON body describing the prompt and parameters like temperature, and receives a JSON response containing the model's reply. Everything in this lesson, DNS, TCP, TLS, methods, and status codes, applies unchanged.
Common mistakes