Key Takeaways

  • A metered inference API turns mobile serving cost from fixed per install into variable per session. Your most engaged users become your most expensive, and engagement stops being an unambiguously good signal.
  • Write down a cost-per-interaction ceiling and a latency ceiling before you write the integration. Derive both from revenue per user and observed abandonment, not from the provider's pricing page.
  • Sort every model-backed interaction into compute-fresh, cached, precomputed or on-device before implementing it. Anything you cannot justify in the compute-fresh column is a design defect, not an optimization opportunity.
  • Design the degradation path with the happy path. To the user a slow response and a poor response end the session identically, so the timeout is a product decision, not an infrastructure default.
  • Attribute inference spend per user, cohort, feature and code path at the moment of the call. Aggregate averages conceal exactly the heavy-use cohort whose economics decide whether the feature is viable.

For years, a user who opened your app forty times a day was your best user. Add one metered AI feature and they may become your most expensive one. Most teams discover this a couple of quarters too late, when the architecture is already fixed.

The delay has a simple cause: at launch, few users are heavy users and the provider is usually fast, so nothing looks wrong.

Total spend and average latency, the two numbers a team watches first, stay healthy for months, because the cost sits in one small cohort and an average hides it. No one is yet looking at cost per user, or at what the client does when a response arrives late.

In this article, I argue that cost per interaction and a latency ceiling are architectural constraints, decided before the integration is written and not tuned after launch.

Why AI features break the mobile cost model

The economics of a consumer app have had the same shape for a decade. You pay to acquire a user, you pay a small and nearly flat amount to serve them, and the rest is margin. Because serving cost barely moves with usage, the whole retention playbook of streaks, push notifications, and daily rewards rests on one assumption: more engagement is more value.

Metered inference breaks that assumption quietly. You are billed per token, per image or per second of audio, so serving cost now scales with what the user does. A conversational feature that costs a fraction of a cent per turn is nearly free for the user who opens it weekly and real money for the user who lives in it for forty minutes a day. The engagement curve and the margin curve now point in opposite directions.

Here is its shape with illustrative numbers. Say the feature costs $0.004 per interaction and the app monetizes at $0.90 per monthly active user.

| Cohort | Interactions / month | Inference cost / user | Revenue / user | Margin | | Light, 60% of MAU | 15 | $0.06 | $0.65 | +$0.59 | | Regular, 30% of MAU | 90 | $0.36 | $1.15 | +$0.79 | | Heavy, 10% of MAU | 700 | $2.80 | $1.60 | −$1.20 |

The blended number looks fine: roughly $0.42 of cost against $0.90 of revenue. But the top decile, the users who drive word of mouth, are served at a loss, and the loss grows with every retention win. I call this the cost inversion: the moment the users you most want to keep become the users you can least afford.

Figure 1: the cost inversion. Revenue per user flattens with engagement while inference cost per user rises linearly. The two cross inside the heavy cohort, at roughly 380 interactions a month on these illustrative numbers. Source: image generated by the author.

Click here to [expand image above to full-size/filters:no_upscale()/articles/mobile-ai-cost-latency-budgets/en/resources/262figure-1-1795602641000.jpg>)]

The second shift is subtler. When your backend serves a feed, latency is yours to profile and fix. When a third-party model produces the response, most of the latency is out of reach: provider queueing, model load, token generation rate, regional routing. You can observe it but you cannot fix it. What you control is what the client does while it waits, and when it stops waiting.

The first time I saw this, the signal was not the invoice itself but its slope. About four months after launch, inference spend was growing faster than active users, and when I cut the request logs by cohort the top decile accounted for most of the growth. Nobody had done anything wrong. The retention work had succeeded, and that was the problem. Both shifts surface one or two quarters after launch, when the heavy cohort grows large enough to move the invoice and a provider has a slow week. By then the fix is a rewrite.

What to do now: plot your inference invoice against your active-user count for the last three months. If cost is growing faster than users, the inversion has already started.

Setting the budget before the integration

The cost ceiling comes top-down from revenue, never bottom-up from the pricing page. The question is not what the API costs but how much of a user's value this feature can consume and still leave the product viable. Illustrative derivation: revenue per active user is $0.90 a month. The feature may consume a quarter of that, $0.225. Divide by P90 usage rather than the average, because the heavy cohort is the one that hits the ceiling. At 300 interactions a month, that is $0.00075 per interaction.

Compare that with $0.004 from the table and the feature is roughly five times over budget for the users who matter most. Knowing that before you build tells you that "call the model every time" will not work. It has to be a mix of cached, precomputed and on-device paths, and that is an architecture decision, not a tuning pass. For a subscription product the arithmetic is price, minus the store's cut, minus the share reserved for everything else, divided by P90 subscriber usage.

