Blog · July 18, 2026

TokenLens: Your Prompt Has a Price Tag Now

Tokens are the currency of working with language models, and almost every tool asks you to spend them blind. You paste a wall of text, hit send, and find out afterwards what it cost — if you ever look. This week we shipped TokenLens on every chat input in app.nyquest.ai: a live token count, a real cost estimate for the model you have selected, and an Optimize button that can shrink or sharpen your prompt before it goes anywhere — without ever losing the details that matter.

1,248 tokens · 4.9% of context · ~$0.0025 [▮▮▮▯▯] ✦ Optimize ▾

The counter is honest, which is rarer than it sounds

The count you see is computed by the same tokenizer stack that powers our compression engine — typically in about a millisecond. When an exact count is not available, TokenLens shows an approximation and marks it (≈) instead of pretending. Costs come from the same live model registry that prices your requests: real per-million rates for the model you actually picked. If we do not have a price, we show nothing — never a made-up zero.

Tap the count for the full picture: your message, the output reservation you have planned, the model's context window, what remains, and projected output cost — labeled as projected, because nobody knows how long a model will ramble before it does.

Optimization you can actually trust

Every prompt optimizer faces the same temptation: the easiest way to save tokens is to delete things, and the model doing the deleting does not always know what was load-bearing. An IP address. A file path. The words "do not execute this."

So TokenLens treats optimization as a pipeline with a conscience:

  1. Deterministic pass — rule-based cleanup where code, numbers, URLs, dates, and file paths are untouchable by construction
  2. LLM rewrite — clarity and compression, with a manifest of your protected details sent along as data it must preserve
  3. Integrity validation — URLs, IPs, hostnames, env vars, function names, numbers, dates, quoted values, CLI flags… and every "do not"
  4. Automatic repair — if anything protected went missing, one repair pass restores it, then validation runs again
  5. Your review — a diff, the token math, every change listed. Nothing replaces your text without your say-so. Undo included.

The negative-requirement check is the part we are proudest of. If you wrote "do not change the API URL" three slightly different ways, the optimizer is allowed to say it once — that is good compression. What it is never allowed to do is stop saying it. The validator compares prohibitions by meaning, not by counting sentences.

The validator caught us first

Here is the part that belongs on an engineering blog. While testing with a deliberately adversarial prompt — a rambling networking request stuffed with an API endpoint, three IP addresses, a router hostname, an environment variable, a function name, retry counts, and a fake credential planted to test secret detection — the integrity validator flagged a dropped URL. Working that failure exposed five real bugs in our own pipeline before any user hit them: a silent parsing failure that was quietly discarding the entire rewrite stage, markdown backticks getting glued onto extracted URLs, prose like "the variable (see above)" being mistaken for a function name, sentences being split in the middle of api.example.com, and filler words polluting the prohibition matcher.

We fixed the pipeline, not the test. That adversarial prompt now runs against production every morning as part of our daily suite — all thirteen protected details must survive optimization, the prohibitions must survive, and the planted credential must be detected and warned about. The suite is at 125 assertions, and the results are emailed to us whether they flatter us or not.

What it will not do

Being precise about the claim, as usual: optimization savings depend entirely on the prompt. Rambling, repetitive prompts shrink a lot; tight prompts full of protected technical detail shrink very little, and TokenLens will tell you so rather than inflate the number — "This prompt is already efficient" is a result we show proudly. When a prompt is mostly IP addresses and prohibitions, refusing to compress it is the feature working. And if it detects something that looks like a credential in your text, it warns you before the text goes anywhere for optimization.

Verified before shipping:

  • Live on all 12 composers — every desktop chassis and the mobile app — desktop, mobile, dark and light
  • 37 unit tests across the counting, entity-extraction, integrity, and diff logic, plus the daily 13-entity regression
  • First live repair: the rewrite dropped a "do not" instruction, the validator caught it, the repair pass restored it, re-validation passed — automatically, before anything was shown to the user
  • Prompt text stays out of logs and analytics — we record token counts and durations, never your words

Where this goes

TokenLens is built as a self-contained core with no dependencies on the rest of our frontend — deliberately. The same counting, integrity, and diff machinery that guards prompts inside Nyquest is designed to travel: a browser extension that brings the same lens to any chat window you use is on the roadmap. The platform that gets cheaper the longer you talk now also shows you the meter.

Watch your next prompt get cheaper →

← All posts