RAG System
BetaRetrieval-Augmented Generation — index your documents and get AI answers grounded in them.
RAG (Retrieval-Augmented Generation) lets the model answer from your own documents. You add documents once. When someone asks a question, Tarqa finds the most relevant passages and gives them to the model, so its answer is based on your data and not just general knowledge.
In the dashboard, Build → Data Sources lets you upload files or add web pages, then switch on Data Sources under the Playground's message box. The API below does the same thing from your own app.
How it works
- 1Index your documentsYour text is split into small chunks and turned into embeddings, a searchable form that captures meaning.
- 2Search by meaningA question is matched against those chunks by meaning (not just keywords), and each match gets a relevance score.
- 3Answer with contextThe best-matching chunks are given to the model along with the question, and it writes an answer grounded in them.
Use it from the API
- 1Create a conversation (your knowledge base)POST
/api/v1/context/conversations/createRequest{ "title": "Product Documentation Q&A", "knowledgeBaseType": "custom" } - 2Index a documentPOST
/api/v1/rag/indexRequest{ "conversationId": "conv_abc123", "documentText": "TarqaAI is a unified AI platform...", "metadata": { "source": "product-docs", "category": "features" } } - 3Ask a questionPOST
/api/v1/rag/chatRequest{ "conversationId": "conv_abc123", "message": "What AI models does TarqaAI support?", "model": "gemini-2.5-flash", "topK": 3 }topKis how many matching chunks to give the model.
You can also search without generating an answer (POST /v1/rag/search) and check index size (GET /v1/rag/stats/:conversationId). See Endpoints.