# Connecting and SDKs

> The 12 official client libraries, install commands, and AI framework integrations.

URL: https://docs.hotkv.com/sdks/


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](https://www.apache.org/licenses/LICENSE-2.0), and
their source is on [GitHub](https://github.com/hotkv-ltd).

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](https://docs.hotkv.com/ai-features/index.md).

Against a [cluster](https://docs.hotkv.com/clustering/index.md), use an SDK's cluster client or a cluster-aware
Redis library: see [Cluster clients](https://docs.hotkv.com/clustering/clients/index.md) 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.

## Quick start

**Python**

```bash
pip install hotkv-client
```

```python
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.

**Node.js**

```bash
npm install @hotkv/client
```

```ts
import { HotKV } from "@hotkv/client";

const client = new HotKV({ url: "hotkv://127.0.0.1:6379" });
await client.set("greeting", "hello");
console.log(await client.get("greeting"));
await client.close();
```

Written in TypeScript with full `.d.ts` types; ships as both ESM and
CommonJS.

**Go**

```bash
go get github.com/hotkv-ltd/hotkv-go-client
```

```go
package main

import (
    "context"
    "fmt"
    "time"

    hotkv "github.com/hotkv-ltd/hotkv-go-client"
)

func main() {
    client, _ := hotkv.NewClient(&hotkv.Options{Addr: "localhost:6379"})
    defer client.Close()

    ctx := context.Background()
    client.Set(ctx, "key", "value", 60*time.Second)
    val, _ := client.Get(ctx, "key").Result()
    fmt.Println(val)
}
```

**Rust**

```toml
[dependencies]
hotkv-client = "1"
# For TLS (hotkvs:// / rediss://), use this line instead:
# hotkv-client = { version = "1", features = ["tls"] }
# The example below also needs a Tokio runtime:
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
```

```rust
use hotkv::Client;

#[tokio::main]
async fn main() -> hotkv::Result<()> {
    let client = Client::connect("hotkv://127.0.0.1:6379").await?;
    client.set("greeting", "hello").await?;
    let value: Option<String> = client.get("greeting").await?;
    println!("{value:?}");
    Ok(())
}
```

The crate is named `hotkv-client` on crates.io and imported as `hotkv`. A blocking
wrapper (`hotkv::blocking::BlockingClient`) is available for callers outside a
Tokio runtime.

**Java**

```xml
<dependency>
  <groupId>com.hotkv</groupId>
  <artifactId>hotkv-client</artifactId>
  <version>1.0.0</version>
</dependency>
```

```java
import com.hotkv.HotKV;

try (HotKV client = HotKV.create("hotkv://localhost:6379")) {
    client.set("greeting", "hello, HotKV");
    System.out.println(client.get("greeting"));
}
```

Zero runtime dependencies: built only on the JDK. Requires Java 17+.

**C#**

```bash
dotnet add package HotKV.Client
```

```csharp
using HotKV;
using HotKV.Commands;

await using var client = await HotKVClient.ConnectAsync("hotkv://localhost:6379");
await client.StringSetAsync("greeting", "hello from .NET");
Console.WriteLine(await client.StringGetAsync("greeting"));
```

Targets `net8.0` and `netstandard2.1`.

**Ruby**

```ruby
gem "hotkv"
```

```ruby
require "hotkv"

client = HotKV::Client.new(url: "hotkv://localhost:6379")
client.set("greeting", "hello")
puts client.get("greeting")
client.close
```

Requires Ruby 3.0 or newer; zero runtime dependencies beyond Ruby's own
standard library.

**PHP**

```bash
composer require hotkv/client
```

```php
<?php
require __DIR__ . '/vendor/autoload.php';

use HotKV\Client;

$client = new Client('hotkv://127.0.0.1:6379');
$client->set('greeting', 'hello from HotKV');
echo $client->get('greeting');
$client->close();
```

Pure PHP, zero runtime dependencies, requires PHP 8.1+.

**Elixir**

```elixir
def deps do
  [{:hotkv, "~> 1.0"}]
end
```

```elixir
{:ok, conn} = HotKV.start_link(url: "hotkv://127.0.0.1:6379")

{:ok, "OK"} = HotKV.command(conn, ["SET", "greeting", "hello"])
{:ok, "hello"} = HotKV.command(conn, ["GET", "greeting"])
```

**Perl**

```bash
curl -L https://github.com/hotkv-ltd/hotkv-perl-client/archive/refs/heads/main.tar.gz | tar xz
cd hotkv-perl-client-main
perl Makefile.PL && make && make install
```

```perl
use HotKV;

my $kv = HotKV->new(url => 'hotkv://127.0.0.1:6379');
$kv->set('greeting', 'hello world');
print $kv->get('greeting'), "\n";
$kv->close;
```

Zero mandatory runtime dependencies beyond core Perl 5.16+ modules;
`IO::Socket::SSL` is only required for TLS connections.

**C**

```bash
curl -L https://github.com/hotkv-ltd/hotkv-c-client/archive/refs/tags/v1.0.0.tar.gz | tar xz
cd hotkv-c-client-1.0.0
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DHOTKV_BUILD_TESTS=OFF -DHOTKV_BUILD_EXAMPLES=OFF
cmake --build build
cmake --install build --prefix /usr/local
```

```c
#include <hotkv.h>

int main(void) {
    hotkv_context_t *ctx = hotkv_connect("127.0.0.1", 6379);
    hotkv_reply_t *reply = hotkv_set(ctx, "key", 3, "value", 5);
    hotkv_free_reply(reply);
    reply = hotkv_get(ctx, "key", 3);
    hotkv_free_reply(reply);
    hotkv_disconnect(ctx);
    return 0;
}
```

The library is built from source, as shown. Then compile with `cc -o myapp myapp.c -lhotkv`, or with
`pkg-config --cflags --libs libhotkv`. Configure with `-DHOTKV_USE_SSL=ON`
for TLS support. Requires a C11 compiler.

**C++**

```bash
curl -L https://github.com/hotkv-ltd/hotkv-cpp-client/archive/refs/tags/v1.0.0.tar.gz | tar xz
cd hotkv-cpp-client-1.0.0
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DHOTKV_CPP_BUILD_TESTS=OFF
cmake --build build
cmake --install build --prefix /usr/local
```

```cmake
find_package(hotkv-cpp CONFIG REQUIRED)
target_link_libraries(myapp PRIVATE hotkv::hotkv-cpp)
```

```cpp
#include <hotkv/hotkv.hpp>

int main() {
    hotkv::Client client = hotkv::Client::connect("hotkv://127.0.0.1:6379");
    client.set("greeting", "hello, hotkv");
    auto value = client.get("greeting");
}
```

Requires C++20. TLS uses OpenSSL and is built in by default when OpenSSL
is found (`-DHOTKV_CPP_WITH_TLS=OFF` leaves it out).

## Framework integrations

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](https://docs.hotkv.com/ai-features/index.md). The Python examples below use a
`client` created as in the Python tab of the [Quick start](#quick-start); the framework
packages themselves (`langchain-core`, `llama-index-core`, `litellm`) come
with the matching extra.

### LangChain (Python)

```bash
pip install "hotkv-client[langchain]"
```

```python
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`.

### LlamaIndex (Python)

```bash
pip install "hotkv-client[llamaindex]"
```

```python
from hotkv.integrations.llama_index import HotKVVectorStore

vector_store = HotKVVectorStore(client, index_name="docs", dims=1536)
```

Also included: `HotKVKVStore` and `HotKVChatStore`.

### LiteLLM (Python)

```bash
pip install "hotkv-client[litellm]"
```

```python
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.

### Vercel AI SDK (Node.js)

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.

```ts
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.

### LangChain.js (Node.js)

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

```ts
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.

## Next steps

- [AI features guide](https://docs.hotkv.com/ai-features/index.md)
- [MCP server](https://docs.hotkv.com/ai/mcp-server/index.md), the
  [LangGraph checkpointer and store](https://docs.hotkv.com/ai/langgraph/index.md) and the
  [caching gateway](https://docs.hotkv.com/ai/gateway/index.md) for AI assistants and agents
- [Command reference](https://docs.hotkv.com/commands/index.md)
- [Security](https://docs.hotkv.com/security/index.md) for TLS certificate options