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,ragDeleteWorkspaceand theragTurbovecconfig. - Python:
rag,rag_with_progressand theRagRequesttypes. - Kotlin:
client.retrievaland theRagRequesttypes.
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:
- JavaScript and TypeScript: use
@qvac/ragfor the managed document store, orembed()with the TurboVec index or an external vector DB. - Python, Kotlin and React Native: build retrieval from
embed()and the SDK vector index, or call the CLI vector stores. See Python and Kotlin and React Native.
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:
| Package | Pin |
|---|---|
@qvac/sdk | ~0.24.0 |
tetherto-qvac-sdk (Python) | ~=0.24.0 |
@qvac/cli | ~0.20.0 |
| Kotlin SDK | the 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>andrag-turbovec/<workspace>, next to the SDKcacheDirectory(~/.qvac/rag-hyperdbby default; under$SNAP_USER_COMMON/.qvacin 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 openaivector stores up to CLI 0.20.x were SDK workspaces named after the store id, in the same folders. Later versions keep stores inserve/vector-storesnext to thecacheDirectory. 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
spacewhen the vectors change (model, revision, pooling); a namespace rejects vectors from another space. - On Node,
@qvac/turbovec-ggmldoes not load, so every search scans all chunks unless you supply your own index throughcreateRag({ index: { provider } }). CallindexStatus({ 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/ragon Bare.
| SDK function | @qvac/rag |
|---|---|
ragIngest | ingest({ namespace, documents: [{ id, text }] }); chunk options go to createRag({ chunking }), onProgress and signal to the second argument of ingest |
ragSaveEmbeddings | ingest with { id, spaceId, chunks: [{ content, embedding }] }; no port needed |
ragChunk | ingest chunks text itself; for chunks alone, use rag-extract/chunk |
ragSearch | search({ scope: { namespace }, query, k }) |
ragDeleteEmbeddings | deleteDocuments({ namespace, documentIds }) |
ragReindex | not needed; the index follows every write |
ragCloseWorkspace | rag.close(), then corestore.close() |
ragListWorkspaces, ragDeleteWorkspace | listNamespaces() 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 openaiwith an embedding model and call/v1/filesand/v1/vector_storesfrom any OpenAI client. See Vector stores. - Build retrieval from the SDK. Embed with
embed_batch(Python) orclient.embeddings.embed(Kotlin), index the vectors withvector_index(Python) orclient.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?")