@latten/cost
v0.1.2
Published
Cut LLM costs in your AI app and coding agents. On-device detection of wasted tokens (redundant calls, stuck loops, oversized + uncached context) with copy-paste fixes. Local-first, values-free.
Maintainers
Readme
@latten/cost — cut your LLM bill without slowing down
Spend big on AI. Just keep the bill in view.
Your token spend keeps climbing — more agents, bigger context, more calls — and it's hard to see where the money actually goes. @latten/cost finds the spend you can recover and shows you, on your machine, calmly. No dashboard to babysit, no data leaves your laptop, no throttling your AI. Keep the throttle where it is; we just point at the money sitting on the table.
npm install @latten/costSee what you can recover (free, local, 30 seconds)
Point it at a coding-agent session and it tells you, in dollars, what's recoverable:
import {
detectRedundantRoundTrips,
detectStuckLoop,
detectMissingEnvBootstrap,
detectOversizedPriming,
detectUncachedContext,
flag,
newFlagState,
} from '@latten/cost'
const suggestions = [
...detectRedundantRoundTrips(session),
...detectStuckLoop(session),
...detectMissingEnvBootstrap(session),
...detectOversizedPriming(session),
...detectUncachedContext(session),
]
flag(suggestions, newFlagState()).lines.forEach((l) => console.log(l.text))
// "Latten spotted about $0.42 you could recover across 6 turns (oversized context). Want the fix?"That number is your activation moment. Most sessions have some — the question is how much, and whether you act on it.
How it reduces LLM costs
@latten/cost detects the common, expensive token-waste patterns on-device:
- Redundant round-trips — the agent re-polls a tool whose result didn't change.
- Stuck loops — repeated output that isn't making progress.
- Oversized context — large prompts paying full price every turn instead of cached.
- Uncached repeated context — the same big context re-sent, uncached.
- Missing env bootstrap — early turns burned re-discovering the environment.
Each finding comes with a copy-paste fix and a fix tier (safe → control-flow), and a ledger that tracks the savings you've actually realized — never hypothetical waste. The "Saved with Latten" number is honest by construction.
It's local-first and values-free: it works on token counts, costs, and equality-only hashes — your prompts and code never leave the machine.
Reduce costs in your production app (paid)
Free keeps your coding-agent spend in view. When you want the same on every crossing in your production app — see and cut what your live LLM calls cost, across your whole team — that's the paid tier, part of Latten for Developers. Same engine, pointed at your app instead of your laptop.
| | Free | Solo $49/mo | Team $199/mo flat | |---|---|---|---| | Recoverable-spend detection in your coding agent | ✓ | ✓ | ✓ | | Cost visibility across your production app | | ✓ (1 app) | ✓ (up to 5 seats, multiple apps) | | Team-wide savings ledger | | | ✓ |
Pricing is flat and predictable — we never charge by the call, because metering your spend would mean charging you more to be more efficient. That's backwards.
Honest about what it is
Detection isn't magic: we catch the waste patterns we know, and we label fidelity honestly (measured vs estimated). The ledger only ever counts savings from fixes you applied. We'd rather under-claim and keep your trust than inflate a number.
Why local-first
Built by developers who went all-in on AI and wanted to keep the throttle without the bill-shock. Your spend data is yours; it stays on your machine unless you choose to share it. Same posture as @latten/redact, our sibling package that keeps secrets and PII out of your LLM calls.
Cut the bill, keep the speed. npm install @latten/cost.
You moved fast with AI. Latten helps you stay in control of it. See what your AI costs — and where your data goes: Latten turns the AI calls across your company into one live graph — cost, reach, and PII exposure, attributed and observed from real traffic. One prompt to your coding agent, a PR you review, live in minutes. latten.io
