SDK Vector Module

Use @hostfunc/sdk/vector for vector CRUD and retrieval workflows.

SDK API Reference

upsert

await upsert(namespace: string, vectors: VectorRecord[]): Promise<UpsertResult>

Insert or update vectors and metadata in a namespace.

Returns

UpsertResult with namespace + upserted count.

query

await query(namespace: string, embedding: number[], options?: { topK?: number; includeValues?: boolean }): Promise<QueryResult>

Execute similarity search against the namespace.

Returns

QueryResult containing ranked matches.

deleteVectors

await deleteVectors(namespace: string, ids: string[]): Promise<DeleteResult>

Delete vectors by id from a namespace.

Returns

DeleteResult with namespace + deleted count.

getNamespace

const ns = getNamespace(namespace: string)

Create a scoped helper object with upsert/query/delete bound to one namespace.

Returns

{ upsert(vectors), query(embedding, options), deleteVectors(ids) } helper object.

SDK Code Examples

Embedding + semantic query

Create embeddings with AI module and search nearest matches.

typescript
import { createEmbedding } from "@hostfunc/sdk/ai";import { upsert, query } from "@hostfunc/sdk/vector";const { embedding } = await createEmbedding("customer profile text");await upsert("profiles", [{ id: "cus_123", values: embedding }]);const results = await query("profiles", embedding, { topK: 5 });

Best Practices

  • Use stable namespace names by domain (profiles, docs, incidents, etc.).
  • Store lightweight metadata for filtering and downstream display.
  • Tune topK based on latency/quality trade-offs for each workload.
  • Configure vector backends in integrations settings before production usage.

Related Documentation