Migration: RAG moved from the SDK to @qvac/rag. A standalone package for ingestion and retrieval.
QVAC Logo
RAGMigrate from the SDK RAG API
v0.12, the current release

Migrate from the SDK RAG API

Move from the SDK's built-in RAG workspaces to @qvac/rag, the vector index or the CLI vector stores.

What changed

@qvac/sdk 0.24.x is the last line with the built-in RAG API. Later versions remove it:

  • JavaScript/TypeScript: ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace and the ragTurbovec config.
  • Python: rag, rag_with_progress and the RagRequest types.
  • Kotlin: client.retrieval and the RagRequest types.

embed(), createVectorIndex() and loadVectorIndex() stay. A managed document store now lives in the standalone @qvac/rag package, and qvac serve openai vector stores are built on it.

Your route forward depends on the language:

Existing workspaces and CLI vector stores are not migrated — keep your source documents and ingest them again after upgrading. See Existing data.

Staying on the RAG API for now

If you are not ready to migrate, pin the last versions that include the built-in RAG API:

PackagePin
@qvac/sdk~0.24.0
tetherto-qvac-sdk (Python)~=0.24.0
@qvac/cli~0.20.0
Kotlin SDKthe Maven ZIPs on the sdk-v0.24.0 release

Existing data

Workspaces are not migrated, and the old API has no export, so keep your source documents and ingest them again after upgrading.

  • SDK workspaces stay on disk in rag-hyperdb/<workspace> and rag-turbovec/<workspace>, next to the SDK cacheDirectory (~/.qvac/rag-hyperdb by default; under $SNAP_USER_COMMON/.qvac in the Snap). Newer versions never read or delete them: keep them while you still run 0.24.x, then delete them by hand.
  • qvac serve openai vector stores up to CLI 0.20.x were SDK workspaces named after the store id, in the same folders. Later versions keep stores in serve/vector-stores next to the cacheDirectory. Upload the files again and attach them to new stores.

JavaScript and TypeScript: @qvac/rag

npm install @qvac/rag corestore

@qvac/rag runs on Bare and Node; on Bare, also install @qvac/turbovec-ggml 0.8 or later for indexed search. It stores documents in a Corestore you create and close, and gets vectors from an embeddings port you supply.

import Corestore from 'corestore'
import { createRag, type EmbeddingsPort } from '@qvac/rag'
import { embed, embedBatch, loadModel, GTE_LARGE_FP16 } from '@qvac/sdk'

const modelId = await loadModel({ modelSrc: GTE_LARGE_FP16 })

const port: EmbeddingsPort = {
  // Identifies the vectors; a namespace only accepts vectors from its space.
  space: {
    model: 'gte-large-fp16',
    revision: '1',
    dimensions: 1024,
    metric: 'cosine',
    normalized: false,
    documentEncoding: '',
    queryEncoding: '',
    preprocessing: 'none'
  },
  async embedDocuments(texts) {
    const { embedding } = await embedBatch({ modelId, inputs: texts })
    return Float32Array.from(embedding.flat())
  },
  async embedQuery(text) {
    const { embedding } = await embed({ modelId, input: text })
    return Float32Array.from(embedding)
  }
}

const corestore = new Corestore('./rag/docs') // locks its folder: one per folder per process
const rag = createRag({ corestore, embeddings: port, index: { dir: './rag/docs-index' } })
await rag.ready()
await rag.createNamespace({ name: 'docs', space: port.space })
await rag.ingest({ namespace: 'docs', documents: [{ id: 'intro', text }] })
const hits = await rag.search({ scope: { namespace: 'docs' }, query, k: 5 })
await rag.close()
await corestore.close()
  • The port can wrap any embedding function: another model, a remote API or your own code.
  • Without a port, ingest precomputed vectors and search with { vector, spaceId }.
  • Change space when the vectors change (model, revision, pooling); a namespace rejects vectors from another space.
  • On Node, @qvac/turbovec-ggml does not load, so every search scans all chunks unless you supply your own index through createRag({ index: { provider } }). Call indexStatus({ namespace }) to see which path a namespace is on. The scan suits small stores: at 100,000 chunks of 768 dimensions a scan takes about 1.3 s, against about 21 ms with the index on Bare. Past that, run @qvac/rag on Bare.
SDK function@qvac/rag
ragIngestingest({ namespace, documents: [{ id, text }] }); chunk options go to createRag({ chunking }), onProgress and signal to the second argument of ingest
ragSaveEmbeddingsingest with { id, spaceId, chunks: [{ content, embedding }] }; no port needed
ragChunkingest chunks text itself; for chunks alone, use rag-extract/chunk
ragSearchsearch({ scope: { namespace }, query, k })
ragDeleteEmbeddingsdeleteDocuments({ namespace, documentIds })
ragReindexnot needed; the index follows every write
ragCloseWorkspacerag.close(), then corestore.close()
ragListWorkspaces, ragDeleteWorkspacelistNamespaces() and dropNamespace({ name }); or delete the Corestore folder

See the API reference for the full API.

React Native and Expo

@qvac/rag is not supported in React Native or Expo apps yet. Build retrieval from the SDK instead: embed with embed() or embedBatch(), index the vectors with createVectorIndex(), and keep the documents in your own store. The TurboVec index example shows how.

Python and Kotlin

@qvac/rag is JavaScript only. From Python or Kotlin, either:

  • Use the CLI vector stores. Run qvac serve openai with an embedding model and call /v1/files and /v1/vector_stores from any OpenAI client. See Vector stores.
  • Build retrieval from the SDK. Embed with embed_batch (Python) or client.embeddings.embed (Kotlin), index the vectors with vector_index (Python) or client.vectorIndex (Kotlin), and keep the documents in your own store. The TurboVec index, MongoDB and SQLite examples show both languages.
from openai import OpenAI

client = OpenAI(base_url="http://localhost:11435/v1", api_key="unused")
store = client.vector_stores.create(name="my-docs")
file = client.files.create(file=open("notes.txt", "rb"), purpose="assistants")
client.vector_stores.files.create(vector_store_id=store.id, file_id=file.id)
hits = client.vector_stores.search(vector_store_id=store.id, query="what is in the notes?")

On this page

Ask anything about QVAC.