Get better results for far less cost. TokenStretcher decomposes complex work, routes tasks intelligently, and enforces hard prepaid budgets so you never blow past limits.
Project description
TokenStretcher
Higher quality results for far less cost.
Most people throw entire complex tasks at a powerful model in one giant prompt. This wastes massive context on irrelevant details, produces unfocused output, and makes it easy to blow past budgets.
TokenStretcher works differently.
It breaks complex work into focused subtasks, routes each piece to the right model, executes in parallel where it makes sense, and synthesizes a superior final result — while using dramatically fewer tokens overall.
Typical real-world outcome on hard tasks: 30–60% lower cost with better, more reliable results than a single massive prompt.
Using with a virtual key (tsai_...)?
Just run:
tokenstretcher --key "tsai_YourKeyHere" "your complex task"
That's it — the official hosted proxy is used automatically. No extra environment variables or config needed.
Why Giant Prompts Are Wasteful
- 70%+ of the tokens often go to context that doesn't matter for the current part of the work.
- One model is forced to be a jack-of-all-trades.
- Output quality suffers from lack of focus.
- Costs are unpredictable and easy to overrun.
With TokenStretcher
- Prepaid only, hard caps — You preload funds. The system enforces your budget in real time. No surprise bills, ever.
- Focused work — Each part of the task gets only the context and expertise it needs.
- Better results — Specialists handle what they're good at. You get sharper, more production-grade output.
- Full visibility — Every run gives you a clear report so you can see exactly what you got for the cost.
You stay in control. The system stays efficient.
Real Results on Complex Tasks
Here are outcomes from recent production-grade tasks (measured against strong single-prompt baselines using the same underlying models):
EvalForge — Complete LLM Evaluation & Prompt Optimization Platform
- Requirements: evaluation engine with multiple dimensions + caching/routing, prompt optimizer with Pareto analysis, analytics (kappa, cost curves, exports), background jobs, auth/billing integration, FastAPI + HTMX UI, SDK + CLI, Docker, full tests, demo.
- Result: 52% token reduction, "excellent" quality rating, clean modular production code delivered across specialized components.
Personal Finance Dashboard — Full end-to-end system
- Requirements: CoinGecko price data, 30/90-day metrics (volatility, Sharpe, correlations, trends), FastAPI + JWT auth, Redis-backed background jobs, interactive HTMX frontend, CSV/PDF export, pytest suite with golden data, Docker Compose, comprehensive README.
- Result: 9%+ token savings (significant improvement vs earlier versions), fully working runnable system with real calculations, auth, jobs, and frontend.
On the right tasks (new features, large refactors, multi-domain systems with research + code + tests + infra), teams routinely see 30–60%+ effective cost reduction while getting more focused, higher-quality deliverables.
Quick Start
If you have a virtual key (recommended for most users)
pip install tokenstretcher
# Just use your key — the hosted proxy is used automatically
tokenstretcher --key "tsai_YourKeyHere" "Build a production FastAPI service with JWT auth, user CRUD, and rate limiting"
# Or with JSON (great when called from other AI tools)
tokenstretcher --key "tsai_YourKeyHere" --json "your complex task"
No extra environment variables or config needed. The hosted proxy is used automatically for tsai_ keys.
Advanced / self-hosted use
pip install tokenstretcher
tokenstretcher "Build a production FastAPI service with JWT auth, user CRUD, and rate limiting"
tokenstretcher --plan-only "your task here"
tokenstretcher --json "your task here"
(Use --key + --base-url or environment variables if you are connecting to a different proxy.)
If you are operating the proxy server itself for virtual keys, see DEPLOYMENT.md (and the /admin/export-keys endpoint) for Redis + persistent volume recommendations so keys survive restarts.
Python API
from tokenstretcher import run
result = await run(
"Create a complete, secure FastAPI authentication system with refresh tokens and roles"
)
print(result.final_output)
print(result.savings.summary())
Built for Agentic Tools
TokenStretcher is designed to be called as a tool by other AI coding environments (Grok Build, OpenCode, Cursor, Aider, Continue.dev, etc.).
Every run returns structured results and clear savings data so the calling agent can decide intelligently when decomposition is worth it.
Prepay Model — Zero Surprise Bills
- Add funds to your wallet.
- Run tasks.
- Every call is tracked against your prepaid balance in real time.
- If balance is too low, it simply stops — no overages.
This is the safest possible way to use powerful models at scale, whether you're a human or an autonomous agent.
Installation
pip install tokenstretcher
Why It Matters
Most AI usage today is extremely wasteful.
TokenStretcher gives you a practical way to get better work while using far fewer tokens and staying within hard budget limits.
Prepaid. Hard-capped. Focused. Effective.
That’s the entire point.
License
TokenStretcher is released under the Business Source License (BSL 1.1).
Free for individuals and internal use. Commercial resale or hosting as a paid service requires a separate license after the change date.
See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tokenstretcher-1.3.2.tar.gz.
File metadata
- Download URL: tokenstretcher-1.3.2.tar.gz
- Upload date:
- Size: 53.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb8b80aada4a6df46ded09a2c0acd61cba0895d1aa1130ab580216f5763c702b
|
|
| MD5 |
b835044c4b4824086e849a09a16a214e
|
|
| BLAKE2b-256 |
f7a3fa958399d7db7057a8c1ae1d85a6bc26696a9dadaf1b80c7a3e225f6055c
|
File details
Details for the file tokenstretcher-1.3.2-py3-none-any.whl.
File metadata
- Download URL: tokenstretcher-1.3.2-py3-none-any.whl
- Upload date:
- Size: 51.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faa7746fdc4cdf51006cbd49642495af6c4d253c52ca682ff808f2be0b63aa7c
|
|
| MD5 |
8b0a5692727f04c21a4ac6f29bdaaafa
|
|
| BLAKE2b-256 |
af2512d0a53616580cdb47ba176ff2deca08192b3e98f41062778a36f24f46c1
|