Urgent.News

One page, thousands of outlets. See who else covered it.

Editions

AI

PromptShrink

How I Cut LLM Token Usage by Up to 60% in Production If you work with LLM APIs (OpenAI, Anthropic, Gemini), you know the pain: every call costs money, and a big chunk of that cost is pure waste — verbose prompts, code pasted with no filtering, repeated context the model doesn't even need to understand the task. That's why I built PromptShrink: a prompt pre-processor that trims the excess before…

In the production environment, LLM APIs like OpenAI, Anthropic, and Gemini can be costly due to the extra token usage from verbose prompts, unnecessary code, and repeated context that the model does not require to comprehend the task. To address this issue, PromptShrink was developed - a prompt pre-processor tool that reduces the excess before the API call is made, without losing the essential information for the model to understand.

The primary issue arises from paying per token for code snippets and long prompts, which includes comments, whitespace, and formatting meant for human consumption. These elements are irrelevant to the model's task and contribute to unnecessary costs. At a large scale, such as thousands of calls per month, these token wastages can result in a significant bill.

PromptShrink tackles this problem by packaging entire repositories, minifying code, and eliminating comments before they are used as context in any LLM. The tool estimates savings by simulating the real dollar cost difference between current spending and the optimized version, visualizes the results on a dashboard, and can be integrated with your code through a Python SDK.

Additionally, a browser extension enables a 'Shrink' button directly in popular LLM platforms like ChatGPT, Claude.ai, Google AI Studio, and Poe. PromptShrink is open source, with a CLI, a FastAPI backend, and a Python SDK, allowing anyone in production to utilize LLMs without paying for unnecessary tokens.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

More from Monday 17 August →