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
| Package | Registry | Install | Status |
|---|---|---|---|
| klyro-db 0.1.1 | npm | npm install klyro-db | Published |
| klyro-db 0.1.1 | PyPI | pip install klyro-db | Published |
| klyro/go | Go source module | go get github.com/Hitesh-s0lanki/klyro/go | Typed client |
| redis-rs | crates.io | cargo add redis | Raw 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
Client options
| Option | Type | Default | Meaning |
|---|---|---|---|
| host | string | 127.0.0.1 | Klyro server host |
| port | number | 7171 | Klyro server port |
| lazyConnect | boolean | false | Wait for client.connect() before opening the socket |
| connectTimeout | number | 10000 | ioredis connection timeout in milliseconds |
| retryStrategy | function | ioredis default | Controls 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
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
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
| Library | Function | What it does |
|---|---|---|
| TypeScript / JavaScript | createClient(options?) | Creates an ioredis client for 127.0.0.1:7171 by default and attaches memory plus memoryBuffer. It does not launch Klyro. |
| Python | Klyro(host='127.0.0.1', port=7171, **kwargs) | Creates a redis.Redis subclass, forces binary replies so vectors remain intact, and attaches memory. |
| Go | NewClient(options) | Creates a go-redis client. Nil options, or options with an empty address, use 127.0.0.1:7171. |
| Go | Wrap(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.
| TypeScript | Python | Go | Purpose |
|---|---|---|---|
| create | create | Create | Create a SEARCH, VECTOR, or HYBRID index. VECTOR and HYBRID require a dimension; returns OK or an error. |
| info | info | Info | Return mode, dimension, metric, weights, half-life, record/vector/term counts, average document length, and estimated bytes. |
| config | config | Config | Change weights, half-life, or both. At least one change is required; returns OK or an error. |
| card | card | Card | Return the number of live, non-expired records in the index. |
| add | add | Add | Insert or replace a record and return its ID. Accepts text, optional ID/vector/metadata/importance/TTL, and NX or XX. |
| get | get | Get | Return one decoded record, or null/None/nil when its ID is missing. Return flags can include metadata or the vector and omit text. |
| mget | mget | MGet | Return records in the requested ID order, retaining a null/None/nil entry for every missing ID. |
| del | delete | Delete | Delete one or more records and return the number removed. At least one ID is required. |
| setMeta | set_metadata | SetMetadata | Set one or more metadata fields and return how many fields were newly added. The metadata collection cannot be empty. |
| delMeta | delete_metadata | DeleteMetadata | Remove one or more metadata fields and return how many existed. At least one field is required. |
| expire | expire | Expire | Set a record TTL in seconds and return whether the record exists. Zero clears its deadline. |
| scan | scan | Scan | Page through record IDs with an optional count and filters. Returns a cursor and IDs; stop when the cursor is 0. |
| search | search | Search | Run BM25 keyword retrieval with optional top-K, filters, return flags, and component scores. |
| vsearch | vector_search | VectorSearch | Run exact vector retrieval with the index metric and the same retrieval options as search. |
| query | query | Query | Run text, vector, or hybrid retrieval. Accepts query-level weights and LINEAR or RRF fusion; text or vector is required. |
Options shared by the functions
| Concept | TypeScript | Python | Go | Behavior |
|---|---|---|---|---|
| Create | MemoryCreateOptions | MemoryCreate | CreateOptions | Mode, dimension, metric, optional weights, and recency half-life in seconds. |
| Configure | MemoryConfigOptions | MemoryConfig | ConfigOptions | New weights and/or half-life. Existing records are not rewritten. |
| Add | MemoryAddOptions | MemoryAdd | AddOptions | Text is required. ID, vector, metadata, importance, record TTL, and NX/XX are optional. |
| Return flags | MemoryReturnOptions | MemoryReturn | ReturnOptions | NOTEXT, WITHMETA, and WITHVEC control the fields returned for records. |
| Search | MemorySearchOptions | MemorySearch | SearchOptions | Adds top-K, repeated AND filters, and WITHSCORES to the return flags. |
| Query | MemoryQueryOptions | MemoryQuery | QueryOptions | Adds text/vector inputs, per-query weights, and fusion to search options. |
| Scan | MemoryScanOptions | MemoryScan | ScanOptions | Controls the requested page count and optional repeated AND filters. |
| Weights | MemoryWeights | Weights | Weights | Keyword, vector, recency, and importance values are sent in that order. |
| Filter | MemoryFilter | Filter | Filter | Field, operator, and value. Operators are EQ, NE, GT, GTE, LT, LTE, IN, and CONTAINS. |
Decoded result types
| Result | Fields and behavior |
|---|---|
| MemoryInfo | Index configuration and live statistics. Half-life is in seconds; avg_doc_len is numeric; bytes is an estimate. |
| MemoryRecord | ID, optional text, importance, created/updated timestamps, remaining pttl, and optionally metadata/vector. |
| MemoryHit | A MemoryRecord plus the final score. WITHSCORES adds keyword_score, vector_score, and recency_score. |
| MemoryScanResult / ScanResult | A string cursor and the current page of record IDs. |
Record ttl, expire, and index half-life inputs use seconds. Returned created_at, updated_at, and pttl values use milliseconds. A pttl of -1 means the record has no deadline.
Creating a client opens a connection; it does not start Klyro. Run the server with npx klyro-db, Docker, or the native binary first. The npm package also includes the server launcher; the PyPI wheel and Go module are client libraries.
What an SDK adds over raw commands
- Typed records. Metadata as an object rather than repeated
META field valuetriples. - Vector marshalling. A number array becomes float32 bytes without you reaching for
struct.packorFloat32Array. - Parsed results.
WITHSCOREScomes 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
NXandXXfailures are server errors, not null results.MEM.MGETpreserves input order and returns null entries for missing IDs.MEM.SCANreturns a cursor; continue until it is"0".NOTEXTomits text. Metadata and vectors are only present when requested.- Memory helpers issue individual commands. Use the underlying client for pipelines or transactions.
The SDKs are ergonomics. Every capability is reachable over RESP with the client you already have, and will stay that way.
