# How to track LLM cost in the Vercel AI SDK > Culpa's Vercel AI SDK middleware wraps generate calls. Streaming is out of scope for now, so a chat product captures a fraction of its own spend. URL: https://getculpa.com/track-llm-cost-vercel-ai-sdk Last reviewed: 2026-08-02 ## Answer Culpa's Vercel AI SDK adapter is middleware you pass to wrapLanguageModel, and it reports token usage from the SDK's own usage object. It wraps generate calls, and streaming capture stays out of scope for now, so a streaming chat product records only part of its spend. Culpa, a local-first LLM cost, margin, and forecast ledger, meters what the adapter reports and shows the gap against your invoice. ## Why this happens The adapter is honest about what it sees, and a reader deserves the same. It hooks wrapGenerate, reads the SDK's usage object, and handles both the v1 field names and the v2 ones. What it doesn't hook is wrapStream. On a chat product that streams almost every response to the browser, the calls the adapter never sees are the majority of the traffic, so a ledger built on this path alone reads far below the invoice. That's a capture gap rather than a pricing error, and it's fixed by moving the capture point. ## What this usually looks like - Your Culpa totals sit far below the provider invoice and the gap holds steady month to month. - Most of your product streams responses, and most of your captured calls don't. - Captured call count is a small fraction of the requests your logs show. - The shortfall started the day the adapter went in, rather than drifting. ## Common mistakes - Treating adapter coverage as complete without reconciling against the invoice. Why it hurts: A capture gap looks exactly like low spend until somebody compares the two numbers. Do instead: Reconcile captured spend against the invoice in the first week, and treat the gap as the finding. - Capturing at the framework when the framework can't see streams. Why it hurts: You measure the part of your traffic that matters least on a product built around streaming. Do instead: Point the base URL at Culpa instead, which sees every call regardless of how the SDK consumes it. - Confusing the Vercel AI SDK adapter with deploying on Vercel. Why it hurts: They're separate problems, and solving one leaves the other open. Do instead: Use the adapter for capture and a relay for reach if your app runs in the cloud. ## Self-check - Count what share of your responses stream. On a chat product it's usually most of them. - Compare captured call count against your own request logs for the same period. - Compare captured spend against the provider invoice. The ratio is your coverage. - Check whether your highest-spend feature is a streaming one. - Decide whether to move capture to the request path rather than waiting on stream support. ## What a streaming product captures through generate-only middleware (illustrative) A chat product making 2 million model calls a month on GPT-5.4 at real rates of $0.0025 per 1k input and $0.015 output, each call sending 3,000 input tokens and returning 500. The 82% streaming share is modelled. Per call: (3 x $0.0025) + (0.5 x $0.015) = $0.0075 + $0.0075 = $0.015 Real spend: 2,000,000 x $0.015 = $30,000 a month Non-streaming calls at 18% of traffic: 360,000 x $0.015 = $5,400 The ledger shows $5,400 against a $30,000 invoice Coverage is 18%, so 82% of spend has no feature, user or conversation attached to it The adapter priced every call it saw correctly and saw less than a fifth of them. On a streaming product the capture point matters more than the pricing does. ## Cost figures Every figure carries its confidence and its source. No figure on this site is provider-reported. - $5,400 to $30,000 — modelled monthly spend captured through generate-only middleware against the real invoice [estimated] Source: Both endpoints from the teardown arithmetic at real GPT-5.4 rates per 1k from the price book, effective 2026-07-02. A range because call volume and the streaming share are modelled. - 18% — modelled capture coverage on a product where 82% of responses stream [calculated] Source: 360,000 captured calls divided by 2,000,000 total, from the teardown arithmetic. ## FAQ Q: Does Culpa's Vercel AI SDK adapter capture streamed responses? A: Not yet. The middleware wraps generate calls, and stream capture is deliberately out of scope for the current release. If most of your traffic streams, point your base URL at Culpa instead so capture happens on the request path. Q: Will the adapter break my app if Culpa is down? A: No. It fails open by contract. Reporting rides a call that never throws, and a failed generate is recorded while your own error is rethrown untouched, so a Culpa problem stays a Culpa problem. Q: Does the adapter import the ai package? A: No, it's duck-typed and never imports it. That keeps your dependency tree unchanged and means a version bump in the SDK can't break the adapter through a type mismatch. ## Sources - OpenAI API pricing: https://developers.openai.com/api/docs/pricing Run the free Cost Leak Scan: https://app.getculpa.com/scan?source=pseo&slug=track-llm-cost-vercel-ai-sdk&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.