Skip to main content

OmniCache

PyPI version License: MIT

OmniCache is a local acceleration sidecar for AI coding agents (Claude Code, Cursor, Aider, and custom LLM workflows).

It sits between your coding assistant and upstream LLM providers (Anthropic, OpenAI, Gemini) to eliminate redundant tool executions, stream terminal tokens smoothly, and share cached knowledge across developer sessions.


Why OmniCache?

How OmniCache Complements Native Anthropic Prompt Caching

Anthropic’s native prompt caching is great at discounting prefix tokens within a single active conversation. However, it structurally leaves two major gaps open in real-world coding agent loops:

┌───────────────────────────────────────────────┬───────────────────────────────┬─────────────────────────────────┐
│ Capability                                    │ Native Provider Caching       │ OmniCache Acceleration Sidecar  │
├───────────────────────────────────────────────┼───────────────────────────────┼─────────────────────────────────┤
│ In-Session Prefix Input Token Discount        │ ✅ 90% (Anthropic ephemeral)  │ ✅ Supported (Passthrough)      │
│ Redundant Disk Tool Replay (git/grep/read)    │ ❌ No (Hits disk & LLM every turn) │ ✅ <0.3ms (Git-state hashed)    │
│ Cross-Session Memory (New CLI sessions)       │ ❌ 0% (Expires in 5 minutes)   │ ✅ Persistent (SQLite / Redis)  │
│ Cross-Teammate Knowledge Sharing              │ ❌ 0% (Isolated per session)  │ ✅ Shared Team Redis Store      │
│ Terminal SSE Stream Jitter Replay             │ ❌ No                         │ ✅ ~65 tok/s (Glitch-free CLI)  │
│ Multi-Modal Visual Deduplication (Screenshots) │ ❌ No (Re-uploads megabytes)   │ ✅ Perceptual dHash Match       │
└───────────────────────────────────────────────┴───────────────────────────────┴─────────────────────────────────┘
  1. Tool-Call Acceleration: When Claude Code repeatedly calls git_status, grep_search, or read_file, native caching still runs the tool on disk and pays for the network roundtrip. OmniCache cryptographically hashes your Git working tree state (HEAD commit + git status --porcelain). If files haven't changed, tool calls return in <0.3ms with $0.00 spent. The moment you edit a file, the cache instantly invalidates.
  2. Persistent Cross-Session & Team Memory: Native prompt cache is ephemeral (5-minute TTL). OmniCache stores answers in an embedded SQLite WAL database or shared Redis, so opening a new session or having a teammate ask a similar architecture question reuses existing answers.
  3. Smooth CLI Stream Replaying: Returning a 4,000-token cached completion instantaneously in 0ms can cause buffer overflows and terminal glitches in interactive CLIs. OmniCache emulates natural token-streaming (~65 tokens/sec with subtle stochastic jitter).

Installation

Standard (PyPI)

pip install omnicache-proxy

Android & Edge (Termux 1-Line Setup)

curl -fsSL https://raw.githubusercontent.com/13manmayarai-hash/omnicache-proxy/main/scripts/install_termux.sh | bash

Docker & Redis Cluster

docker compose up -d

Zero-Config Quickstart (omnicache run)

The easiest way to use OmniCache is the zero-config run wrapper. It automatically launches the background proxy, injects provider environment variables (ANTHROPIC_BASE_URL, OPENAI_BASE_URL), and displays a session savings ledger when finished:

1. Launch Claude Code

omnicache run claude

2. Launch Cursor / VS Code / Other Agent Scripts

omnicache run cursor .
# or custom Python agent scripts:
omnicache run python my_coding_agent.py

When you exit your session, OmniCache outputs a clean summary:

╭──────────────────────────────────────────────────╮
│ ⚡ OmniCache Session Telemetry                   │
│  - Tokens Saved:       1,840 tokens              │
│  - Avoided Cost:    $ 0.0142 USD                 │
│  - Tool Replays:          14 cached tool calls   │
╰──────────────────────────────────────────────────╯

Manual Quickstart

1. Start the Background Daemon

omnicache

By default, the proxy runs on http://127.0.0.1:8000.

2. Configure Your Client Manually

Claude Code (Terminal CLI)

export ANTHROPIC_BASE_URL="http://127.0.0.1:8000"
claude

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    api_key="your-api-key",
    base_url="http://127.0.0.1:8000/v1"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "How do I configure CORS headers in FastAPI?"}]
)
print(response.choices[0].message.content)

