AI & MCP
API cost per feature: three numbers before you ship
A feature's API cost is input, output and price per million: 3,000 plus 400 tokens cost 0.00184 USD on gpt-4.1-mini, list of 1 November 2026.
Key points
- A call with 3,000 input tokens and 400 output tokens costs 0.00184 USD on gpt-4.1-mini, 0.00506 on o4-mini and 0.015 on claude-sonnet-4-6.
- Ten thousand calls a month make 18.40, 50.60 and 150.00 USD with the same three models.
- Cached input at 0.10 USD per million brings the same call to 0.00094 USD, when the provider offers it.
The cost of an AI feature comes from three numbers: input tokens, output tokens and price per million tokens. Everything else is a guess, and guesses do not pass a budget review.
Three numbers, not one
- Cost per call: input plus output of a single request.
- Calls per user per month: read it from the log, do not estimate it from the product.
- Cost per feature: total calls times unit cost, plus retries and errors.
The sum, in code
const MODELS = {
mini: { input: 0.4, output: 1.6 },
reasoning: { input: 1.1, output: 4.4 },
sonnet: { input: 3, output: 15 },
};
export function costPerCall(model, inputTokens, outputTokens) {
const price = MODELS[model];
return (inputTokens * price.input + outputTokens * price.output) / 1_000_000;
}
for (const name of Object.keys(MODELS)) {
const one = costPerCall(name, 3000, 400);
console.log(name, one.toFixed(5), (one * 10000).toFixed(2));
}
With 3,000 input tokens and 400 output tokens, one call costs 0.00184 USD on gpt-4.1-mini, 0.00506 on o4-mini and 0.015 on claude-sonnet-4-6. Ten thousand calls a month make 18.40, 50.60 and 150.00 USD. Save the block as cost.mjs and run it with node cost.mjs.
The list in a table
| Model | Input USD/M | Output USD/M | One call | 10,000 calls |
|---|---|---|---|---|
| gpt-4.1-mini | 0.40 | 1.60 | 0.00184 | 18.40 |
| o4-mini | 1.10 | 4.40 | 0.00506 | 50.60 |
| claude-sonnet-4-6 | 3.00 | 15.00 | 0.015 | 150.00 |
The gap between the small model and the reasoning one is 2.75 times on the same call: 0.00506 divided by 0.00184. Before paying it, a test on your case set must show that the dearer model solves cases the other one misses.
Context is the expensive line
Every turn resends the whole conversation: ten turns of 3,000 tokens of history send 165,000 tokens in total, not 30,000, because the sum grows with the square of the turns. Summarising or cutting the history costs less than moving to a smaller model.
What stays out
- Embeddings and images: billed separately, on different lists.
- Retries and errors: one retry after a timeout doubles that turn.
- Evaluations and tests: every eval run burns tokens like production.
The limitation
The sum holds for one model and one provider, and the list changes without notice: 0.40 and 1.60 USD per million is the value read on 1 November 2026, not a promise. Estimating tokens from characters is approximate, and the reasoning tokens of a reasoning model are billed as output but never appear in the text.
Where to continue
The cost of a full task is in an agent's cost per task, the weight of long context in long context and cost, the measured comparison between models in evaluating a model for code. To show the sum you need a pricing table or a project data table, inside dashboard components and 111,985 components.
Frequently asked questions
What does a call with 3,000 input tokens and 400 output tokens cost?
0.00184 USD on gpt-4.1-mini, 0.00506 on o4-mini and 0.015 on claude-sonnet-4-6, with the per-million prices read on models.dev on 1 November 2026. Ten thousand calls a month make 18.40, 50.60 and 150.00 USD.
Is the cheapest model enough?
It depends on the task, and the answer is measured: if the small model passes the same threshold on your case set, the saving is real. If the task needs one more reasoning step, the dearer model can cost less per correct answer.
How do I measure tokens instead of estimating?
Read the usage field the provider returns with every response: input, output and cached tokens. Estimating from characters works for the first budget only; the actual figure comes from usage, with one log line per call.
Does caching reduce the cost?
Yes on the cached part: at 0.10 instead of 0.40 USD per million, the same call drops from 0.00184 to 0.00094 USD. Writing to the cache can cost more than normal input, so it pays only on prefixes reused often.
Do I need a spending cap?
Yes: a quota per user, an alert at 80% and a hard cap per feature. A retry loop without a cap burns the budget in an afternoon, and the cap is the only defence that does not depend on the client code.