Finding · affects your ai bill
LLM calls with no output cap
A model call without max_tokens lets every answer be as long as the model wants, and output tokens are the expensive ones.
Why it matters
Output tokens cost several times more than input tokens on almost every model. A call with no output cap hands the length decision to the model, and a verbose model, a prompt that invites detail, or a user who asks for "everything" all push the same line of code toward the model's maximum.
The average looks fine in testing. The tail is what you pay for: a few long answers per thousand can be most of the month's output spend, and nothing in the code stops them.
What it looks like
A chat route on the platform's key, with no limit on the response:
const result = streamText({
model: openai("gpt-5"),
messages,
// no maxOutputTokens: the model decides how long every answer is
});How to fix it
const result = streamText({
model: openai("gpt-5"),
messages,
maxOutputTokens: 1_000, // sized to what the UI shows
});- Pass an explicit cap on every call (max_tokens, maxTokens, maxOutputTokens or max_output_tokens, depending on the SDK), sized to the UI: about 1,000 for chat, 50 for titles, more only where long output is the product.
- Alert on per-user daily token spend, so one account can't run up the bill unnoticed.
- Scan again: the line moves from "no ceiling" to a bounded range.
A real example: Vercel AI Chatbot
Computed by Skeram’s engine from the published teardown of Vercel AI Chatbot, at 10,000 monthly users (critical):
1 route calls an LLM on your key with no output cap. No max_tokens is passed, so each response is as long as the model decides. These calls are $2,114–$35,344/mo at 10,000 monthly users assuming 600 output tokens — a verbose model or a prompt that invites long answers moves that figure with no ceiling.
Suggested fix: Pass an explicit max_tokens on every call sized to the UI (chat ~1K, titles ~50); alert on per-user daily token spend.
Evidence: app/(chat)/api/chat/route.ts:269-330, app/(chat)/actions.ts:28-34, app/(chat)/api/chat/route.ts:125-133.
How Skeram detects it
Skeram reads every model call site and records whether a literal output cap is passed. Calls on your own key with no cap are priced at a high-output assumption and flagged; calls on keys your users bring are not your bill and are not flagged.
When it starts to hurt: Graded on the money: a warning once uncapped calls reach about $100 a month at the slider's audience, critical at $1,000.
Every finding cites the file and line it came from, and scanning again after a fix shows it resolved in History. How the analysis works.
Questions
Does max_tokens make answers worse?
Only if it's smaller than the answers the product needs. Size it to the UI: if the chat window shows about 600 words, a cap of about 1,000 tokens changes nothing users see and removes the runaway cases.
What if I stream the response?
Streaming doesn't change the bill. A streamed answer with no cap costs exactly what the same answer costs unstreamed.
Related findings
- Public endpoints that spend your LLM budget: A route that calls a model on your key without a signed-in user lets anyone on the internet spend your budget.
Find it in your code
Skeram reads your repo, prices every model call from 100 to 100,000 users, and flags these patterns with the file and line.