Aggressive Claude context optimizer by Xtream-ITSolutions UG - Cut costs by 50-95%
Project description
xithead
Aggressive Claude Context Optimizer — bis zu 95% Token-Einsparung
Was ist xithead?
xithead ist ein Claude-spezifischer Context Optimizer von Xtream-ITSolutions UG.
Er sitzt zwischen deiner App und der Claude API, komprimiert Prompts aggressiv und cached Antworten — du sendest weniger Tokens und zahlst deutlich weniger.
- Drop-in Proxy — keine Code-Änderungen nötig
- Immer Sonnet 4.6 — das beste Modell, automatisch gepinnt
- Ultra-Modus standardmäßig — 50–95% Einsparung ab dem ersten Request
- Live Dashboard — Einsparungen in Echtzeit auf
localhost:8787/dashboard
Schnellstart — Windows (empfohlen)
# PowerShell als Administrator, einmalig:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
iex (irm https://raw.githubusercontent.com/xtream-itsolutions/headroom/main/headroom.ps1)
Danach neues Terminal öffnen und loslegen:
xithead # Claude starten — ultra-aggressiv, 50-95% Einsparung
xithead-proxy # Proxy + Dashboard auf http://localhost:8787/dashboard
xithead-stats # Einsparungen anzeigen
xithead-update # xithead aktualisieren
xithead-help # Alle Befehle
VS Code: Terminal mit
Strg+\`` öffnen, PowerShell wählen,xithead` eingeben — fertig.
Installation
Python
pip install xithead # nur CLI + Optimizer
pip install "xithead[proxy]" # + Proxy + Dashboard (empfohlen)
npm / Node.js
npm install -g xithead
CLI Befehle
xithead proxy # Proxy starten (Port 8787) + Dashboard
xithead optimize "prompt" # Prompt optimieren und Einsparung zeigen
xithead stats # Session-Statistiken
xithead cache stats # Cache-Statistiken
xithead cache clear # Cache leeren
xithead model set claude-sonnet-4-6 # Modell setzen
xithead model show # Aktuelles Modell anzeigen
Features
| Feature | Beschreibung | Einsparung |
|---|---|---|
| 🔥 Prompt Caching | cache_control-Marker automatisch injizieren |
Bis 90% auf Cache-Hits |
| 🗜️ Context Compression | Redundanz entfernen, Nachrichten deduplizieren | 30–60% weniger Tokens |
| 💾 Multi-Layer Cache | RAM + SQLite, SHA-256 Keys, TTL | Wiederholte Calls gratis |
| ✂️ Context Trim | Alten Context trimmen (verhindert 400-Fehler) | Spart Input-Tokens |
| 📉 Verbosity Reduction | System-Prompts komprimieren | 10–40% Einsparung |
| 📊 Live Dashboard | Token- & Kosten-Tracking in Echtzeit | Volle Transparenz |
| 🔌 Drop-in Proxy | Keine Code-Änderungen | Funktioniert mit jedem Client |
Einsparungs-Beispiele
| Anwendungsfall | Original | Nach xithead | Gespart |
|---|---|---|---|
| Code-Review (wiederholter Kontext) | 50.000 Tokens | 4.000 Tokens | 92% |
| Chat mit langem System-Prompt | 10.000 Tokens | 2.000 Tokens | 80% |
| Agentischer Loop (Tool-Ergebnisse) | 100.000 Tokens | 25.000 Tokens | 75% |
| Einfaches Q&A | 500 Tokens | 400 Tokens | ~20% |
Python API
from xithead import optimize_for_claude
messages = [{"role": "user", "content": "Sehr langer Prompt hier..."}]
result = optimize_for_claude(messages, model="claude-sonnet-4-6")
print(f"Tokens gespart: {result.tokens_saved}")
print(f"Kosten gespart: ${result.cost_saved_usd:.4f}")
print(f"Kompression: {result.compression_ratio:.1%}")
print(f"Cache-Hit: {result.cache_hit}")
# Optimierte messages an Anthropic API übergeben:
# client.messages.create(messages=result.messages, ...)
Konfiguration
from xithead.claude_optimizer import ClaudeOptimizer, ClaudeOptimizerConfig
config = ClaudeOptimizerConfig(
enable_prompt_caching=True,
enable_dedup=True,
enable_verbosity_reduction=True,
enable_context_trim=True,
max_context_tokens=180_000,
cache_ttl_seconds=86400,
)
optimizer = ClaudeOptimizer(config)
result = optimizer.optimize(messages, system="Du bist ein hilfreicher Assistent.", model="claude-sonnet-4-6")
Node.js / JavaScript API
const { optimize, createOptimizedClient, injectCacheControl } = require('xithead');
const Anthropic = require('@anthropic-ai/sdk');
// Option 1: Manuell optimieren
const result = optimize({ messages, system, model: 'claude-sonnet-4-6' });
console.log(result.tokensSaved, result.costSavedUsd);
// Option 2: Wrapped Client (optimiert automatisch jeden Call)
const client = new Anthropic();
const xitClient = createOptimizedClient(client);
const response = await xitClient.messages.create({
model: 'claude-sonnet-4-6',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hallo!' }],
});
console.log(xitClient.getStats());
Proxy-Modus (Zero Code Changes)
# Proxy starten
xithead proxy --port 8787
# Dashboard öffnen
# → http://localhost:8787/dashboard
# Deinen Claude Client auf den Proxy zeigen lassen:
export ANTHROPIC_BASE_URL=http://localhost:8787
claude # oder jede andere App
In PowerShell:
$env:ANTHROPIC_BASE_URL = "http://localhost:8787"
claude
Wie es funktioniert
Deine App → xithead Proxy → Optimierter Request → Claude API
│
├─ Cache-Lookup (API-Call überspringen wenn gecacht)
├─ Nachrichten-Deduplizierung
├─ System-Prompt Kompression
├─ cache_control Marker injizieren
├─ Context-Window Trim (verhindert 400-Fehler)
└─ Token/Kosten-Tracking
Umgebungsvariablen
| Variable | Standardwert | Beschreibung |
|---|---|---|
XITHEAD_MODEL |
claude-sonnet-4-6 |
Claude-Modell |
XITHEAD_ENABLE_CACHE_CONTROL |
1 |
Prompt-Caching aktivieren |
XITHEAD_ENABLE_DEDUP |
1 |
Nachrichten-Dedup aktivieren |
XITHEAD_ENABLE_CONTEXT_TRIM |
1 |
Context-Trim aktivieren |
HEADROOM_COMPRESSION_RATIO_TARGET |
0.3 |
Kompressions-Ziel (0.3 = 70%) |
HEADROOM_STRENGTH |
aggressive |
Kompressions-Stärke |
CLAUDE_CODE_MAX_OUTPUT_TOKENS |
2048 |
Max. Output-Tokens |
Beitragen
Wir freuen uns über Beiträge! Öffne ein Issue oder Pull Request.
Tritt unserer Community bei: discord.gg/xtream-itsolutions
Lizenz
Apache 2.0 — siehe LICENSE.
Made with ❤️ by Xtream-ITSolutions UG
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 xithead-1.2.0.tar.gz.
File metadata
- Download URL: xithead-1.2.0.tar.gz
- Upload date:
- Size: 40.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
490fc47d49d778464b957872b8c8603c275f3773b824908f64906e149e635100
|
|
| MD5 |
1b6268c31e10f3044c7d87d59c0b1573
|
|
| BLAKE2b-256 |
c7765bea2d2cfa184db76e4c3e320ce6449e3abaf6cbdb58e0e8ca15adf9303b
|
File details
Details for the file xithead-1.2.0-py3-none-any.whl.
File metadata
- Download URL: xithead-1.2.0-py3-none-any.whl
- Upload date:
- Size: 39.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff99b9d4e7e1943edef22c8754e6f5548f620aaf2d6d416e23a0bba82df48d09
|
|
| MD5 |
ed7ff6ace655b755435499db6c070460
|
|
| BLAKE2b-256 |
1aa2da86c81a18c63d19c7a89f776d46690736b1710e86f19404533172918277
|