What Is an AI API?
Every part so far has covered the model itself and how to prompt it. This part covers the real, practical interface a developer actually uses to reach that model — an API — directly setting up the coding project starting in part 16.
A real, practical definition
An AI API (Application Programming Interface) is a real, defined way
for your own code to send a prompt to a hosted, already-trained
language model, and receive its generated response back — over
the real internet, using standard HTTP requestsThis is genuinely the same kind of interface any other real web API uses (a weather API, a payments API) — the AI-specific part is entirely in what the request contains (part 11's system/user/assistant messages) and what the response contains (generated text), not in some fundamentally different, exotic mechanism.
The real, complete request/response cycle
1. Your code sends a real HTTPS request to the provider's API
endpoint, including your prompt (formatted per part 11) and a
real API key identifying your account
2. The provider's real infrastructure runs your request through the
actual, trained model (part 5's inference phase)
3. The generated response comes back as real, structured data
(typically JSON) — the model's text, plus real metadata like
token counts (part 8)Nothing about calling the API involves your own code doing any of the real model computation itself — that happens entirely on the provider's real infrastructure. Your application's job is genuinely just: format a correct request, send it, and handle the real response — exactly what part 16's actual code does.
API keys: real, practical authentication
A real API key is a long, secret string identifying your account —
included with every real request, and used by the provider to
track usage and apply real, per-token billing (part 8)A real API key should never be written directly into real, committed source code or exposed in a real frontend application a browser can inspect — it should live in a real, server-side environment variable, exactly the same security discipline any other real secret (a database password, a payment provider key) requires. Part 16's actual setup covers this concretely.
A real, minimal request, conceptually
POST https://api.provider.example/v1/messages
Headers: { "x-api-key": "your-real-api-key" }
Body: {
"model": "a-real-model-identifier",
"max_tokens": 1024,
"messages": [
{ "role": "user", "content": "What subscriptions do you offer?" }
]
}This is a genuine, real illustration of the actual shape of the request — a specific model identifier (providers offer several real models, differing in capability, speed, and cost), a real limit on how many tokens the response can generate, and the real messages array from part 11.
What actually varies between real AI API providers
Real, genuine differences between providers:
- Available models, and their real capabilities and context windows
- Real, per-token pricing
- Specific real request/response format details
- Real additional features — tool use, streaming (part 17), vision
Real, genuine similarities:
- The core request/response cycle described above
- The system/user/assistant structure from part 11
- Standard, real HTTPS + API key authenticationThis series' real coding project (parts 16 through 18) uses one specific, real provider's API directly — but the underlying concepts (messages, tokens, context windows, streaming) transfer genuinely well to any other real provider's API, since they're describing the same real, underlying mechanism from parts 4 through 9, just with provider-specific real syntax differences.
Why using an API is genuinely simpler than the concepts behind it
Everything covered in parts 1 through 13 — neural networks, training,
tokenization, attention — happens entirely on the PROVIDER's side
Your real code only needs to: format a correct request, send it, and
handle the response — genuinely comparable in complexity to calling
any other real, well-documented web APIThis is worth stating plainly before part 16's actual code: understanding how the underlying model works (parts 4 through 9) is what makes an application built on it genuinely reliable and well-designed — but using the API itself, mechanically, is real, standard, approachable web development, not something that requires real, deep ML expertise to do correctly.
Next: reading real AI API documentation — endpoints, authentication, and rate limits, the practical skill that sets up actually writing the code in part 16.