Back to home

Developer

API & MCP

Clean prompts programmatically — in your agents, pipelines, and coding tools. Removes filler, hedging, and redundancy while keeping every requirement: same result, fewer input tokens. Two ways to save: a pre-cleaner that cleans your prompt before your agent sees it, and a plug-and-play MCP (plus a REST endpoint) for cleaning inside agents and pipelines.

Your API keys

Create a free account (the free tier includes API access), generate a key — shown once — then use it below.

API keys are tied to your account. Sign in or create a free account to generate one — the free tier includes API access.

Pre-cleaner — clean in the chat box, before you send

To actually cut your input tokens, the cleaned text has to replace the raw one before you hit send. This hotkey does exactly that: type your messy prompt straight into any chat box — Claude Code, Codex, ChatGPT desktop — press Ctrl+Shift+K, and it is replaced in place with the cleaned version. No browser tab, no copy-paste, and the raw prompt is never sent. (For one-off prompts, the playground does the same in the browser.)

Windows only for now — the hotkey uses Windows APIs; macOS and Linux support is coming. Your key is read from the ~/.atc/key file (preferred) or the ATC_API_KEY environment variable — never hardcode it.

1.  Set your API key

Terminal
# Store your key once in ~/.atc/key (read first, no restart needed):
New-Item -ItemType Directory -Force "$HOME\.atc" | Out-Null
Set-Content "$HOME\.atc\key" "atc_YOUR_KEY" -NoNewline -Encoding ascii

The ~/.atc/key file is read first and needs no restart — set it once. An ATC_API_KEY env var also works as a fallback.

2.  Download & run the hotkey

Save the script, then run it from PowerShell. Leave the window open (minimized is fine) — it listens for the hotkey in the background.

↓ Download clean-before-send.ps1
PowerShell
# keep this window open (minimize it)
powershell -NoProfile -ExecutionPolicy Bypass -File clean-before-send.ps1

3.  Use it

  • Ctrl+Shift+K — in a GUI chat box (Claude Code / Codex desktop, web chats): type your messy prompt, press it, and the box is replaced with the cleaned version. Review, then send.
  • Ctrl+Shift+J — for terminals (Codex CLI): copy your messy text, press it, then paste the cleaned text back.
  • Ctrl+Shift+M — cycle mode: plain-cleancavemanstructured-clean.
  • Ctrl+Shift+L — cycle the cleaner model.
  • Ctrl+Shift+Q — quit.

The window shows the current mode + cleaner and reprints them on each change. ATC_MODE / ATC_MODEL just set the starting values (defaults plain-clean / gemini-2.5-flash) — change them live with Ctrl+Shift+M / L, no relaunch.

No target-model option here — a target only changes the token-count estimate shown in the playground UI; it does not affect the clean itself, and the hotkey has no display to show it against. Pick a target in the playground when you want that readout.

Why not a /clean command? A Claude Code /clean slash command is possible, but whatever you type after it is still recorded as your prompt for that turn — so it does not actually keep the raw tokens out of the model. The in-place hotkey above is what delivers real input-token savings.

Connect the MCP

Remote MCP over Streamable HTTP at https://aitokencleaner.com/api/mcp — nothing to install. It exposes the clean_prompt tool plus an /atc_clean slash command, so your agent cleans long prompts before sending them anywhere.

Works with Claude Code, Cursor, and any MCP client that accepts an Authorization header. Browser sign-in (OAuth) is coming soon.

Connect in 3 steps

1.  Create an API key

Use the panel above — copy it once and keep it safe.

2.  Add the server to your client

Claude Code (CLI)

Run these commands in your terminal. The MCP connects via the claude CLI — no npm install needed.

1. Create an API key above (if you haven’t already)

Copy it once — shown only once.

2. Add the server to Claude Code

Terminal
claude mcp add token-cleaner --transport http https://aitokencleaner.com/api/mcp --header "Authorization: Bearer atc_YOUR_KEY"

3. Verify it’s connected

Terminal
claude mcp list

Look for ✓ Connected next to token-cleaner.

4. Use it in your Claude Code chat

Ask Claude Code to clean a prompt — it calls the clean_prompt tool automatically. Or type the /atc_clean slash command yourself. Either way the MCP cleans your input and returns the leaner version with stats.

Cursor / other clients (mcp.json)

