End-to-end pipeline
Ingest → parse → chunk → embed → store → retrieve → answer, every stage swappable.
The TypeScript RAG engine — ingest, retrieve, and answer with citations over a clean REST API, on your own Postgres and your own LLM key.
Apache-2.0 · TypeScript-native · runs on any Postgres with pgvector · no proprietary vector database.
$ npm install @usetheo/ragcoming to npmBuilding RAG in-house means stitching a loader, chunker, embedder, vector store, retriever, reranker, LLM client, ingest queue, and citation tracking — then keeping it correct. Managed RAG APIs solve that but take your data and bill per call. Theo Knowledge gives you the whole pipeline as code you own: point it at Postgres, give it an LLM key, and you have a RAG service on your own infrastructure.
Ingest → parse → chunk → embed → store → retrieve → answer, every stage swappable.
Every answer maps back to the exact chunks it used.
Dense vector (pgvector HNSW), keyword (Postgres FTS), and hybrid RRF.
Opt-in groundedness self-check and corrective query-rewrite, zero new deps.
Token-by-token over Server-Sent Events.
Typed errors, retries, auto-pagination and streaming built in.
import { RagClient } from '@usetheo/rag-sdk';
const theo = new RagClient({ apiKey: process.env.THEORAG_API_KEY });
const answer = await theo.answers.create({
collection_id: 'col_abc',
question: 'How long do refunds take?',
self_check: true, // populate confidence
corrective: true, // relevance-gate + query rewrite
});
console.log(answer.answer, answer.confidence, answer.citations);A cited answer with opt-in groundedness and corrective retrieval.
The TypeScript ecosystem forces a choice: glue a fragile in-house pipeline, or hand your data to a managed API that bills per call and locks you in. Comparison from public docs, mid-2026.
| Capability | Theo Knowledge | Ragie | R2R | LlamaCloud |
|---|---|---|---|---|
| Open source | Apache-2.0 | No | Yes | No |
| Primary language | TypeScript | Closed API | Python | Python / TS SDK |
| Default vector store | Postgres + pgvector | Proprietary | Postgres + pgvector | LlamaCloud |
| Hybrid retrieval | Vector + keyword + RRF | Yes | Yes | Yes |
| Runs on infra you own | Any Postgres | No | Yes | No |
The TypeScript-native, self-hosted choice — parity with managed RAG services while your data and your authorization layer stay on infrastructure you control.
RAG is table stakes for AI products, but teams are stuck gluing a pipeline or renting a managed API. Theo Knowledge lands the whole pipeline as Apache-2.0 TypeScript on Postgres you already run.
$ npm install @usetheo/ragcoming to npmRead the docs → docs.usetheo.dev
View the source → github.com/usetheodev/theo-rag