Docs/API Reference

Document Q&A

Upload documents and ask questions about them using RAG.

Upload documents (PDF, DOCX, TXT) and ask questions about them. Behind the scenes this is RAG: Tarqa finds the relevant sections and the model answers from them, citing what it used.

Good for

No-code route

Upload files in Build → Data Sources, then turn on Data Sources under the Playground's message box and ask away.

How to do it

  1. 1
    Create a conversation
    cURL
    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. 2
    Index your document

    Send the document's text, plus any metadata you want to keep with it.

    cURL
    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. 3
    Ask questions
    cURL
    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
      }'

FAQ

Can I ask about several documents at once?
Yes. Index them all into the same conversation, and every question searches across all of them.
How do I get better answers?
Ask specific questions and raise topK if answers miss details. See RAG System.