Skip to main content

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.


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

CLI

pip install tokenstretcher

# Run a task
tokenstretcher "Build a production FastAPI service with JWT auth, user CRUD, and rate limiting"

# See the plan only (no cost)
tokenstretcher --plan-only "Refactor the entire payment module"

# JSON output (ideal when called by other AI agents)
tokenstretcher --json "Design a multi-tenant permissions system"

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

  1. Add funds to your wallet.
  2. Run tasks.
  3. Every call is tracked against your prepaid balance in real time.
  4. 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

Optional proxy features (for running your own prepaid key service):

pip install "tokenstretcher[proxy]"

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

tokenstretcher-1.3.0.tar.gz (51.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tokenstretcher-1.3.0-py3-none-any.whl (48.9 kB view details)

Uploaded Python 3

File details

Details for the file tokenstretcher-1.3.0.tar.gz.

File metadata

  • Download URL: tokenstretcher-1.3.0.tar.gz
  • Upload date:
  • Size: 51.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.5

File hashes

Hashes for tokenstretcher-1.3.0.tar.gz
Algorithm Hash digest
SHA256 d05c3e7e92decc23cfc084493ef60be79b44ede4e98d8a8a1efc9c63a2f89932
MD5 e8087ff5502a27eda88acf6acbc9cc46
BLAKE2b-256 2b16943dd2a0a0ebbd97313535e9fab64d5e30972637ce1f72f8b6530a163600

See more details on using hashes here.

File details

Details for the file tokenstretcher-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: tokenstretcher-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 48.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.5

File hashes

Hashes for tokenstretcher-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 144d2989baf645fb3c88efa3d70406d53650c0e39868d47952dda3757b69c7e2
MD5 895ee5fd32d6bc6ea7acdf7e3152b20a
BLAKE2b-256 292f0f1a5c2ba935aac2d38bd725a33ae3c564dd075b272d9f9293b4061ee23e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page