Docs

JavaScript: Vectors and embeddings

Turn text into embeddings, store vectors with metadata and run similarity search with @sovaria/sdk.

Updated Nov 11, 2026

sovaria.vector stores embeddings in collections and finds the nearest ones to a query — the building block for semantic search and retrieval-augmented generation.

await sovaria.vector.upsert('articles', [
  { id: 'a1', text: 'How to reset your password', metadata: { lang: 'en' } },
  { id: 'a2', text: 'Exporting invoices as PDF', metadata: { lang: 'en' } },
])

const hits = await sovaria.vector.search('articles', 'forgot my login', { topK: 3, metadataFilter: { lang: 'en' } })

#sovaria.vector

sovaria.vector.embed

Embed.

sovaria.vector.embed(
  texts: string[],
): Promise<{ vectors: number[][]; dim: number; count: number; }>

Parameters

textsstring[]required
Texts to embed.

Returns

Promise<{ vectors: number[][]; dim: number; count: number; }> — { vectors } — one array of numbers per text.

{
  "vectors": [
    [
      0.012,
      -0.044,
      "…"
    ],
    [
      0.031,
      0.007,
      "…"
    ]
  ],
  "dim": 1536,
  "count": 2,
  "model": "openai/text-embedding-3-small@1536"
}

sovaria.vector.upsert

Upsert.

sovaria.vector.upsert(
  collection: string,
  docs: Array<{ id?: string; text: string; metadata?: JsonObject }>,
): Promise<JsonObject>

Parameters

collectionstringrequired
Collection name.
docsArray<{ id?: string; text: string; metadata?: JsonObject }>required
[{ id?, text, metadata? }]; texts are embedded for you.

Returns

Promise<JsonObject>

{
  "inserted": 2,
  "updated": 0,
  "dim": 1536,
  "size": 2
}

sovaria.vector.setCollection

Collection settings (team / service key): appSearch lets the project's apps search it.

sovaria.vector.setCollection(
  collection: string,
  settings: { appSearch?: boolean },
): Promise<JsonObject>

Parameters

collectionstringrequired
settings{ appSearch?: boolean }required

Returns

Promise<JsonObject>

{
  "collection": "help-articles",
  "settings": {
    "app_search": true
  }
}

sovaria.vector.listCollections

List collections.

sovaria.vector.listCollections(): Promise<JsonObject>

Returns

Promise<JsonObject>

{
  "collections": [
    {
      "name": "help-articles",
      "dim": 1536,
      "size": 2,
      "model": "openai/text-embedding-3-small@1536",
      "app_search": false
    }
  ],
  "model": "openai/text-embedding-3-small@1536",
  "semantic": true
}

sovaria.vector.listRecords

List records.

sovaria.vector.listRecords(
  collection: string,
  options?: { limit?: number; offset?: number } = {},
): Promise<JsonObject>

Parameters

collectionstringrequired
options{ limit?: number; offset?: number }optionaldefault {}

Returns

Promise<JsonObject>

{
  "collection": "help-articles",
  "dim": 1536,
  "total": 2,
  "records": [
    {
      "id": "a1",
      "text": "How to reset your password",
      "metadata": {
        "lang": "en"
      }
    }
  ]
}

sovaria.vector.deleteRecord

Delete record.

sovaria.vector.deleteRecord(
  collection: string,
  recordId: string,
): Promise<JsonObject>

Parameters

collectionstringrequired
recordIdstringrequired

Returns

Promise<JsonObject>

sovaria.vector.deleteCollection

Delete collection.

sovaria.vector.deleteCollection(collection: string): Promise<JsonObject>

Parameters

collectionstringrequired

Returns

Promise<JsonObject>