AI Interviews · Question

Project deep dive on an LLM integration framework the candidate built: how were tokens handled and allocated, and was pricing per query or per token?

Project presentation / deep dive question reported at LinkedIn (2026). Sources, confidence and an answer card.

Researched · updated

r2a-020 AI Engineer Serving, latency & cost Project presentation / deep dive Senior Medium confidence
On this page

What they’re really asking

If you only remember one thing, say this in the first minute: “We metered in tokens, because that’s what the providers bill and limit, and one request can cost a thousand times another. Every call carried the customer, user and feature, and every attempt, retries included, wrote a cost record that we checked against the provider’s invoice. Limits reserved the worst case when a request started and refunded the unused part when it ended. Underneath, pricing was per token. A per-query price only made sense on top, where usage was predictable, and always with a cap on heavy users.”

The rest of this page explains each part of that answer, so you can tell your own project’s version of it.

This is a project deep dive, not a design round. The interviewers want to see that you understood the economics of what you built: how usage was counted, attributed and limited, and why the pricing unit was chosen.

If you have built billing or metering for a normal API, most of this will feel familiar. Two things are different when the API calls a large language model (LLM):

  1. The unit of cost is the token, and it varies enormously. A token is a small piece of text, roughly ¾ of a word. Providers charge per million tokens. One request may send 100 tokens; another sends 100,000. Counting requests tells you little about cost.
  2. There are several kinds of token at different prices. Input tokens (what you send) and output tokens (what the model writes) are priced differently. Cached input tokens are input the provider has seen recently and can reuse, such as a long fixed instruction block, and they are much cheaper. A good answer counts all three separately.

A LinkedIn Senior candidate presented a framework that let customers call external LLMs, and it became “a long conversation about token handling and how usage gets assigned correctly”, plus “How was pricing thought about, per query or per token?” (Aced (formerly Exponent)first-hand · 2026).

Clarify first

Here you are the one being asked, so clarify your own project before the round. Know these answers cold:

  • Who paid for the tokens: your company, each customer, or both?
  • Were limits per customer, per user or per feature, and in requests or tokens?
  • Where did token counts come from: your own tokenizer (the code that splits text into tokens), or the usage the provider reported back?
  • What happened on errors, retries and client disconnects: who was charged?
  • What was the cost per customer per month, roughly, and how spread out was it?

Answer

Structure the story around four decisions, each with the alternative you rejected. A simple picture helps the interviewer follow:

Customer app
   │  request + customer, user, feature, prompt version
   ▼
Your framework
   │  1. reserve tokens (input + max reply) against the customer's limit
   │  2. call the provider
   │  3. read the provider's reported usage: input, cached input, output
   │  4. refund unused tokens; write one cost record per attempt
   ▼
Cost ledger ──► daily check against the provider's invoice
           └──► per-customer and per-feature reports, pricing

1. Metering unit: tokens

Providers bill and limit in tokens, and request sizes vary by orders of magnitude, so a request count says little about cost. Count input, cached input and output separately, because they are priced differently. As fetched 2026-10-11, Claude Sonnet 5 lists $2 per million input tokens, $0.20 per million cached input tokens and $10 per million output tokens (Anthropic pricing). Output costs five times input on that model, and cached input a tenth of input, so mixing them up skews every number.

2. Attribution

Every call carries customer, user, feature and prompt version (which exact instructions were sent). Each attempt, including retries, writes a cost record: tokens by kind, model, the version of the price table used, and cost. Reconcile the ledger against the provider’s invoice. Say it like this: “When the ledger and the invoice disagree, it’s almost always retries we didn’t count or an exit path that didn’t write a record.”

3. Allocation and limits

When a request starts, nobody knows how long the reply will be. So reserve the worst case: the input plus max_tokens, the cap the caller set on the reply’s length. When it ends, refund what was not used, from the provider’s reported counts. Refund on every exit path: success, error, timeout and client disconnect.

Follow one request through it

A customer’s request sends 1,500 input tokens with max_tokens of 1,000, and the model writes 300 tokens.

MomentWhat happensRunning totalWhat to say in the interview
StartReserve 1,500 + 1,000 against the customer’s tokens-per-minute limit.2,500 reserved”We reserve the worst case because the reply’s length isn’t known yet.”
Provider repliesProvider reports 1,500 input, 300 output.—“We trust the provider’s counts for billing, and compare them with ours.”
EndRefund 700; write the cost record with customer, feature and prompt version.1,800 charged”Without the refund we’d admit 28% fewer requests under the same limit.”
Retry caseIf the first attempt failed and was retried, two records are written.two rows”Retries are counted, or the invoice won’t match.”
The arithmetic behind the numbers (for a Staff-level follow-up)
Why the refund matters
admitted per minute = TPM limit ÷ tokens reserved per request
TPM limit
assumed 40 M tokens per minute
Worked example

Input 1,500, max_tokens 1,000, actual output 300: without refunds 40 M ÷ 2,500 = 16,000 requests/min; with refunds 40 M ÷ 1,800 ≈ 22,200, so never refunding admits 28% fewer

4. Pricing: per token underneath, per query only on top

Per query is simpler for customers and predictable for finance, but it moves the token variance onto you: one heavy user can cost many times the average. Use it only where usage is predictable, or behind a per-user cap. Cursor’s 2025 apology after moving from request-based to usage-based pricing shows the cost of getting this wrong in public (TechCrunch, 2025-07-07).

Say it like this: “We metered per token. We could present a per-query price to customers whose usage was steady, but always with a cap behind it, because a flat price on a variable cost puts the risk on whoever holds the cap.”

Close with a number

End with a number you know from your own project, such as cost per customer per month, and one thing you would change. If you don’t know your project’s numbers, find them before the round.

Senior vs Staff

Token handling deep dive

Senior

  • Explains counting, attribution, reserve and refund, and the per-token versus per-query choice with its risk.

Staff

  • Connects the pricing unit to margins and customer behaviour, describes the invoice reconciliation and who owned budget decisions, and says what data would change the pricing.

In plain words: a Senior answer explains the mechanics correctly. A Staff answer also ties the pricing unit to the company’s margins and to how customers behave, says who owned budget decisions, and names the data that would change the pricing.

Small-team version

At a 50–500 person company this is usually internal chargeback, not customer billing: which feature or team spent what.

  • Tag every call with a feature, and log tokens by kind from day one. A weekly cost-per-feature report is a day of work.
  • Use guardrails: provider spend caps and a budget per feature.
  • Present it simply: per-token metering with a per-query view is a sensible outcome for internal customers.

Why it matters, in money. In the family walkthrough’s worked example (assumed volumes, list prices fetched 2026-10-11), support answers at 50,000 calls a day cost about $9,600 a month with prompt caching, nightly summaries on the batch API (a provider discount for work nobody waits on) about $5,100, and ticket tagging on gpt-5-nano about $43. One feature is 65% of the $14,743 total. That is the number a cost-per-feature report exists to show: without tags, the bill is one number and nobody knows which lever to pull.

Pitfalls

  • Not knowing your own project’s cost numbers. The interviewer will ask, and “I’m not sure” undoes the story.
  • Counting only output tokens, or ignoring cached-input pricing. The three kinds are priced differently, so the totals come out wrong.
  • No story for retries and disconnects. Those are exactly where the ledger and the invoice disagree.
  • Defending per-query pricing with no cap on heavy users. A flat price on a variable cost loses money on the heaviest users.

Go deeper

Family