How to calculate LLM API costs: input tokens, output tokens and currency conversion

Calculate input and output charges separately. A price per million tokens is a billing unit, not a fixed charge for every API request.

Start with one request

For a text API that bills input and output separately, cost = input token count / input billing quantity × input unit price + output token count / output billing quantity × output unit price. For a per-million-token quote, divide by 1,000,000. For a per-thousand-token quote, divide by 1,000. Check the unit before applying the formula.

Suppose input costs CNY 2 per million tokens and output costs CNY 8 per million tokens. A request with 10,000 input tokens and 2,000 output tokens costs 0.02 + 0.016 = CNY 0.036. Repeating the same workload 1,000 times costs CNY 36. These are teaching assumptions, not current quotes for any model.

Tokens are not interchangeable with words, characters or Chinese characters. Tokenization differs between models. Use provider usage records when reconciling a bill. Image, audio, video and per-request charges have their own billing units and cannot automatically use this text-token formula.

Count the whole conversation or agent task

Input can include system instructions, the current question, retrieved passages, tool results and conversation history sent again. If each turn resends the complete history, input grows over the conversation. Add the actual usage of every request to calculate the total.

One agent task can involve planning, tool selection, result processing, retries and a final answer. Estimate the entire task and multiply by task volume. Counting only the final answer misses intermediate requests. Reasoning and other output usage may also be billed; check the specific API definition.

Convert currencies after calculating the original charge

First calculate the charge in its original currency, then multiply by your exchange-rate assumption. A hypothetical USD 5 bill at CNY 7 per USD is CNY 35. That example rate is not live and excludes taxes, payment fees and top-up charges.

The pricing workspace shows estimated conversions. Model pages retain original currencies, units and sources. Region, context length, batch versus realtime mode, time windows and service tiers must also match before comparing offers.

Use your own workload

Sample real tasks and record input, output, cache hits and the number of calls. Estimate typical and peak volumes separately. Until cache hits are verified, include a no-cache budget scenario.

Select models and the relevant billing conditions in the pricing workspace, then enter usage. Open model details to check official sources, observation times and update status. An estimate can differ from the final provider bill.

1,000 calls per day: a monthly budget

Assume 10,000 input and 2,000 output tokens per call, 1,000 calls per day, and 30 days: 300 million input and 60 million output tokens. At hypothetical rates of CNY 2 and CNY 8 per million, cost is 300×2+60×8=CNY 1,080. Replace these teaching rates with observed model quotes.

Find quotes and calculate costs