Skip to main content

The 7 Engineering Layers of an AI System, Explained from Zero

From GPUs to observability: what each layer of an AI system does, what breaks when it is weak, who owns it, and which layers most teams simply rent through a model API.

The 7 Engineering Layers of an AI System, Explained from Zero

You type “summarize this contract” into a chat window, and a few seconds later a tidy summary appears. What happened in between? Which machines worked on your text, and who built each part?

In this post, an AI system means everything between the sentence you type and the answer you read: the chips, the software and the people who run them. It is written for complete beginners. Knowing the parts turns a vague “the AI is slow” into “this part is slow”, and shows you which part you would actually build.

The usual answer to “what happened in between” is a pile of words: GPUs, Kubernetes, fine-tuning, inference, agents, tracing. Don’t worry if none of them mean anything yet. This post puts them in order, starting with the part you can see (the app you typed into) and walking down to the chips that do the math.

First, the words

These are the only terms you need to follow this post. Each one is explained again where it first appears.

  • Model — a program that learned patterns from a huge number of examples and now turns the text you send into the text you get back.
  • Prompt — everything sent to the model in one go: instructions, documents and your question.
  • Token — a small piece of text (a word or part of a word); the unit a model reads, writes and is billed by.
  • Training — the one-time, expensive process of showing a model huge numbers of examples so it learns.
  • Inference — using the finished model to answer a request; it happens every time anyone asks anything.
  • GPU (graphics processing unit) — a chip that does huge amounts of simple arithmetic at the same time, which is exactly what models need.
  • Model API — a web address where you send text to someone else’s model and get text back, paying for what you use.
  • Observability — recording what the system did, so you can see afterwards how long it took, what it cost and where it failed.

The short answer

An AI system is a stack of seven layers: each layer stands on the one below and uses what it provides. Numbered from the bottom, they are compute (the chips), infrastructure (deciding which machine does which job), training (making the model), inference (running the model on a request), distributed inference (running it for many users at once), applications (the product you use) and observability (recording what happened). Many product teams build only the top two and rent the bottom five through a model API.

Think of a restaurant. There are stoves (compute). Someone decides which cook uses which stove (infrastructure). A chef spent years learning to cook (training). The chef prepares your order (inference). A big kitchen runs many chefs in parallel to feed a full dining room (distributed inference). The waiter and the menu turn “I’m hungry” into a clear order and bring the plate back (application). The manager watches waiting times, food costs and returned dishes (observability).

The seven engineering layers of an AI system stacked from compute at the bottom to observability at the top, with a bracket showing that a model API provides layers one to five and your team builds layers six and seven

The diagram numbers the layers from the bottom (1, the chips) to the top (7); this post keeps those numbers but walks the layers from the top down, starting with layers 6 and 7, the part your team builds.

One caveat: this seven-layer split is a teaching model, not an official standard. Some people draw the lines differently or add a separate data layer. And observability does not strictly sit on top of the stack: it records what happens in every layer.

Why think in layers at all

Without a map, every AI problem looks the same: “the AI is slow”, “the AI is expensive”, “the AI is wrong”. Those complaints usually live in different layers and are fixed by different people.

Layers let you locate a problem. A slow answer might come from too many users for the available GPUs (layer 5) or from an app that calls the model eight times when two would do (layer 6). If you cannot tell these apart, you fix the wrong thing.

The honest part: you probably rent layers 1 to 5

A model API is a web address you send text to and get text back from, paying for what you use. (API stands for application programming interface: an agreed way for one program to ask another for something.) The companies that train large models offer one, and cloud platforms, companies such as AWS, Google Cloud or Azure that rent out computers over the internet, resell access to many models.

Calling such an API rents layers 1 to 5 in one step. Someone else bought the GPUs, decided which jobs run on them, trained the model, tuned the serving software (the programs that run a model for many users) and spread it across data centers (buildings full of computers).

In restaurant terms, you run the dining room and order from a professional kitchen next door. You design the menu, talk to guests and check the bills. You do not own a stove.

This is not a beginner shortcut. It is the common starting point for AI products, because the lower layers are expensive to own and hard to run well. They still set the limits you work inside, so it pays to understand them.

The seven layers, from the top down

We will follow one request. A user uploads a 30-page supplier contract and types “Summarize this contract.” As an illustrative example, say the contract is about 20,000 tokens and the summary about 400. A token is a small piece of text, a word or part of a word; it is the unit models read, write and bill in.