The latency ceiling comes from abandonment data you already have. Take any wait that already exists in your product, such as search or a media load. Plot session continuation against wait time and find the knee. In consumer mobile the knee for a first visible response usually sits between one and two seconds. That matches Jakob Nielsen's response-time limits: about one second keeps the user's flow of thought uninterrupted, and about ten seconds is the limit for holding their attention. Completion can take considerably longer as long as something is visibly happening. That gives two numbers: time to first visible response, the hard ceiling, and time to useful completion, after which the answer is no longer worth waiting for. A typical pair for a conversational feature is 1.5 seconds and 8 seconds. Without them, the timeout is whatever the HTTP client defaults to, which is 60 seconds for URLSession on iOS, and nobody chose that number.

What to do now: put both numbers in a one-page budget worksheet and store it with your architecture decision records. Every later design discussion gets checked against it.

The decision table

With the two ceilings fixed, every model-backed interaction gets sorted into one of four columns.

| Column | Meaning | Cost profile | Latency profile | | Compute fresh | Call the model at request time with the full context. | Full price, every time. | Provider-bound. | | Cache | Serve a previously computed result when the inputs match. | Near zero on hit. | Milliseconds, no model wait. | | Precompute | Generate ahead of time for inputs you can predict. | Batch pricing, amortized. | Milliseconds, no model wait. | | On-device | Run a smaller model on the phone. | Zero marginal cost, but a fixed engineering, battery and coverage cost. | Device-bound, predictable. |

The discipline is that compute-fresh is not the default. An interaction earns its place there by passing three questions. Is the input predictable before the request? If a large share of requests hit a small set of inputs, such as the starter prompts every new user tries or the top hundred catalog items, precompute them in batch at batch pricing. Is the output personalized, or a function of shared inputs? Shared outputs cache across users. Personal ones cache per user at best. Is it time-bound? A summary of an unchanged document is valid indefinitely, and a recommendation that depends on the last hour is not, so the TTL comes from how fast the inputs move rather than from a guess. 

Only an interaction that is unpredictable, personalized, and time-bound belongs in the compute-fresh column. Most, examined honestly, fail at least one test.

Figure 2: the decision flow. Three questions about predictable input, personalized output, and time-bound output can divert an interaction into precompute or cache. Otherwise, the interaction reaches the on-device gate and, past it, compute-fresh. Source: image generated by the author.

Click here to [expand image above to full-size/filters:no_upscale()/articles/mobile-ai-cost-latency-budgets/en/resources/197figure-2-1795602641000.jpg>)]

Here is a composite example, drawn from several projects. A generation feature was calling the model on every request. Request logs showed that about half the requests fell into a few hundred distinct input shapes, and those moved to nightly precompute. A further share were near-duplicates within a single session and became cache hits. Compute-fresh shrank to under a third of traffic with no change in output quality, because the precomputed answers were the answers the model would have produced live.

The cache column has one failure mode that deserves its own paragraph. A request that looks generic, a plain "summarize this", often carries user-specific context the client appended without the cache layer knowing. The key ignores it, and user A is served user B's output. That is a privacy incident, and it is the most common one I have seen in model-backed features. The rule is to build the key from the complete set of inputs that influence the output. I split every request into a shared bucket and a personal bucket at the type level, so the prompt builder and the key builder consume the same structure and cannot drift apart.

The shared bucket holds everything that is the same for all users: the task, the source and its version, the locale and the model version. The personal bucket holds the user ID, the user's preferences and their recent history. Because both builders take the same two buckets, a developer who adds a personal field to the prompt is forced by the type to decide whether it belongs in the key. Recent history is deliberately not keyable: a request that depends on it is not cached at all, which is the honest answer rather than a silent leak.

One more win fits the cache column and costs almost nothing. Most major inference APIs discount repeated prompt prefixes. Put the stable part first, the system prompt, tool definitions and shared context, and the per-user part last, and the prefix is billed at the discounted rate on every call that shares it. Check each provider's current documentation before you put a discount figure into your budget.

What to do now: list every model call the feature makes, put each one in a column, and write one sentence of justification beside each compute-fresh entry.

Client-side design under uncertain latency

You cannot make the provider faster. You can decide what the user sees while waiting and when waiting stops.

To the user, a response that arrives too late and a response that is wrong are the same event: the session ends. That moves the timeout out of infrastructure configuration and into the product specification, where the people who own the user experience answer it using the abandonment curve from the worksheet.

For generative features, streaming is the highest-leverage latency technique I know, because it converts the ceiling from time to complete into time to first token, which is typically an order of magnitude smaller. A user who sees words appearing at 1.2 seconds will wait comfortably for a 7-second completion. The same user staring at a spinner for 7 seconds is gone. On the client, the code that consumes the stream runs two separate deadlines from the worksheet, one for the first token and one for completion, and when a stream stalls after producing partial text it keeps the partial text rather than replacing it with a generic fallback. Where the shape of the response is predictable, you can render the frame before the content arrives. Perceived speed is driven by how quickly the screen changes, not by how quickly the data lands.

Every interaction also needs a written answer to "what does the user see if the model does not respond in time?" In order of preference, the user sees a live answer within the ceiling, then a cached or similar answer from the decision table, then a template or precomputed answer, and finally an explicit "try again" with the user's input preserved. Decide every rung before launch. If the specification has a screen for "response arrived" and none for "nothing arrived in 1.5 seconds", it is not finished.

