Skip to main content

The generative AI primer

At its core, a has a surprisingly straightforward job: given a sequence of text, it predicts what comes next, generating one piece at a time. Every modern concept built around these systems—autonomous agents, retrieval-augmented generation, persistent memory, tool calling, protocols like MCP, and API gateways—is scaffolding engineered around that core prediction loop to turn raw text completion into practical software.

Much of the confusion in applied AI stems from conflating the model itself with the systems built around it. Most industry vocabulary does not describe neural network weights; it describes what gets packaged into the prompt, what external actions the model can trigger, how traffic gets routed across vendors, and where the compute actually executes. Confusing these layers leads to expensive architectural mistakes—such as treating a larger context window as an alternative to a searchable knowledge base, or assuming an LLM router and an MCP gateway solve the same problem. Understanding where each layer begins and ends is essential once engineering budgets and production reliability are on the line.

This primer focuses on foundational concepts rather than vendor branding. At the bottom of most pages, vendor-specific tabs show how providers name these concepts and where their implementations diverge. Because the ecosystem evolves quickly, every claim in those tabs is explicitly marked confirmed or unconfirmed, and unverified details are noted rather than guessed.

What is in scope

This guide covers generative language models—text generation, conversational reasoning, and the surrounding plumbing that connects models to data and tools. It does not cover classical machine learning: training custom classification models from scratch, manual feature engineering, or statistical predictive modeling belong to separate disciplines. The focus here begins with pre-trained foundation models that you access through a hosted API or deploy onto rented cloud hardware.

How generation actually works

Before untangling the surrounding infrastructure, it helps to understand the underlying prediction cycle.

When you send text to a model, the text is split into —short character fragments averaging three or four letters in English. The model passes these tokens through its parameters and calculates a probability distribution across its entire vocabulary for the next potential token. A sampling algorithm selects one of those candidates, appends it to the prompt, and repeats the forward pass. This loop continues until the model emits a designated end-of-sequence token or hits an enforced length ceiling.

Two practical realities follow directly from this process:

First, the model operates purely on the input placed immediately before it. It possesses no innate recollection of previous conversations, no implicit visibility into local files, and no background awareness of the world beyond what is explicitly included in the prompt. Everything the model appears to remember must be actively re-assembled into its context window on every call.

Second, token selection incorporates controlled randomness. Sending the identical prompt multiple times can yield slightly different completions. This stochastic behavior gives language models their conversational flexibility, but it also means deterministic unit tests will break unless your architecture accounts for variance.

When a model generates fluent, convincing text that is completely untruthful, it is not broken; it is simply predicting likely token sequences without an internal fact-checking engine. The industry refers to this as a , reflecting the reality that language models lack any native way to assess whether their statements correspond to external facts.

How this primer is organised

The primer is structured into six sections, starting with the model itself and moving outward into surrounding systems. You begin with the mechanics of a single model call, explore what fits into the prompt, examine how models invoke external tools, and look at the harnesses that orchestrate multi-step tasks. The final sections cover cross-cutting organizational concerns: the gateways that manage enterprise traffic and the tradeoffs between hosted cloud APIs and self-hosted open models.

Organizing the material by architectural layer rather than by product keeps the guide durable. Specific developer tools and vendor interfaces change every quarter, but the core boundaries between contexts, harnesses, tools, and gateways remain consistent.

The model is the small box in the middle. Almost everything a practitioner designs and operates sits in the components surrounding it.

SectionCore questionStarting point
The modelHow do models process text, sample outputs, and perform reasoning steps?Tokens and the context window
ContextWhat can the model see, and how do you manage information within window limits?What fills a context window
Tools and extensionsHow do models interact with external systems and trigger real actions?Tool calls
HarnessesHow does client software manage iterative execution, permissions, and state?The agentic loop
GatewaysHow do you route requests, manage credentials, and monitor usage across teams?LLM gateways and routers
Sourcing a modelWhat are the tradeoffs between commercial hosted APIs and self-hosted models?Open and closed models
PageCore focus
Tokens and the context windowThe fundamental units models read, compute, and bill on
Inference and samplingWhy completions vary and how sampling parameters influence output
Reasoning modelsHow test-time compute and internal reasoning chains improve complex problem solving
What fills a context windowEverything packaged alongside the user prompt and where token budgets go
Context management and compactionHow to sustain long-running sessions across strict context ceilings
Embeddings, vector stores, and RAGHow to retrieve relevant knowledge from large document collections on demand
MemoryHow information persists across independent sessions
Tool callsHow models request external actions and how callers execute them
Skills, plugins, and MCPThe three primary ways to extend agent harnesses
MCP in depthHow the Model Context Protocol structures client-server communication
The agentic loopHow harnesses chain model outputs and tool execution to solve multi-step tasks
Comparing harnessesArchitectural differences across modern agent environments
LLM gateways and routersCentralized routing, rate limiting, and observability for model calls
MCP gatewaysManaging security, access control, and credentials across multiple MCP servers
Open and closed modelsThe operational, licensing, and legal distinctions between hosted and open weights
Local and cloud inferenceInfrastructure costs, latency, hardware requirements, and deployment tradeoffs