We start with the two layers your own team builds (6 and 7), then go down through the five you usually rent (5 to 1).

Layer 6: Applications

What it is. Everything that turns a raw model into a product. The model only maps text to text. The application decides what goes in and what happens to what comes out.

For our contract, the application extracts text from the PDF, adds instructions (“summarise for a non-lawyer; list parties, dates, payment terms and risks”), calls the model, and checks the answer before showing it. Together, the instructions, the contract text and the question form the prompt: everything the model receives in one request.

Common building blocks:

  • RAG (retrieval-augmented generation): finding the relevant pieces of your own documents (this search step is called retrieval) and putting them in the prompt. See RAG explained for beginners.
  • Tools: functions the model may ask your code to run, such as a database lookup.
  • Agents: a loop in which the model picks a step, your code runs it, and the model reads the result and picks the next one. See AI agents and tool calling.

Examples. Frameworks (ready-made skeletons for an application) such as LangChain or Pydantic AI, or plain code calling the API.

When it is weak. A capable model gets the wrong documents, vague instructions and no checks. The summary sounds confident and misses the termination clause (the part that says how the contract can be ended).

Who owns it. Software and AI engineers on product teams. Most readers of this post will work here.

Layer 7: Observability

What it is. Recording what the system did, so you can see how long it took, what it cost, where it failed, and whether the answer was any good.

Ordinary software is mostly right or wrong. AI output can be fluent, well formatted and incorrect, with no error message. So this layer records a trace: the story of one request, with every model call, retrieval step and tool call, including timings, inputs and outputs. Recording traces is called tracing. On top of traces you run evals, repeatable tests of answer quality, covered in evals in 2026.

Examples. Tracing tools such as Langfuse or Pydantic Logfire.

When it is weak. You learn about problems from angry users and from the invoice. Nobody notices that table six sent the soup back three nights running.

Who owns it. The product team that owns layer 6, often with platform engineers (the people who run the shared servers and tools other teams build on).

Everything below this point is what a model API rents to you. Your request leaves your code and enters someone else’s system.

Layer 5: Distributed inference

What it is. Making many GPUs on many machines behave like one reliable service.

One copy of a model on one GPU serves a limited number of users. A real product runs many copies on many servers (computers that answer requests over a network), and needs load balancing (sending each request to a server with free capacity) and autoscaling (adding servers when traffic, the number of incoming requests, grows, and removing them when it drops).

Two measures pull against each other. Latency is how long one user waits; in chat, the wait before the first word matters most. Throughput is how much work the whole system finishes per second. Packing more requests onto each GPU raises throughput and lowers cost, but each user gets a slower response. A full restaurant is profitable, and every table waits longer.

Examples. Several copies of an inference engine such as vLLM (layer 4, next) behind a load balancer, kept running by Kubernetes (layer 2, further down); Ray Serve, the model-serving part of Ray (also layer 2).

When it is weak. The product works in a demo and falls over on Monday at noon: requests stuck in queues, timeouts (requests that give up after waiting too long), “try again later”.

Who owns it. Infrastructure and reliability engineers at the model provider, or your platform team if you host models yourself (run them on machines you control instead of calling an API).

Layer 4: Inference

What it is. Using a finished model to answer a request. Training happens once; inference happens every time anyone asks anything.

A model first reads the whole prompt, then writes the answer one token at a time, each token depending on everything before it. An inference engine is the software that makes this efficient. Its main tricks are below; they are the most technical part of the post, and a first-time reader can skim them.

  • KV cache. (KV stands for key–value, the kind of internal notes the model keeps.) To write token 201, the model needs its internal notes about tokens 1 to 200. Instead of recomputing them for every new token, the engine keeps them in memory, the GPU’s own fast storage. Like reading the contract once and keeping margin notes, instead of rereading it before each word of the summary. The price is memory: the cache grows with the text, one reason long documents are expensive.
  • Batching. A GPU can process several requests in one pass, like an oven baking twelve dishes at once.
  • Quantization. Storing the model’s numbers with less precision so it needs less memory and runs faster, for a small loss in quality. Like saving a photo at lower quality.
  • Prompt caching. If many requests start with the same long text, the work for that shared beginning is reused.

