Practise AI System Design one question at a time. Answer out loud or in writing, get graded, and see exactly what you missed.
What does an "AI system design" interview round actually test, and how is it different from designing the model itself?
The round tests whether you can build a reliable product around a model you did not train. You treat the model as a remote dependency. It is paid per token, sometimes slow, and non-deterministic, so the same input can give different output.
Model design asks how to make the model better. System design asks what to do when it is wrong, slow, or down.
| Designing the model | Designing the system | |
|---|---|---|
| What you work on | Data, architecture, training loss | Latency and cost budgets |
| How you measure it | Offline benchmark scores | Evals on live traffic |
| What you ship | One artifact | Retrieval, state, guardrails, fallbacks |
Interviewers listen for numbers: cost per request, a latency target, and a plan for failure. Saying "just call the API" without those is the usual reason people fail.
Missed:
“Time to first token is how long the user stares at nothing before output starts, and total latency is how long until the response is completely done. They're driven by different things. Before anything comes out, the model has to read the whole input, so a big system prompt plus a stack of retrieved documents pushes the first token back, and so does sitting in the provider's queue. After that it produces tokens one at a time, so a long answer takes longer to finish even if it started quickly. Which one you care about depends on how the output gets used. In a chat window with streaming, people start reading straight away, so the first token is what makes it feel fast. But if the model is filling in a JSON form for a backend job or picking a function to call, half a response is useless, so what counts is when the last token lands.”
Knew itNails both metrics and their drivers, and correctly ties the choice to use case (streaming chat vs JSON/tool calls). Doesn't mention tracking both at p95 per route or that a fast first token can still hide a slow overall response.
Missed: Doesn't mention tracking both metrics at p95 per route rather than a single blended number.
Missed: Doesn't flag that a fast first token can still hide a slow overall response, which is the practical reason both matter together.
Get your own answers graded
Sign up free. Your account comes with 50 credits for grading, and it remembers what you missed.
What it covers
- Architecture layers and hosting
- Conversation state and memory
- Latency and streaming
- Prompt and semantic caching
- Gateways and model routing
- Cost modeling and budgets
- Scaling, quotas and queueing
- Reliability and failover
- RAG and grounded answers
- Guardrails and data protection
- Agents, tools and human review
- Evals, observability and rollouts
All 54 questions
Architecture layers and hosting
What the round tests, the layers of a production LLM app, and when to use hosted APIs instead of running your own inference.
- What does an "AI system design" interview round actually test, and how is it different from designing the model itself?
- What are the core architecture layers of a production LLM application?
- Build versus buy: hosted model APIs versus self-hosting. How do you decide? Pro
- When and how would you self-host LLM inference at scale (batching, KV cache, GPU autoscaling)? Pro
Conversation state and memory
Stateless model APIs, context window budgets, storing chat history, and memory for long-lived assistants and agents.
- The LLM API is stateless. What does that mean for conversation design? Pro
- What is the context window, and how does it constrain system design? Pro
- Design a ChatGPT-style conversational assistant. Walk through the architecture. Pro
- How would you design conversation state and memory storage for a chat product? Pro
- Design the memory architecture for a long-lived agent that operates over days or weeks. Pro
Latency and streaming
Time to first token, streaming over SSE or WebSockets, latency budgets per stage, and real-time voice pipelines.
- What is time-to-first-token versus total latency, and why do both matter?
- Why is streaming important for LLM UX, and what does it change about your architecture?
- How do you set and enforce a latency budget across an LLM request pipeline? Pro
- How do you architect streaming at scale (SSE/WebSockets), including load balancers and reconnection? Pro
- Design a real-time voice assistant: what is the end-to-end latency budget, and where does it break? Pro
Prompt and semantic caching
Prefix caching, exact-match and semantic caches, how to tune thresholds, and how to prevent wrong or stale hits.
- What is prompt (prefix) caching, and why does it matter for cost and latency?
- What is the difference between exact-match caching and semantic caching? Pro
- Design a semantic cache. How does it work, and what breaks it? Pro
- How do you optimize prompt caching at scale: prefix design, invalidation, and hit rate? Pro
- Semantic caching correctness: how do you tune the threshold and prevent wrong or stale hits? Pro
Gateways and model routing
The LLM gateway as a single entry point, cheap-first cascades, and routing requests by cost, latency and quality.
Cost modeling and budgets
What drives token cost, estimating cost per conversation, per-tenant budgets, and a standing cost optimization program.
- What are the main cost drivers of an LLM system, and how do you reason about them? Pro
- How do you model and estimate the cost per conversation for an LLM product? Pro
- How do you enforce per-tenant cost controls and budgets, with hard and soft limits? Pro
- Design an end-to-end cost optimization program for a high-volume LLM product. Pro
Scaling, quotas and queueing
Async jobs, multi-tenant rate limits, handling 429s and backpressure, fair queueing, and capacity on a shared platform.
- How would you handle long-running LLM jobs, like processing a 500-page document? Pro
- How do you handle multi-tenancy in an LLM platform: rate limiting, quotas, and noisy neighbors? Pro
- How do you scale LLM inference: autoscaling and load-balancing across providers and regions? Pro
- How do you handle provider rate limits (429s) and backpressure under load? Pro
- Design the queueing system for spiky, asynchronous LLM workloads with priorities and fairness. Pro
- Design a global, multi-tenant LLM platform serving many internal product teams. Cover capacity, quotas, and chargeback. Pro
Reliability and failover
Fallbacks, graceful degradation, active-active setups across regions and providers, and SLOs with error budgets.
- What is a fallback, and why does every LLM system need one? Pro
- What does graceful degradation look like when a model provider is down or filters a request? Pro
- Design a multi-region, multi-provider active-active setup for high availability. Pro
- Define SLOs and a reliability strategy for an LLM system, including error budgets and a degradation ladder. Pro
RAG and grounded answers
Choosing RAG over fine-tuning or long context, access-controlled retrieval, answers with citations, and abstaining.
- Design an AI customer support bot that answers from company documentation and can escalate to humans. Pro
- Design an enterprise RAG search system over internal documents with access control. Pro
- How do you design a system that grounds its answers and abstains instead of hallucinating? Pro
- How do you decide between RAG, fine-tuning, and long-context prompting when a model needs your private data? Pro
- Design a Perplexity-style answer engine that searches the web and cites its sources. Pro
Guardrails and data protection
Where guardrails go in the pipeline, layered defenses against prompt injection, and keeping PII away from hosted providers.
Agents, tools and human review
Reliable structured output and tool calls, agent platforms and coding assistants, and human-in-the-loop review.
- How would you design human-in-the-loop escalation and review? Pro
- Design an AI coding assistant (IDE autocomplete plus a chat/agent mode). Pro
- How do you get reliable structured output and tool calls from a model at scale: schemas, validation, and retry handling? Pro
- Design an AI agent platform: orchestration, tool registry, sandboxing, and reliability. Pro
Evals, observability and rollouts
Evals and monitoring, tracing and token accounting, shadow and canary rollouts, model migrations, and data flywheels.
- What should you instrument for evals and monitoring in a production LLM system? Pro
- How do you safely roll out a prompt or model change using shadow traffic and canaries? Pro
- How would you design a data flywheel that improves the system over time? Pro
- Design end-to-end observability for a multi-step LLM request, including token accounting. Pro
- How do you safely handle provider model deprecations and migrations? Pro
All questions
Showing of 54What does an "AI system design" interview round actually test, and how is it different from designing the model itself?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
The round tests whether you can build a reliable product around a model you did not train. You treat the model as a remote dependency. It is paid per token, sometimes slow, and non-deterministic, so the same input can give different output.
Model design asks how to make the model better. System design asks what to do when it is wrong, slow, or down.
| Designing the model | Designing the system | |
|---|---|---|
| What you work on | Data, architecture, training loss | Latency and cost budgets |
| How you measure it | Offline benchmark scores | Evals on live traffic |
| What you ship | One artifact | Retrieval, state, guardrails, fallbacks |
Interviewers listen for numbers: cost per request, a latency target, and a plan for failure. Saying "just call the API" without those is the usual reason people fail.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are the core architecture layers of a production LLM application?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A production LLM app is a normal web app plus two layers, orchestration and model access. The model is one dependency, not the system.
- The client renders streamed output and holds the UI session.
- The application API owns auth and business rules, and persists conversation history.
- Orchestration builds each request from retrieval, templates and tool calls, and runs multi-step flows.
- The data layer holds the vector index, documents and application database.
- Model access talks to providers and holds their keys. It runs retries and timeouts, and tracks spend.
- Providers are hosted APIs or self-hosted inference.
Safety checks, evals and telemetry are not a layer. They wrap every call.
These are logical layers, so start in one process. From day one, nothing outside model access imports a provider SDK.
// the only module that imports a provider SDK
export async function complete({ model, messages }) {
return client.messages.create({ model, messages, max_tokens: 1024 });
}
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is time-to-first-token versus total latency, and why do both matter?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Time-to-first-token (TTFT) is the wait from sending the request until the first token comes back. Total latency is the wait until the last token arrives.
Roughly, total = TTFT + output_tokens * time_per_output_token.
TTFT depends on prompt length, queue wait and prefill, the pass that reads the whole prompt before generating. It is what the user feels in streamed chat. Total latency depends on the number of output tokens and decode speed. It matters for JSON, tool calls and batch jobs, where nothing is usable early.
The two move independently. Trimming the prompt cuts TTFT. Trimming the answer cuts total latency.
So track both at p95, per route. A fast first token followed by a slow 800-token answer still fails a voice agent. One blended number hides which half is broken.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Why is streaming important for LLM UX, and what does it change about your architecture?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Streaming sends tokens as the model writes them, so the user reads the first words in under a second, not a spinner. Total time barely changes. The wait just feels shorter.
It changes the architecture because the reply stops being one JSON object. You hold a connection open, usually with Server-Sent Events (SSE), a one-way stream over HTTP. Every hop must forward chunks without buffering, and proxies, gzip and gateways buffer by default.
The HTTP status goes out before the answer exists. So a mid-stream failure needs an in-band error event, not a 500. Token counts also arrive last, so keep a copy of the stream on the server for logging, caching and output checks.
let full = '';
for await (const chunk of stream) {
full += chunk.delta; // server-side copy
res.write(`data: ${JSON.stringify(chunk)}\n\n`);
}
res.write(`event: done\ndata: ${JSON.stringify(usage)}\n\n`);
await logAndCache(full); // only possible after the last chunk
If the user stops a bad answer, abort the upstream call. Otherwise you pay for tokens nobody ever sees.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is prompt (prefix) caching, and why does it matter for cost and latency?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Prompt caching stores the model's internal state for a prompt prefix, its KV cache, so a later request with the same prefix skips recomputing it. The match is prefix-based from the first token, so put stable parts first and the changing user turn last. One edited character early invalidates everything after it.
// Anthropic-style: mark where the stable prefix ends
const req = {
system: [
{ type: 'text', text: instructions + toolDocs,
cache_control: { type: 'ephemeral' } } // cache up to here
],
messages: [{ role: 'user', content: userTurn }] // changes every call
};
Cost falls because cached tokens are read back at a steep discount. Writing the cache can cost more than plain input, so it pays off only on repeats. Providers also set a minimum prefix size, so short prompts never cache.
Latency falls because caching shortens prefill, the pass over the input before the first output token. Time-to-first-token drops, but generation speed is unchanged. Entries usually expire after minutes of inactivity, so repeated, bursty traffic gains most.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is an LLM gateway (or AI proxy), and what belongs in it?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
An LLM gateway, or AI proxy, is one internal service that every app calls instead of calling model providers directly. It is a reverse proxy for model traffic, so cross-cutting concerns live in one place.
// app code: one endpoint, provider-shaped body, no provider keys
const res = await fetch('https://gateway.internal/v1/messages', {
method: 'POST',
headers: { 'x-tenant-id': tenantId, 'x-trace-id': traceId },
body: JSON.stringify({ model: 'claude-sonnet-4-6', messages, stream: true })
});
The gateway owns:
- provider keys and caller auth, so no key sits in app code
- per-tenant rate limits and quotas
- retries, timeouts and failover
- trace IDs, token accounting and request logs, so usage is measured once
Prompt templates, retrieval and business logic stay in the app. So do conversation state and response rendering.
Keep it thin. It sits on the hot path of every request, so it must pass streamed chunks through untouched. It is also a single point of failure, so it needs health checks and a bypass path.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is model routing, and what is a "cheap-first" cascade?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Model routing sends each request to the model that fits what the request needs. Small, cheap models handle easy work, and large models handle the hard cases. The router decides before the call, using rules, request length or a small classifier.
A cheap-first cascade decides after the fact instead. You always call the cheap model first and check its answer. You escalate to the stronger model only when that check fails.
async function cascade(prompt) {
const draft = await call('small-model', prompt);
if (passesCheck(draft)) return draft; // most traffic stops here
return call('large-model', prompt); // escalation pays twice
}
The tradeoff is that an escalated request pays for both calls and both latencies. A cascade saves money only while the escalation rate stays low. The check must also be cheap, because a check that calls a big model to grade defeats the point.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The LLM API is stateless. What does that mean for conversation design?
What is the context window, and how does it constrain system design?
What is the difference between exact-match caching and semantic caching?
What is a fallback, and why does every LLM system need one?
What are the main cost drivers of an LLM system, and how do you reason about them?
Design a ChatGPT-style conversational assistant. Walk through the architecture.
Design an AI customer support bot that answers from company documentation and can escalate to humans.
How would you handle long-running LLM jobs, like processing a 500-page document?
Design a semantic cache. How does it work, and what breaks it?
Design a model routing layer. How do you decide which model handles a request?
How do you handle multi-tenancy in an LLM platform: rate limiting, quotas, and noisy neighbors?
How would you design conversation state and memory storage for a chat product?
How do you set and enforce a latency budget across an LLM request pipeline?
Where should guardrails live in the pipeline, and what are the tradeoffs of each placement?
Design an enterprise RAG search system over internal documents with access control.
How do you scale LLM inference: autoscaling and load-balancing across providers and regions?
How do you model and estimate the cost per conversation for an LLM product?
What does graceful degradation look like when a model provider is down or filters a request?
What should you instrument for evals and monitoring in a production LLM system?
How would you design human-in-the-loop escalation and review?
Build versus buy: hosted model APIs versus self-hosting. How do you decide?
How do you handle provider rate limits (429s) and backpressure under load?
Design an AI coding assistant (IDE autocomplete plus a chat/agent mode).
How do you design a system that grounds its answers and abstains instead of hallucinating?
How do you get reliable structured output and tool calls from a model at scale: schemas, validation, and retry handling?
How do you decide between RAG, fine-tuning, and long-context prompting when a model needs your private data?
Design a multi-region, multi-provider active-active setup for high availability.
How do you optimize prompt caching at scale: prefix design, invalidation, and hit rate?
How do you enforce per-tenant cost controls and budgets, with hard and soft limits?
Design an AI agent platform: orchestration, tool registry, sandboxing, and reliability.
How do you safely roll out a prompt or model change using shadow traffic and canaries?
How would you design a data flywheel that improves the system over time?
Semantic caching correctness: how do you tune the threshold and prevent wrong or stale hits?
Design the queueing system for spiky, asynchronous LLM workloads with priorities and fairness.
How do you architect streaming at scale (SSE/WebSockets), including load balancers and reconnection?
Design the memory architecture for a long-lived agent that operates over days or weeks.
How would you design layered defenses against prompt injection in RAG and agents?
Design end-to-end observability for a multi-step LLM request, including token accounting.
How do you make routing decisions with evals to balance cost, latency, and quality?
How do you safely handle provider model deprecations and migrations?
Design a global, multi-tenant LLM platform serving many internal product teams. Cover capacity, quotas, and chargeback.
Define SLOs and a reliability strategy for an LLM system, including error budgets and a degradation ladder.
Design an end-to-end cost optimization program for a high-volume LLM product.
When and how would you self-host LLM inference at scale (batching, KV cache, GPU autoscaling)?
Design a real-time voice assistant: what is the end-to-end latency budget, and where does it break?
How do you keep PII and regulated data out of third-party model providers while still using hosted APIs?
Design a Perplexity-style answer engine that searches the web and cites its sources.
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
AI System Design in pictures.
A quick recap of AI System Design in 42 short animated pictures, one idea at a time. About 11 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.
Pro The first chapter is free to play. The other 38 pictures come with Pro.
AI System Design cheatsheet
- Layers & the gateway01
- Latency & streaming02
- Context, state & memory03
- Prompt & semantic caches04
- Routing & cost05
- Tenants, limits & queues06
- Failures & fallbacks07
- Guardrails & grounding08
- Evals, tracing & rollout09
- Designs interviewers ask for10
- The model11
- + 5 more inside
This picture is part of Pro. The first chapter is free to play; the other 38 pictures come with Pro.
Get Pro · $10/mo Already Pro? Sign in47 of 54 AI System Design answers are in Pro.
Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.
- Full answers + code
- AI explanations, simpler or deeper
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.