A Project by SILICON VALLEY GLOBAL PH INC
TokenSaveOS is an open-source AI agent optimization platform developed by SILICON VALLEY GLOBAL PH INC. It optimizes how AI coding agents consume tokens, manage context, and route requests — reducing total AI API costs by up to 88% without replacing underlying LLM models.
xychart-beta
title "Token Volume Payload Reduction Curve (Tokens per Request)"
x-axis ["Raw Codebase Payload", "1. Context Engine", "2. Token Engine", "3. Prompt Cache", "4. Model Router"]
y-axis "Tokens Consumed" 0 --> 100000
line [100000, 18000, 8500, 2400, 1200]
100k ──┐ (Raw Codebase Payload)
│
80k │
│
60k │
│
40k │
│
20k └───┐ (1. Context Engine: 100k ➔ 18k)
└───┐ (2. Token Engine: 18k ➔ 8.5k)
0k └───┐ (3. Prompt Cache: 8.5k ➔ 2.4k)
└──────────★ Final Optimized Payload: 1,200 Tokens (-88% Net Reduction)
For Cursor IDE, Antigravity IDE, VS Code, and Terminal, run TokenSaveOS directly as your standalone optimized agent:
# Execute any AI task with 88% cost optimization
tokensave run "Refactor security policy and optimize database queries"- Context Engine: Prunes repository files from 100,000 → 8,000 tokens.
- Smart Model Router: Automatically selects Haiku (simple tasks) or Opus (complex architecture).
- Token Compression: Strips prompt filler words, code comments, and JSON whitespace.
- Persistent Savings Vault: Records exact token savings and USD cost reduction to
~/.tokensave/state.json.
Raw Customer Request
│
┌───────────────────────────┴───────────────────────────┐
▼ ▼
1. Context Intelligence Engine 2. Token Optimization Engine
(Prunes 100k → 8k tokens) (Prunes 50-60% prompt filler)
│ │
└───────────────────────────┬───────────────────────────┘
│
┌───────────────────────────┴───────────────────────────┐
▼ ▼
3. Provider Prompt Caching 4. Smart Agent Router
(90% discount on repeat context) (Routes simple tasks to Haiku)
- 80% to 92% Reduction in Input Context Payload: Scans repository import graphs and Git activity to select only relevant files (~8,000 tokens) instead of dumping a raw 100,000-token monorepo into the prompt.
- 40% to 60% Reduction in Prompt Text:
Strips conversational filler ("Can you please", "kindly", "in order to"), code comments (
/* ... */,# ...), JSON whitespace, and duplicate lines. - Empirical Test:
"Can you please analyze this code and explain what improvements can be made?"(22 tokens) ➔"analyze this code and explain"(9 tokens) — 59.1% Token Reduction.
- 90% Cost Discount on Cached Input Tokens:
Injects provider-native prompt cache breakpoints (
cache_control: { type: "ephemeral" }for Anthropic Claude). Cached context is billed at $0.30/1M tokens instead of $3.00/1M tokens.
- 73% to 94% Cost Reduction Per Routed Request: Routes simple tasks (typos, formatting, minor edits) to Claude 3.5 Haiku ($0.80/1M tokens) instead of expensive Claude 3.7 Sonnet ($3.00/1M) or Opus ($15.00/1M).
- 35% to 55% Additional Code Token Reduction: Parses TypeScript, JavaScript, and Python code ASTs to strip unexported helper functions, docstrings, and comments while keeping exported interfaces intact for LLM prompts.
- Real-Time Model Price Comparison: Calculates exact input/output/cached token costs across Anthropic, OpenAI, Google Gemini, and Groq to recommend the lowest-cost model for any task.
- Real-Time Loop Abort & Token Cap Safeguard: Monitors SSE LLM output streams chunk-by-chunk to detect and abort infinite repetitive loops and runaway token spikes.
For an engineering team executing 10,000 AI coding requests per month:
| Metric | Without TokenSaveOS | With TokenSaveOS | Net Customer Savings |
|---|---|---|---|
| Avg. Tokens per Request | 50,000 tokens | 8,000 tokens | 84% fewer tokens |
| Monthly Token Volume | 500,000,000 tokens | 80,000,000 tokens | 420,000,000 tokens saved |
| Prompt Caching Discount | None ($3.00 / 1M) | 80% Cached ($0.30 / 1M) | 90% cache discount |
| Monthly AI API Bill | $1,500.00 / month | $180.00 / month | $1,320.00 Saved / Month |
| Overall Cost Reduction | 0% | 88.0% | 88% Net Savings |
# Install globally
npm install -g @svgph/tokensaveos
# Run Standalone Agent Mode (Primary Recommended Flow)
tokensave run "Refactor security policy"
# Start Zero-Code LLM API Proxy (http://localhost:8080)
tokensave proxy
# Launch Live Web Analytics Dashboard (http://localhost:3005)
tokensave dashboard
# Manage Developer Spending Budgets
tokensave budget set 100
# Generate Encrypted Vault Signature for Team Sync
tokensave sync
# View Real Savings Dashboard
tokensave stats
# Pre-flight Prompt Compression
tokensave optimize "Can you please analyze this code..."
# Initialize Project & Memory
tokensave initTokenSaveOS is open-source software developed by SILICON VALLEY GLOBAL PH INC and licensed under the MIT License.