mcp.json
{
  "mcpServers": {
    "token-cleaner": {
      "url": "https://aitokencleaner.com/api/mcp",
      "headers": { "Authorization": "Bearer atc_YOUR_KEY" }
    }
  }
}

3.  Use it

Ask in chat — tell the agent to clean a prompt; it calls clean_prompt and returns the cleaned text with token stats:

In your Claude Code chat
Clean this with token-cleaner: "could you please write me a really nice short calm poem about the sea, nothing too long, something relaxing"

Or the slash command /atc_clean (shown as /mcp__token-cleaner__atc_clean in Claude Code) cleans your prompt and continues with the leaner version automatically:

Slash command
/atc_clean write a professional but warm email to my manager asking for Friday off for a personal appointment

Troubleshooting

“Failed to connect” in Claude Code? A stale entry in another scope (local / project) can shadow your key. Remove it from every scope, then add it once:

Reset all scopes
claude mcp remove token-cleaner -s local
claude mcp remove token-cleaner -s project
claude mcp remove token-cleaner -s user

Then run claude mcp list (should show none) and re-add with a fresh key. If you rotate your key, remove & re-add the server so it picks up the new one.

Browser sign-in (OAuth)

Coming soon

One-click login with no key to paste is on the way. For now, use the API-key method above.

Tool parameters: text (required) · mode · sub_format · model · target_model · concise — same semantics as the REST API below.

How auth works: your tool sends your atc_ key as the Authorization header on every call, so each clean is tied to and billed on your account. Revoke a key anytime above.

REST API

POST https://aitokencleaner.com/api/v1/clean with your key as a Bearer token.

cURL
curl -X POST https://aitokencleaner.com/api/v1/clean \
  -H "Authorization: Bearer atc_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "could you please write me a really nice short poem about the sea, nothing too long please, maybe something calm",
    "mode": "plain-clean",
    "target_model": "gemini-2.5-flash"
  }'

Response

JSON
{
  "cleaned": "Write a short, calm poem about the sea.",
  "mode": "plain-clean",
  "model": "gemini-2.5-flash",
  "stats": {
    "original_tokens": 28,
    "cleaned_tokens": 10,
    "savings_percent": 64,
    "estimated_usd_saved": 0.0000054,
    "target_model": "gemini-2.5-flash"
  },
  "usage": { "credits_charged": 0, "cleans_today": 1, "daily_limit": 100 }
}

Parameters

FieldTypeNotes
promptstringRequired. The prompt to clean (2,000 chars free / 10,000 Pro).
modestringplain-clean (default) · caveman · structured-clean
sub_formatstringFor structured-clean: json (default) or xml.
modelstringCleaner model (default gemini-2.5-flash) — see the table below.
target_modelstringWhere the cleaned prompt will be used — tunes token math and the $-saved estimate.
concisebooleanAppends a directive so the target AI answers concisely. Not applied to structured-clean.

Cleaner models & credits

Model idNameTierCredits / clean (paid)
gemini-3.5-flashGemini 3.5 FlashStandard1
gemini-2.5-flashdefaultGemini 2.5 FlashStandard1
mistral-large-latestMistral Large 3Standard1
open-mixtral-8x22bMixtral 8x22BStandard1
ministral-8b-latestMinistral 8BStandard1
ministral-14b-latestMinistral 14BStandard1
sarvam-30bSarvam 30BStandard1
llama-3.3-70b-versatileLlama 3.3 70BStandard1

Latency note: gemini-3.5-flash currently responds noticeably slower (~10s+) than the other cleaners — its internal reasoning can’t be fully disabled yet. For latency-sensitive use (the hotkey, agent loops), prefer the default gemini-2.5-flash or llama-3.3-70b-versatile.

Limits & pricing

  • Free accounts: 100 cleans per rolling 24 hours — one shared pool across the pre-cleaner hotkey, REST API, and MCP (they all use the same key). Separate from your 4 web-playground cleans. 2,000 chars per prompt, standard models.
  • Paid API usage — credit packs: buy API credits in packs of 50–250 (no subscription needed, they never expire, 250 balance cap) — 1 credit per standard clean, 3 per premium; no daily cap; 10,000 chars per prompt. Buy credits.
  • Separate from the app: the $7.99/mo Pro subscription covers the web playground only — its monthly credits don’t apply here, and API credits don’t work in the playground.
  • Rate limit: 10 requests/min free, 30/min with API credits (per account).