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

# Documents and PDFs

> Send document blocks and PDF sources through the Messages compatibility layer.

`Messages API` accepts Anthropic-style `document` blocks for PDFs and text-like document content.

Use this when your existing Anthropic-style client already works with document blocks and you want to keep that format.

## Document Source Types

Supported `document.source` variants on this surface are:

* `{"type":"url","url":"https://..."}`
* `{"type":"base64","media_type":"application/pdf","data":"..."}`
* `{"type":"text","media_type":"text/plain","data":"..."}`
* `{"type":"content","content": ... }`

<Tabs>
  <Tab title="URL">
    Use this when the document is already hosted and reachable by URL.

    ```json theme={null}
    {
      "type": "url",
      "url": "https://example.com/report.pdf"
    }
    ```
  </Tab>

  <Tab title="Base64">
    Use this when you need to send the PDF inline as a base64 payload.

    ```json theme={null}
    {
      "type": "base64",
      "media_type": "application/pdf",
      "data": "JVBERi0xLjQ..."
    }
    ```
  </Tab>

  <Tab title="Text">
    Use this when the source is already extracted plain text rather than a raw
    PDF binary.

    ```json theme={null}
    {
      "type": "text",
      "media_type": "text/plain",
      "data": "Section 1: ..."
    }
    ```
  </Tab>

  <Tab title="Content">
    Use this when you want the document source itself to be built from typed
    content blocks.

    ```json theme={null}
    {
      "type": "content",
      "content": [
        {
          "type": "text",
          "text": "Inside doc"
        }
      ]
    }
    ```
  </Tab>
</Tabs>

## When to use this surface

* you already depend on Messages document semantics
* your app needs PDFs or other document-like content inside an Anthropic-style conversation

If you are starting fresh, compare this with [Responses Multimodal Inputs](/api/responses/multimodal-inputs).

## PDF URL Example

<CodeGroup>
  ```python Python theme={null}
  from anthropic import Anthropic

  client = Anthropic(
      base_url="https://api.naga.ac",
      api_key="YOUR_API_KEY",
  )

  message = client.messages.create(
      model="claude-sonnet-4.5",
      max_tokens=256,
      messages=[
          {
              "role": "user",
              "content": [
                  {
                      "type": "document",
                      "title": "Quarterly Report",
                      "source": {
                          "type": "url",
                          "url": "https://example.com/report.pdf",
                      },
                  },
                  {
                      "type": "text",
                      "text": "What are the key findings in this document?",
                  },
              ],
          }
      ],
  )

  print(message.content)
  ```

  ```javascript Node.js theme={null}
  import Anthropic from '@anthropic-ai/sdk';

  const client = new Anthropic({
    baseURL: 'https://api.naga.ac',
    apiKey: 'YOUR_API_KEY',
  });

  const message = await client.messages.create({
    model: 'claude-sonnet-4.5',
    max_tokens: 256,
    messages: [
      {
        role: 'user',
        content: [
          {
            type: 'document',
            title: 'Quarterly Report',
            source: {
              type: 'url',
              url: 'https://example.com/report.pdf',
            },
          },
          {
            type: 'text',
            text: 'What are the key findings in this document?',
          },
        ],
      },
    ],
  });

  console.log(message.content);
  ```

  ```bash cURL theme={null}
  curl https://api.naga.ac/v1/messages \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "claude-sonnet-4.5",
      "max_tokens": 256,
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "type": "document",
              "title": "Quarterly Report",
              "source": {
                "type": "url",
                "url": "https://example.com/report.pdf"
              }
            },
            {
              "type": "text",
              "text": "What are the key findings in this document?"
            }
          ]
        }
      ]
    }'
  ```
</CodeGroup>

## Content-Source Example

The compatibility layer also accepts `content`-source documents.

```json theme={null}
{
  "role": "user",
  "content": [
    {
      "type": "document",
      "title": "Spec",
      "source": {
        "type": "content",
        "content": [
          {
            "type": "text",
            "text": "Inside doc"
          }
        ]
      }
    }
  ]
}
```

## Caveats

* document support still depends on the selected model
* large PDFs increase token usage after provider-side parsing
* use this API only when you specifically need Anthropic-compatible document semantics

## Common mistakes

* assuming every model that supports text also supports document blocks
* sending very large documents without expecting higher token cost
* mixing Messages document syntax with Chat Completions or Responses file syntax

## Related Docs

* [Capability-level Multimodal Inputs](/build/multimodal-inputs)
* [Messages API](/api/messages)
* [Create message](/api-reference/endpoints/messages/create)
