Skip to main content
RunAnywhere.rag.open creates a session that owns one corpus and its index. The session loads the embedding model and, when you pass one, the language model.
Leave llmModel null for a retrieval-only session. search still works; query and queryStream throw.
The Flutter RAG bridge owns a single native session. Opening a second session supersedes the first, and calls on the superseded session throw SDKException. Close one before opening the next.

open

It throws SDKException when a model cannot be loaded or the index cannot be created. The RAG backend registers itself here, so there is no separate wiring step.

RagConfig

The session

clear drops every document but keeps the session open. close destroys the index.

Ingesting

RagDocument.file reads UTF-8 text and throws when the path does not exist. It sets sourceUri for you. ingestAll runs the documents one at a time and stops at the first failure.

Retrieval without generation

Match carries text, score, and metadata. topK overrides the session config for one call.

Answering

RagResult carries answer, sources (the Match list the answer was grounded in), and metrics, a full GenerationResult for the generation half.

Streaming an answer

Retrieval finishes first, so RagRetrieved arrives before any token. RagEvent is sealed.

Statistics

Models

RAG needs an embedding model, and an embedding model needs its vocabulary next to the weights, which means a multi-file registration.
Register the ONNX backend with await Onnx.register() before opening a session.

Complete example

See also

Embeddings

Vectors and reranking

Models

Multi-file registration