Part 6 of 7 — How AI Actually Works

The Interface Layer

How the outside world talks to the model — and how to talk back effectively.

The model is running. Inference is ready. Now something has to connect your words to the model's input and the model's output back to you. The interface layer is everything between the user and the inference engine — the API, the web UI, the system prompt, and the prompt itself. Understanding this layer is where knowing how to use AI well begins.

Three Ways to Reach a Model

Web UI

Claude.ai, ChatGPT. A browser interface that handles authentication, conversation history, file uploads, and streaming display. The UI calls the API on your behalf — you never see the raw request.

API

Direct programmatic access. You construct the request, set the parameters, handle the response. Full control — system prompts, temperature, max tokens, model selection. Used by developers building applications on top of AI.

CLI Tools

Tools like sgpt, fabric, and aider bring AI to the terminal. They wrap the API in a shell-friendly interface — pipe text in, get text out. A sysadmin's natural habitat for AI interaction.

The API — What a Request Actually Looks Like

When any client — web UI, CLI tool, or your own script — talks to an AI model, it sends an HTTP POST request with a JSON body. Here is what a minimal Anthropic API request looks like:

POST https://api.anthropic.com/v1/messages

{
  "model": "claude-sonnet-4-6",
  "max_tokens": 1024,
  "system": "You are a helpful Unix sysadmin assistant.",
  "messages": [
    {
      "role": "user",
      "content": "Explain what a KV cache is in plain language."
    }
  ]
}

Every field matters:

The web UI builds this JSON for you invisibly. The CLI tools build it from your shell command. When you use the API directly, you build it yourself.

The System Prompt — The Hidden First Message 📖 Glossary

Every AI product you use has a system prompt — a set of instructions sent to the model before your first message that shapes how it behaves. You usually never see it. It is set by the operator — the company or developer who built the product.

The system prompt is how Claude.ai tells Claude to be helpful and honest. It is how a customer service bot is told to only discuss products from one company. It is how a coding assistant is told to prefer Python. The model itself is the same — the system prompt is what makes different products feel different.

Think of the system prompt like a config file: The model is the application binary — the same everywhere. The system prompt is /etc/app.conf — it configures behavior for this particular deployment. Two products running the same model with different system prompts can feel completely different to a user.

Anatomy of What the Model Sees

When you send a message, the model does not just see your words. It sees the assembled context — everything stacked together in order:

System Prompt
You are a Unix sysadmin assistant. Be concise and technical. Prefer command-line solutions.
Conversation History
User: How do I find large files?
Assistant: Use find with -size: find / -size +100M
Your Message
How do I sort that output by size?
Model Generates
Pipe to sort: find / -size +100M -exec ls -lh {} \; | sort -k5 -rh

The model has no memory between sessions. What looks like memory is actually the conversation history being sent with every request. The web UI manages this for you — appending each turn to the messages array. When the context window fills up, older turns are dropped.

Prompt Engineering — Talking to the Model Effectively 📖 Glossary

Because the model generates the most probable continuation of your prompt, how you phrase your request directly shapes what you get back. This is prompt engineering — not magic, just understanding that you are steering a probability distribution.

A few principles that consistently improve results:

Prompt engineering as query optimization: A poorly written SQL query gets you the wrong data or a table scan. A well-written query gets you exactly what you need efficiently. Prompts work the same way — vague input produces vague output; precise input produces precise output. The model is not guessing at your intent; it is generating the most probable response to the exact text you provided.

Parameters You Can Control