0
Programming Foundations
Phase 0Module 7 of 14

HTTP

Every AI service speaks HTTP. You need to understand methods, headers, status codes, and bodies to build and debug integrations.

HTTP is ordering at a restaurant — you place an order (request), the kitchen works on it, and brings food or an error back (response).

Visual Workflows

Start here — study each diagram, then use + / to zoom if needed.

Overview

100%
Loading diagram...

Scroll inside the frame · use + / − to zoom

100%
Loading diagram...

Scroll inside the frame · use + / − to zoom

Key Takeaways

  • 1.HTTP is the request-response protocol behind every web API — including every LLM provider you'll ever integrate with.
  • 2.A client sends a method (GET/POST), URL, headers, and optional body.
  • 3.The server returns a status code and response body.
  • 4.LLM APIs use POST with JSON.

Real Example

Scenario

Your chat app returns 401 Unauthorized when a user sends a message.

What you would do

The Authorization header with the Bearer token was missing. Adding it returns 200 with the LLM response.

Practice Task

Send a GET request with curl -v https://httpbin.org/get. Then send a POST with curl -X POST -H "Content-Type: application/json" -d '{"name":"test"}' https://httpbin.org/post. Write down the status code and response body for each.

Commands

Commands to Remember

  • curl -X GET https://api.example.com/data # send a GET request to read data
  • curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' URL # send POST with JSON body
  • curl -v URL # verbose mode — see headers, status code, and response

Cheat Sheet

Quick recap

quick ref
  • Methods: GET read · POST action · PUT replace · PATCH update · DELETE remove
  • Every request has: URL, Headers, Body (optional)
  • Key headers: Authorization Bearer token, Content-Type application/json
  • Status codes: 200 OK · 401 Unauthorized · 429 Rate Limited · 500 Server Error
  • Stateless — each request is independent
  • LLM APIs use POST + JSON · always set timeouts
  • HTTPS = HTTP + TLS encryption

Common Mistakes

  • No timeout on HTTP calls
  • API keys in URL instead of headers
  • Ignoring 429 rate limits