Examples. vLLM, an open-source engine (free to use, with code anyone can read) that started at UC Berkeley, built around smarter management of KV-cache memory; llama.cpp for running models on a laptop.

When it is weak. Every answer is slow and every token costs more than it should.

Who owns it. Model-serving engineers (who run models for others to call) and performance engineers who specialise in machine learning (ML), the field of building models that learn from examples.

Layer 3: Training and fine-tuning

What it is. The process that produces the model, by adjusting billions of internal numbers called weights until the model predicts text well.

Three things get confused here:

  • Pre-training teaches a model from scratch on enormous amounts of text. It needs large GPU clusters (thousands of connected GPUs), and few organisations do it. This is culinary school.
  • Fine-tuning continues training an existing model on a smaller, specific dataset (a collection of examples), such as your support tickets. A trained chef learning your house recipes.
  • Prompting changes nothing in the model. You write clear instructions and supply the right documents. Handing the chef a clear order.

For our contract, prompting is almost certainly enough: the model already knows how to summarise.

Examples. PyTorch, the code library (ready-made code you call from your own program) most models are trained in. Hugging Face, a website and toolkit for sharing and fine-tuning models.

When it is weak. The model lacks a skill, and no application code fully hides that.

Who owns it. Researchers and ML engineers.

Layer 2: Infrastructure

What it is. Software that decides which job (a piece of work, such as a training run or a copy of a model answering requests) runs on which machine, starts it, and restarts it after a crash. This is called scheduling.

The problem it solves. GPUs are expensive, and an idle one still costs money. With a hundred machines and dozens of jobs, nobody can place work by hand.

Examples. Kubernetes, a widely used system for running software across many machines, which can hand out GPUs as a schedulable resource. Ray, an open-source framework for spreading AI and Python programs across many machines.

When it is weak. Jobs wait in line while GPUs sit unused elsewhere, and one crashed machine takes the service down. Plenty of stoves, nobody assigning them.

Who owns it. Platform, DevOps or MLOps engineers: the people who keep software running on servers (MLOps is the same work for machine learning systems).

Layer 1: Compute

What it is. The physical chips that do the arithmetic. Underneath, a language model is an enormous number of multiplications and additions over tables of numbers.

Why GPUs. A normal processor (CPU, central processing unit, the main chip in every computer) has a few very capable cores, the parts of a chip that each carry out instructions, and they do complicated things one after another. A GPU (graphics processing unit) has thousands of simple cores that all do the same small operation at once, and model math has exactly that shape. One fast cook versus a hundred people chopping onions together. Some companies also build their own specialised chips, called accelerators, for this job.

Examples. GPUs rented from clouds such as AWS, Google Cloud or Azure, or from GPU-focused providers.

When it is weak. With too few chips, or too little memory on them, the model does not fit or answers slowly. The model itself and the KV cache for our 20,000 tokens (layer 4) must both fit in GPU memory.

Who owns it. Cloud providers and hardware teams, almost never a product team.

One request, all seven layers

Now watch the contract travel down the stack and back up.

The path of one summarize-this-contract request through the layers: the application builds the prompt, the distributed layer queues and routes it, the inference engine reads the prompt and writes the answer on a GPU, the application checks the result, and observability records every step, with most time and money spent in the GPU steps

  1. You send the message. The browser uploads the contract and your sentence.
  2. The application builds the prompt (layer 6). It extracts the text, adds instructions and sends one request to the model API. Ordinary code: quick and cheap.
  3. The request is queued and routed (layer 5). A load balancer picks a server with capacity and sends the request there. In heavy traffic, your request waits here. Layer 2 keeps those servers running.
  4. The engine reads the prompt (layer 4, on layer 1 hardware). The 20,000 example tokens pass through the model on a GPU and fill the KV cache. A longer document means a longer wait before the first word.
  5. The engine writes the answer. The 400 example tokens come out one by one. This is often the longest part of the wait, because every new token needs another pass through the model, which is why chat interfaces show text as it is produced.
  6. The application checks and formats (layer 6). It might confirm that the quoted dates really appear in the contract, then displays the result.
  7. You read the summary. Layer 7 has stored a trace: time per step, tokens in and out, cost, failures.

Layer 3 is missing because it finished long ago. Training made the chef; it is not part of tonight’s service.

Most of the time and money went to steps 4 and 5, the GPU work. Your bill is counted in tokens, and tokens are GPU time. So your main lever from layer 6 is to send fewer, better tokens; see token economics.

