Skip to content
RAG · CITED ANSWERS

Drop documents in. Get cited answers out.

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.

  • 39REST endpoints
  • 3Retrieval strategies
  • OpenAPI 3.1Auto-generated spec
  • Zero-depTyped SDK
  • RRFHybrid fusion
  • Apache-2.0License
$ npm install @usetheo/ragcoming to npm

Building 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.

What you get

Concretely, what ships.

End-to-end pipeline

Ingest → parse → chunk → embed → store → retrieve → answer, every stage swappable.

Citations by default

Every answer maps back to the exact chunks it used.

Three retrieval strategies

Dense vector (pgvector HNSW), keyword (Postgres FTS), and hybrid RRF.

Self-RAG + corrective

Opt-in groundedness self-check and corrective query-rewrite, zero new deps.

Streaming answers

Token-by-token over Server-Sent Events.

Typed zero-dep SDK

Typed errors, retries, auto-pagination and streaming built in.

Feel it
typescript
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.

What you'd ship

Things you would actually build.

  • 01An internal handbook Q&A that answers "How much PTO do I accrue?" with citations to the source doc.
  • 02A support assistant that returns grounded answers with a high / medium / low confidence signal.
  • 03A multi-tenant knowledge API where each workspace’s documents stay isolated.
  • 04A document-ingest service that survives crashes — the worker resumes mid-pipeline.
  • 05A streaming answer UI, token-by-token over SSE, embedded in your own app.
  • 06Webhook-driven pipelines that react to document.status_changed with signed, retried delivery.
Why Theo Knowledge

How it compares.

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.

CapabilityTheo KnowledgeRagieR2RLlamaCloud
Open sourceApache-2.0NoYesNo
Primary languageTypeScriptClosed APIPythonPython / TS SDK
Default vector storePostgres + pgvectorProprietaryPostgres + pgvectorLlamaCloud
Hybrid retrievalVector + keyword + RRFYesYesYes
Runs on infra you ownAny PostgresNoYesNo

The TypeScript-native, self-hosted choice — parity with managed RAG services while your data and your authorization layer stay on infrastructure you control.

Why now

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.

Status

Honest claims only.

  • Full ingest → retrieve → answer pipeline, validated against real Postgres and OpenAI.
  • Three retrieval strategies with citations on every answer; async ingest worker with checkpoints.
  • Apache-2.0, TypeScript-native, on your own Postgres — SDK publishing to npm next.

Drop documents in. Get cited answers out.

$ npm install @usetheo/ragcoming to npm

Read the docs → docs.usetheo.dev

View the source → github.com/usetheodev/theo-rag