tokenstretcher 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tokenstretcher-1.3.0/LICENSE +76 -0
- tokenstretcher-1.3.0/MANIFEST.in +18 -0
- tokenstretcher-1.3.0/PKG-INFO +181 -0
- tokenstretcher-1.3.0/PYPI_README.md +132 -0
- tokenstretcher-1.3.0/README.md +448 -0
- tokenstretcher-1.3.0/pyproject.toml +82 -0
- tokenstretcher-1.3.0/requirements.txt +23 -0
- tokenstretcher-1.3.0/setup.cfg +4 -0
- tokenstretcher-1.3.0/tokenstretcher/__init__.py +80 -0
- tokenstretcher-1.3.0/tokenstretcher/agent.py +148 -0
- tokenstretcher-1.3.0/tokenstretcher/cli.py +402 -0
- tokenstretcher-1.3.0/tokenstretcher/config.py +175 -0
- tokenstretcher-1.3.0/tokenstretcher/email.py +214 -0
- tokenstretcher-1.3.0/tokenstretcher/key_manager.py +191 -0
- tokenstretcher-1.3.0/tokenstretcher/manager.py +472 -0
- tokenstretcher-1.3.0/tokenstretcher/mcp_server.py +30 -0
- tokenstretcher-1.3.0/tokenstretcher/models.py +286 -0
- tokenstretcher-1.3.0/tokenstretcher/prompts.py +163 -0
- tokenstretcher-1.3.0/tokenstretcher/stats.py +170 -0
- tokenstretcher-1.3.0/tokenstretcher/utils.py +639 -0
- tokenstretcher-1.3.0/tokenstretcher/wallet.py +172 -0
- tokenstretcher-1.3.0/tokenstretcher.egg-info/PKG-INFO +181 -0
- tokenstretcher-1.3.0/tokenstretcher.egg-info/SOURCES.txt +25 -0
- tokenstretcher-1.3.0/tokenstretcher.egg-info/dependency_links.txt +1 -0
- tokenstretcher-1.3.0/tokenstretcher.egg-info/entry_points.txt +2 -0
- tokenstretcher-1.3.0/tokenstretcher.egg-info/requires.txt +27 -0
- tokenstretcher-1.3.0/tokenstretcher.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Business Source License 1.1 (BSL 1.1)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TokenStretcher Contributors
|
|
4
|
+
|
|
5
|
+
Parameters:
|
|
6
|
+
- Licensor: TokenStretcher Contributors
|
|
7
|
+
- Licensed Work: TokenStretcher (all files in this repository)
|
|
8
|
+
- Additional Use Grant: You may use the Licensed Work for non-commercial purposes,
|
|
9
|
+
including personal use and use inside internal tools at companies.
|
|
10
|
+
- Change Date: Four years from the date this file was first published.
|
|
11
|
+
- Change License: MIT License
|
|
12
|
+
|
|
13
|
+
On the fourth anniversary of the date this file was first published, this license
|
|
14
|
+
will automatically convert to the MIT License.
|
|
15
|
+
|
|
16
|
+
Until the Change Date, the following restrictions apply:
|
|
17
|
+
|
|
18
|
+
**Commercial Use Restriction:**
|
|
19
|
+
You may NOT use this software, in whole or in substantial part, to provide a
|
|
20
|
+
commercial service, hosted product, or resold offering (including as part of an
|
|
21
|
+
AI coding agent, devtool, or proxy service) without a separate commercial license
|
|
22
|
+
from the Licensor.
|
|
23
|
+
|
|
24
|
+
This includes, but is not limited to:
|
|
25
|
+
- Offering TokenStretcher (or a derivative) as a paid or freemium service
|
|
26
|
+
- Embedding it into a commercial AI coding product and charging for usage
|
|
27
|
+
- Reselling access to the decomposition, routing, or proxy capabilities
|
|
28
|
+
|
|
29
|
+
The intent is to keep the local client and core ideas open for individuals and
|
|
30
|
+
builders, while protecting the commercial rights around the prepaid proxy model
|
|
31
|
+
and high-quality orchestration intelligence.
|
|
32
|
+
|
|
33
|
+
For commercial licensing inquiries, contact the maintainers.
|
|
34
|
+
|
|
35
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
36
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
37
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
38
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
39
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
40
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
41
|
+
SOFTWARE.
|
|
42
|
+
|
|
43
|
+
ADDITIONAL DISCLAIMER FOR PAID / PROXY USAGE:
|
|
44
|
+
|
|
45
|
+
This software includes functionality that can be used to operate a paid proxy
|
|
46
|
+
service that resells or intermediates access to third-party large language model
|
|
47
|
+
APIs (such as those provided by xAI, OpenAI, Anthropic, etc.).
|
|
48
|
+
|
|
49
|
+
THE AUTHORS AND COPYRIGHT HOLDERS PROVIDE NO WARRANTY that:
|
|
50
|
+
- Use of this software (including the proxy, virtual key, and prepaid billing
|
|
51
|
+
components) complies with the terms of service of any third-party LLM provider.
|
|
52
|
+
- The prepaid balance tracking, virtual key system, or billing logic is accurate,
|
|
53
|
+
secure, or free from errors.
|
|
54
|
+
- Any funds collected through the use of this software will be honored, refunded,
|
|
55
|
+
or result in continued service.
|
|
56
|
+
- The software will be available, error-free, or suitable for any particular
|
|
57
|
+
commercial purpose.
|
|
58
|
+
|
|
59
|
+
USERS WHO OPERATE PAID INSTANCES OF THIS SOFTWARE (including via Lemon Squeezy,
|
|
60
|
+
Stripe, or any other payment processor) ASSUME ALL RISK AND LIABILITY for
|
|
61
|
+
compliance with applicable laws, third-party terms of service, data protection
|
|
62
|
+
regulations, and consumer protection obligations.
|
|
63
|
+
|
|
64
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY INDIRECT,
|
|
65
|
+
INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES, INCLUDING BUT NOT
|
|
66
|
+
LIMITED TO LOSS OF PROFITS, DATA, USE, GOODWILL, OR OTHER INTANGIBLE LOSSES,
|
|
67
|
+
RESULTING FROM (A) THE USE OR INABILITY TO USE THE SOFTWARE; (B) ANY CONDUCT OR
|
|
68
|
+
CONTENT OF ANY THIRD PARTY; (C) ANY CONTENT OBTAINED FROM THE SOFTWARE; OR (D)
|
|
69
|
+
UNAUTHORIZED ACCESS, USE, OR ALTERATION OF YOUR TRANSMISSIONS OR CONTENT,
|
|
70
|
+
WHETHER BASED ON WARRANTY, CONTRACT, STATUTE, TORT (INCLUDING NEGLIGENCE), OR
|
|
71
|
+
ANY OTHER LEGAL THEORY, WHETHER OR NOT WE HAVE BEEN INFORMED OF THE POSSIBILITY
|
|
72
|
+
OF SUCH DAMAGE.
|
|
73
|
+
|
|
74
|
+
YOU ARE SOLELY RESPONSIBLE FOR ENSURING THAT YOUR USE OF THIS SOFTWARE, INCLUDING
|
|
75
|
+
ANY PAID PROXY OR BILLING FUNCTIONALITY, COMPLIES WITH ALL APPLICABLE LAWS AND
|
|
76
|
+
THE TERMS OF SERVICE OF ANY LLM PROVIDERS WHOSE MODELS ARE ACCESSED THROUGH IT.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include pyproject.toml
|
|
4
|
+
include requirements.txt
|
|
5
|
+
|
|
6
|
+
# Explicitly exclude sensitive / user-specific files
|
|
7
|
+
exclude .env
|
|
8
|
+
exclude .env.*
|
|
9
|
+
exclude .tokensaver/config.toml
|
|
10
|
+
prune .tokensaver
|
|
11
|
+
prune tests
|
|
12
|
+
prune examples
|
|
13
|
+
prune .venv
|
|
14
|
+
prune __pycache__
|
|
15
|
+
global-exclude *.pyc
|
|
16
|
+
global-exclude *.pyo
|
|
17
|
+
global-exclude *.egg-info
|
|
18
|
+
global-exclude .DS_Store
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tokenstretcher
|
|
3
|
+
Version: 1.3.0
|
|
4
|
+
Summary: 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.
|
|
5
|
+
Author: TokenStretcher Contributors
|
|
6
|
+
License: Business Source License 1.1
|
|
7
|
+
Project-URL: Homepage, https://github.com/ResponsiveDesignLLC/TokenStretcher
|
|
8
|
+
Project-URL: Documentation, https://github.com/ResponsiveDesignLLC/TokenStretcher#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/ResponsiveDesignLLC/TokenStretcher
|
|
10
|
+
Project-URL: Issues, https://github.com/ResponsiveDesignLLC/TokenStretcher/issues
|
|
11
|
+
Keywords: ai,llm,agents,token-optimization,cost-saving,orchestration,grok,litellm
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Internet :: Proxy Servers
|
|
22
|
+
Classifier: Topic :: Office/Business :: Financial :: Point-Of-Sale
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: litellm>=1.40.0
|
|
27
|
+
Requires-Dist: pydantic>=2.7.0
|
|
28
|
+
Requires-Dist: pyyaml>=6.0
|
|
29
|
+
Requires-Dist: rich>=13.7.0
|
|
30
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
31
|
+
Requires-Dist: aiofiles>=23.0.0
|
|
32
|
+
Requires-Dist: tomli>=2.0.0; python_version < "3.11"
|
|
33
|
+
Provides-Extra: mcp
|
|
34
|
+
Requires-Dist: mcp>=1.0.0; extra == "mcp"
|
|
35
|
+
Provides-Extra: proxy
|
|
36
|
+
Requires-Dist: fastapi>=0.110.0; extra == "proxy"
|
|
37
|
+
Requires-Dist: uvicorn[standard]>=0.29.0; extra == "proxy"
|
|
38
|
+
Requires-Dist: python-multipart>=0.0.9; extra == "proxy"
|
|
39
|
+
Requires-Dist: resend>=0.8.0; extra == "proxy"
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
42
|
+
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
43
|
+
Requires-Dist: ruff; extra == "dev"
|
|
44
|
+
Requires-Dist: mypy; extra == "dev"
|
|
45
|
+
Requires-Dist: black; extra == "dev"
|
|
46
|
+
Requires-Dist: build; extra == "dev"
|
|
47
|
+
Requires-Dist: twine; extra == "dev"
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
# TokenStretcher
|
|
51
|
+
|
|
52
|
+
**Higher quality results for far less cost.**
|
|
53
|
+
|
|
54
|
+
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.
|
|
55
|
+
|
|
56
|
+
**TokenStretcher works differently.**
|
|
57
|
+
|
|
58
|
+
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.
|
|
59
|
+
|
|
60
|
+
Typical real-world outcome on hard tasks: **30–60% lower cost** with **better, more reliable results** than a single massive prompt.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Why Giant Prompts Are Wasteful
|
|
65
|
+
|
|
66
|
+
- 70%+ of the tokens often go to context that doesn't matter for the current part of the work.
|
|
67
|
+
- One model is forced to be a jack-of-all-trades.
|
|
68
|
+
- Output quality suffers from lack of focus.
|
|
69
|
+
- Costs are unpredictable and easy to overrun.
|
|
70
|
+
|
|
71
|
+
## With TokenStretcher
|
|
72
|
+
|
|
73
|
+
- **Prepaid only, hard caps** — You preload funds. The system enforces your budget in real time. No surprise bills, ever.
|
|
74
|
+
- **Focused work** — Each part of the task gets only the context and expertise it needs.
|
|
75
|
+
- **Better results** — Specialists handle what they're good at. You get sharper, more production-grade output.
|
|
76
|
+
- **Full visibility** — Every run gives you a clear report so you can see exactly what you got for the cost.
|
|
77
|
+
|
|
78
|
+
You stay in control. The system stays efficient.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Real Results on Complex Tasks
|
|
83
|
+
|
|
84
|
+
Here are outcomes from recent production-grade tasks (measured against strong single-prompt baselines using the same underlying models):
|
|
85
|
+
|
|
86
|
+
**EvalForge** — Complete LLM Evaluation & Prompt Optimization Platform
|
|
87
|
+
- 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.
|
|
88
|
+
- Result: **52% token reduction**, "excellent" quality rating, clean modular production code delivered across specialized components.
|
|
89
|
+
|
|
90
|
+
**Personal Finance Dashboard** — Full end-to-end system
|
|
91
|
+
- 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.
|
|
92
|
+
- Result: **9%+ token savings** (significant improvement vs earlier versions), fully working runnable system with real calculations, auth, jobs, and frontend.
|
|
93
|
+
|
|
94
|
+
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.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Quick Start
|
|
99
|
+
|
|
100
|
+
### CLI
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pip install tokenstretcher
|
|
104
|
+
|
|
105
|
+
# Run a task
|
|
106
|
+
tokenstretcher "Build a production FastAPI service with JWT auth, user CRUD, and rate limiting"
|
|
107
|
+
|
|
108
|
+
# See the plan only (no cost)
|
|
109
|
+
tokenstretcher --plan-only "Refactor the entire payment module"
|
|
110
|
+
|
|
111
|
+
# JSON output (ideal when called by other AI agents)
|
|
112
|
+
tokenstretcher --json "Design a multi-tenant permissions system"
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Python API
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from tokenstretcher import run
|
|
119
|
+
|
|
120
|
+
result = await run(
|
|
121
|
+
"Create a complete, secure FastAPI authentication system with refresh tokens and roles"
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
print(result.final_output)
|
|
125
|
+
print(result.savings.summary())
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Built for Agentic Tools
|
|
131
|
+
|
|
132
|
+
TokenStretcher is designed to be called as a tool by other AI coding environments (Grok Build, OpenCode, Cursor, Aider, Continue.dev, etc.).
|
|
133
|
+
|
|
134
|
+
Every run returns structured results and clear savings data so the calling agent can decide intelligently when decomposition is worth it.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Prepay Model — Zero Surprise Bills
|
|
139
|
+
|
|
140
|
+
1. Add funds to your wallet.
|
|
141
|
+
2. Run tasks.
|
|
142
|
+
3. Every call is tracked against your prepaid balance in real time.
|
|
143
|
+
4. If balance is too low, it simply stops — no overages.
|
|
144
|
+
|
|
145
|
+
This is the safest possible way to use powerful models at scale, whether you're a human or an autonomous agent.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Installation
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
pip install tokenstretcher
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Optional proxy features (for running your own prepaid key service):
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
pip install "tokenstretcher[proxy]"
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Why It Matters
|
|
164
|
+
|
|
165
|
+
Most AI usage today is extremely wasteful.
|
|
166
|
+
|
|
167
|
+
TokenStretcher gives you a practical way to get **better work** while using **far fewer tokens** and staying within hard budget limits.
|
|
168
|
+
|
|
169
|
+
Prepaid. Hard-capped. Focused. Effective.
|
|
170
|
+
|
|
171
|
+
That’s the entire point.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
TokenStretcher is released under the Business Source License (BSL 1.1).
|
|
178
|
+
|
|
179
|
+
Free for individuals and internal use. Commercial resale or hosting as a paid service requires a separate license after the change date.
|
|
180
|
+
|
|
181
|
+
See the LICENSE file for details.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# TokenStretcher
|
|
2
|
+
|
|
3
|
+
**Higher quality results for far less cost.**
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
**TokenStretcher works differently.**
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
Typical real-world outcome on hard tasks: **30–60% lower cost** with **better, more reliable results** than a single massive prompt.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Why Giant Prompts Are Wasteful
|
|
16
|
+
|
|
17
|
+
- 70%+ of the tokens often go to context that doesn't matter for the current part of the work.
|
|
18
|
+
- One model is forced to be a jack-of-all-trades.
|
|
19
|
+
- Output quality suffers from lack of focus.
|
|
20
|
+
- Costs are unpredictable and easy to overrun.
|
|
21
|
+
|
|
22
|
+
## With TokenStretcher
|
|
23
|
+
|
|
24
|
+
- **Prepaid only, hard caps** — You preload funds. The system enforces your budget in real time. No surprise bills, ever.
|
|
25
|
+
- **Focused work** — Each part of the task gets only the context and expertise it needs.
|
|
26
|
+
- **Better results** — Specialists handle what they're good at. You get sharper, more production-grade output.
|
|
27
|
+
- **Full visibility** — Every run gives you a clear report so you can see exactly what you got for the cost.
|
|
28
|
+
|
|
29
|
+
You stay in control. The system stays efficient.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Real Results on Complex Tasks
|
|
34
|
+
|
|
35
|
+
Here are outcomes from recent production-grade tasks (measured against strong single-prompt baselines using the same underlying models):
|
|
36
|
+
|
|
37
|
+
**EvalForge** — Complete LLM Evaluation & Prompt Optimization Platform
|
|
38
|
+
- 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.
|
|
39
|
+
- Result: **52% token reduction**, "excellent" quality rating, clean modular production code delivered across specialized components.
|
|
40
|
+
|
|
41
|
+
**Personal Finance Dashboard** — Full end-to-end system
|
|
42
|
+
- 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.
|
|
43
|
+
- Result: **9%+ token savings** (significant improvement vs earlier versions), fully working runnable system with real calculations, auth, jobs, and frontend.
|
|
44
|
+
|
|
45
|
+
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.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
### CLI
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install tokenstretcher
|
|
55
|
+
|
|
56
|
+
# Run a task
|
|
57
|
+
tokenstretcher "Build a production FastAPI service with JWT auth, user CRUD, and rate limiting"
|
|
58
|
+
|
|
59
|
+
# See the plan only (no cost)
|
|
60
|
+
tokenstretcher --plan-only "Refactor the entire payment module"
|
|
61
|
+
|
|
62
|
+
# JSON output (ideal when called by other AI agents)
|
|
63
|
+
tokenstretcher --json "Design a multi-tenant permissions system"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Python API
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from tokenstretcher import run
|
|
70
|
+
|
|
71
|
+
result = await run(
|
|
72
|
+
"Create a complete, secure FastAPI authentication system with refresh tokens and roles"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
print(result.final_output)
|
|
76
|
+
print(result.savings.summary())
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Built for Agentic Tools
|
|
82
|
+
|
|
83
|
+
TokenStretcher is designed to be called as a tool by other AI coding environments (Grok Build, OpenCode, Cursor, Aider, Continue.dev, etc.).
|
|
84
|
+
|
|
85
|
+
Every run returns structured results and clear savings data so the calling agent can decide intelligently when decomposition is worth it.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Prepay Model — Zero Surprise Bills
|
|
90
|
+
|
|
91
|
+
1. Add funds to your wallet.
|
|
92
|
+
2. Run tasks.
|
|
93
|
+
3. Every call is tracked against your prepaid balance in real time.
|
|
94
|
+
4. If balance is too low, it simply stops — no overages.
|
|
95
|
+
|
|
96
|
+
This is the safest possible way to use powerful models at scale, whether you're a human or an autonomous agent.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Installation
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pip install tokenstretcher
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Optional proxy features (for running your own prepaid key service):
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pip install "tokenstretcher[proxy]"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Why It Matters
|
|
115
|
+
|
|
116
|
+
Most AI usage today is extremely wasteful.
|
|
117
|
+
|
|
118
|
+
TokenStretcher gives you a practical way to get **better work** while using **far fewer tokens** and staying within hard budget limits.
|
|
119
|
+
|
|
120
|
+
Prepaid. Hard-capped. Focused. Effective.
|
|
121
|
+
|
|
122
|
+
That’s the entire point.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
TokenStretcher is released under the Business Source License (BSL 1.1).
|
|
129
|
+
|
|
130
|
+
Free for individuals and internal use. Commercial resale or hosting as a paid service requires a separate license after the change date.
|
|
131
|
+
|
|
132
|
+
See the LICENSE file for details.
|