Why a weak lower layer caps everything above

Each layer can only use what the layer below gives it. Improvements at the top do not travel downward.

Suppose you build an excellent agent that reviews a contract in twelve careful model calls. If each call waits on a slow inference service, the user waits twelve times as long. Agent design cannot fix that; you can only make fewer calls or get faster inference. The best waiter cannot serve food faster than the kitchen cooks it.

Further down it is the same. A fast engine cannot serve a thousand users from one GPU. Good scheduling cannot create GPUs you do not have. A perfect prompt cannot give a model a skill it never learned.

There is a quieter reverse effect: a wasteful upper layer burns whatever the lower layers provide. An app that resends the whole contract with every follow-up question is slow and costly on any infrastructure.

So ask “which layer?” before “which fix?”.

The seven layers in one table

The table lists the layers in their numbered order, from the chips (1) up to observability (7), as in the first diagram.

#LayerJob in one lineExample toolsIf it is weakTypical ownerRestaurant
1ComputeDo the raw mathGPUs from cloud providersModel does not fit or runs slowlyCloud and hardware teamsStoves
2InfrastructurePlace jobs on machinesKubernetes, RayIdle GPUs, queues, outagesPlatform / DevOpsKitchen manager
3Training / fine-tuningGive the model its skillsPyTorch, Hugging FaceModel lacks the abilityResearchers, ML engineersCulinary school
4InferenceAnswer one request efficientlyvLLM, llama.cppSlow, costly tokensModel-serving engineersChef cooking an order
5Distributed inferenceServe many users reliablyLoad balancers, autoscalers, Ray ServeCollapses under real trafficInfrastructure / SRE (site reliability engineering)A full kitchen line
6ApplicationsTurn a model into a productLangChain, Pydantic AI, plain codeCapable model, useless answersProduct and AI engineersWaiter and menu
7ObservabilitySee speed, cost, failures, qualityLangfuse, LogfireYou learn from complaintsProduct and platform teamsManager on the floor

Common mistakes and misconceptions

  • “To work in AI I must learn to train models.” In my view, the AI work that product companies need most is in layers 6 and 7. Training is a specialised career, not an entry ticket.
  • “Fine-tuning is the first thing to try.” Try a better prompt, then retrieval of the right documents, then fine-tuning. Each step costs more and is harder to undo.
  • “The API is the model.” The API is five layers in a box. Slowness at peak hours is layer 5, not the model getting less intelligent.
  • “We will add observability later.” Without traces you cannot tell a bad prompt from bad retrieval. Add it before the first real user.
  • “Hosting our own model is obviously cheaper.” Only if your GPUs stay busy, and someone still has to run layers 2, 4 and 5.

When you don’t need to go below layer 6

If you are just starting out, the short answer is that you don’t; the rest of this section is for teams deciding whether to run models themselves.

For a prototype (a first rough version to test an idea), an internal tool, or a product with modest traffic, a hosted API, where the provider runs the model for you, is the right answer. You also do not need an agent framework for a single model call.

Going lower makes sense in four situations:

  • Cost at scale. With steady, high volume, running an open model (one whose weights anyone may download and run) on rented GPUs can cost less than paying per token. Calculate with your own numbers first.
  • Privacy and on-premises rules. Some data may not leave your network or country, so the model must run where the data is, on your own premises.
  • Latency. Voice and real-time features may need a model close to users, or a smaller, faster one you control.
  • Custom models. If no hosted model behaves the way you need, you fine-tune, and then you must serve the result.

There are steps in between: many providers will host an open model for you or sell you dedicated capacity (GPUs reserved for you alone).

How to get there

I’d learn top-down, in the same order this post walks the layers, because the top is where you can build something real in a weekend.

  1. Basics. Enough Python (a popular programming language) to call a web API, and Git (a tool that saves the history of your code) to save your work.
  2. Layer 6, simplest form. Call a model API directly, no framework. Project: a script that summarises a text file into parties, dates and risks.
  3. Layer 6, real patterns. Add retrieval, then one tool, then a small agent loop. Project: answer questions about a folder of your own documents.
  4. Layer 7. Add tracing and write ten test cases with expected answers. Project: change the prompt and let the numbers tell you whether it improved.
  5. A taste of layers 4 and 1. Run a small open model on your laptop and compare a quantized version with a larger one.
  6. Layers 5 and 2, if your job needs them. Put an inference engine in a container (a sealed package holding a program and everything it needs to run), send many requests at the same time, and watch latency trade against throughput.
  7. Layer 3, last and optional. Fine-tune a small model to learn what fine-tuning can and cannot change.

