← Blog

LLM Cost Estimator: How to Predict Spend Before You Ship

2026-09-18 · 4 min read · SubToAPI Team

An LLM cost estimator is a method (or tool) for predicting how much a given workload will cost before you run it in production. Instead of discovering your monthly bill after the fact, you model it upfront using expected token volume, model pricing, and request patterns — so you can pick the right model, set budgets, and avoid surprises.

The core problem estimators solve is simple: LLM pricing is usage-based and non-obvious. A prompt that looks small in your editor might expand to thousands of tokens once you add system instructions, retrieved context, and conversation history. Getting a rough number right before launch is far cheaper than finding out from an invoice.

Why cost estimation is harder than it looks

Most developers start by multiplying "tokens per request" by "price per token" and calling it done. That undershoots real spend for a few reasons:

A usable estimator accounts for these factors, even approximately, instead of just token-times-price.

Building a basic estimator

The simplest estimator needs three inputs: average input tokens per request, average output tokens per request, and expected request volume.

function estimateMonthlyCost({
  requestsPerDay,
  avgInputTokens,
  avgOutputTokens,
  inputPricePerMillion,
  outputPricePerMillion,
}) {
  const monthlyRequests = requestsPerDay * 30;
  const inputCost =
    (monthlyRequests * avgInputTokens / 1_000_000) * inputPricePerMillion;
  const outputCost =
    (monthlyRequests * avgOutputTokens / 1_000_000) * outputPricePerMillion;
  return {
    inputCost: inputCost.toFixed(2),
    outputCost: outputCost.toFixed(2),
    total: (inputCost + outputCost).toFixed(2),
  };
}

const estimate = estimateMonthlyCost({
  requestsPerDay: 5000,
  avgInputTokens: 900,
  avgOutputTokens: 350,
  inputPricePerMillion: 3,
  outputPricePerMillion: 15,
});

console.log(estimate);

This gets you a first-pass number fast. The accuracy depends entirely on how good your token estimates are, which is where most teams get it wrong.

Getting realistic token counts

Don't guess average token counts — measure them. Two practical approaches:

  1. Sample real traffic. Log actual token usage from a handful of test requests or a staging environment. Most API responses include usage metadata with exact input and output token counts, which is far more reliable than counting words and dividing by 0.75.
  2. Account for worst-case, not just average. If your app has a "long document summarization" feature alongside a simple chatbot, estimate them separately. Blending averages across very different request types hides your real cost drivers.

If you're building on SubToAPI, every response includes usage metadata with exact token counts for input and output, which you can log and feed directly into your estimator instead of relying on approximations. See the messages docs for the response shape.

curl https://api.subtoapi.app/v1/messages \
  -H "Authorization: Bearer $SUBTOAPI_KEY" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-4",
    "max_tokens": 512,
    "messages": [{"role": "user", "content": "Summarize this report..."}]
  }'

The response's usage object gives you real numbers to plug back into your estimator, closing the loop between prediction and reality.

Estimating conversational workloads

Chat-style products need a different model than single-shot requests. Estimate cost per conversation, not per message:

function estimateConversationCost({
  turns,
  avgTurnTokens,
  outputTokensPerTurn,
  inputPricePerMillion,
  outputPricePerMillion,
}) {
  // each turn resends all prior turns as input
  let totalInputTokens = 0;
  for (let t = 1; t <= turns; t++) {
    totalInputTokens += avgTurnTokens * t;
  }
  const totalOutputTokens = outputTokensPerTurn * turns;

  const inputCost = (totalInputTokens / 1_000_000) * inputPricePerMillion;
  const outputCost = (totalOutputTokens / 1_000_000) * outputPricePerMillion;
  return (inputCost + outputCost).toFixed(4);
}

Run this per conversation length you actually see (e.g., median 3 turns, p95 12 turns), not just an average — long conversations dominate cost disproportionately.

From estimate to budget

Once you have a per-request or per-conversation number, multiply by expected volume and add margin for:

If you're comparing this estimate against actual provider pricing before committing to a plan, check /pricing for how flat per-seat pricing compares to raw token costs — for teams with predictable usage, a fixed monthly seat price can be easier to budget against than variable token billing, even if the raw math is close.

Questions

What's the difference between a cost calculator and a cost estimator? A calculator typically computes cost for a fixed, known input (like "10,000 tokens at $3/million"). An estimator predicts cost for a workload you haven't run yet, using assumptions about traffic, conversation length, and token distribution — it's forward-looking rather than a single computation.

How accurate can an LLM cost estimator realistically be? Within 15-20% if you use real sampled token counts and realistic conversation-length distributions. Estimates based on guessed averages or word counts instead of actual tokenization can be off by 50% or more, especially for multi-turn chat.

Should I estimate cost before or after choosing a model? Before. Run the same workload estimate against two or three candidate models' pricing to see how output-heavy or context-heavy your use case is — that often changes which model is actually cheapest, not just which is fastest. Once you've picked, sign up and pull real usage numbers from the quickstart to validate your estimate against actual traffic.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →