Skip to content

Integrations

SDKs & packages

The TypeScript, Python, and Go clients wrap every MEM.* command in a typed surface, while raw RESP remains available in any language.

Packages

PackageRegistryInstallStatus
klyro-db 0.1.1npmnpm install klyro-dbPublished
klyro-db 0.1.1PyPIpip install klyro-dbPublished
klyro/goGo source modulego get github.com/Hitesh-s0lanki/klyro/goTyped client
redis-rscrates.iocargo add redisRaw RESP client

npm provides the typed TypeScript client and native server launcher. PyPI provides the typed Python client. The repository's Go module wraps go-redis with typed memory methods. Other languages use raw commands; see client libraries.

TypeScript

terminal
npm install klyro-db@0.1.1
memory.ts
import { createClient } from "klyro-db";

const klyro = createClient();

await klyro.memory.create("user:123", { mode: "HYBRID", dim: 3 });
await klyro.memory.add("user:123", {
  text: "User prefers PostgreSQL for backend projects.",
  vector: [0.12, 0.81, 0.43],
  meta: { type: "preference" },
  importance: 0.85,
});

const hits = await klyro.memory.query("user:123", {
  text: "preferred database?",
  vector: [0.10, 0.79, 0.46],
  topK: 5,
});

Client options

OptionTypeDefaultMeaning
hoststring127.0.0.1Klyro server host
portnumber7171Klyro server port
lazyConnectbooleanfalseWait for client.connect() before opening the socket
connectTimeoutnumber10000ioredis connection timeout in milliseconds
retryStrategyfunctionioredis defaultControls reconnect timing

createClient() returns an ioredis client, so ordinary Redis methods retain their upstream types. Klyro's 15 memory commands live under client.memory. Use client.memoryBuffer when IDs, text, or metadata contain arbitrary bytes. Both memory surfaces encode number arrays and Float32Array values as little-endian float32 vectors; returned vectors are Float32Array values.

TypeScript result shapes

Records expose id, optional text, importance, millisecond created_at and updated_at timestamps, and pttl in milliseconds. Requested metadata is a Map. Search hits add score, while withScores adds the keyword, vector, and recency components.

Python

terminal
pip install klyro-db==0.1.1
memory.py
from klyro_db import Klyro, MemoryAdd, MemoryCreate, MemoryQuery

klyro = Klyro(host="localhost", port=7171)

klyro.memory.create("user:123", MemoryCreate(mode="HYBRID", dim=3))
klyro.memory.add("user:123", MemoryAdd(
    text="User prefers PostgreSQL for backend projects.",
    vector=[0.12, 0.81, 0.43],
    metadata={"type": "preference"},
    importance=0.85,
))

hits = klyro.memory.query("user:123", MemoryQuery(
    text="preferred database?",
    vector=[0.10, 0.79, 0.46],
    top_k=5,
))

Klyro subclasses redis-py's Redis, so standard commands remain available on the same object. Its memoryproperty provides typed dataclasses and decoded replies for every current MEM.* command. The distribution includes a py.typed marker for mypy, Pyright, and compatible editors. Vector sequences are encoded as little-endian float32 bytes and decoded to tuples. Timestamps and pttl are milliseconds; TTL and half-life inputs are seconds.

Go

terminal
go get github.com/Hitesh-s0lanki/klyro/go
memory.go
import klyro "github.com/Hitesh-s0lanki/klyro/go"

db := klyro.NewClient(nil)

db.Memory.Create(ctx, "user:123", klyro.CreateOptions{
  Mode: klyro.Hybrid,
  Dim: 3,
})
db.Memory.Add(ctx, "user:123", klyro.AddOptions{
  Text: "User prefers PostgreSQL for backend projects.",
  Vector: []float32{0.12, 0.81, 0.43},
})

hits, err := db.Memory.Query(ctx, "user:123", klyro.QueryOptions{
  Text: "preferred database?",
  Vector: []float32{0.10, 0.79, 0.46},
  SearchOptions: klyro.SearchOptions{TopK: 5},
})

NewClient embeds the go-redis universal client, so its standard commands remain available. Typed memory methods live under client.Memory. Use klyro.Wrap to add them to an existing go-redis client.

Go option zero values

Go uses zero values to mean “not supplied”: an empty mode defaults to HYBRID, an empty metric defaults to COSINE, and zero values for TopK, TTL, and HalfLife are omitted. Use pointers for optional importance and weights. Calling Expire(ctx, key, id, 0) is the explicit exception: it is sent to the server and clears a record deadline.

Client construction

LibraryFunctionWhat it does
TypeScript / JavaScriptcreateClient(options?)Creates an ioredis client for 127.0.0.1:7171 by default and attaches memory plus memoryBuffer. It does not launch Klyro.
PythonKlyro(host='127.0.0.1', port=7171, **kwargs)Creates a redis.Redis subclass, forces binary replies so vectors remain intact, and attaches memory.
GoNewClient(options)Creates a go-redis client. Nil options, or options with an empty address, use 127.0.0.1:7171.
GoWrap(client)Adds the typed Memory API to an existing redis.UniversalClient without creating another connection pool.

All typed memory functions

The names differ by language, but each row calls the same server command. TypeScript methods return promises; Python methods are synchronous; Go methods receive a context and return a value plus an error.

TypeScriptPythonGoPurpose
createcreateCreateCreate a SEARCH, VECTOR, or HYBRID index. VECTOR and HYBRID require a dimension; returns OK or an error.
infoinfoInfoReturn mode, dimension, metric, weights, half-life, record/vector/term counts, average document length, and estimated bytes.
configconfigConfigChange weights, half-life, or both. At least one change is required; returns OK or an error.
cardcardCardReturn the number of live, non-expired records in the index.
addaddAddInsert or replace a record and return its ID. Accepts text, optional ID/vector/metadata/importance/TTL, and NX or XX.
getgetGetReturn one decoded record, or null/None/nil when its ID is missing. Return flags can include metadata or the vector and omit text.
mgetmgetMGetReturn records in the requested ID order, retaining a null/None/nil entry for every missing ID.
deldeleteDeleteDelete one or more records and return the number removed. At least one ID is required.
setMetaset_metadataSetMetadataSet one or more metadata fields and return how many fields were newly added. The metadata collection cannot be empty.
delMetadelete_metadataDeleteMetadataRemove one or more metadata fields and return how many existed. At least one field is required.
expireexpireExpireSet a record TTL in seconds and return whether the record exists. Zero clears its deadline.
scanscanScanPage through record IDs with an optional count and filters. Returns a cursor and IDs; stop when the cursor is 0.
searchsearchSearchRun BM25 keyword retrieval with optional top-K, filters, return flags, and component scores.
vsearchvector_searchVectorSearchRun exact vector retrieval with the index metric and the same retrieval options as search.
queryqueryQueryRun text, vector, or hybrid retrieval. Accepts query-level weights and LINEAR or RRF fusion; text or vector is required.

Options shared by the functions

ConceptTypeScriptPythonGoBehavior
CreateMemoryCreateOptionsMemoryCreateCreateOptionsMode, dimension, metric, optional weights, and recency half-life in seconds.
ConfigureMemoryConfigOptionsMemoryConfigConfigOptionsNew weights and/or half-life. Existing records are not rewritten.
AddMemoryAddOptionsMemoryAddAddOptionsText is required. ID, vector, metadata, importance, record TTL, and NX/XX are optional.
Return flagsMemoryReturnOptionsMemoryReturnReturnOptionsNOTEXT, WITHMETA, and WITHVEC control the fields returned for records.
SearchMemorySearchOptionsMemorySearchSearchOptionsAdds top-K, repeated AND filters, and WITHSCORES to the return flags.
QueryMemoryQueryOptionsMemoryQueryQueryOptionsAdds text/vector inputs, per-query weights, and fusion to search options.
ScanMemoryScanOptionsMemoryScanScanOptionsControls the requested page count and optional repeated AND filters.
WeightsMemoryWeightsWeightsWeightsKeyword, vector, recency, and importance values are sent in that order.
FilterMemoryFilterFilterFilterField, operator, and value. Operators are EQ, NE, GT, GTE, LT, LTE, IN, and CONTAINS.

Decoded result types

ResultFields and behavior
MemoryInfoIndex configuration and live statistics. Half-life is in seconds; avg_doc_len is numeric; bytes is an estimate.
MemoryRecordID, optional text, importance, created/updated timestamps, remaining pttl, and optionally metadata/vector.
MemoryHitA MemoryRecord plus the final score. WITHSCORES adds keyword_score, vector_score, and recency_score.
MemoryScanResult / ScanResultA string cursor and the current page of record IDs.

What an SDK adds over raw commands

  • Typed records. Metadata as an object rather than repeated META field value triples.
  • Vector marshalling. A number array becomes float32 bytes without you reaching for struct.pack or Float32Array.
  • Parsed results. WITHSCORES comes back as a score object rather than a flat array to index by position.
  • Structured filters. Pass filter objects or dataclasses instead of assembling repeated protocol tokens. The server remains the authority for field, operator, and value validation.

Important behavior

  • NX and XX failures are server errors, not null results.
  • MEM.MGET preserves input order and returns null entries for missing IDs.
  • MEM.SCAN returns a cursor; continue until it is "0".
  • NOTEXT omits text. Metadata and vectors are only present when requested.
  • Memory helpers issue individual commands. Use the underlying client for pipelines or transactions.