@eimen/token-saver
Version:
Strip polite fluff from AI prompts to cut token use and cost.
90 lines (61 loc) • 2.1 kB
Markdown
Cut polite fluff out of your prompts so you spend less on tokens.
> 04/17/2025: Sam Altman admits that saying "Please" and "Thank You" to ChatGPT is wasting millions of dollars in computing power.
Disclaimer: Only works with English as of now.
```bash
npm i @eimen/token-saver
```
```js
import TokenSaver from "@eimen/token-saver";
const saver = new TokenSaver();
const out = saver.process("Please summarise this text, thank you!");
console.log(out.cleaned); // "Summarise this text."
console.log(out.estimatedTokensSaved); // 3
```
```js
const TokenSaver = require("@eimen/token-saver");
```
| Option | Default | What it does |
| ----------------------- | :-----: | -------------------------------------------------- |
| `removePoliteness` | `true` | kill _please_, _thank you_ and similar niceties |
| `removeFillers` | `true` | kill _um_, _uh_, _actually_, _well_ … |
| `removeRedundantIntros` | `true` | kill “I was wondering if you could” style prefixes |
| `tokenCharRatio` | 4 | char‑per‑token estimate for savings calculation |
Pass a partial options object to the constructor:
```js
new TokenSaver({ removeFillers: false });
```
```ts
clean(prompt: string): string
process(prompt: string): {
original: string;
cleaned: string;
charsSaved: number;
estimatedTokensSaved: number;
}
```
Types are shipped in `index.d.ts`.
```bash
npx @eimen/token-saver "Please help me. Thanks!"
```
_(CLI is just `node -e` sugar; no global install needed.)_
- ChatGPT Turbo is ~4 characters per token. Two polite words can cost 1–2 tokens.
- Multiply by millions of prompts. Real money.
- Faster requests, shorter logs.
```bash
git clone https://github.com/eimenhmdt/token-saver
cd token-saver
npm i
npm test
```
MIT