Retries are the most expensive mistake in the category, and the one I learned the hard way. During a provider slowdown, a client built with an unbounded retry-on-timeout loop retried each request several times, each one billed, so spend ran at several times a normal day in exactly the week when successful responses fell. The loop was already in users' hands, and we could not patch the installed apps. What finally stopped it was a server-side kill switch. The switch already existed, but we had never planned to use it as a cost control. The fix used several mechanisms, including a retry budget, exponential backoff with jitter, an idempotency key so your backend recognizes a retried request and does not send it to the provider as new work, and a server-side circuit breaker. The mobile-specific word is "server-side". App versions in the wild cannot be hot-fixed, and a retry loop shipped in last quarter's build will run until that cohort updates, which for some users is never. So cost guards live on the server or behind remote config, never only in client code.

Two small components sit in front of every provider call. A budget guard atomically adds the estimated cost of the request to the user's spend for the day and refuses the request if the total exceeds the per-user ceiling, before anything is sent to the provider. The ceiling comes straight from the budget: in the illustrative numbers, $0.225 a month is about $0.0075 a day. A circuit breaker counts consecutive provider failures, opens after a threshold, refuses everything for a cooldown, then lets a single probe through. Guard first, breaker second. Because the budget is reserved before the call, a request that would exceed the ceiling never becomes a billable event, and a retry is a new reservation, which caps what a runaway loop can cost. Neither refusal is retried. Both map straight onto the degradation ladder. A user who reaches the ceiling is not blocked. They get the next rung, a cached or precomputed answer, instead of a fresh one.

What to do now: search your client for retry logic around inference calls. Anything without a bound is a liability you cannot recall from the field.

Instrumenting for cost

The provider's invoice arrives monthly, in aggregate. It tells you what you spent, not who you spent it on or which code path spent it. That attribution has to happen at the point of call.

For each call, log a hashed user and cohort identifier, the client app version so a bad build can be isolated, the feature, the model, the code path taken, units consumed and an estimated cost computed locally from the current rate, latency to first token and to completion, and the outcome: ok, timeout, provider error, budget-refused or circuit-open. A middleware around the inference client emits exactly that record, and a nightly reconciliation against the provider's usage data corrects the estimates, since a timed-out request may still be billed for its input.

Then build a dashboard of cost per user by engagement decile, with the top decile called out, and track that decile's share of total spend over time. When the share climbs, the cost inversion is happening and you have weeks rather than a quarter to respond. Page on spend per active user rising day over day, on a single user spending many times the P99, on cache hit rate dropping after a deploy, and on retry rate spiking. Do not page on total spend. Total spend going up usually means growth happened, which is the point.

What to do now: add app version and code path to whatever you already log around the inference call. Those two fields turn an invoice into a diagnosis.

Where the boundary moves next

On-device inference is maturing quickly. Apple's Foundation Models framework exposes its on-device language model to third-party apps on iOS 26 and later, on devices that support Apple Intelligence. Google ships Gemini Nano to Android apps through the ML Kit GenAI APIs, running in the AICore system service. Open-weight small models run through Core ML, MediaPipe and ExecuTorch on hardware many users already carry. The temptation is to read this as if the cost problem is going away. It is not going away, rather he boundary between on-device and remote work is moving.

However, on-device is cheap but not free. Marginal cost is zero, but you pay in device coverage, because older phones lack the hardware or the OS version; in battery and heat; in app size or the need to download a model; and in iteration speed, because you cannot swap the model server-side on a Tuesday afternoon.

The durable pattern is hybrid routing: classify, extract and short-rewrite on-device, and generate remotely. In a composite case using the illustrative budget, a feature ran a classification step and then a generation step, both remote, at about $0.004 per interaction. Classification moved on-device and filtered out roughly 70% of requests that did not need generation at all. Cost per interaction for the heavy cohort fell to about $0.0012. That was still above the $0.00075 ceiling, so on-device classification alone was not enough. To close the remaining gap, the team also moved the predictable inputs to nightly precompute, as described in the decision table. Precompute took about half of the remaining calls, as in the earlier composite example, which brought the cost to about $0.0006 per interaction, under the ceiling. The routing itself is budget-driven: by payload size, by the latency budget, and by the user's remaining spend allowance in the current window, so a user approaching their ceiling is routed to the cheaper path before they cross it. What stays remote regardless is long-context generation, anything that needs fresh world knowledge, and anything where the quality gap between a small model and a frontier model would cost you users.

Conclusion

The mobile industry spent a decade learning to treat serving cost as a rounding error and engagement as the metric that matters. A metered inference API invalidates both lessons at once. Serving cost becomes the dominant variable cost as it scales with engagement, making the users you most want to keep the most expensive to serve. Latency moves outside the team's control while remaining entirely the team's problem. None of that is an argument against model-backed features. Teams that set a cost limit per interaction and a wait limit per response before building can choose their architecture; teams that find those limits on the invoice have it chosen for them.

原文来源:infoq.com