By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
You're building an AI system and need to know if it's viable before you spend engineering time on it. System design for AI starts with four numbers: tokens, cost, latency, and concurrency. Get these wrong and you'll either blow your budget or discover too late that your infrastructure can't handle the load.
Models process text as tokens—chunks that average about three-quarters of an English word, though this varies by model and language. Providers bill input and output tokens separately, and output costs more. That's the first thing to nail down.
Once you know token counts, multiply by the per-token price. Providers quote prices per million tokens.
cost = input_tokens * price_in / 1,000,000
+ output_tokens * price_out / 1,000,000
Example: 1,000 in + 500 out, $3 / $15 per million tokens
= 0.003 + 0.0075 = $0.0105 per request
x 10,000 requests/day x 30 days = $3,150 / monthThe example shows 1,000 input tokens and 500 output tokens at $3 and $15 per million respectively comes to $0.0105 per request. Scale that to 10,000 requests a day over 30 days and you're at $3,150 a month.
Here's the trap: a long system prompt gets paid for on every request. If you add 2,000 tokens and handle 1 million requests a month, that's 2 billion extra input tokens you're paying for. This is why caching matters.
Two latency metrics matter. Time to first token (TTFT) is how long before the user sees anything—driven by prompt length, queueing, and retrieval. Time to last token is the full response duration, driven mostly by how many tokens you generate.
With streaming, users judge your app by TTFT. Without it, they judge it by the full wait. This changes what you optimize for.
How many requests are actually in flight at once? Little's Law tells you: in-flight requests equals arrival rate times average time in the system.
20 requests / second x 3.5 seconds each = 70 requests in flight
Your provider limits, your connection pools and your autoscaling
all have to handle 70 simultaneous long-lived requests - not 20.A system handling 20 requests per second with 3.5 second latency has 70 requests in flight simultaneously. Your provider limits, connection pools, and autoscaling all have to handle 70, not 20. A system that runs fine at 20 RPS with 50 ms latency can collapse at 20 RPS with 3.5 second latency because of the concurrency spike.
Build this into your design process before you write code.
Prices and limits change often. Treat any number in this course as an example and read your provider's current pricing page.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.