# Chat with all PDFs

To chat with all PDFs you just need to have at least one PDF uploaded using the [<mark style="color:blue;">upload</mark>](https://api.pdf.ai/v1/upload-pdf) API endpoint.

{% hint style="info" %}
Using the `save_chat` option you can save chat all history and can find the same  in PDF.ai/documents/chat/all
{% endhint %}

## Chat with all PDFs

## Chat with all PDFs

<mark style="color:green;">`POST`</mark> `https://pdf.ai/api/v1/chat-all`

Ask questions to get responses from any PDF

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| X-API-Key<mark style="color:red;">\*</mark> | string | \<API-key>  |

#### Request Body

| Name                                      | Type    | Description                                                                                                                              |
| ----------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| save\_chat                                | boolean | Option to save chat history                                                                                                              |
| message<mark style="color:red;">\*</mark> | string  | Message or question you want to get answer from PDF                                                                                      |
| use\_gpt4                                 | boolean | <p>To get response using GPT-4 model. <br>Default model: gpt-4-turbo</p>                                                                 |
| model                                     | string  | <p>To choose GPT-4 model<br>"gpt-4o" or "gpt-4-turbo"(default). gpt-4o message costs 2 credits, gpt-4-turbo message costs 4 credits.</p> |
| language                                  | string  | Response language e.g., "french"                                                                                                         |
| tag                                       | string  | To filter results based on tag, e.g., "Books"                                                                                            |
| topMatches                                | number  | <p>Max number of relevant or best-matched documents to consider for answering the query<br>Default: 10</p>                               |
| sys\_prompt                               | string  | Customized system prompt                                                                                                                 |

{% tabs %}
{% tab title="200 Response to your message or question" %}

```json
{
   "content": "This is the answer to your message or question",
   "references": [
      {
         "pageNumber": 71,
         "fromLine": 41,
         "toLine": 48,
         "docId": "abcd1234",
         "url": "https://cdn.openai.com/papers/gpt-4.pdf",
      }
   ]
}
```

{% endtab %}

{% tab title="401 Invalid API key" %}

```json
{
    "error": "Invalid API key"
}
```

{% endtab %}

{% tab title="400: Bad Request No API key or message is present" %}

```json
{
    "error": "No API key present"
}
```

{% endtab %}
{% endtabs %}
