AI system design: the big picture

Start here. This guide explains what AI system design is, how it differs from classic system design, what a language model actually does, how the parts of an AI application fit together, and which page to read next for your role.

The big picture in 60 seconds

  • AI system design is the engineering of products that use models as a component: serving, retrieval, tools, safety, evaluation, and cost.
  • The model is one box. Most of the work sits around it: getting the right context in, checking what comes out, and keeping it fast, safe, and affordable.
  • What is new compared with classic design: outputs are probabilistic, cost scales with tokens, quality must be measured with an evaluation set, and the model can be manipulated by text.
  • Seven building blocks: gateway, orchestrator, retrieval, tools, model serving, guardrails, and monitoring.
  • Read in this order: this page, then your role's path below.

What AI system design is

Classic system design asks how to build a service that handles a lot of traffic and stays correct: databases, caches, queues, load balancers. AI system design asks the same questions and adds new ones, because one component, the model, behaves differently from everything else you deploy. It is slow and expensive per request, its output varies, and it can be steered by the text it reads.

So the discipline covers the model and everything around it. How is it served and scaled? How does it get the right information, from your documents or from live systems? How are its actions limited? How do you know the answers are good, and what happens when they are not? How do you keep the cost per request under control? The pages in this section answer those questions one at a time.

A language model in five ideas

Most AI products today are built on large language models (LLMs). You do not need to know how they are trained to design a system around one. Five ideas are enough.

  • It predicts the next token. A token is a small piece of text, often a word or part of one. The model reads a sequence of tokens and produces the most likely next one, then repeats. Everything it writes is built this way.
  • It has a context window. It can only read a limited number of tokens at once. Anything not in the prompt is unknown to it. This is the single most important constraint when designing a system.
  • It is stateless. It remembers nothing between calls. A conversation feels continuous only because the application sends the history again each time.
  • It is probabilistic. The same prompt can give different answers. A setting called temperature controls how much it varies: low is steadier, high is more varied.
  • It can be confidently wrong. A model writes fluent text whether or not it is right. This is called hallucination, and the main defences are giving it real sources, checking its output, and letting it say 'I do not know'.
The whole interaction in a few lines (illustrative) (python)
# Illustrative: a chat application is a loop around a stateless model call.
# llm.generate() is a placeholder for any model API.

history = []

def chat(user_message):
    history.append({'role': 'user', 'content': user_message})
    reply = llm.generate(
        system='You are a helpful assistant for Acme customers.',
        messages=history,          # the model sees only what we send, every time
        temperature=0.2,           # low: steadier answers
        max_tokens=400,            # caps cost and length
    )
    history.append({'role': 'assistant', 'content': reply})
    return reply

How it differs from classic system design

QuestionClassic serviceAI service
Is the output predictable?Yes: same input, same outputNo: wording varies and answers can be wrong
How is quality checked?Unit and integration tests with exact answersAn evaluation set, scoring rules, and sometimes a judge model
What does a request cost?Small and roughly constantProportional to tokens; large and variable
What dominates latency?Network and database callsReading the prompt and generating tokens one by one
What is the main security risk?Bad input reaching code or dataInstructions hidden in text the model reads
What changes behaviour?Code deploysCode, prompts, model versions, retrieved documents, and provider updates
How do you debug?Logs and stack tracesFull traces of prompts, retrieved context, tool calls, and outputs

The parts of an AI application

A typical AI application has seven building blocks. Small products use only a few of them, and large ones use all of them. Each has its own page in this section.

The orchestrator coordinates retrieval, tools, and the model; guardrails and monitoring wrap the whole flow.

A worked example: a customer support assistant

Take a company that wants an assistant answering questions about orders and policies. Following one question through the blocks shows how they fit. A customer asks, 'Can I return the headphones I bought last week?'

  • Gateway: checks the user is signed in, applies a per-user rate limit, and looks for an identical recent answer in the cache.
  • Orchestrator: a short workflow. First it asks a small, cheap model to classify the question as a returns question.
  • Tools: it calls the order lookup function to find which headphones the customer bought and on what date. This is live data the model could never know by itself.
  • Retrieval: it searches the returns policy documents for the passage about electronics.
  • Model serving: it sends the order details and the policy passage to a larger model with an instruction to answer only from them and to cite the policy.
  • Guardrails: the answer is checked to match the required format, to contain no personal data it should not show, and to make no promise the policy does not allow.
  • Monitoring: the whole path is recorded as a trace, with token counts and cost, and the answer is sampled for quality review.
The support flow end to end (illustrative) (python)
# Illustrative: every helper is a placeholder for one of the building blocks above.

def handle_question(user, question):
    gate = gateway.check(user, question)          # auth, rate limit, cache lookup
    if gate.cached:
        return gate.cached
    category = classify(question)                 # small, cheap model
    order = lookup_order(user.id, question)       # a tool: live data
    policy = retrieve_policy(category, question)  # retrieval: documents
    answer = generate_answer(question, order, policy)   # larger model, grounded in both
    checked = guardrails.check_output(answer, policy)   # format, privacy, promises
    trace.record(user, question, order, policy, answer, checked)
    return checked.text if checked.ok else escalate_to_human(user, question)

Four trade-offs you will meet in every design

  • Quality, latency, and cost pull against each other. A larger model, more retrieved context, or an extra checking step each improve quality and raise time and cost. Good designs spend effort only where it pays.
  • Freedom and control pull against each other. The more a model decides, the more it can handle, and the harder it is to predict and test. Use the least freedom that solves the task.
  • Freshness and cost pull against each other. Caching saves money and can serve stale answers.
  • Convenience and privacy pull against each other. Sending data to a hosted model is easy and moves data outside your boundary. Self-hosting keeps it in and costs more to run.

Where to start, by role

Every page in this section ends with notes for developers, architects, ML engineers, and product managers. If you want a focused path, start with the one below and follow the links at the end of each page.

If you areRead firstThen
New to AIThis pageTypes of RAG, then tool calling and MCP
A developer building a featureTool calling and MCPTypes of RAG, guardrails, evaluation
An architect planning a platformThe gateway, cost, and reliability guideHow inference works, orchestration, guardrails
An ML or data engineerEvaluation and monitoringVector search and chunking, fine-tuning, inference
A product managerThe playbook and case studiesGuardrails and privacy, evaluation, cost
Preparing for an interviewThe playbook and case studiesEvery page's trade-offs table

What this means for your role

Common mistakes

Further reading

The model is a powerful part, and only a part. The rest of the system is what makes it useful, safe, and affordable.

Search topics

↑↓ to move · Enter to open · Esc to close