Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

Connecting and SDKs

Last updated

HotKV ships 12 official client SDKs. Each one covers the standard commands and adds typed helpers for the HotKV-exclusive and AI/enterprise commands. The SDKs are open source under the Apache License 2.0, and their source is on GitHub.

Because HotKV speaks RESP2/RESP3, any Redis-compatible client library also works against it unchanged, for standard commands; reach for a HotKV SDK when you also want typed access to HotKV-exclusive commands (TAG.*, VSIM.*, NEXPIRE, …) and the AI/LLM commands covered in the AI features guide.

Against a cluster, use an SDK’s cluster client or a cluster-aware Redis library: see Cluster clients for the supported ones and for the SDKs that have a cluster class.

Most SDKs accept either explicit options (host, port, username, password) or a connection URL: hotkv:// for a plain connection, hotkvs:// for TLS, and, for drop-in migration, redis:///rediss://. See each SDK’s own TLS options for certificate and mutual-TLS configuration.

Terminal window
pip install hotkv-client
import hotkv
client = hotkv.HotKV(host="localhost", port=6379)
client.set("greeting", "hello")
print(client.get("greeting")) # b"hello"
client.close()

The package is installed as hotkv-client and imported as hotkv. An asyncio client is available as hotkv.asyncio.HotKV, mirroring the sync client method for method.

The Python and Node.js SDKs ship integrations for the AI frameworks teams already build with, on top of the same prompt cache (PCACHE) and semantic cache (SCACHE) covered in the AI features guide. The Python examples below use a client created as in the Python tab of the Quick start; the framework packages themselves (langchain-core, llama-index-core, litellm) come with the matching extra.

Terminal window
pip install "hotkv-client[langchain]"
from langchain_core.globals import set_llm_cache
from hotkv.integrations.langchain import HotKVCache
set_llm_cache(HotKVCache(client, namespace="chat-responses", ttl=3600))

Also included: HotKVSemanticCache (caches by embedding similarity), HotKVVectorStore (a VectorStore backed by VSIM.*), and HotKVChatMessageHistory.

Terminal window
pip install "hotkv-client[llamaindex]"
from hotkv.integrations.llama_index import HotKVVectorStore
vector_store = HotKVVectorStore(client, index_name="docs", dims=1536)

Also included: HotKVKVStore and HotKVChatStore.

Terminal window
pip install "hotkv-client[litellm]"
import litellm
from hotkv.integrations.litellm import HotKVCache
litellm.cache = litellm.Cache()
litellm.cache.cache = HotKVCache(client, namespace="litellm-cache")

LiteLLM’s own built-in litellm.Cache(type="redis", ...) also works against HotKV unchanged for exact-match caching, since HotKV speaks the Redis wire protocol. Reach for this integration when you also want semantic caching (HotKVSemanticCache, in the same module), or want caching to keep working on a plan or license without the prompt cache feature: HotKVCache falls back to plain GET/SET there.

Ships in the @hotkv/client npm package as @hotkv/client/ai-sdk. Install the AI SDK itself (ai, version 5 or newer) and your model provider package alongside it.

import { wrapLanguageModel, generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { HotKV } from "@hotkv/client";
import { hotkvCache } from "@hotkv/client/ai-sdk";
const client = new HotKV({ url: "hotkv://127.0.0.1:6379" });
const model = wrapLanguageModel({
model: openai("gpt-4o"),
middleware: hotkvCache({ client, ttlSeconds: 3600 }),
});
const { text } = await generateText({ model, prompt: "Summarize this in one line." });

hotkvCache() is language model middleware for wrapLanguageModel(): it caches both generateText() results and streamText() streams.

Ships in the @hotkv/client npm package as @hotkv/client/langchain. Install @langchain/core and your model package alongside it.

import { HotKV } from "@hotkv/client";
import { HotKVCache } from "@hotkv/client/langchain";
import { ChatOpenAI } from "@langchain/openai";
const client = new HotKV({ url: "hotkv://127.0.0.1:6379" });
const model = new ChatOpenAI({
cache: new HotKVCache(client, { namespace: "chat-responses", ttlSeconds: 3600 }),
});

HotKVSemanticCache(client, embeddings, { threshold }) does the same by embedding similarity.