AI article

Cost per Task, Not Cost per Token: Build an LLM Cost Calculator in TypeScript

Community description: Model launches this month sell cost per task, not price per token. Build a tiny TypeScript calculator with sourced prices, cache hits, retries, tool turns and latency. No API key.

Dev.to | Sep 30, 2026 | Bobby Hall Jr

Automated excerpt

It lists $2. 73 versus $1. 50 per task, because Grok 4. 7 (high) used 66k output tokens per task and Grok 4. 6 (medium) used 28k. Time to first token is one number inside it. console. log("Step 5: same example task, every model"); console. log(` cache hit rate: ${(cacheHitRate(turns) * 100). toFixed(1)}%`); for (const [model, price] of Object. entries(PRICES)) { console. log(` ${model. padEnd(18)} ${usd(taskCost(turns, price))} per task`); Same task. Same price, different effort, almost twice the cost per task.

Selected automatically from source text; not independently written or fact-checked. Read the original for full context.

Read the original article

More AI news