---
title: Supporto PDF
url: https://platform.claude.com/docs/it/build-with-claude/pdf-support
description: "Elabora PDF con Claude: estrai testo, analizza grafici e comprendi i contenuti visivi dei tuoi documenti."
featureMetadata:
  status: stable
  zdr:
    eligibility: eligible
    note: Excludes [Covered Models](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention#model-specific-data-retention-requirements).
  supportedModels:
    - claude-fable-5-2
    - claude-mythos-5-2
    - claude-fable-5-1
    - claude-mythos-5-1
    - claude-fable-5
    - claude-mythos-5
    - claude-mythos-preview
    - claude-opus-5-5
    - claude-opus-5
    - claude-sonnet-5-5
    - claude-sonnet-5
    - claude-haiku-5-5
    - claude-haiku-4-5-20251001
    - claude-opus-4-8
    - claude-opus-4-7
    - claude-opus-4-6
    - claude-sonnet-4-6
    - claude-opus-4-5-20251101
    - claude-sonnet-4-5-20250929
  supportedPlatforms:
    Claude API: stable
    Amazon Bedrock:
      availability: stable
      note: Solo sorgenti base64.
    Amazon Bedrock (bedrock-runtime):
      availability: stable
      note: Solo sorgenti base64.
    Claude Platform on AWS: stable
    Claude Models on Google Cloud (Anthropic managed): stable
    Claude Models on Google Cloud (Google managed):
      availability: stable
      note: Solo sorgenti base64.
    Microsoft Foundry:
      availability: stable
      note: Le sorgenti `file_id` richiedono un deployment Hosted on Anthropic.
---

Puoi chiedere a Claude informazioni su qualsiasi testo, immagine, grafico e tabella presente nei PDF che fornisci. Alcuni casi d’uso di esempio:

* Analizzare report finanziari e comprendere grafici/tabelle
* Estrarre informazioni chiave da documenti legali
* Aiutare nella traduzione di documenti
* Convertire le informazioni dei documenti in formati strutturati

## Prima di iniziare

### Verifica i requisiti dei PDF

Claude funziona con qualsiasi PDF standard. Assicurati che la dimensione della tua richiesta rispetti questi requisiti:

| Requisito | Limite |
| ----- | ----- |
| Dimensione massima della richiesta | 128 MB sulla Claude API di prima parte (varia in base alla piattaforma; vedi [limiti di dimensione delle richieste](https://platform.claude.com/docs/it/api/overview#request-size-limits)) |
| Numero massimo di pagine per richiesta | 600 (100 quando la finestra di contesto della richiesta è inferiore a 1M di token) |
| Formato | PDF standard (senza password/crittografia) |

Entrambi i limiti si applicano all’intero payload della richiesta, incluso qualsiasi altro contenuto inviato insieme ai PDF. Per PDF di grandi dimensioni, valuta di caricarli con la [Files API](https://platform.claude.com/docs/it/build-with-claude/files) e di referenziarli tramite `file_id` per mantenere ridotti i payload delle richieste.

<Tip>
  I PDF densi (molte pagine con caratteri piccoli, tabelle complesse o grafica pesante) possono riempire la “context window” (finestra di contesto) prima di raggiungere il limite di pagine. Le richieste con PDF di grandi dimensioni possono anche fallire prima di raggiungere il limite di pagine, anche quando si usa la Files API. Prova a suddividere il documento in sezioni; per file di grandi dimensioni, poiché ogni pagina viene elaborata come immagine, anche ridurre la risoluzione delle immagini incorporate può aiutare.
</Tip>

Poiché il supporto PDF si basa sulle capacità di visione di Claude, è soggetto alle stesse [limitazioni e considerazioni](https://platform.claude.com/docs/it/build-with-claude/vision#limitations) degli altri compiti di visione.

### Piattaforme e modelli supportati

Tutti i [modelli attivi](https://platform.claude.com/docs/it/models/overview) supportano l’elaborazione dei PDF.

<Note>
  I file di testo semplice come .txt, .csv o .md possono essere usati direttamente nei blocchi documento: caricali nella Files API con tipo MIME `text/plain` e fai loro riferimento tramite `file_id`. I formati binari come .xlsx o .docx non sono supportati nei blocchi documento, quindi convertili prima in testo o PDF. Vedi [Lavorare con altri formati di file](https://platform.claude.com/docs/it/build-with-claude/files#working-with-other-file-formats).
</Note>

## Elabora PDF con Claude

### Invia la tua prima richiesta PDF

Inizia con un esempio che usa la Messages API. Per fornire un PDF a Claude, invialo in un [blocco di contenuto `document`](https://platform.claude.com/docs/it/api/messages#document_block_param) con uno dei tre tipi di sorgente. La tua piattaforma determina quali tipi puoi usare (vedi [Disponibilità](https://platform.claude.com/docs/it/build-with-claude/pdf-support#feature-availability)). Tra questi tipi, scegli in base a dove si trova il PDF, alle sue dimensioni e alla frequenza con cui lo usi:

1. **Un PDF ospitato online:** referenzialo tramite il suo URL ([Opzione 1: Documento PDF basato su URL](https://platform.claude.com/docs/it/build-with-claude/pdf-support#option-1-url-based-pdf-document)).
2. **Un PDF sul tuo sistema locale o senza un URL:** invialo come dati codificati in base64 ([Opzione 2: Documento PDF codificato in base64](https://platform.claude.com/docs/it/build-with-claude/pdf-support#option-2-base64-encoded-pdf-document)).
3. **Un PDF di grandi dimensioni o che userai ripetutamente:** caricalo con la [Files API](https://platform.claude.com/docs/it/build-with-claude/files) e referenzialo tramite il suo `file_id` ([Opzione 3: Files API](https://platform.claude.com/docs/it/build-with-claude/pdf-support#option-3-files-api)).

#### Opzione 1: Documento PDF basato su URL

Referenzia il PDF tramite il suo URL:

<CodeGroup>
  ```bash cURL
  curl https://api.anthropic.com/v1/messages \
    -H "content-type: application/json" \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2026-10-21" \
    -d '{
      "model": "claude-opus-5-5",
      "max_tokens": 1024,
      "messages": [{
        "role": "user",
        "content": [{
          "type": "document",
          "source": {
            "type": "url",
            "url": "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
          }
        },
        {
          "type": "text",
          "text": "What are the key findings in this document?"
        }]
      }]
    }'
  ```

  ```bash CLI
  ant messages create <<'YAML'
  model: claude-opus-5-5
  max_tokens: 1024
  messages:
    - role: user
      content:
        - type: document
          source:
            type: url
            url: https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf
        - type: text
          text: What are the key findings in this document?
  YAML
  ```

  ```python Python
  client = anthropic.Anthropic()
  message = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      messages=[
          {
              "role": "user",
              "content": [
                  {
                      "type": "document",
                      "source": {
                          "type": "url",
                          "url": "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf",
                      },
                  },
                  {"type": "text", "text": "What are the key findings in this document?"},
              ],
          }
      ],
  )

  print(message.content)
  ```

  ```typescript TypeScript
  const anthropic = new Anthropic();

  const response = await anthropic.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "document",
            source: {
              type: "url",
              url: "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
            }
          },
          {
            type: "text",
            text: "What are the key findings in this document?"
          }
        ]
      }
    ]
  });

  console.log(response);
  ```

  ```csharp C#
  var client = new AnthropicClient();

  // Crea un blocco documento con un URL
  var documentParam = new DocumentBlockParam
  {
      Source = new UrlPdfSource
      {
          Url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf",
      },
  };

  // Crea un messaggio con blocchi di contenuto documento e testo
  var message = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Messages =
      [
          new UserMessageParam
          {
              Content = new List<ContentBlockParam>
              {
                  documentParam,
                  new TextBlockParam("What are the key findings in this document?"),
              },
          },
      ],
  });

  Console.WriteLine(string.Join("\n", message.Content));
  ```

  ```go Go
  client := anthropic.NewClient()

  message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
  	Model:     anthropic.ModelClaudeOpus5_5,
  	MaxTokens: 1024,
  	Messages: []anthropic.MessageParam{
  		anthropic.NewUserMessage(
  			anthropic.NewDocumentBlock(anthropic.URLPDFSourceParam{
  				URL: "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf",
  			}),
  			anthropic.NewTextBlock("What are the key findings in this document?"),
  		),
  	},
  })
  if err != nil {
  	panic(err)
  }

  fmt.Printf("%+v\n", message.Content)
  ```

  ```java Java
  AnthropicClient client = AnthropicOkHttpClient.fromEnv();

  // Crea un blocco documento con URL
  DocumentBlockParam documentParam = DocumentBlockParam.builder()
      .source(
          UrlPdfSource.builder()
              .url(
                  "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
              )
              .build()
      )
      .build();

  // Crea un messaggio con blocchi di contenuto documento e testo
  MessageCreateParams params = MessageCreateParams.builder()
      .model(Model.CLAUDE_OPUS_5_5)
      .maxTokens(1024)
      .addUserMessageOfContentBlockParams(
          List.of(
              ContentBlockParam.ofDocument(documentParam),
              ContentBlockParam.ofText(
                  TextBlockParam.builder()
                      .text("What are the key findings in this document?")
                      .build()
              )
          )
      )
      .build();

  Message message = client.messages().create(params);
  IO.println(message.content());
  ```

  ```php PHP
  $client = new Client();

  $message = $client->messages->create(
      maxTokens: 1024,
      messages: [
          [
              'role' => 'user',
              'content' => [
                  [
                      'type' => 'document',
                      'source' => [
                          'type' => 'url',
                          'url' => 'https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf',
                      ],
                  ],
                  [
                      'type' => 'text',
                      'text' => 'What are the key findings in this document?',
                  ],
              ],
          ],
      ],
      model: Model::CLAUDE_OPUS_5_5,
  );

  echo $message;
  ```

  ```ruby Ruby
  anthropic = Anthropic::Client.new

  message = anthropic.messages.create(
    model: Anthropic::Model::CLAUDE_OPUS_5_5,
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "document",
            source: {
              type: "url",
              url: "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
            }
          },
          {type: "text", text: "What are the key findings in this document?"}
        ]
      }
    ]
  )

  puts(message.content)
  ```
</CodeGroup>

La risposta restituisce l’analisi di Claude come blocchi di testo in `content`, con il consumo di token in `usage`:

```json Output
{
  "id": "msg_01Hfp8YuFjQ55VgWbpdHDehB",
  "type": "message",
  "role": "assistant",
  "model": "claude-opus-5-5",
  "content": [
    {
      "type": "text",
      "text": "This document is an addendum to the Claude 3 model card, reporting updated evaluation results. The key findings include..."
    }
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 45000,
    "output_tokens": 300
  }
}
```

#### Opzione 2: Documento PDF codificato in base64

Invia il PDF come dati codificati in base64 nella richiesta stessa. La maggior parte degli esempi seguenti scarica un PDF di esempio e lo codifica, quindi non richiede alcun file locale. Per inviare un file locale in quegli esempi, sostituisci le righe che scaricano e codificano il PDF con le righe commentate:

<CodeGroup>
  ```bash cURL
  # Metodo 1: recupera e codifica un PDF remoto
  curl -sL "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf" | base64 | tr -d '\n' > pdf_base64.txt

  # Metodo 2: codifica un file PDF locale
  # base64 document.pdf | tr -d '\n' > pdf_base64.txt

  # Crea un file di richiesta JSON usando il contenuto di pdf_base64.txt
  jq -n --rawfile PDF_BASE64 pdf_base64.txt '{
    "model": "claude-opus-5-5",
    "max_tokens": 1024,
    "messages": [{
      "role": "user",
      "content": [{
        "type": "document",
        "source": {
          "type": "base64",
          "media_type": "application/pdf",
          "data": $PDF_BASE64
        }
      },
      {
        "type": "text",
        "text": "What are the key findings in this document?"
      }]
    }]
  }' > request.json

  # Invia la richiesta API usando il file JSON
  curl https://api.anthropic.com/v1/messages \
    -H "content-type: application/json" \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2026-10-21" \
    -d @request.json
  ```

  ```bash CLI
  ant messages create --model claude-opus-5-5 --max-tokens 1024 <<'YAML'
  messages:
    - role: user
      content:
        - type: document
          source:
            type: base64
            media_type: application/pdf
            data: "@./document.pdf"
        - type: text
          text: What are the key findings in this document?
  YAML
  ```

  ```python Python
  import base64
  import httpx2

  # Per prima cosa, carica e codifica il PDF
  pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
  pdf_data = base64.standard_b64encode(
      httpx2.get(pdf_url, follow_redirects=True).content
  ).decode("utf-8")

  # Alternativa: carica da un file locale
  # with open("document.pdf", "rb") as f:
  #     pdf_data = base64.standard_b64encode(f.read()).decode("utf-8")

  # Invia a Claude usando la codifica base64
  client = anthropic.Anthropic()
  message = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      messages=[
          {
              "role": "user",
              "content": [
                  {
                      "type": "document",
                      "source": {
                          "type": "base64",
                          "media_type": "application/pdf",
                          "data": pdf_data,
                      },
                  },
                  {"type": "text", "text": "What are the key findings in this document?"},
              ],
          }
      ],
  )

  print(message.content)
  ```

  ```typescript TypeScript
  // Metodo 1: recupera e codifica un PDF remoto
  const pdfURL =
    "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";
  const pdfResponse = await fetch(pdfURL);
  const arrayBuffer = await pdfResponse.arrayBuffer();
  const pdfBase64 = Buffer.from(arrayBuffer).toString("base64");

  // Metodo 2: carica da un file locale
  // import { readFile } from "node:fs/promises";
  // const pdfBase64 = (await readFile("document.pdf")).toString("base64");

  // Invia la richiesta API con il PDF codificato in base64
  const anthropic = new Anthropic();
  const response = await anthropic.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "document",
            source: {
              type: "base64",
              media_type: "application/pdf",
              data: pdfBase64
            }
          },
          {
            type: "text",
            text: "What are the key findings in this document?"
          }
        ]
      }
    ]
  });

  console.log(response);
  ```

  ```csharp C#
  var client = new AnthropicClient();

  // Metodo 1: scarica e codifica un PDF remoto
  var pdfUrl = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";
  using var httpClient = new HttpClient();
  var pdfBase64 = Convert.ToBase64String(await httpClient.GetByteArrayAsync(pdfUrl));

  // Metodo 2: carica da un file locale
  // var pdfBase64 = Convert.ToBase64String(await File.ReadAllBytesAsync("document.pdf"));

  // Crea un blocco documento con dati base64
  var documentParam = new DocumentBlockParam
  {
      Source = new Base64PdfSource { Data = pdfBase64 },
  };

  // Crea un messaggio con blocchi di contenuto documento e testo
  var message = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Messages =
      [
          new UserMessageParam
          {
              Content = new List<ContentBlockParam>
              {
                  documentParam,
                  new TextBlockParam("What are the key findings in this document?"),
              },
          },
      ],
  });

  Console.WriteLine(string.Join("\n", message.Content));
  ```

  ```go Go
  // Per prima cosa, carica e codifica il PDF
  pdfURL := "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
  resp, err := http.Get(pdfURL)
  if err != nil {
  	panic(err)
  }
  defer resp.Body.Close()
  pdfBytes, err := io.ReadAll(resp.Body)
  if err != nil {
  	panic(err)
  }
  pdfBase64 := base64.StdEncoding.EncodeToString(pdfBytes)

  // Alternativa: carica da un file locale (negli import, sostituisci "io" e "net/http" con "os")
  // pdfBytes, err := os.ReadFile("document.pdf")
  // pdfBase64 := base64.StdEncoding.EncodeToString(pdfBytes)

  // Invia a Claude usando la codifica base64
  client := anthropic.NewClient()
  message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
  	Model:     anthropic.ModelClaudeOpus5_5,
  	MaxTokens: 1024,
  	Messages: []anthropic.MessageParam{
  		anthropic.NewUserMessage(
  			anthropic.NewDocumentBlock(anthropic.Base64PDFSourceParam{
  				Data: pdfBase64,
  			}),
  			anthropic.NewTextBlock("What are the key findings in this document?"),
  		),
  	},
  })
  if err != nil {
  	panic(err)
  }

  fmt.Printf("%+v\n", message.Content)
  ```

  ```java Java
  AnthropicClient client = AnthropicOkHttpClient.fromEnv();

  // Metodo 1: scarica e codifica un PDF remoto
  String pdfUrl =
      "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";
  HttpClient httpClient = HttpClient.newBuilder()
      .followRedirects(HttpClient.Redirect.NORMAL)
      .build();
  HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create(pdfUrl))
      .GET()
      .build();

  HttpResponse<byte[]> response = httpClient.send(
      request,
      HttpResponse.BodyHandlers.ofByteArray()
  );
  String pdfBase64 = Base64.getEncoder().encodeToString(response.body());

  // Metodo 2: carica da un file locale
  // byte[] fileBytes = Files.readAllBytes(Path.of("document.pdf"));
  // String pdfBase64 = Base64.getEncoder().encodeToString(fileBytes);

  // Crea un blocco documento con dati base64
  DocumentBlockParam documentParam = DocumentBlockParam.builder()
      .source(Base64PdfSource.builder()
          .data(pdfBase64)
          .build())
      .build();

  // Crea un messaggio con blocchi di contenuto documento e testo
  MessageCreateParams params = MessageCreateParams.builder()
      .model(Model.CLAUDE_OPUS_5_5)
      .maxTokens(1024)
      .addUserMessageOfContentBlockParams(
          List.of(
              ContentBlockParam.ofDocument(documentParam),
              ContentBlockParam.ofText(
                  TextBlockParam.builder()
                      .text("What are the key findings in this document?")
                      .build()
              )
          )
      )
      .build();

  Message message = client.messages().create(params);
  IO.println(message.content());
  ```

  ```php PHP
  $client = new Client();

  // Per prima cosa, carica e codifica il PDF
  $pdf_url = 'https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf';
  $pdf_bytes = file_get_contents($pdf_url)
      ?: throw new \RuntimeException('Could not fetch the PDF.');
  $pdf_data = base64_encode($pdf_bytes);

  // Alternativa: carica da un file locale
  // $pdf_bytes = file_get_contents('document.pdf')
  //     ?: throw new \RuntimeException('Could not read document.pdf.');
  // $pdf_data = base64_encode($pdf_bytes);

  // Invia a Claude usando la codifica base64
  $message = $client->messages->create(
      maxTokens: 1024,
      messages: [
          [
              'role' => 'user',
              'content' => [
                  [
                      'type' => 'document',
                      'source' => [
                          'type' => 'base64',
                          'mediaType' => 'application/pdf',
                          'data' => $pdf_data,
                      ],
                  ],
                  [
                      'type' => 'text',
                      'text' => 'What are the key findings in this document?',
                  ],
              ],
          ],
      ],
      model: Model::CLAUDE_OPUS_5_5,
  );

  echo $message;
  ```

  ```ruby Ruby
  require "open-uri"

  # Per prima cosa, carica e codifica il PDF
  pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
  pdf_bytes = URI.open(pdf_url, "rb", &:read)
  pdf_data = [pdf_bytes].pack("m0") # Encode as base64 without newlines

  # Alternativa: carica da un file locale
  # pdf_data = [File.binread("document.pdf")].pack("m0")

  # Invia a Claude usando la codifica base64
  anthropic = Anthropic::Client.new
  message = anthropic.messages.create(
    model: Anthropic::Model::CLAUDE_OPUS_5_5,
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "document",
            source: {
              type: "base64",
              media_type: "application/pdf",
              data: pdf_data
            }
          },
          {type: "text", text: "What are the key findings in this document?"}
        ]
      }
    ]
  )

  puts(message.content)
  ```
</CodeGroup>

#### Opzione 3: Files API

Per i PDF che userai ripetutamente, o quando vuoi evitare l’overhead della codifica, usa la [Files API](https://platform.claude.com/docs/it/build-with-claude/files):

<CodeGroup>
  ```bash cURL
  # Per prima cosa, carica il tuo PDF nella Files API
  curl -sS -X POST https://api.anthropic.com/v1/files \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2026-10-21" \
    -F "file=@document.pdf"

  # Poi usa il file_id della risposta di caricamento nel tuo messaggio
  curl https://api.anthropic.com/v1/messages \
    -H "content-type: application/json" \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2026-10-21" \
    -d '{
      "model": "claude-opus-5-5",
      "max_tokens": 1024,
      "messages": [{
        "role": "user",
        "content": [{
          "type": "document",
          "source": {
            "type": "file",
            "file_id": "'"$FILE_ID"'"
          }
        },
        {
          "type": "text",
          "text": "What are the key findings in this document?"
        }]
      }]
    }'
  ```

  ```bash CLI
  # Per prima cosa, carica il tuo PDF nella Files API
  ant files upload --file ./document.pdf

  # Poi usa il file_id della risposta di caricamento nel tuo messaggio
  ant messages create <<YAML
  model: claude-opus-5-5
  max_tokens: 1024
  messages:
    - role: user
      content:
        - type: document
          source:
            type: file
            file_id: $FILE_ID
        - type: text
          text: What are the key findings in this document?
  YAML
  ```

  ```python Python
  client = anthropic.Anthropic()

  # Carica il file PDF
  with open("/path/to/document.pdf", "rb") as f:
      file_upload = client.files.upload(file=("document.pdf", f, "application/pdf"))

  # Usa il file caricato in un messaggio
  message = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      messages=[
          {
              "role": "user",
              "content": [
                  {
                      "type": "document",
                      "source": {"type": "file", "file_id": file_upload.id},
                  },
                  {"type": "text", "text": "What are the key findings in this document?"},
              ],
          }
      ],
  )

  print(message.content)
  ```

  ```typescript TypeScript
  import Anthropic, { toFile } from "@anthropic-ai/sdk";
  import fs from "node:fs";

  const anthropic = new Anthropic();

  // Carica il file PDF
  const fileUpload = await anthropic.files.upload({
    file: await toFile(fs.createReadStream("/path/to/document.pdf"), undefined, {
      type: "application/pdf"
    })
  });

  // Usa il file caricato in un messaggio
  const response = await anthropic.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "document",
            source: {
              type: "file",
              file_id: fileUpload.id
            }
          },
          {
            type: "text",
            text: "What are the key findings in this document?"
          }
        ]
      }
    ]
  });

  console.log(response);
  ```

  ```csharp C#
  var client = new AnthropicClient();

  // Carica il file PDF
  var fileUpload = await client.Files.Upload(new FileUploadParams
  {
      File = new BinaryContent
      {
          Stream = File.OpenRead("/path/to/document.pdf"),
          FileName = "document.pdf",
          ContentType = new("application/pdf"),
      },
  });

  // Usa il file caricato in un messaggio
  var message = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Messages =
      [
          new UserMessageParam
          {
              Content = new List<ContentBlockParam>
              {
                  new DocumentBlockParam
                  {
                      Source = new FileDocumentSource { FileID = fileUpload.ID },
                  },
                  new TextBlockParam("What are the key findings in this document?"),
              },
          },
      ],
  });

  Console.WriteLine(string.Join("\n", message.Content));
  ```

  ```go Go
  client := anthropic.NewClient()

  // Carica il file PDF
  pdfFile, err := os.Open("/path/to/document.pdf")
  if err != nil {
  	panic(err)
  }
  defer pdfFile.Close()

  fileUpload, err := client.Files.Upload(context.TODO(), anthropic.FileUploadParams{
  	File: anthropic.File(pdfFile, "document.pdf", "application/pdf"),
  })
  if err != nil {
  	panic(err)
  }

  // Usa il file caricato in un messaggio
  message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
  	Model:     anthropic.ModelClaudeOpus5_5,
  	MaxTokens: 1024,
  	Messages: []anthropic.MessageParam{
  		anthropic.NewUserMessage(
  			anthropic.NewDocumentBlock(anthropic.FileDocumentSourceParam{
  				FileID: fileUpload.ID,
  			}),
  			anthropic.NewTextBlock("What are the key findings in this document?"),
  		),
  	},
  })
  if err != nil {
  	panic(err)
  }

  fmt.Printf("%+v\n", message.Content)
  ```

  ```java Java
  AnthropicClient client = AnthropicOkHttpClient.fromEnv();

  // Carica il file PDF
  FileMetadata file = client
      .files()
      .upload(FileUploadParams.builder()
          .file(Path.of("/path/to/document.pdf"))
          .build());

  // Usa il file caricato in un messaggio
  MessageCreateParams params = MessageCreateParams.builder()
      .model(Model.CLAUDE_OPUS_5_5)
      .maxTokens(1024)
      .addUserMessageOfContentBlockParams(
          List.of(
              ContentBlockParam.ofDocument(
                  DocumentBlockParam.builder()
                      .fileSource(file.id())
                      .build()
              ),
              ContentBlockParam.ofText(
                  TextBlockParam.builder()
                      .text("What are the key findings in this document?")
                      .build()
              )
          )
      )
      .build();

  Message message = client.messages().create(params);
  IO.println(message.content());
  ```

  ```php PHP
  use Anthropic\Core\FileParam;

  $client = new Client();

  // Carica il file PDF
  $document = fopen('/path/to/document.pdf', 'rb')
      ?: throw new \RuntimeException('Could not open /path/to/document.pdf.');

  $file_upload = $client->files->upload(
      file: FileParam::fromResource($document, contentType: 'application/pdf'),
  );

  // Usa il file caricato in un messaggio
  $message = $client->messages->create(
      maxTokens: 1024,
      messages: [
          [
              'role' => 'user',
              'content' => [
                  [
                      'type' => 'document',
                      'source' => [
                          'type' => 'file',
                          'fileID' => $file_upload->id,
                      ],
                  ],
                  [
                      'type' => 'text',
                      'text' => 'What are the key findings in this document?',
                  ],
              ],
          ],
      ],
      model: Model::CLAUDE_OPUS_5_5,
  );

  echo $message;
  ```

  ```ruby Ruby
  anthropic = Anthropic::Client.new

  # Carica il file PDF
  file_upload = File.open("/path/to/document.pdf", "rb") do |pdf_file|
    anthropic.files.upload(
      file: Anthropic::FilePart.new(pdf_file, filename: "document.pdf", content_type: "application/pdf")
    )
  end

  # Usa il file caricato in un messaggio
  message = anthropic.messages.create(
    model: Anthropic::Model::CLAUDE_OPUS_5_5,
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "document",
            source: {type: "file", file_id: file_upload.id}
          },
          {type: "text", text: "What are the key findings in this document?"}
        ]
      }
    ]
  )

  puts(message.content)
  ```
</CodeGroup>

### Come funziona il supporto PDF

Quando invii un PDF a Claude, si verificano i seguenti passaggi:

<Steps>
  <Step title="Il sistema estrae i contenuti del documento.">
    * Il sistema converte ogni pagina del documento in un’immagine.
    * Il sistema estrae il testo di ogni pagina e lo fornisce insieme all’immagine di quella pagina.
  </Step>

  <Step title="Claude analizza sia il testo sia le immagini.">
    * Claude riceve ogni documento come combinazione di testo e immagini.
    * Poiché Claude riceve un’immagine di ogni pagina, puoi chiedere approfondimenti sugli elementi visivi di un PDF, come grafici, diagrammi e altri contenuti non testuali.
  </Step>

  <Step title="Claude usa i contenuti del PDF nella sua risposta, se pertinente.">
    Claude può attingere sia ai contenuti testuali sia a quelli visivi nella sua risposta.
  </Step>
</Steps>

### Stima i tuoi costi

Il conteggio dei token di un file PDF dipende dal testo totale estratto dal documento e dal numero di pagine:

* Costi dei token di testo: ogni pagina utilizza tipicamente 1.500–3.000 token a seconda della densità del contenuto. Si applicano i prezzi standard dell’API senza costi aggiuntivi per i PDF.
* Costi dei token di immagine: l’immagine di ogni pagina utilizza al massimo 1.568 token visivi su ogni modello, perché l’API adatta le immagini delle pagine ai limiti del livello di risoluzione standard. Per sapere come contare i token visivi di un’immagine, consulta [Risoluzione e costo in token](https://platform.claude.com/docs/it/build-with-claude/vision#evaluate-image-size).

Puoi usare il [conteggio dei token](https://platform.claude.com/docs/it/build-with-claude/token-counting) per stimare i costi dei tuoi PDF specifici.

## Ottimizza l’elaborazione dei PDF

Puoi combinare il supporto PDF con altre funzionalità:

* [Usa la cache dei prompt](https://platform.claude.com/docs/it/build-with-claude/pdf-support#use-prompt-caching) per migliorare le prestazioni nelle analisi ripetute.
* [Elabora batch di documenti](https://platform.claude.com/docs/it/build-with-claude/pdf-support#process-document-batches) per gestire documenti in grandi volumi.
* [Usa gli strumenti](https://platform.claude.com/docs/it/agents-and-tools/tool-use/overview) per far estrarre a Claude informazioni specifiche dai documenti da usare come input degli strumenti.

### Migliora le prestazioni

Segui queste best practice per risultati ottimali:

* Posiziona i PDF prima del testo nelle tue richieste
* Usa font standard
* Assicurati che il testo sia chiaro e leggibile
* Ruota le pagine nell’orientamento verticale corretto
* Usa i numeri di pagina logici (dal visualizzatore PDF) nei prompt
* Suddividi i PDF di grandi dimensioni in parti quando necessario
* Abilita la cache dei prompt per le analisi ripetute

### Scala la tua implementazione

Per l’elaborazione ad alto volume, valuta questi approcci:

#### Usa la cache dei prompt

Memorizza nella cache i PDF con il [“prompt caching” (cache dei prompt)](https://platform.claude.com/docs/it/build-with-claude/prompt-caching) per migliorare le prestazioni nelle query ripetute:

<CodeGroup>
  ```bash cURL
  curl -sL "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf" |
    base64 | tr -d '\n' |
    jq -Rs '{
      model: "claude-opus-5-5",
      max_tokens: 1024,
      messages: [{
        role: "user",
        content: [
          {
            type: "document",
            source: {type: "base64", media_type: "application/pdf", data: .},
            cache_control: {type: "ephemeral"}
          },
          {type: "text", text: "Which model has the highest human preference win rates across each use-case?"}
        ]
      }]
    }' |
    curl https://api.anthropic.com/v1/messages \
      -H "content-type: application/json" \
      -H "x-api-key: $ANTHROPIC_API_KEY" \
      -H "anthropic-version: 2026-10-21" \
      -d @-
  ```

  ```bash CLI
  ant messages create <<'YAML'
  model: claude-opus-5-5
  max_tokens: 1024
  messages:
    - role: user
      content:
        - type: document
          source:
            type: base64
            media_type: application/pdf
            data: "@./document.pdf"
          cache_control:
            type: ephemeral
        - type: text
          text: Which model has the highest human preference win rates across each use-case?
  YAML
  ```

  ```python Python
  import base64
  import httpx2

  # Per prima cosa, carica e codifica il PDF
  pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
  pdf_data = base64.standard_b64encode(
      httpx2.get(pdf_url, follow_redirects=True).content
  ).decode("utf-8")

  # Crea un messaggio con il documento in cache
  client = anthropic.Anthropic()
  message = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      messages=[
          {
              "role": "user",
              "content": [
                  {
                      "type": "document",
                      "source": {
                          "type": "base64",
                          "media_type": "application/pdf",
                          "data": pdf_data,
                      },
                      "cache_control": {"type": "ephemeral"},
                  },
                  {
                      "type": "text",
                      "text": "Which model has the highest human preference win rates across each use-case?",
                  },
              ],
          }
      ],
  )

  print(message.content)
  ```

  ```typescript TypeScript
  // Per prima cosa, carica e codifica il PDF
  const pdfURL =
    "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";
  const pdfResponse = await fetch(pdfURL);
  const arrayBuffer = await pdfResponse.arrayBuffer();
  const pdfBase64 = Buffer.from(arrayBuffer).toString("base64");

  // Crea un messaggio con il documento in cache
  const anthropic = new Anthropic();
  const response = await anthropic.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "document",
            source: {
              type: "base64",
              media_type: "application/pdf",
              data: pdfBase64
            },
            cache_control: { type: "ephemeral" }
          },
          {
            type: "text",
            text: "Which model has the highest human preference win rates across each use-case?"
          }
        ]
      }
    ]
  });

  console.log(response);
  ```

  ```csharp C#
  var client = new AnthropicClient();

  // Scarica e codifica il PDF
  var pdfUrl = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";
  using var httpClient = new HttpClient();
  var pdfBase64 = Convert.ToBase64String(await httpClient.GetByteArrayAsync(pdfUrl));

  var message = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Messages =
      [
          new UserMessageParam
          {
              Content = new List<ContentBlockParam>
              {
                  new DocumentBlockParam
                  {
                      Source = new Base64PdfSource { Data = pdfBase64 },
                      CacheControl = new CacheControlEphemeral(),
                  },
                  new TextBlockParam("Which model has the highest human preference win rates across each use-case?"),
              },
          },
      ],
  });

  Console.WriteLine(message);
  ```

  ```go Go
  // Per prima cosa, carica e codifica il PDF
  pdfURL := "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
  resp, err := http.Get(pdfURL)
  if err != nil {
  	panic(err)
  }
  defer resp.Body.Close()
  pdfBytes, err := io.ReadAll(resp.Body)
  if err != nil {
  	panic(err)
  }
  pdfBase64 := base64.StdEncoding.EncodeToString(pdfBytes)

  // Crea un blocco documento con il controllo della cache
  client := anthropic.NewClient()
  message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
  	Model:     anthropic.ModelClaudeOpus5_5,
  	MaxTokens: 1024,
  	Messages: []anthropic.MessageParam{
  		anthropic.NewUserMessage(
  			anthropic.ContentBlockParamUnion{
  				OfDocument: &anthropic.DocumentBlockParam{
  					Source: anthropic.DocumentBlockParamSourceUnion{
  						OfBase64: &anthropic.Base64PDFSourceParam{
  							Data: pdfBase64,
  						},
  					},
  					CacheControl: anthropic.NewCacheControlEphemeralParam(),
  				},
  			},
  			anthropic.NewTextBlock("Which model has the highest human preference win rates across each use-case?"),
  		),
  	},
  })
  if err != nil {
  	panic(err)
  }

  fmt.Printf("%+v\n", message.Content)
  ```

  ```java Java
  AnthropicClient client = AnthropicOkHttpClient.fromEnv();

  // Scarica e codifica il PDF
  String pdfUrl =
      "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";
  HttpClient httpClient = HttpClient.newBuilder()
      .followRedirects(HttpClient.Redirect.NORMAL)
      .build();
  HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create(pdfUrl))
      .GET()
      .build();

  HttpResponse<byte[]> response = httpClient.send(
      request,
      HttpResponse.BodyHandlers.ofByteArray()
  );
  String pdfBase64 = Base64.getEncoder().encodeToString(response.body());

  MessageCreateParams params = MessageCreateParams.builder()
      .model(Model.CLAUDE_OPUS_5_5)
      .maxTokens(1024)
      .addUserMessageOfContentBlockParams(
          List.of(
              ContentBlockParam.ofDocument(
                  DocumentBlockParam.builder()
                      .source(Base64PdfSource.builder()
                          .data(pdfBase64)
                          .build())
                      .cacheControl(CacheControlEphemeral.builder().build())
                      .build()
              ),
              ContentBlockParam.ofText(
                  TextBlockParam.builder()
                      .text(
                          "Which model has the highest human preference win rates across each use-case?"
                      )
                      .build()
              )
          )
      )
      .build();

  Message message = client.messages().create(params);
  IO.println(message);
  ```

  ```php PHP
  $client = new Client();

  // Carica e codifica il PDF
  $pdf_url = 'https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf';
  $pdf_bytes = file_get_contents($pdf_url)
      ?: throw new \RuntimeException('Could not fetch the PDF.');
  $pdf_data = base64_encode($pdf_bytes);

  $message = $client->messages->create(
      maxTokens: 1024,
      messages: [
          [
              'role' => 'user',
              'content' => [
                  [
                      'type' => 'document',
                      'source' => [
                          'type' => 'base64',
                          'mediaType' => 'application/pdf',
                          'data' => $pdf_data,
                      ],
                      'cacheControl' => ['type' => 'ephemeral'],
                  ],
                  [
                      'type' => 'text',
                      'text' => 'Which model has the highest human preference win rates across each use-case?',
                  ],
              ],
          ],
      ],
      model: Model::CLAUDE_OPUS_5_5,
  );

  echo $message;
  ```

  ```ruby Ruby
  require "open-uri"

  # Carica e codifica il PDF
  pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
  pdf_bytes = URI.open(pdf_url, "rb", &:read)
  pdf_data = [pdf_bytes].pack("m0") # Encode as base64 without newlines

  anthropic = Anthropic::Client.new

  message = anthropic.messages.create(
    model: Anthropic::Model::CLAUDE_OPUS_5_5,
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "document",
            source: {
              type: "base64",
              media_type: "application/pdf",
              data: pdf_data
            },
            cache_control: {type: "ephemeral"}
          },
          {
            type: "text",
            text: "Which model has the highest human preference win rates across each use-case?"
          }
        ]
      }
    ]
  )

  puts(message.content)
  ```
</CodeGroup>

#### Elabora batch di documenti

Usa la [Message Batches API](https://platform.claude.com/docs/it/build-with-claude/batch-processing) per elaborare molti PDF in un’unica richiesta:

<CodeGroup>
  ```bash cURL
  curl -sL "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf" | base64 | tr -d '\n' > pdf_base64.txt
  # Crea un file di richiesta JSON usando il contenuto di pdf_base64.txt
  jq -n --rawfile PDF_BASE64 pdf_base64.txt '{
    "requests": [
    {
      "custom_id": "my-first-request",
      "params": {
        "model": "claude-opus-5-5",
        "max_tokens": 1024,
        "messages": [{
          "role": "user",
          "content": [{
            "type": "document",
            "source": {
              "type": "base64",
              "media_type": "application/pdf",
              "data": $PDF_BASE64
            }
          },
          {
            "type": "text",
            "text": "Which model has the highest human preference win rates across each use-case?"
          }]
        }]
      }
    },
    {
      "custom_id": "my-second-request",
      "params": {
        "model": "claude-opus-5-5",
        "max_tokens": 1024,
        "messages": [{
          "role": "user",
          "content": [{
            "type": "document",
            "source": {
              "type": "base64",
              "media_type": "application/pdf",
              "data": $PDF_BASE64
            }
          },
          {
            "type": "text",
            "text": "Extract 5 key insights from this document."
          }]
        }]
      }
    }]
  }' > request.json

  # Poi esegui la chiamata API usando il file JSON
  curl https://api.anthropic.com/v1/messages/batches \
    -H "content-type: application/json" \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2026-10-21" \
    -d @request.json
  ```

  ```bash CLI
  ant messages:batches create <<'YAML'
  requests:
    - custom_id: my-first-request
      params:
        model: claude-opus-5-5
        max_tokens: 1024
        messages:
          - role: user
            content:
              - type: document
                source:
                  type: base64
                  media_type: application/pdf
                  data: "@./document.pdf"
              - type: text
                text: >-
                  Which model has the highest human preference win rates
                  across each use-case?
    - custom_id: my-second-request
      params:
        model: claude-opus-5-5
        max_tokens: 1024
        messages:
          - role: user
            content:
              - type: document
                source:
                  type: base64
                  media_type: application/pdf
                  data: "@./document.pdf"
              - type: text
                text: Extract 5 key insights from this document.
  YAML
  ```

  ```python Python
  import base64
  import httpx2

  # Per prima cosa, carica e codifica il PDF
  pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
  pdf_data = base64.standard_b64encode(
      httpx2.get(pdf_url, follow_redirects=True).content
  ).decode("utf-8")

  # Crea un batch di richieste che usano il documento
  client = anthropic.Anthropic()
  message_batch = client.messages.batches.create(
      requests=[
          {
              "custom_id": "my-first-request",
              "params": {
                  "model": "claude-opus-5-5",
                  "max_tokens": 1024,
                  "messages": [
                      {
                          "role": "user",
                          "content": [
                              {
                                  "type": "document",
                                  "source": {
                                      "type": "base64",
                                      "media_type": "application/pdf",
                                      "data": pdf_data,
                                  },
                              },
                              {
                                  "type": "text",
                                  "text": "Which model has the highest human preference win rates across each use-case?",
                              },
                          ],
                      }
                  ],
              },
          },
          {
              "custom_id": "my-second-request",
              "params": {
                  "model": "claude-opus-5-5",
                  "max_tokens": 1024,
                  "messages": [
                      {
                          "role": "user",
                          "content": [
                              {
                                  "type": "document",
                                  "source": {
                                      "type": "base64",
                                      "media_type": "application/pdf",
                                      "data": pdf_data,
                                  },
                              },
                              {
                                  "type": "text",
                                  "text": "Extract 5 key insights from this document.",
                              },
                          ],
                      }
                  ],
              },
          },
      ]
  )

  print(message_batch)
  ```

  ```typescript TypeScript
  // Per prima cosa, carica e codifica il PDF
  const pdfURL =
    "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";
  const pdfResponse = await fetch(pdfURL);
  const arrayBuffer = await pdfResponse.arrayBuffer();
  const pdfBase64 = Buffer.from(arrayBuffer).toString("base64");

  // Crea un batch di richieste che usano il documento
  const anthropic = new Anthropic();
  const response = await anthropic.messages.batches.create({
    requests: [
      {
        custom_id: "my-first-request",
        params: {
          model: "claude-opus-5-5",
          max_tokens: 1024,
          messages: [
            {
              role: "user",
              content: [
                {
                  type: "document",
                  source: {
                    type: "base64",
                    media_type: "application/pdf",
                    data: pdfBase64
                  }
                },
                {
                  type: "text",
                  text: "Which model has the highest human preference win rates across each use-case?"
                }
              ]
            }
          ]
        }
      },
      {
        custom_id: "my-second-request",
        params: {
          model: "claude-opus-5-5",
          max_tokens: 1024,
          messages: [
            {
              role: "user",
              content: [
                {
                  type: "document",
                  source: {
                    type: "base64",
                    media_type: "application/pdf",
                    data: pdfBase64
                  }
                },
                {
                  type: "text",
                  text: "Extract 5 key insights from this document."
                }
              ]
            }
          ]
        }
      }
    ]
  });

  console.log(response);
  ```

  ```csharp C#
  var client = new AnthropicClient();

  // Scarica e codifica il PDF
  var pdfUrl = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";
  using var httpClient = new HttpClient();
  var pdfBase64 = Convert.ToBase64String(await httpClient.GetByteArrayAsync(pdfUrl));

  var batch = await client.Messages.Batches.Create(new BatchCreateParams
  {
      Requests =
      [
          new()
          {
              CustomID = "my-first-request",
              Params = new()
              {
                  Model = Model.ClaudeOpus5_5,
                  MaxTokens = 1024,
                  Messages =
                  [
                      new UserMessageParam
                      {
                          Content = new List<ContentBlockParam>
                          {
                              new DocumentBlockParam
                              {
                                  Source = new Base64PdfSource { Data = pdfBase64 },
                              },
                              new TextBlockParam("Which model has the highest human preference win rates across each use-case?"),
                          },
                      },
                  ],
              },
          },
          new()
          {
              CustomID = "my-second-request",
              Params = new()
              {
                  Model = Model.ClaudeOpus5_5,
                  MaxTokens = 1024,
                  Messages =
                  [
                      new UserMessageParam
                      {
                          Content = new List<ContentBlockParam>
                          {
                              new DocumentBlockParam
                              {
                                  Source = new Base64PdfSource { Data = pdfBase64 },
                              },
                              new TextBlockParam("Extract 5 key insights from this document."),
                          },
                      },
                  ],
              },
          },
      ],
  });

  Console.WriteLine(batch);
  ```

  ```go Go
  // Per prima cosa, carica e codifica il PDF
  pdfURL := "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
  resp, err := http.Get(pdfURL)
  if err != nil {
  	panic(err)
  }
  defer resp.Body.Close()
  pdfBytes, err := io.ReadAll(resp.Body)
  if err != nil {
  	panic(err)
  }
  pdfBase64 := base64.StdEncoding.EncodeToString(pdfBytes)

  // Crea un batch di richieste che usano il documento
  client := anthropic.NewClient()
  batch, err := client.Messages.Batches.New(context.TODO(), anthropic.MessageBatchNewParams{
  	Requests: []anthropic.MessageBatchNewParamsRequest{
  		{
  			CustomID: "my-first-request",
  			Params: anthropic.MessageBatchNewParamsRequestParams{
  				Model:     anthropic.ModelClaudeOpus5_5,
  				MaxTokens: 1024,
  				Messages: []anthropic.MessageParam{
  					anthropic.NewUserMessage(
  						anthropic.NewDocumentBlock(anthropic.Base64PDFSourceParam{
  							Data: pdfBase64,
  						}),
  						anthropic.NewTextBlock("Which model has the highest human preference win rates across each use-case?"),
  					),
  				},
  			},
  		},
  		{
  			CustomID: "my-second-request",
  			Params: anthropic.MessageBatchNewParamsRequestParams{
  				Model:     anthropic.ModelClaudeOpus5_5,
  				MaxTokens: 1024,
  				Messages: []anthropic.MessageParam{
  					anthropic.NewUserMessage(
  						anthropic.NewDocumentBlock(anthropic.Base64PDFSourceParam{
  							Data: pdfBase64,
  						}),
  						anthropic.NewTextBlock("Extract 5 key insights from this document."),
  					),
  				},
  			},
  		},
  	},
  })
  if err != nil {
  	panic(err)
  }

  fmt.Printf("%+v\n", batch)
  ```

  ```java Java
  AnthropicClient client = AnthropicOkHttpClient.fromEnv();

  // Scarica e codifica il PDF
  String pdfUrl =
      "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf";
  HttpClient httpClient = HttpClient.newBuilder()
      .followRedirects(HttpClient.Redirect.NORMAL)
      .build();
  HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create(pdfUrl))
      .GET()
      .build();

  HttpResponse<byte[]> response = httpClient.send(
      request,
      HttpResponse.BodyHandlers.ofByteArray()
  );
  String pdfBase64 = Base64.getEncoder().encodeToString(response.body());

  BatchCreateParams params = BatchCreateParams.builder()
      .addRequest(
          BatchCreateParams.Request.builder()
              .customId("my-first-request")
              .params(
                  BatchCreateParams.Request.Params.builder()
                      .model(Model.CLAUDE_OPUS_5_5)
                      .maxTokens(1024)
                      .addUserMessageOfContentBlockParams(
                          List.of(
                              ContentBlockParam.ofDocument(
                                  DocumentBlockParam.builder()
                                      .source(Base64PdfSource.builder()
                                          .data(pdfBase64)
                                          .build())
                                      .build()
                              ),
                              ContentBlockParam.ofText(
                                  TextBlockParam.builder()
                                      .text(
                                          "Which model has the highest human preference win rates across each use-case?"
                                      )
                                      .build()
                              )
                          )
                      )
                      .build()
              )
              .build()
      )
      .addRequest(
          BatchCreateParams.Request.builder()
              .customId("my-second-request")
              .params(
                  BatchCreateParams.Request.Params.builder()
                      .model(Model.CLAUDE_OPUS_5_5)
                      .maxTokens(1024)
                      .addUserMessageOfContentBlockParams(
                          List.of(
                              ContentBlockParam.ofDocument(
                                  DocumentBlockParam.builder()
                                      .source(Base64PdfSource.builder()
                                          .data(pdfBase64)
                                          .build())
                                      .build()
                              ),
                              ContentBlockParam.ofText(
                                  TextBlockParam.builder()
                                      .text("Extract 5 key insights from this document.")
                                      .build()
                              )
                          )
                      )
                      .build()
              )
              .build()
      )
      .build();

  MessageBatch batch = client.messages().batches().create(params);
  IO.println(batch);
  ```

  ```php PHP
  $client = new Client();

  // Carica e codifica il PDF
  $pdf_url = 'https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf';
  $pdf_bytes = file_get_contents($pdf_url)
      ?: throw new \RuntimeException('Could not fetch the PDF.');
  $pdf_data = base64_encode($pdf_bytes);

  $batch = $client->messages->batches->create(
      requests: [
          [
              'customID' => 'my-first-request',
              'params' => [
                  'model' => Model::CLAUDE_OPUS_5_5,
                  'maxTokens' => 1024,
                  'messages' => [
                      [
                          'role' => 'user',
                          'content' => [
                              [
                                  'type' => 'document',
                                  'source' => [
                                      'type' => 'base64',
                                      'mediaType' => 'application/pdf',
                                      'data' => $pdf_data,
                                  ],
                              ],
                              [
                                  'type' => 'text',
                                  'text' => 'Which model has the highest human preference win rates across each use-case?',
                              ],
                          ],
                      ],
                  ],
              ],
          ],
          [
              'customID' => 'my-second-request',
              'params' => [
                  'model' => Model::CLAUDE_OPUS_5_5,
                  'maxTokens' => 1024,
                  'messages' => [
                      [
                          'role' => 'user',
                          'content' => [
                              [
                                  'type' => 'document',
                                  'source' => [
                                      'type' => 'base64',
                                      'mediaType' => 'application/pdf',
                                      'data' => $pdf_data,
                                  ],
                              ],
                              [
                                  'type' => 'text',
                                  'text' => 'Extract 5 key insights from this document.',
                              ],
                          ],
                      ],
                  ],
              ],
          ],
      ],
  );

  echo $batch;
  ```

  ```ruby Ruby
  require "open-uri"

  # Carica e codifica il PDF
  pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
  pdf_bytes = URI.open(pdf_url, "rb", &:read)
  pdf_data = [pdf_bytes].pack("m0") # Encode as base64 without newlines

  anthropic = Anthropic::Client.new

  message_batch = anthropic.messages.batches.create(
    requests: [
      {
        custom_id: "my-first-request",
        params: {
          model: Anthropic::Model::CLAUDE_OPUS_5_5,
          max_tokens: 1024,
          messages: [
            {
              role: "user",
              content: [
                {
                  type: "document",
                  source: {
                    type: "base64",
                    media_type: "application/pdf",
                    data: pdf_data
                  }
                },
                {
                  type: "text",
                  text: "Which model has the highest human preference win rates across each use-case?"
                }
              ]
            }
          ]
        }
      },
      {
        custom_id: "my-second-request",
        params: {
          model: Anthropic::Model::CLAUDE_OPUS_5_5,
          max_tokens: 1024,
          messages: [
            {
              role: "user",
              content: [
                {
                  type: "document",
                  source: {
                    type: "base64",
                    media_type: "application/pdf",
                    data: pdf_data
                  }
                },
                {
                  type: "text",
                  text: "Extract 5 key insights from this document."
                }
              ]
            }
          ]
        }
      }
    ]
  )

  puts(message_batch)
  ```
</CodeGroup>

I batch vengono elaborati in modo asincrono. Per controllare l’avanzamento e recuperare i risultati al termine dell’elaborazione, consulta [Elaborazione batch](https://platform.claude.com/docs/it/build-with-claude/batch-processing).

## Prossimi passi

<CardGroup cols={2}>
  <Card title="Visione" icon="image" href="https://platform.claude.com/docs/it/build-with-claude/vision">
    Scopri come contare i token visivi di un’immagine e quali limitazioni i PDF condividono con gli altri compiti di visione.
  </Card>

  <Card title="Prova gli esempi PDF" icon="file" href="https://platform.claude.com/cookbook/multimodal-getting-started-with-vision">
    Esplora esempi pratici di elaborazione dei PDF nella ricetta del Claude Cookbook.
  </Card>

  <Card title="Consulta il riferimento API" icon="code" href="https://platform.claude.com/docs/it/api/messages/create">
    Consulta la documentazione API completa per il supporto PDF.
  </Card>
</CardGroup>

## Disponibilità

La funzionalità Supporto PDF è disponibile su tutti i modelli e idonea per conservazione zero dei dati e preparazione HIPAA.

### Supporto API

#### [Messages API](https://platform.claude.com/docs/it/build-with-claude/working-with-messages)

* Disponibilità: Sempre attivo

| Stato | Piattaforme cloud |
| ----- | ----- |
| Disponibile | Claude API, [Claude Platform on AWS](https://platform.claude.com/docs/it/build-with-claude/claude-platform-on-aws), [Claude Models on Google Cloud (Anthropic managed)](https://platform.claude.com/docs/it/build-with-claude/claude-models-on-google-cloud/anthropic-managed) |
| Disponibile<sup>1</sup> | [Microsoft Foundry](https://platform.claude.com/docs/it/build-with-claude/claude-in-microsoft-foundry) |
| Disponibile<sup>2</sup> | [Amazon Bedrock (bedrock-runtime)](https://platform.claude.com/docs/it/build-with-claude/claude-on-amazon-bedrock-legacy) |
| Disponibile<sup>2</sup> | [Amazon Bedrock](https://platform.claude.com/docs/it/build-with-claude/claude-in-amazon-bedrock), [Claude Models on Google Cloud (Google managed)](https://platform.claude.com/docs/it/build-with-claude/claude-models-on-google-cloud/google-managed) |

1. Le sorgenti `file_id` richiedono un deployment Hosted on Anthropic.
2. Solo sorgenti base64.

#### [Managed Agents](https://platform.claude.com/docs/it/managed-agents/overview)

* Disponibilità: Sempre attivo

| Stato | Piattaforme cloud |
| ----- | ----- |
| Disponibile | Tutte le piattaforme supportate |

### Gestione dei dati

[Panoramica sulla gestione dei dati](https://platform.claude.com/docs/it/manage-claude/api-and-data-retention#feature-eligibility)

| Elemento | Conservazione zero dei dati | HIPAA |
| ----- | ----- | ----- |
| Stato | Idoneo (esclude [Modelli coperti](https://platform.claude.com/docs/it/manage-claude/api-and-data-retention#model-specific-data-retention-requirements)) | Idoneo |
| Dettagli | — | L’idoneità HIPAA si applica ai PDF inviati inline tramite la Messages API, non tramite la Files API. |

Endpoint applicabili:

* `/v1/messages`
