Inference & pricing
Build guide

How to build a document Q&A tool with Vikasit AI

Document Q&A lets users ask questions about a specific file — a PDF, contract, or report. For documents that fit in context, you can pass the full text directly; for larger ones, combine with retrieval.

Recommended model

Vikasit 3

Reliable comprehension and formatting at a low price make it ideal for extracting answers from a single document. Step up to Vikasit 3 Max for dense, technical files.

Steps

  1. 1

    Extract plain text from the document (e.g. with pdfplumber or python-docx).

  2. 2

    If the text fits in the context window, include it directly in the prompt.

  3. 3

    For larger documents, chunk and retrieve relevant sections first (see the RAG guide).

  4. 4

    Instruct the model to answer strictly from the document and to quote sources.

  5. 5

    Call the Vikasit chat API with the document text and the user's question.

  6. 6

    Display the answer with the supporting passage highlighted.

Code

The Vikasit Inference API is OpenAI-compatible, so this uses the standard OpenAI Python SDK pointed at https://api.vikasit.ai/v1.

document-qa.py
from openai import OpenAI

client = OpenAI(
    base_url="https://api.vikasit.ai/v1",
    api_key="sk-vikasit-...",  # get one at vikasit.ai/auth
)

def ask_document(doc_text: str, question: str) -> str:
    resp = client.chat.completions.create(
        model="vikasit-3",
        messages=[
            {
                "role": "system",
                "content": "Answer questions strictly from the document. Quote the relevant lines.",
            },
            {"role": "user", "content": f"Document:\n{doc_text}\n\nQuestion: {question}"},
        ],
    )
    return resp.choices[0].message.content

Build your document Q&A tool today

Get an API key and 2M free tokens a day on Vikasit Nova. Pay-as-you-go, no minimums, OpenAI-compatible.