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.3.tar.gz (40.1 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.3-py3-none-any.whl (39.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xithead-1.1.3.tar.gz
  • Upload date:
  • Size: 40.1 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.3.tar.gz
Algorithm Hash digest
SHA256 aa6c21d88bb98162968686aef21728dc88d2beea2144a8189eb577d9e64bc028
MD5 87fe5f73a018f028109f9339c16bbf7b
BLAKE2b-256 4d4dad18197e7a627e79d7b385355393730df83b6b23a08048a68617dcb366fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xithead-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 39.8 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d540f604c42cfc16569376591ac9c737bdc7e8c8fd69ceae1972c03178da7ac7
MD5 808c4e3db1683c1905c1169cb66c252a
BLAKE2b-256 d88abda2eeaa4fe7c9b3afbfa99761b654c8be5793fe73d74cea8b906d93cdd5

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