Each page ends with the terms it introduced. The central glossary indexes all of them with direct references to their defining chapters, while the interactive quiz helps verify your practical understanding of the material.

Terms introduced

  • Generative AI: systems that produce new text, images, audio, or code from a prompt, rather than classifying or scoring something that already exists.
  • Large language model: a model trained to predict the next chunk of text, big enough that predicting text well requires it to encode a great deal about the world.
  • Foundation model: a model trained once, at great expense, on a broad corpus, then adapted or prompted for many tasks rather than trained per task.
  • Hallucination: a fluent, confident output that is not true. The model has no mechanism for telling the difference.
  • Prompt: the text sent to a model for it to continue, including everything the harness added that you did not type.

How providers do it

The same call in three vendors' words. Two of these differences are structural rather than cosmetic: where the system prompt goes, and what the model's own turns are called.

ConceptAnthropicOpenAIGoogle
The callPOST /v1/messagesPOST /responsesmodels.generateContent
System promptTop-level system; no system roleinstructions, or a developer messagesystemInstruction
The model's own turnRole assistantOutput itemsRole model
Conversation carried byThe full messages array, resentThe input, or a previous response idThe full contents array, resent
Sampling controlstemperature, top_p, top_k, all deprecated on the newest modelsNot on the create-response reference pagegenerationConfig
Open weights publishedNoneYes, separately from the hosted familyYes, under the Gemma name

Every row is marked in the tab it came from. The OpenAI rows are the weakest, because its reference pages did not answer the system-prompt and sampling questions directly. This table asks nothing about model names, context window sizes or prices, and no tab on this page carries them. Where a page does ask, such as tokens and the context window, those figures are confirmed against the vendor's own documentation on the date in each tab's _Last verified line. They are also the figures that go stale fastest, so a tab that has not been re-read is a tab whose numbers should be checked before anybody quotes them.

The row that costs the most to get wrong is the first one. Three different call shapes is why an LLM gateway exists at all, and why the compatibility layer a gateway offers is never quite lossless.

What this maps to: Anthropic sells inference against the Claude family and does not publish weights. The unit you call is the Messages API, and the vocabulary in it lines up closely with this primer: messages, tokens, tools, a top-level system prompt.

ConceptAt AnthropicStatus
The text-generation callPOST /v1/messages. Required: model, messages, max_tokensconfirmed
System promptA top-level system parameter. There is no system role for input messagesconfirmed
Message rolesuser and assistantconfirmed
Sampling controlstemperature, top_p and top_k are documented as deprecated: models released after Claude Opus 4.6 do not accept themconfirmed
Model names and context window sizesChanges with each releaseunconfirmed; read the model comparison page before quoting a number
Open weightsNone publishedunconfirmed; no announcement read today, and the absence of one is not a commitment

Their vocabulary

Standard termTheir term
System promptSystem prompt, passed as system
Tool definitiontools, with an input_schema
Tool callA tool_use content block
Tool resultA tool_result content block, sent in a user message
ReasoningExtended thinking

Where to look

The API reference for the Messages endpoint is the authoritative page for parameter names. The model comparison table is where context windows and maximum output lengths live, and it is the page that changes most often.

Last verified: 2026-09-09 against https://platform.claude.com/docs/en/api/messages.


Check your understanding

0 of 4 answered

  1. What operation is a large language model actually performing?
  2. A model states a court case that does not exist, with a plausible citation. What has gone wrong?
  3. A team has two systems. One scores each incoming support ticket for urgency on a scale of one to five. The other drafts a reply. Which is generative AI?
  4. Why does this primer cut the subject into layers rather than into products?