Skip to main content

Python client, SDK middleware, and framework integrations for ferrocache — a distributed semantic cache for LLM applications

Project description

ferrocache

Python client, SDK middleware, and framework integrations for ferrocache — a distributed semantic cache for LLM applications written in Rust.

Install

pip install ferrocache                    # base client (zero deps)
pip install ferrocache[openai]            # + OpenAI middleware
pip install ferrocache[anthropic]         # + Anthropic middleware
pip install ferrocache[langchain]         # + LangChain cache backend
pip install ferrocache[llamaindex]        # + LlamaIndex LLM wrapper
pip install ferrocache[mcp]               # + MCP server for Claude Desktop
pip install ferrocache[all]               # everything

Quick start

from ferrocache import FerrocacheClient

client = FerrocacheClient("http://localhost:3000")
client.insert(embedding=[0.1, 0.2, 0.3], response="cached answer", query_text="my query")
hit = client.query(embedding=[0.1, 0.2, 0.3], threshold=0.92)

SDK middleware (one-line integration)

from openai import OpenAI
from ferrocache.middleware import wrap_openai

client = wrap_openai(OpenAI())  # all chat completions now check cache first
from anthropic import Anthropic
from ferrocache.middleware import wrap_anthropic

client = wrap_anthropic(Anthropic())

Framework integration

# LangChain
from langchain.globals import set_llm_cache
from ferrocache.langchain import FerrocacheCache
set_llm_cache(FerrocacheCache())
# LlamaIndex
from llama_index.llms.openai import OpenAI
from ferrocache.llamaindex import FerrocacheLLM
llm = FerrocacheLLM(inner=OpenAI(model="gpt-4o-mini"))

MCP server (Claude Desktop / Claude Code)

pip install ferrocache[mcp]
python3 -m ferrocache.mcp_server

Three tools — semantic_cache_lookup, semantic_cache_store, cache_status — accept text and embed locally before talking to the cache. See the setup guide for Claude Desktop / Claude Code config.

Configuration

Env var Default Used by
FERROCACHE_URL http://localhost:3000 middleware, frameworks
FERROCACHE_THRESHOLD 0.92 middleware, frameworks
FERROCACHE_EMBED_MODEL all-MiniLM-L6-v2 MCP server

All wrappers default to fail_open=True — a cache outage falls through to the real call rather than crashing.

See the main repo for the Rust server, benchmarks, and full architecture docs.

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

ferrocache-1.0.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

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

ferrocache-1.0.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file ferrocache-1.0.0.tar.gz.

File metadata

  • Download URL: ferrocache-1.0.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ferrocache-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6796a324a3364d14a90ac744c9477fe4778ba7e19e500e69d4ea6e79ecf2e8a2
MD5 0a4f16934f10415004cb77507d801aba
BLAKE2b-256 eb7e2b3196fdcde5cda7f47cdc844ba502f98b81f931639d61ea246730d1fd58

See more details on using hashes here.

Provenance

The following attestation bundles were made for ferrocache-1.0.0.tar.gz:

Publisher: release.yml on nickleodoen/ferrocache

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ferrocache-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ferrocache-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ferrocache-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6ee64951eaa03c9f68e4f63d28e309a80f57029411012ce9781629b1dc18ce88
MD5 490e7c0b18e4bc354dda534d24de8a88
BLAKE2b-256 41a8b829bb5940ca071935eba7f44038bd95d5d8e27e4d0ff22c6e91a071a732

See more details on using hashes here.

Provenance

The following attestation bundles were made for ferrocache-1.0.0-py3-none-any.whl:

Publisher: release.yml on nickleodoen/ferrocache

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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