System Design for AI
The earlier pages of this module each explain one part: prompts, retrieval, tools, evals, monitoring, security. System design is the job of putting the parts together so that the whole system gives good answers, stays up under load, and costs what the business can pay.
6 min read6 মিনিটে পড়া যায় · 6 sections6টি সেকশন · 6 sources6টি সোর্স · updated Nov 2026আপডেট: Nov 2026
A request meets the router, then overloadএকটা অনুরোধ router-এ পৌঁছায়, তারপর ওভারলোড
Push traffic up and watch the design fall back from full RAG to a degraded answer to plain errors.ট্রাফিক বাড়ান আর দেখুন ডিজাইন পূর্ণ RAG থেকে degraded উত্তরে, তারপর সাধারণ এররে নেমে আসে।
You’ll learnআপনি শিখবেন
- What the router sends whererouter কী কোথায় পাঠায়
- Why the batch API suits nightly jobsরাতের জবে batch API কেন ভালো
- How the cache cuts model callsক্যাশ কীভাবে মডেল কল কমায়
- What a degraded response isdegraded উত্তর কী
- When a design may only return errorsকখন ডিজাইন শুধু এরর দিতে পারে
In plain words
Anthropic's first advice is to find the simplest solution that works, and to add complexity only when it is needed. Sometimes that means no agentic system at all Source 1সোর্স 1. Agentic systems often give better task results in exchange for more latency and cost Source 1সোর্স 1.
The basic building block is an augmented LLM: a model with retrieval, tools, and memory Source 1সোর্স 1. On top of it, you choose one of 2 shapes Source 1সোর্স 1:
| Shape | Who decides the steps |
|---|---|
| Workflow | Your code. The LLM and the tools run through predefined code paths. |
| Agent | The LLM. It directs its own process and tool use. |
Workflows give predictability and consistency for tasks that are well defined Source 1সোর্স 1. Then you design the rest like any system: what happens under load, what it costs, and what fails.
সহজ English
Anthropic's first advice is this. Find the simplest solution that works. Add complexity only when you need it. Sometimes that means no agentic system at all Source 1সোর্স 1. Agentic systems often give better task results, but they cost more and take longer Source 1সোর্স 1.
The basic building block is an augmented LLM. It is a model with retrieval, tools, and memory Source 1সোর্স 1. On top of it, you choose one of 2 shapes Source 1সোর্স 1.
- A workflow: your code decides the steps. The LLM and the tools run through code paths that you wrote before.
- An agent: the LLM decides the steps. It directs its own process and its own tool use.
Workflows are predictable and consistent for tasks that are well defined Source 1সোর্স 1. Then you design the rest like any system. What happens under load? What does it cost? What fails?
বাংলা ব্যাখ্যা
Anthropic-এর প্রথম পরামর্শ: যে সবচেয়ে সহজ সমাধান কাজ করে, সেটা খুঁজুন, আর দরকার হলেই কেবল জটিলতা বাড়ান। কখনও এর মানে কোনো agentic সিস্টেমই না বানানো Source 1সোর্স 1। Agentic সিস্টেম প্রায়ই ভালো ফলাফলের বদলে বেশি latency আর খরচ নেয় Source 1সোর্স 1।
মূল বিল্ডিং ব্লক হলো একটা augmented LLM: রিট্রিভাল, টুল আর মেমরিসহ একটা মডেল Source 1সোর্স 1। এর ওপর আপনি 2টা আকারের একটা বেছে নেন Source 1সোর্স 1:
- ওয়ার্কফ্লো: ধাপগুলো ঠিক করে আপনার কোড। LLM আর টুল আগে থেকে লেখা কোড-পথ ধরে চলে।
- এজেন্ট: ধাপগুলো ঠিক করে LLM। সে নিজের প্রসেস আর টুলের ব্যবহার নিজেই চালায়।
ভালোভাবে সংজ্ঞায়িত টাস্কে ওয়ার্কফ্লো অনুমানযোগ্যতা আর ধারাবাহিকতা দেয় Source 1সোর্স 1। তারপর বাকিটা যেকোনো সিস্টেমের মতো ডিজাইন করুন: লোডে কী হয়, খরচ কত, আর কী ব্যর্থ হয়।
How it works
A reference shape
Tutorial's own view of a common design for a question-answering app:
+--> router (cheap model or rules) --+--> FAQ answer (cached)
user --> API| +--> RAG path:
| retrieve -> rerank -> LLM -> checks
+--> rate limit, auth, logging |
+--> tools (read-only by default)
offline: documents -> pipeline -> vector index
nightly jobs -> batch APIThe parts and the reasons
- Retrieval (RAG). The RAG paper combines a model's own knowledge with an outside index that a retriever searches Source 2সোর্স 2. The authors note that a model alone has trouble updating its knowledge and showing where an answer came from Source 2সোর্স 2. An index of your documents addresses both.
- Routing. Routing classifies an input and sends it to a specialized task. Without it, tuning for one kind of input can hurt the others Source 1সোর্স 1.
- Prompt caching. A long system prompt or document set that repeats can be cached as a prefix. This cuts processing time and cost Source 3সোর্স 3. The default cache lifetime is 5 minutes, and a 1-hour lifetime is also available Source 3সোর্স 3.
- Batch work. Jobs that do not need an instant answer, such as nightly evals or bulk tagging, can use the Message Batches API. It charges 50% of the standard price, a batch ends when all requests finish, and a batch that is not done within 24 hours expires Source 4সোর্স 4.
- Capacity. The model API has limits in requests and tokens per minute Source 6সোর্স 6. Your own design needs a plan for overload too Source 5সোর্স 5.
Overload and failure
Google SRE describes degraded responses: answers that are less accurate or have less data, but cost less to compute, such as a search over only part of the data Source 5সোর্স 5. Under extreme overload, even that may not work, and the service may have to return errors Source 5সোর্স 5. SRE also describes per-customer quotas, so that one client cannot use all the capacity Source 5সোর্স 5.
Tutorial's own view: for an AI app, a degraded response can be a smaller model, fewer retrieved chunks, or a "please try again" message with the FAQ links. Decide this in the design, not during the incident.
সহজ English
A reference shape. Here is the tutorial's own view of a common design for an app that answers questions. The user calls the API. The API checks the rate limit and the login, and it logs the request. A router sends easy questions to a cached FAQ answer. The router is a cheap model or simple rules. Other questions take the RAG path. The app finds documents, ranks them, asks the LLM, and checks the answer. Tools are read-only by default. Offline, a pipeline turns documents into a vector index. Nightly jobs use the batch API.
The parts and the reasons.
- Retrieval (RAG). The RAG paper combines the knowledge inside a model with an outside index. A retriever searches the index Source 2সোর্স 2. The authors note two problems of a model alone. It is hard to update its knowledge. It is hard to show where an answer came from Source 2সোর্স 2. An index of your documents helps with both.
- Routing. Routing sorts an input and sends it to a special task. Without it, tuning for one kind of input can hurt the others Source 1সোর্স 1.
- Prompt caching. A long system prompt or set of documents can repeat. You can cache it as a prefix. This cuts processing time and cost Source 3সোর্স 3. The cache lasts 5 minutes by default. A 1-hour lifetime is also available Source 3সোর্স 3.
- Batch work. Some jobs do not need an answer at once. Nightly evals and bulk tagging are examples. They can use the Message Batches API. It charges 50% of the standard price. A batch ends when all requests finish. A batch that is not done within 24 hours expires Source 4সোর্স 4.
- Capacity. The model API has limits in requests and tokens per minute Source 6সোর্স 6. Your own design needs a plan for overload too.
Overload and failure. Google SRE describes degraded responses. These answers are less accurate or have less data. But they cost less to compute. One example is a search over only part of the data Source 5সোর্স 5. Under extreme overload, even that may not work. The service may have to return errors Source 5সোর্স 5. SRE also describes quotas for each customer. Then one client cannot use all the capacity Source 5সোর্স 5.
The tutorial's own view: for an AI app, a degraded response can be a smaller model, fewer documents, or a "please try again" message with the FAQ links. Decide this in the design, not during the incident.
বাংলা ব্যাখ্যা
একটা নমুনা আকার। প্রশ্নের উত্তর দেওয়া অ্যাপের একটা সাধারণ ডিজাইন নিয়ে টিউটোরিয়ালের নিজের মত এই। ইউজার API কল করেন। API রেট লিমিট আর লগইন চেক করে, আর রিকুয়েস্ট লগ করে। একটা router সহজ প্রশ্ন পাঠায় ক্যাশ করা FAQ উত্তরে; router হলো একটা সস্তা মডেল বা সহজ নিয়ম। অন্য প্রশ্ন যায় RAG পথে: অ্যাপ ডকুমেন্ট খোঁজে, সাজায়, LLM-কে জিজ্ঞেস করে, আর উত্তর চেক করে। টুলগুলো ডিফল্টভাবে read-only। অফলাইনে একটা পাইপলাইন ডকুমেন্টকে ভেক্টর ইনডেক্সে পরিণত করে। রাতের জবগুলো batch API ব্যবহার করে।
অংশগুলো আর তার কারণ।
- রিট্রিভাল (RAG)। RAG পেপার মডেলের নিজের জ্ঞানের সঙ্গে একটা বাইরের ইনডেক্স মেলায়, যেটা একটা retriever খোঁজে Source 2সোর্স 2। লেখকরা বলেন, একা একটা মডেলের জ্ঞান আপডেট করা আর উত্তর কোথা থেকে এল তা দেখানো কঠিন Source 2সোর্স 2। আপনার ডকুমেন্টের একটা ইনডেক্স দুটোতেই সাহায্য করে।
- রাউটিং। রাউটিং একটা ইনপুটকে শ্রেণিভুক্ত করে একটা বিশেষ টাস্কে পাঠায়। এটা না থাকলে এক ধরনের ইনপুটের জন্য টিউন করলে অন্যগুলোর ক্ষতি হতে পারে Source 1সোর্স 1।
- প্রম্পট ক্যাশিং। বারবার আসা লম্বা সিস্টেম প্রম্পট বা ডকুমেন্টের সেট একটা prefix হিসেবে ক্যাশ করা যায়। এতে প্রসেসিংয়ের সময় আর খরচ কমে Source 3সোর্স 3। ডিফল্টভাবে ক্যাশ 5 মিনিট থাকে, 1 ঘণ্টার মেয়াদও পাওয়া যায় Source 3সোর্স 3।
- ব্যাচের কাজ। যে কাজে সঙ্গে সঙ্গে উত্তর লাগে না, যেমন রাতের eval বা একসঙ্গে অনেক কিছু ট্যাগ করা, সেগুলো Message Batches API ব্যবহার করতে পারে। এটা স্বাভাবিক দামের 50% নেয়, আর সব রিকুয়েস্ট শেষ হলে একটা batch শেষ হয়; 24 ঘণ্টার মধ্যে শেষ না হলে batch expire হয়ে যায় Source 4সোর্স 4।
- ক্ষমতা (capacity)। মডেল API-র প্রতি মিনিটে রিকুয়েস্ট আর টোকেনের লিমিট আছে Source 6সোর্স 6। আপনার নিজের ডিজাইনেও ওভারলোডের পরিকল্পনা লাগবে।
ওভারলোড আর ব্যর্থতা। Google SRE degraded response-এর কথা বলে: এমন উত্তর, যা কম নির্ভুল বা কম ডেটার, কিন্তু হিসাব করতে কম খরচ, যেমন ডেটার শুধু একটা অংশে সার্চ Source 5সোর্স 5। চরম ওভারলোডে এটাও কাজ না করতে পারে, তখন সার্ভিসকে এরর ফেরত দিতে হতে পারে Source 5সোর্স 5। SRE প্রতিটা কাস্টমারের জন্য কোটার কথাও বলে, যাতে একজন ক্লায়েন্ট সব ক্ষমতা নিয়ে নিতে না পারে Source 5সোর্স 5।
টিউটোরিয়ালের নিজের মত: একটা AI অ্যাপে degraded response হতে পারে একটা ছোট মডেল, কম ডকুমেন্ট, বা FAQ লিংকসহ "আবার চেষ্টা করুন" মেসেজ। এটা ডিজাইনের সময়ই ঠিক করুন, ইনসিডেন্টের সময় নয়।
A real-life example
A software company wants an assistant that answers questions from its 20,000 help-center articles, for 50,000 users a day.
Version 1 was a single agent with a web-search tool and 12 other tools. It was slow, costly, and hard to test. The redesign follows the "simplest solution" advice Source 1সোর্স 1:
- A router sends billing questions to a billing prompt and product questions to the RAG path Source 1সোর্স 1.
- The RAG path retrieves from an index of the help-center articles Source 2সোর্স 2. Tutorial's own view: the app can then show the source article with each answer.
- The system prompt and the style guide are a cached prefix, because every request repeats them Source 3সোর্স 3.
- The nightly job that re-tags new articles runs through the batch API at half price Source 4সোর্স 4.
- When the model API returns 429s, the app serves a degraded answer: the 3 best-matching article links with no generated text Source 5সোর্স 5 Source 6সোর্স 6.
The team can now test each part on its own, and test the whole path end to end.
সহজ English
A software company wants an assistant. It answers questions from 20,000 help-center articles, for 50,000 users a day.
Version 1 was a single agent. It had a web-search tool and 12 other tools. It was slow, cost a lot, and was hard to test. The redesign follows the "simplest solution" advice Source 1সোর্স 1.
- A router sends billing questions to a billing prompt. It sends product questions to the RAG path Source 1সোর্স 1.
- The RAG path searches an index of the help-center articles Source 2সোর্স 2. The tutorial's own view: the app can then show the source article with each answer.
- The system prompt and the style guide are a cached prefix, because every request repeats them Source 3সোর্স 3.
- A nightly job tags new articles again. It runs through the batch API at half price Source 4সোর্স 4.
- The model API can return 429s. Then the app gives a degraded answer: the links to the 3 best-matching articles, with no generated text Source 5সোর্স 5 Source 6সোর্স 6.
Now the team can test each part on its own. It can also test the whole path from end to end.
বাংলা ব্যাখ্যা
একটা সফটওয়্যার কোম্পানি এমন একটা অ্যাসিস্ট্যান্ট চায়, যা তাদের 20,000 হেল্প-সেন্টার আর্টিকেল থেকে দিনে 50,000 ইউজারের প্রশ্নের উত্তর দেবে।
ভার্সন 1 ছিল একটা একক এজেন্ট, একটা ওয়েব-সার্চ টুল আর আরও 12টা টুলসহ। এটা ধীর, ব্যয়বহুল আর টেস্ট করা কঠিন ছিল। নতুন ডিজাইন "সবচেয়ে সহজ সমাধান"-এর পরামর্শ মেনে চলে Source 1সোর্স 1:
- একটা router বিলিংয়ের প্রশ্ন পাঠায় একটা বিলিং প্রম্পটে, আর প্রোডাক্টের প্রশ্ন পাঠায় RAG পথে Source 1সোর্স 1।
- RAG পথ হেল্প-সেন্টার আর্টিকেলের একটা ইনডেক্স থেকে খোঁজে, Source 2সোর্স 2 টিউটোরিয়ালের নিজের মত: অ্যাপ তখন প্রতিটা উত্তরের সাথে সোর্স আর্টিকেল দেখাতে পারে।
- সিস্টেম প্রম্পট আর স্টাইল গাইড একটা ক্যাশ করা prefix, কারণ প্রতিটা রিকুয়েস্টে এগুলো আসে Source 3সোর্স 3।
- নতুন আর্টিকেল আবার ট্যাগ করার রাতের জব batch API দিয়ে অর্ধেক দামে চলে Source 4সোর্স 4।
- মডেল API 429 ফেরত দিলে অ্যাপ একটা degraded উত্তর দেয়: সবচেয়ে মেলে এমন 3টা আর্টিকেলের লিংক, কোনো তৈরি করা লেখা ছাড়া Source 5সোর্স 5 Source 6সোর্স 6।
এখন টিম প্রতিটা অংশ আলাদা করে টেস্ট করতে পারে, আর পুরো পথটা শুরু থেকে শেষ পর্যন্তও টেস্ট করতে পারে।
Common mistakes
- An agent for a fixed task. If the steps are known, a workflow is more predictable and more consistent Source 1সোর্স 1.
- One prompt for every kind of question. Tuning it for one type of input can make other types worse. Routing separates them Source 1সোর্স 1.
- No source for answers. A model alone cannot easily show where an answer came from Source 2সোর্স 2. Without retrieval and citations, a tester cannot check an answer against a document.
- Real-time calls for offline work. Bulk jobs pay the full price, when the batch API charges 50% of it Source 4সোর্স 4.
- No plan for overload. Under heavy load, a service may only be able to return errors Source 5সোর্স 5. Tutorial's own view: design the degraded mode and test it.
- Cache that expires before reuse. The default cache lives 5 minutes Source 3সোর্স 3. Traffic that comes less often than that pays to write the cache without reading it.
সহজ English
- An agent for a fixed task. If you know the steps, a workflow is more predictable and more consistent Source 1সোর্স 1.
- One prompt for every kind of question. Tuning it for one type of input can make the other types worse. Routing keeps them apart Source 1সোর্স 1.
- No source for answers. A model alone cannot easily show where an answer came from Source 2সোর্স 2. Without retrieval and citations, a tester cannot check an answer against a document.
- Real-time calls for offline work. Bulk jobs pay the full price. The batch API charges only 50% of it Source 4সোর্স 4.
- No plan for overload. Under heavy load, a service may only be able to return errors Source 5সোর্স 5. The tutorial's own view: design the degraded mode, and test it.
- A cache that expires before reuse. The default cache lives 5 minutes Source 3সোর্স 3. If traffic comes less often, you pay to write the cache but never read it.
বাংলা ব্যাখ্যা
- নির্দিষ্ট টাস্কের জন্য এজেন্ট। ধাপগুলো জানা থাকলে ওয়ার্কফ্লো বেশি অনুমানযোগ্য আর ধারাবাহিক Source 1সোর্স 1।
- সব ধরনের প্রশ্নের জন্য এক প্রম্পট। এক ধরনের ইনপুটের জন্য টিউন করলে অন্যগুলো খারাপ হতে পারে। রাউটিং এগুলো আলাদা রাখে Source 1সোর্স 1।
- উত্তরের কোনো সোর্স নেই। একা একটা মডেল সহজে দেখাতে পারে না উত্তর কোথা থেকে এল Source 2সোর্স 2। রিট্রিভাল আর সাইটেশন ছাড়া একজন টেস্টার উত্তরকে কোনো ডকুমেন্টের সঙ্গে মেলাতে পারেন না।
- অফলাইন কাজে রিয়েল-টাইম কল। একসঙ্গে অনেক কাজের জব পুরো দাম দেয়, অথচ batch API নেয় তার মাত্র 50% Source 4সোর্স 4।
- ওভারলোডের পরিকল্পনা নেই। ভারী লোডে একটা সার্ভিস হয়তো শুধু এরর ফেরত দিতে পারে Source 5সোর্স 5। টিউটোরিয়ালের নিজের মত: degraded মোড ডিজাইন করুন আর টেস্ট করুন।
- আবার ব্যবহারের আগেই মেয়াদ শেষ হওয়া ক্যাশ। ডিফল্ট ক্যাশ 5 মিনিট থাকে Source 3সোর্স 3। এর চেয়ে কম ঘন ঘন ট্রাফিক এলে ক্যাশ লেখার খরচ দেন, কিন্তু পড়া হয় না।
What a tester can check
Tutorial advice
These test ideas are the tutorial's own advice.
- Draw the diagram. Ask the team for the design diagram. Mark each model call, each store, and each tool. Each one is a test target and a failure point.
- Test each route. Write questions for each route of the router, and edge cases that sit between 2 routes.
- Check the sources. For 20 answers, open the cited article and check that it supports the answer.
- Force the degraded mode. In staging, block the model API. Check that users get the planned fallback, not a stack trace.
- Load test the full path. Measure latency and errors at the expected peak, and find which part saturates first.
- Check the batch path. Submit a small batch and check that results arrive, and that failed items are retried or reported.
সহজ English
These test ideas are the tutorial's own advice.
- Draw the diagram. Ask the team for the design diagram. Mark each model call, each store, and each tool. Each one is a test target and a failure point.
- Test each route. Write questions for each route of the router. Add edge cases that sit between 2 routes.
- Check the sources. For 20 answers, open the cited article. Check that it supports the answer.
- Force the degraded mode. In staging, block the model API. Check that users get the planned fallback, not a stack trace.
- Load test the full path. Measure latency and errors at the expected peak. Find which part fills up first.
- Check the batch path. Submit a small batch. Check that results arrive. Check that failed items are retried or reported.
বাংলা ব্যাখ্যা
এই টেস্টের ধারণাগুলো টিউটোরিয়ালের নিজের পরামর্শ।
- ডায়াগ্রাম আঁকুন। টিমের কাছে ডিজাইন ডায়াগ্রাম চান। প্রতিটা মডেল কল, প্রতিটা স্টোর আর প্রতিটা টুল চিহ্নিত করুন। প্রতিটাই একটা টেস্টের লক্ষ্য আর একটা ব্যর্থতার জায়গা।
- প্রতিটা রুট টেস্ট করুন। Router-এর প্রতিটা রুটের জন্য প্রশ্ন লিখুন, আর এমন edge case যোগ করুন যা 2টা রুটের মাঝামাঝি।
- সোর্স চেক করুন। 20টা উত্তরের জন্য উল্লেখ করা আর্টিকেল খুলুন, আর দেখুন সেটা উত্তরকে সমর্থন করে কি না।
- Degraded মোড চালু করান। Staging-এ মডেল API আটকে দিন। ইউজার পরিকল্পিত বিকল্প উত্তর পান কি না দেখুন, stack trace নয়।
- পুরো পথে লোড টেস্ট। প্রত্যাশিত সর্বোচ্চ লোডে latency আর এরর মাপুন, আর কোন অংশ আগে ভরে যায় খুঁজুন।
- Batch পথ চেক করুন। একটা ছোট batch জমা দিন। ফল আসে কি না, আর ব্যর্থ আইটেম আবার চেষ্টা হয় বা রিপোর্ট হয় কি না দেখুন।
Key words
| Word | Meaning |
|---|---|
| Augmented LLM | A model with retrieval, tools, and memory Source 1সোর্স 1 |
| Workflow | LLMs and tools that run through predefined code paths Source 1সোর্স 1 |
| Agent | An LLM that directs its own process and tool use Source 1সোর্স 1 |
| RAG | A model combined with a retriever over an outside index Source 2সোর্স 2 |
| Prompt caching | Reuse a cached prompt prefix to cut time and cost Source 3সোর্স 3 |
| Batch API | Send many requests for asynchronous processing at a lower price Source 4সোর্স 4 |
| Degraded response | A cheaper, less complete answer served under overload Source 5সোর্স 5 |