Skip to main content

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

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

  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

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.

Metadata

Release files for tokenstretcher 1.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tokenstretcher 1.3.3
File Size Uploaded
tokenstretcher-1.3.3.tar.gz 70.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tokenstretcher 1.3.3
File Interpreter ABI Platform
tokenstretcher-1.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 139.6 kB

Release files / tokenstretcher-1.3.3.tar.gz

Download URL tokenstretcher-1.3.3.tar.gz
Size 70.4 kB
Tags Source
SHA-256 checksum
How to use checksums
44cfd43fada39ce36b3797dafb16a56f938551aed08d6cd04543e727baabe018
BLAKE2b-256 checksum
How to use checksums
bd7e81d8c157be23b70398bf35905e506894055be60a63ba9d9a1589b7f8cd7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.5

Release files / tokenstretcher-1.3.3-py3-none-any.whl

Download URL tokenstretcher-1.3.3-py3-none-any.whl
Size 69.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75aaae7cb0f4d9d9882c7323c49ee179804827228719cbb88eda56181e9cbf9f
BLAKE2b-256 checksum
How to use checksums
246807474a5259e9ec52be7744f5cf43ef658623ca7ccab5d92f84eb96c1a54a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.5

Release history Release notifications | RSS feed

This release

1.3.3 This release

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

1 release file

1.1.0

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page