# How to track LLM cost in TypeScript > Culpa binds to localhost, so a cloud-hosted TypeScript app has no route home. What that leaves unattributed, and how a relay closes it. URL: https://getculpa.com/track-llm-cost-typescript Last reviewed: 2026-08-02 ## Answer Culpa's TypeScript SDK reports calls to a Culpa server, and the default install binds to localhost only. A cloud-hosted app therefore has no route home, so its spend goes unattributed until a relay gives it a mailbox. Culpa, a local-first LLM cost, margin, and forecast ledger, traces every call it receives, and the question worth asking first is which of your calls can reach it. ## Why this happens Local-first is a privacy property and a reachability constraint at the same time. A server bound to localhost can't be reached from a function running on someone else's infrastructure, which describes most production TypeScript. The result is a ledger that looks healthy and describes your development machine. Development traffic is a rounding error against production, so the coverage number is far worse than it feels, and nothing about the ledger itself signals that it's reading a sliver. ## What this usually looks like - Your ledger has data and your production spend is nowhere in it. - Captured traffic follows your working hours rather than your customers'. - The features you see are the ones you've been developing, not the ones customers use. - Captured totals are orders of magnitude below the invoice rather than a few percent below. ## Common mistakes - Reading a populated ledger as a covered one. Why it hurts: Development traffic populates a dashboard convincingly while representing almost no spend. Do instead: Divide captured spend by the invoice on day one. Coverage is the first number to establish. - Assuming a cloud function can reach a local server. Why it hurts: It can't, and the failure is silent because capture fails open by design. Do instead: Give cloud workloads a relay, which is a reachable mailbox they can post to. - Confusing capture with reach. Why it hurts: You can instrument perfectly and still record nothing if the reports have nowhere to land. Do instead: Treat them as two checks. Is the call instrumented, and can the report arrive? ## Self-check - Divide captured spend by your provider invoice. That single ratio is your coverage. - Check whether the captured traffic pattern matches your customers' hours or your own. - List where your code actually runs, and mark which of those can reach your Culpa server. - Confirm whether a relay is armed for anything running outside your machine. - Re-check coverage after arming it, and expect the number to move a long way. ## A ledger that describes a laptop (illustrative) A product running 2 million calls a month in the cloud and 40,000 on a developer machine, on Claude Haiku 4.5 at real rates of $0.001 per 1k input and $0.005 output. Each call sends 2,000 input tokens and returns 300. Volumes are modelled. Per call: (2 x $0.001) + (0.3 x $0.005) = $0.002 + $0.0015 = $0.0035 Cloud spend: 2,000,000 x $0.0035 = $7,000 a month Development spend: 40,000 x $0.0035 = $140 a month Without a relay the ledger holds $140 of a $7,140 bill Coverage is 2%, and the dashboard looks populated the whole time Two percent coverage on a dashboard that reads as normal. The failure mode of local-first capture isn't an error message, it's a plausible-looking ledger about the wrong machine. ## Cost figures Every figure carries its confidence and its source. No figure on this site is provider-reported. - $140 to $7,140 — modelled monthly spend a local-only ledger captures against the full bill [estimated] Source: Both endpoints from the teardown arithmetic at real Claude Haiku 4.5 rates from the price book, effective 2026-07-02. A range because call volumes are modelled. - 2% — modelled capture coverage for a cloud-hosted product with no relay armed [calculated] Source: $140 divided by $7,140, from the teardown arithmetic. ## FAQ Q: Can a Vercel or Lambda function report to a local Culpa? A: Not directly, because the default install binds to localhost and a cloud function has no route to it. A relay gives those workloads a reachable mailbox to post to, which the local install then pulls from. Q: Is this the same thing as the Vercel AI SDK adapter? A: No, and the two get confused because both mention Vercel. The adapter is about capturing a call. The relay is about the report reaching you when your code runs somewhere else. A cloud app usually needs both. Q: How do I know my coverage is bad? A: Divide captured spend by the provider invoice for the same period. Anything far below one means calls are being made that never reach your ledger, and a populated dashboard isn't evidence against that. ## Sources - Anthropic pricing: https://platform.claude.com/docs/en/docs/about-claude/pricing Run the free Cost Leak Scan: https://app.getculpa.com/scan?source=pseo&slug=track-llm-cost-typescript&cluster=integration Machine-readable index of every guide: https://getculpa.com/api/pages Human-readable index of every guide: https://getculpa.com/guides Site overview: https://app.getculpa.com/llms.txt Privacy: Culpa runs on your infrastructure. Your prompts and responses never leave it. Culpa counts calls to run your plan, and it fails open, so if it ever breaks your app keeps running.