Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Jatin-Mehra119/PDF-Insight-Beta/llms.txt

Use this file to discover all available pages before exploring further.

The /chat endpoint is the core of PDF Insight Pro. On each call, the server retrieves the top-matching document chunks from the session’s FAISS index, loads the conversation history into a ConversationBufferMemory, runs a LangChain tool-calling agent with the Groq-hosted LLM, and returns the generated answer alongside the context chunks that were used to produce it. Optionally, the agent can also perform live web searches via Tavily to supplement the document context.

Request

Method: POST
Path: /chat
Content-Type: application/json
session_id
string
required
The UUID returned by POST /upload-pdf. Identifies which document and conversation context to use.
query
string
required
The natural-language question to ask about the document. Must be at least 3 non-whitespace characters.
When set to true, the agent is given access to a Tavily web search tool and may query the web to supplement information from the document. Requires TAVILY_API_KEY to be set on the server.
model_name
string
default:"meta-llama/llama-4-scout-17b-16e-instruct"
The Groq-hosted LLM to use for this specific request. Overrides the model that was set at upload time for this call only.

Example request body

{
  "session_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "query": "What are the main conclusions of this document?",
  "use_search": false,
  "model_name": "meta-llama/llama-4-scout-17b-16e-instruct"
}

curl example

curl -X POST http://localhost:8000/chat \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
    "query": "What are the main conclusions of this document?",
    "use_search": false,
    "model_name": "meta-llama/llama-4-scout-17b-16e-instruct"
  }'

Response

Status: 200 OK
status
string
Always "success" on a successful response.
answer
string
The LLM-generated answer to the submitted query, grounded in the retrieved document chunks and conversation history.
context_used
array
The list of document chunks retrieved from the FAISS index that were passed to the agent as context. Each element contains the chunk text, its similarity score, and its source metadata.
{
  "status": "success",
  "answer": "The document concludes that renewable energy adoption must accelerate by 2035 to meet the agreed climate targets, citing three primary policy levers...",
  "context_used": [
    {
      "text": "The panel concluded that a tripling of renewable capacity by 2035 is both technically feasible and economically justified...",
      "score": 0.312,
      "metadata": {
        "source": "document.pdf",
        "page": 14
      }
    },
    {
      "text": "Policy lever one: carbon pricing at scale. Policy lever two: direct investment subsidies. Policy lever three: grid modernisation mandates...",
      "score": 0.428,
      "metadata": {
        "source": "document.pdf",
        "page": 15
      }
    }
  ]
}

Errors

StatusDetail
400Query cannot be empty
400Query must be at least 3 characters long
404Session not found or expired. Please upload a document first.
500Session data is incomplete. Please upload the document again.
500Error processing query: {error}
Set use_search: true when your query concerns events or data that may post-date the document, or when the document itself acknowledges that figures are subject to update. The Tavily search tool is invoked by the agent only when it determines the document context alone is insufficient — it does not fire on every request.

Build docs developers (and LLMs) love