Document Q&A

Ask questions about your documents using RAG

What is Document Q&A?

Upload documents (PDF, DOCX, TXT) and ask questions about them. The AI uses RAG to find relevant sections and generate accurate, source-cited answers.

Use cases

Legal document analysis
Extract key terms from contracts, analyze legal documents, find specific clauses.
Research paper review
Summarize findings, extract methodology, compare multiple papers.
Knowledge base search
Build searchable documentation, internal wikis, customer support systems.
Medical report analysis
Extract diagnoses, medications, treatment plans from medical documents.

Complete workflow

1

Create conversation

BASH
curl -X POST https://api.tarqaai.com/api/v1/context/conversations/create \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Legal Contract Analysis",
    "knowledgeBaseType": "custom"
  }'
2

Index your document

BASH
curl -X POST https://api.tarqaai.com/api/v1/rag/index \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "conversationId": "conv_abc123",
    "documentText": "Your full document text here...",
    "metadata": {
      "filename": "contract.pdf",
      "uploadDate": "2026-06-01"
    }
  }'
3

Ask questions

BASH
curl -X POST https://api.tarqaai.com/api/v1/rag/chat \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "conversationId": "conv_abc123",
    "message": "What are the payment terms in this contract?",
    "model": "gemini-2.5-flash",
    "topK": 5
  }'