For the wider career picture, see the AI engineer roadmap for 2026.

Mini glossary

  • KV cache: saved intermediate results that spare the model from rereading everything for each new token.
  • Quantization: storing a model’s numbers with less precision to save memory and time.
  • Latency: how long one request takes.
  • Throughput: how much work the whole system completes per second.
  • Trace: the recorded story of one request, step by step.

Going deeper

Related posts: embeddings and vector databases explained, types of AI models explained, AI agents and tool calling and multi-agent systems.

Sources and further reading

This post is part of the “AI engineering from zero” series: The AI engineer roadmap · Vibe coder vs AI engineer vs AI solutions engineer · 8 types of AI models · Embeddings and vector databases · RAG explained for beginners · AI agents and tool calling.

Part 7 of 7 in “AI engineering from zero”. Previous: AI Agents and Tool Calling Explained from Zero

Share this article
X LinkedIn
Next step

Turn this into a real skill

A structured path from theory to production code — projects and code reviews included.

Advanced 8 weeks

Building LLM-Powered Apps: RAG & Agents

Build production-grade AI applications using large language models. Cover vector databases, retrieval-augmented generation (RAG), autonomous agents, tool use, evaluation, and deployment patterns.

Explore course
Intermediate 7 weeks

AWS Bedrock & AI Services for Developers

Deploy and use AI models on AWS: Bedrock (Claude, Llama, Titan), Lambda, API Gateway, S3, and DynamoDB. Build enterprise AI solutions integrated with your existing backend stack.

Explore course
Intermediate 6 weeks

Building with Claude API: Production AI Apps with the Anthropic SDK

Master Anthropic's Claude API end-to-end: messages API, prompt caching, tool use, extended thinking, streaming, batch processing, files, citations, and vision. Build cost-efficient, production-grade AI features in any backend.

Explore course
Advanced 7 weeks

Building Agents with the Claude Agent SDK

Design and ship custom AI agents with the Claude Agent SDK. Build agent loops, define tools, manage memory and sub-agents, evaluate behavior, and deploy multi-agent systems that solve real engineering tasks autonomously.

Explore course
Advanced 6 weeks

AI-Native SDLC: Engineering Delivery from Intent to Production

Agents made the build step nearly free — now planning, review, and deployment are the bottleneck. Rebuild your delivery lifecycle as a loop: committed artifacts (intent.md → spec.md → plan.md → PR → incident), skills and hooks as governance-as-code, continuous evals on your agent setup, AI review with human approval, and production signals that write the next intent. For tech leads, platform engineers, and engineering managers.

Explore course
Oleksii Anzhiiak

Written by

Oleksii Anzhiiak

Software Architect, Senior .NET Engineer & Co-Founder

Oleksii Anzhiiak is a Software Architect, Senior .NET Engineer, and Co-Founder of ToyCRM.com and ProfectusLab. With over 15 years of experience, he specializes in distributed systems, cloud infrastructure, high-load backend development, and identity platforms. Oleksii designs complex architectures, builds secure authentication systems, and develops modern engineering education programs that help students achieve real career results.

LinkedIn

Recommended Watching

Hand-picked third-party videos related to this topic. Open on YouTube.

~1:56:00
Advanced Andrej Karpathy

Let’s build GPT from scratch

A rare hands-on explanation of GPT internals, connecting theory with real code. Ideal for engineers who want to truly understand how modern LLMs are built.

~1:00:00
Beginner Andrej Karpathy

[1hr Talk] Intro to Large Language Models

Karpathy's full hour walkthrough of how LLMs actually work — inference, training, fine-tuning, and the emerging LLM-OS picture. The clearest single-shot mental model on the internet for engineers new to the field.

~6:00:00
Intermediate AI Engineer (AI Engineer World's Fair)

AI Engineer World's Fair 2025 — Day 1 Keynotes & MCP Track (ft. Anthropic MCP team)

The MCP track keynote with the Anthropic team. If you want to understand why MCP became the industry-standard protocol for connecting LLMs to tools in 2025, this is the single best primary source.

Contact us