Key Features

  • Deterministic Git-Aware Tool Replay:
    • Intercepts and caches idempotent agent tools (git_status, git_diff, read_file, grep_search, list_dir).
    • Cryptographically fingerprinted against git rev-parse HEAD and git status --porcelain.
    • Modifying files or changing branches instantly invalidates stale results with zero false positives.
  • Dual-Tier Cache Engine:
    • L1 Exact Match (Trie Hash / Redis): Sub-0.05ms lookup for identical request payloads.
    • L2 FastHash Semantic Match: In-memory 512-d hyperplane locality-sensitive hashing for syntactically varied queries without external vector DB dependencies.
  • Stream Replayer with Terminal Jitter:
    • Delivers cached SSE streams with natural human-like cadence (~65 tok/s) and <10ms Time-To-First-Token (TTFT) for seamless CLI rendering.
  • Model Context Protocol (MCP) Remote Server:
    • Native /mcp JSON-RPC 2.0 endpoint allowing Claude Code, Cursor, and IDEs to discover and invoke omnicache_replay_tool and omnicache_record_tool.
  • SingleFlight Request Coalescing:
    • Deduplicates concurrent in-flight requests for identical prompts, forwarding only one upstream call.
  • Horizontal Scaling with Redis:
    • Connect to Redis (REDIS_URL="redis://127.0.0.1:6379/0") for shared team memory and multi-worker clusters.
  • Configurable Business Tool Policies & Mutation Guard:
    • Define per-tool dynamic TTLs (tool_policies_records), auto-detect idempotent prefixes (read, view, get, query, check), and strictly block non-idempotent mutation tools (write, delete, pay, charge, execute).
  • Multi-Agent Workspace Sync & CI/CD Cache Warming:
    • Pre-warm workspace repository structures, files, git status, and diffs during CI/CD before coding agent loops run.
    • Export, import, and sync cache snapshots across team members and multi-agent sessions via portable JSON archives or Redis.
  • Explainability Headers:
    • Transparent X-OmniCache-Decision (HIT | MISS), X-Tokens-Saved, and X-Cost-Avoided-USD response headers.

Built-in CLI Utilities

# Check database, port bindings, and vector engine health
omnicache doctor

# Run high-speed micro-benchmarks on your machine
omnicache benchmark

# Pre-warm repository cache for Claude Code or agent sessions
omnicache warm --dir . --max-files 100

# Multi-agent team sync: export, import, push, pull, or check sync status
omnicache sync status
omnicache sync export --output snapshot.json
omnicache sync import --input snapshot.json
omnicache sync push   # Push workspace snapshot to shared Redis
omnicache sync pull   # Pull workspace snapshot from shared Redis

# Print cumulative token and USD savings
omnicache stats

Observability & Diagnostics

  • Web Dashboard & Visualizer: http://localhost:8000/dashboard (features real-time savings velocity timeline and resolution distribution charts powered by Chart.js)
  • Prometheus Metrics: http://localhost:8000/metrics
  • Cache Statistics: http://localhost:8000/v1/cache/stats
  • CSV Export: http://localhost:8000/v1/cache/export

Documentation


License

MIT License. See LICENSE for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

omnicache_proxy-2.9.0.tar.gz (141.7 kB view details)

Uploaded Source

Built Distribution

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

omnicache_proxy-2.9.0-py3-none-any.whl (105.8 kB view details)

Uploaded Python 3

File details

Details for the file omnicache_proxy-2.9.0.tar.gz.

File metadata

  • Download URL: omnicache_proxy-2.9.0.tar.gz
  • Upload date:
  • Size: 141.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for omnicache_proxy-2.9.0.tar.gz
Algorithm Hash digest
SHA256 f1f1e3bcb3c62e42727f5f7f16e79a9426db316ec43e0f8645ab8c23284d155e
MD5 a76cf097dea2c97ee4e0f247da892eb9
BLAKE2b-256 335cb89a129d6fa0a43f045f2b304bf8fda13077090ae3ca8930290942807029

See more details on using hashes here.

File details

Details for the file omnicache_proxy-2.9.0-py3-none-any.whl.

File metadata

File hashes

Hashes for omnicache_proxy-2.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9f0f22fe9983da9d3ed1491fd274ed811ab8a2632bba0612fab64dc5e719b6b
MD5 da3486fcc1589af0262de2499cdc0119
BLAKE2b-256 2c903e8cd61c1ed362bbae32336d2ff214233d63fa1c21f59c3cc1d35d7df368

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.9.0 This release

2 files

2.8.0

2 files

2.7.2

2 files

2.7.1

2 files

2.7.0

2 files

2.6.8

2 files

2.6.7

2 files

2.6.6

2 files

2.6.5

2 files

2.6.4

2 files

2.6.3

2 files

2.6.2

2 files

2.6.1

2 files

2.6.0

2 files

2.5.9

2 files

2.5.8

2 files

2.5.7

2 files

2.5.6

2 files

2.5.5

2 files

2.5.4

2 files

2.5.3

2 files

2.5.2

2 files

2.5.1

2 files

2.5.0

2 files

2.3.0

2 files

2.2.1

2 files

2.2.0

2 files

2.1.4

2 files

2.1.3

2 files

2.1.2

2 files

2.1.1

2 files

2.1.0

2 files

2.0.5

2 files

2.0.4

2 files

2.0.3

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page