Skip to main content

hypercache (Python SDK)

Python client for the HyperCache API. Zero runtime dependencies (stdlib only).

Install

pip install hypercache-kv
export HYPERCACHE_KEY=hck_...

Get a key at hypercache.ai.

Pipeline

Cache, records, and stats in one context:

from hypercache.workflows import Pipeline

with Pipeline("my_pipeline") as p:
    answer, was_hit = p.cached(
        label="gpt_call",
        input_bytes=prompt.encode("utf-8"),
        compute=lambda: call_openai(prompt),
    )
    p.record("output", answer.encode("utf-8"))

print(f"{p.report.n_hits} hits / {p.report.n_misses} misses")

Cache an expensive call

import hypercache

result = hypercache.cache_lookup(b"some input bytes")
if result.hit:
    print(result.value)
else:
    hypercache.cache_put(result.fingerprint_hex, b"my expensive output", ttl=3600)

results = hypercache.cache_lookup_batch([b"in 1", b"in 2", b"in 3"])

Wrap your LLM client

from openai import OpenAI
from hypercache.workflows import wrap_openai

client = wrap_openai(OpenAI())
resp = client.chat.completions.create(model="gpt-4o-mini", messages=[...])

wrap_anthropic does the same for the Anthropic SDK.

Records

import hypercache

fp = hypercache.fingerprint(b"any bytes")
print(fp.record_hex)

Link records to a prior one:

from hypercache.workflows import audit_chain

with audit_chain() as chain:
    r1 = chain.fingerprint(input_bytes)
    r2 = chain.fingerprint(model_output)
    r3 = chain.fingerprint(reviewer_note)

License

MIT. See LICENSE.

Metadata

Release files for hypercache-kv 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hypercache-kv 0.1.2
File Size Uploaded Provenance Actions
hypercache_kv-0.1.2.tar.gz 18.1 kB Without provenance Details for hypercache_kv-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hypercache-kv 0.1.2
File Interpreter ABI Platform Actions
hypercache_kv-0.1.2-py3-none-any.whl Python 3 none any Details for hypercache_kv-0.1.2-py3-none-any.whl

Total release size: 36.1 kB

Release files / hypercache_kv-0.1.2.tar.gz

Download URL hypercache_kv-0.1.2.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
980a22c4cee1c912bbcbfb576d592ab54885f4df78d4c76b7ef3aa5ecaf0fdc4
BLAKE2b-256 checksum
How to use checksums
c28798bd1bdadddd3380e3eeb572e8a8ff63c66b1f48d3f5d233f828e680d2b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / hypercache_kv-0.1.2-py3-none-any.whl

Download URL hypercache_kv-0.1.2-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
825ebe7505516cb61a008eff1cab41fa350917c976d4135f3b30fdbca63e278d
BLAKE2b-256 checksum
How to use checksums
f5352feb13d73fb782f0f63603076128da382299e743d703836e5dfd99a91777
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Security for hypercache-kv 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

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