Chat with PDF

To chat with a PDF you need docId of the PDF. To get docId upload the PDF first.

Using the save_chat option you can save chat history and can find the same in PDF.ai/documents/<docId>

To delete the chat you need to delete the PDF document using delete API.

You can make use of the powerful GPT-4 model to get better answers using use_gpt4 field in the request body. You can choose a specific model between gpt-4-turbo and gpt-4o using model field

Note: There use to be chatId field previously for saving chat but now it's deprecated. You just need to use save_chat field in order to save your chat history now.

Chat with PDF

Chat with a PDF

POST https://pdf.ai/api/v1/chat

Ask questions to get responses from the PDF using docId

Headers

NameTypeDescription

X-API-Key*

string

<API-key>

Request Body

NameTypeDescription

docId*

string

Document ID obtained after uploading PDF

save_chat

boolean

Option to save chat history

message*

string

Message or question you want to get answer from PDF

use_gpt4

boolean

To get response using GPT-4 model. Default model: gpt-4-turbo

model

string

To choose GPT-4 model "gpt-4o" or "gpt-4-turbo"(default). gpt-4o message costs 2 credits, gpt-4-turbo message costs 4 credits.

language

string

Response language e.g., "french"

{
   "content": "This is the answer to your message or question",
   "references": [
      {
         "pageNumber": 71,
         "fromLine": 41,
         "toLine": 48
      }
   ]
}

Last updated