> ## Documentation Index
> Fetch the complete documentation index at: https://docs.geekai.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat with Files

### Supported models

Currently, only Gemini chat models, GLM vision models, and Doubao Seed chat models natively support chatting with PDFs. These include:

* `gemini-4-carbon`
* `gemini-4-argon`
* `gemini-3.8-flash`
* `gemini-3.6-flash`
* `gemini-3.5-flash-lite`
* `gemini-3.5-flash`
* `gemini-3.1-pro-preview`
* `gemini-3.1-pro-preview:fast-thinking`
* `gemini-3.1-flash-lite-preview`
* `gemini-3-flash-preview`
* `gemini-3-flash-preview:no-thinking`
* `gemini-2.5-pro`
* `gemini-2.5-pro:fast-thinking`
* `gemini-2.5-flash`
* `gemini-2.5-flash:no-thinking`
* `gemini-2.5-flash-lite`
* `gemini-2.5-flash-lite:no-thinking`
* `muse-spark-1.3`
* `muse-spark-1.3-contributor`
* `muse-spark-1.2`
* `muse-spark-1.2-contributor`
* `glm-5.3-flashx`
* `glm-5.3-flash`
* `doubao-seed-evolving`
* `doubao-seed-2.1-turbo`
* `doubao-seed-2.1-pro`
* `doubao-seed-2.0-mini`
* `doubao-seed-2.0-lite`
* `doubao-seed-2.0-pro`
* `doubao-seed-2.0-code`

For example, Gemini uses its vision capabilities to understand a PDF in context, rather than just extracting text. It can:

* Analyze and interpret text, images, charts, and tables in documents up to 1,000 pages long
* Extract information into a structured output format
* Summarize and answer questions using both visual and textual elements
* Transcribe documents (for example, into HTML) while preserving their layout and formatting for downstream applications

### Chat with PDFs

**One file**

Send a request with a single PDF:

```bash curl theme={null}
curl --location --request POST 'https://geekai.co/api/v1/chat/completions' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "gemini-3.8-flash",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Summarize the document."
          },
          {
            "type": "file_url",
            "file_url": {
                "url": "https://static.geekai.co/file/2025/04/22/be96ab26e4941f9e3de8da9d5fc089df.pdf",
                "mime_type": "application/pdf"
            }
          }
        ]
      }
    ]
}'
```

**Multiple files**

As with images, you can chat about multiple PDFs. Add a separate `file_url` object to the `content` list for each PDF:

```bash curl theme={null}
curl --location --request POST 'https://geekai.co/api/v1/chat/completions' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "gemini-3.8-flash",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Use the documents to answer question XXX."
          },
          {
            "type": "file_url",
            "file_url": {
              "url": "https://static.geekai.co/file/2025/04/22/pdf1.pdf",
              "mime_type": "application/pdf"
            }
          },
          {
            "type": "file_url",
            "file_url": {
              "url": "https://static.geekai.co/file/2025/04/22/pdf2.pdf",
              "mime_type": "application/pdf"
            }
          }
        ]
      }
    ]
}'
```

> [!NOTE]
>
> Only Gemini models require the `mime_type` field to specify the file type. Omit it for other models.

Gemini does not limit the number of PDFs, but the combined page count must not exceed 1,000.

### Chat with plain-text files

In addition to PDFs, Gemini vision models support these plain-text formats:

* JavaScript: set `mime_type` to `text/javascript`.
* Python: set `mime_type` to `text/x-python`.
* TXT: set `mime_type` to `text/plain`.
* HTML: set `mime_type` to `text/html`.
* CSS: set `mime_type` to `text/css`.
* Markdown: set `mime_type` to `text/markdown`.
* CSV: set `mime_type` to `text/csv`.
* XML: set `mime_type` to `text/xml`.
* RTF: set `mime_type` to `text/rtf`.

For example, a Markdown request has the same structure as a PDF request. Replace `url` and set `mime_type` to `text/markdown`:

```bash curl theme={null}
curl --location --request POST 'https://geekai.co/api/v1/chat/completions' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "gemini-3.8-flash",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Summarize the document."
          },
          {
            "type": "file_url",
            "file_url": {
                "url": "https://static.geekai.co/file/2025/05/15/test.md",
                "mime_type": "text/markdown"
            }
          }
        ]
      }
    ]
}'
```

### Chat with Office files

Only certain GLM vision models natively support Office documents (Word, Excel, and PowerPoint):

* `glm-5.3-flashx`
* `glm-5.3-flash`

Use the same request structure as for a PDF, replacing `mime_type` with the corresponding Office file type:

```bash curl theme={null}
curl --location --request POST 'https://geekai.co/api/v1/chat/completions' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "glm-5.3-flash",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Summarize the document."
          },
          {
            "type": "file_url",
            "file_url": {
                "url": "https://static.geekai.co/file/2026/04/30/test.docx"
            }
          }
        ]
      }
    ]
}'
```

### Other models

If a model cannot chat with files or does not support your file format, use the [file upload](https://docs.geekai.co/en/api/file/upload.md) and [file read](https://docs.geekai.co/en/api/file/extract.md) endpoints to extract the contents. Then pass them as chat context. This API supports PDFs, Office documents, plain text, and other formats.

The example below uses DeepSeek-V4-Flash with a PDF.

**Prepare the file**

Upload the PDF using the file upload endpoint to get its ID:

```bash curl theme={null}
curl --location --request POST 'https://geekai.co/api/v1/files' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@"./test.pdf"' \
--form 'purpose="file-extract"'
```

The `uuid` field in the response uniquely identifies the file. Use it with the file read endpoint to retrieve the contents:

```bash curl theme={null}
curl --location --request GET 'https://geekai.co/api/v1/file/{uuid}/content' \
--header 'Authorization: Bearer $GEEKAI_API_KEY'
```

When `status` is `done`, the `content` field contains the PDF text.

**Chat with the model**

Pass the extracted PDF text as chat context:

```bash curl theme={null}
curl --location --request POST 'https://geekai.co/api/v1/chat/completions' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "deepseek-flash",
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Summarize the following document.\n\nPDF contents: {content}" // Replace content with the content field from the file read response
                }
            ]
        }
    ]
}'
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.