Calculate LLM API Cost Per Successful Task

Compare LLM APIs using accepted results, retries and actual billed usage. Build a workload estimate before choosing a lower token price.

Published
On this page

Overview

The lowest token price does not necessarily produce the lowest application cost. A model that needs repeated corrections can consume more money and time than a model that completes the same task on its first attempt.

Compare providers using a task your application actually performs. Keep the acceptance rule fixed, include failed attempts in the cost total, and measure how many outputs are usable.

Start with request cost

For a basic text request with rates quoted per million tokens:

text
request cost =
    input tokens �� input rate / 1,000,000
  + output tokens �� output rate / 1,000,000

If the provider separately bills cache reads, cache writes or other token categories, calculate those categories using its billing rules. Do not apply the lowest cached-input price to all input tokens.

Use the exact route rate that applies to the request. Prices copied from a model developer's website may differ from a gateway's billable rates. Temporary offers also need an expiry check before you use them in a monthly forecast.

Convert request cost into useful work

Define success before running the comparison. For a support-ticket classifier, success might require a valid category and correct urgency label. For extraction, it might require both a valid schema and accurate field values. A response that parses successfully can still be wrong.

Then calculate:

text
cost per successful task =
    total billed API cost across all attempts
    / number of tasks meeting the acceptance rule

Include generation retries, repair prompts and rejected outputs in the numerator. If no task passes, report that result directly rather than dividing by zero.

Record reviewer time separately when a human must repair outputs. It is an operating cost even if it does not appear on the API invoice.

Build a small comparison from your own inputs

Select a manageable set of representative, non-sensitive inputs. Include short examples, long examples and the cases that have caused failures in your application. Keep model settings and the acceptance rule consistent where the providers' contracts allow it.

Use a worksheet with these fields:

FieldWhat to record
Task referenceA local identifier without personal data
Route and configurationThe exact model ID and relevant settings
AttemptsOriginal call and any repair calls
Billed costConfirmed usage cost for every attempt
Accepted resultWhether the final output met the fixed rule
Completion timeEnd-to-end time, including retries

Do not turn a few examples into a universal model ranking. Use the pilot to reject unsuitable routes and identify which ones deserve a larger evaluation.

Forecast from completed tasks

Multiply the observed cost per successful task by a realistic monthly workload range. Keep the low, expected and high workload assumptions visible. Include a separate allowance for evaluation and development traffic.

Recalculate when prompts, conversation lengths or retry policies change. An application that carries a growing conversation history can have a different cost profile from the short prompts used in its first test.

Avoid estimating a universal cost per hour. An hour of idle chat and an hour of continuous agent execution can contain very different numbers of requests.

Compare SmarToken using the same method

Use the SmarToken pricing table [1] for current route rates and its model directory [2] to identify candidates. Its documentation describes usage records with tokens and billable cost [3], which can support reconciliation against your worksheet.

Do not assume that a lower displayed rate guarantees a lower cost per accepted result. Run your own task set, review quality and latency, and confirm that the route meets your data requirements.

Choose the route that delivers acceptable work within your budget. Start with one bounded API request [4], then evaluate representative tasks before committing a larger workload.

Sources

  1. SmarToken pricing table
  2. model directory
  3. usage records with tokens and billable cost
  4. one bounded API request
Contact support