Skip to main content

Aggressive Claude context optimizer by Xtream-ITSolutions UG - Cut costs by 50-95%

Project description

Xtream-ITSolutions UG

xithead

Aggressive Claude Context Optimizer — bis zu 95% Token-Einsparung

PyPI npm Discord License

💬 Discord · 🐛 Bug melden · ✨ Feature anfragen


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

Discord

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

xithead-1.1.1.tar.gz (41.5 kB view details)

Uploaded Source

Built Distribution

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

xithead-1.1.1-py3-none-any.whl (41.0 kB view details)

Uploaded Python 3

File details

Details for the file xithead-1.1.1.tar.gz.

File metadata

  • Download URL: xithead-1.1.1.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xithead-1.1.1.tar.gz
Algorithm Hash digest
SHA256 4f065b73ac2b0669f70cbf6abdf3884174eb5645381332f9e97537701304d1ba
MD5 0b668bc77a31b9a13aa0687c1a0a2472
BLAKE2b-256 b29909250d325708c6db0fce18efee90c8cd8aae7bb7d7d0964fbc38677bdbda

See more details on using hashes here.

File details

Details for the file xithead-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: xithead-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 41.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xithead-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d77ea479aaab4e7e5d115d1f6a4c905d789b1928c8d2127fd3b4b0d96d82c61
MD5 08e79cd72c58d14eef8ff8c1991e42a1
BLAKE2b-256 1a2056aaa68d707fe02191c28c955c059a2f674a2fb79a06bff643db7583f9be

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