{"slug": "llm-cost-per-user-why-one-user-can-cost-11-a-month", "title": "LLM cost per user: why one user can cost $11 a month", "summary": "A developer has published a method for tracking LLM cost per user, showing that a single heavy user running 4,000 summaries can cost about $11.28 a month on one model versus $4.41 on a cheaper alternative. Because OpenAI, Anthropic and Gemini report token usage differently and their per-user fields exist only for abuse detection, the approach logs user ID, model and normalized token counts per request in the developer's own database and stores costs as integer micro-dollars to avoid float drift.", "body_md": "*Originally published on [Extenify](https://extenify.app/blog/llm-cost-per-user?ref=devto).*\n\nLLM cost per user is the number that tells you whether your AI feature earns money or quietly burns it. Your OpenAI, Claude or Gemini invoice shows the monthly total, but not that one user ran 4,000 summaries while the median user ran 30. Every response already reports its token usage, so you can build the per-user view yourself.\n\nProvider reporting follows your account structure. Anthropic's Usage and Cost Admin API, for example, groups spend by API key, workspace, model and service tier. That helps you check an invoice, but a typical AI extension or SaaS backend sends every user's request through one server and one key.\n\nThe per-user fields that do exist are for abuse detection, not billing:\n\n`safety_identifier` helps OpenAI spot users who break its usage policies.`metadata.user_id` is an external user ID Anthropic may use to detect abuse.\nSend a hashed ID in both, but don't expect a cost report from them. The answer is the same one developers landed on back in 2023: log the user, model and token counts for each call in your own database.\n\nEach provider returns a usage object, but \"input\" means something different in each:\n\n|  | OpenAI (Responses) | Claude (Messages) | Gemini (generateContent) | \n|---|---|---|---|\n| Input field | `input_tokens` | `input_tokens` | `promptTokenCount` | \n| Includes cached tokens? | Yes | **No** | Yes | \n| Cache reads | `input_tokens_details.cached_tokens` | `cache_read_input_tokens` | `cachedContentTokenCount` | \n| Reasoning | inside `output_tokens` | inside `output_tokens` | `thoughtsTokenCount` , separate | \n\nTwo consequences:\n\n`input_tokens` minus cache reads and cache writes. For Claude, total input is cache reads plus cache writes plus `thoughtsTokenCount` to the output count yourself.\nA compact normalizer that maps everything into one shape:\n\n``` js\nconst n = (v) => v ?? 0;\n\nexport function toTokens(provider, u) {\n  if (provider === 'anthropic') {\n    return { fresh: u.input_tokens, cacheRead: n(u.cache_read_input_tokens),\n             cacheWrite: n(u.cache_creation_input_tokens), out: u.output_tokens };\n  }\n  if (provider === 'openai') {\n    const read = n(u.input_tokens_details?.cached_tokens);\n    const write = n(u.input_tokens_details?.cache_write_tokens);\n    return { fresh: u.input_tokens - read - write, cacheRead: read, cacheWrite: write, out: u.output_tokens };\n  }\n  // gemini\n  const read = n(u.cachedContentTokenCount);\n  return { fresh: u.promptTokenCount - read, cacheRead: read, cacheWrite: 0,\n           out: n(u.candidatesTokenCount) + n(u.thoughtsTokenCount) };\n}\n```\n\n**Streaming is covered too.** OpenAI puts usage on the `response.completed` event, Claude's `message_delta` counts are cumulative (keep the last one, don't add them), and Gemini's streamed chunks carry `usageMetadata` (keep the last). Write the record in a `finally` block so a cancelled stream still gets charged to the right user.\n\nToken counts only turn into dollars through a price table, and two details matter:\n\nStore the result as **integer micro-dollars** per request. Summing millions of floats drifts; summing integers doesn't.\n\nHere's why per-request pricing matters. Take a page summary with 6,000 input tokens (4,000 cached) and 500 output tokens. At October 2026 prices it costs about $0.0094 on gpt-6.1-sol and about $0.0037 on Gemini 3.8 Flash. At 40 a day for 30 days, that one user costs roughly **$11.28 a month** on the first model and $4.41 on the second, until the Gemini price doubles in January. If your plan is $5, that line is your whole margin.\n\nEach row needs: a **server-verified** user ID (never a value the extension sends, since anyone can edit extension code), feature name, provider, model, timestamp, normalized tokens, cost in micro-dollars, and status (completed, incomplete, cancelled). Index on `{ userId, at }`.\n\nFrom there, a monthly group-by-user followed by a percentile step (MongoDB 7.0+ has `$percentile`) gives you what you need. Read the results in this order:\n\nRequest quotas protect you from bursts, not from cost: one 200,000-token page costs far more than a short paragraph. Before each call, check the user's month-to-date spend against a dollar limit (at scale, keep a running counter instead of summing every time). Then act on what the ledger shows: send simple tasks to cheaper models, cache shared system prompts, alert on spikes, and add a new price period the day a price change is announced.\n\nOnce a month, compare ledger totals with each provider's own reporting. A gap of more than a few percent usually means a code path, such as a background job, that calls the model without writing a row.\n\nThe [full guide to tracking LLM cost per user across OpenAI, Claude and Gemini](https://extenify.app/blog/llm-cost-per-user?ref=devto) includes the complete price table, ledger code and MongoDB aggregation. And if you want the other half of the unit economics, weekly users and ratings for your extension, [Extenify's browser extension analytics dashboard](https://extenify.app/?ref=devto) tracks them daily on Chrome, Edge and Firefox.\n\n**What does your AI feature's p99 user cost compared with the median, and what did you change once you found out?**", "url": "https://wpnews.pro/news/llm-cost-per-user-why-one-user-can-cost-11-a-month", "canonical_source": "https://dev.to/extensionbooster/llm-cost-per-user-why-one-user-can-cost-11-a-month-52ok", "published_at": "2026-11-15 09:15:28+00:00", "updated_at": "2026-11-15 09:20:46.016329+00:00", "lang": "en", "topics": ["ai-infrastructure", "large-language-models", "ai-tools", "mlops", "developer-tools"], "entities": ["OpenAI", "Anthropic", "Google Gemini", "Claude", "Extenify"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/llm-cost-per-user-why-one-user-can-cost-11-a-month", "markdown": "https://wpnews.pro/news/llm-cost-per-user-why-one-user-can-cost-11-a-month.md", "text": "https://wpnews.pro/news/llm-cost-per-user-why-one-user-can-cost-11-a-month.txt", "jsonld": "https://wpnews.pro/news/llm-cost-per-user-why-one-user-can-cost-11-a-month.jsonld"}}