LLM Output Cost Control Proxy
Atriou2 · reddit · 2026-07-10
After seeing API bills inflated by a few extremely long LLM outputs, the author built a proxy layer to sit in front of model providers and automatically limit abnormally long responses.
Key approaches include:
- Observing actual output lengths by route and setting the limit near the p99 threshold to truncate only extreme long-tail requests.
- Preserving complete sentences during truncation; if the response is JSON, it attempts to repair it to ensure it remains parsable.
- Supporting USD budgets by day, key, route, or end-user, directly intercepting requests before they reach the provider.
- Compatible with OpenAI and Anthropic request formats, requiring only a base URL change to integrate.
This tool uses a BYO key model, stores no prompts or responses, and only logs token counts. The author has opened a free beta, hoping users will route real traffic to test its stability.
More from Infra
- Agent search bottlenecks are now about variance, not raw latency — rohanpaul_ai · 2026-07-22
- Gavin Baker argues Nvidia may be one of open source AI’s biggest supporters — GavinSBaker · 2026-07-22
- AI Power Demand Exposes US Energy Gap, Urging Shift from Scarcity to Abundance — bradneuberg · 2026-07-22
- Gavin Baker says Nvidia’s $630B figure would be system revenue, not all Nvidia’s — GavinSBaker · 2026-07-22
- A Firecracker-based platform says it can host 6,000 AI agents on one 256 GB server — maritime_sh · 2026-07-22
- Report says Nvidia could build 1,000 Vera Rubin racks a day, implying $630B quarterly at system level — GavinSBaker · 2026-07-22