# KV and vector

> KV is a managed Valkey store with Redis-compatible access and an HTTP route. Vector search runs in Postgres with pgvector. These are separate services: KV is not a vector database.

Source: https://docs.infaris.com/en/pulseguard/hosting-kv-vector

## What it is

KV is a managed Valkey store with Redis-compatible access and an HTTP route. Vector search runs in Postgres with pgvector. These are separate services: KV is not a vector database.

## Quick start and CLI

```bash
infaris-guard hosting kv create --name cache
infaris-guard hosting kv link <kvId> --site <siteId>
infaris-guard hosting kv show <kvId>
infaris-guard hosting db extensions enable <databaseId> vector
infaris-guard hosting db vector create <databaseId> --table documents --dimensions 1536 --metric cosine --dry-run
bun add @infaris/kv
```

## SDK and code

```ts
import { Kv } from '@infaris/kv';
const kv = Kv.fromEnv(); // KV_REST_API_URL and KV_REST_API_TOKEN, server only
await kv.set('greeting', 'hallo', { ex: 60 });
console.log(await kv.get<string>('greeting'));
// Use a parameterised Postgres query for vector operations, not a KV command.
```

## Secure defaults

Keep KV tokens on the server. The SDK refuses browser use. Use a read-only token when writes are unnecessary. TCP access needs network configuration. Vector tables follow the same RLS and exposure rules as other tables.

## Limits

KV starts with 256 MiB memory. Eviction and persistence determine behaviour on memory pressure or restart. The HTTP route accepts at most 1 MiB per body and 1,000 commands per batch. pgvector depends on the host image; match dimensions to your embedding model.

## FAQ

**Keep a Redis client?** Test your commands and connection route; dangerous management commands are blocked. **Generate embeddings?** Use a model provider, optionally through [AI Gateway](hosting-ai-gateway); pgvector stores and searches vectors.
