This feature is eligible for Zero Data Retention (ZDR). When your organization has a ZDR arrangement, data sent through this feature is not stored after the API response is returned.
제공하는 PDF의 모든 텍스트, 사진, 차트 및 표에 대해 Claude에게 질문할 수 있습니다. 몇 가지 샘플 사용 사례:
Claude는 모든 표준 PDF에서 작동합니다. 요청 크기가 다음 요구사항을 충족하는지 확인하세요:
| 요구사항 | 제한 |
|---|---|
| 최대 요청 크기 | 32 MB (플랫폼별로 다름) |
| 요청당 최대 페이지 수 | 600 (200k 토큰 컨텍스트 윈도우가 있는 모델의 경우 100) |
| 형식 | 표준 PDF (암호/암호화 없음) |
두 제한 모두 PDF와 함께 전송되는 다른 콘텐츠를 포함한 전체 요청 페이로드에 적용됩니다. 큰 PDF의 경우 Files API로 업로드하고 file_id로 참조하여 요청 페이로드를 작게 유지하는 것을 고려하세요.
밀도가 높은 PDF(많은 작은 글꼴 페이지, 복잡한 표 또는 무거운 그래픽)는 페이지 제한에 도달하기 전에 컨텍스트 윈도우를 채울 수 있습니다. 큰 PDF가 있는 요청은 Files API를 사용하는 경우에도 페이지 제한에 도달하기 전에 실패할 수 있습니다. 문서를 섹션으로 분할해 보세요. 큰 파일의 경우 각 페이지가 이미지로 처리되므로 포함된 이미지를 다운샘플링하면 도움이 될 수 있습니다.
PDF 지원은 Claude의 비전 기능에 의존하므로 다른 비전 작업과 동일한 제한 및 고려사항의 적용을 받습니다.
PDF 지원은 현재 직접 API 액세스 및 Google Vertex AI를 통해 지원됩니다. 모든 활성 모델은 PDF 처리를 지원합니다.
PDF 지원은 이제 Amazon Bedrock에서 다음 고려사항과 함께 사용 가능합니다:
Amazon Bedrock의 Converse API를 통해 PDF 지원을 사용할 때 두 가지 고유한 문서 처리 모드가 있습니다:
중요: Converse API에서 Claude의 전체 시각적 PDF 이해 기능에 액세스하려면 인용을 활성화해야 합니다. 인용이 활성화되지 않으면 API는 기본 텍스트 추출만으로 폴백됩니다. 인용 작업에 대해 자세히 알아보세요.
Converse Document Chat (원본 모드 - 텍스트 추출만)
Claude PDF Chat (새 모드 - 전체 시각적 이해)
고객이 Converse API를 사용할 때 Claude가 PDF의 이미지나 차트를 보지 못한다고 보고하면 인용 플래그를 활성화해야 할 가능성이 높습니다. 이것이 없으면 Converse는 기본 텍스트 추출만으로 폴백됩니다.
이것은 Converse API의 알려진 제약입니다. 인용 없이 시각적 PDF 분석이 필요한 애플리케이션의 경우 대신 InvokeModel API를 사용하는 것을 고려하세요.
.csv, .xlsx, .docx, .md 또는 .txt 파일과 같은 PDF가 아닌 파일의 경우 다른 파일 형식 작업을 참조하세요.
Messages API를 사용한 간단한 예제로 시작하겠습니다. Claude에 PDF를 제공하는 방법은 세 가지입니다:
document 콘텐츠 블록의 base64 인코딩 PDFfile_id가장 간단한 방법은 URL에서 직접 PDF를 참조하는 것입니다:
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-4-7",
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)로컬 시스템에서 PDF를 보내야 하거나 URL을 사용할 수 없을 때:
import base64
import httpx
# First, load and encode the PDF
pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
pdf_data = base64.standard_b64encode(httpx.get(pdf_url).content).decode("utf-8")
# Alternative: Load from a local file
# with open("document.pdf", "rb") as f:
# pdf_data = base64.standard_b64encode(f.read()).decode("utf-8")
# Send to Claude using base64 encoding
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-4-7",
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)반복적으로 사용할 PDF의 경우 또는 인코딩 오버헤드를 피하려는 경우 Files API를 사용하세요:
client = anthropic.Anthropic()
# Upload the PDF file
with open("document.pdf", "rb") as f:
file_upload = client.beta.files.upload(file=("document.pdf", f, "application/pdf"))
# Use the uploaded file in a message
message = client.beta.messages.create(
model="claude-opus-4-7",
max_tokens=1024,
betas=["files-api-2025-04-14"],
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)Claude에 PDF를 보낼 때 다음 단계가 발생합니다:
시스템이 문서의 내용을 추출합니다.
Claude는 텍스트와 이미지를 모두 분석하여 문서를 더 잘 이해합니다.
Claude가 응답하며 필요한 경우 PDF의 내용을 참조합니다.
Claude는 응답할 때 텍스트 및 시각적 콘텐츠를 모두 참조할 수 있습니다. 다음을 통해 성능을 더욱 향상시킬 수 있습니다:
PDF 파일의 토큰 수는 문서에서 추출된 총 텍스트와 페이지 수에 따라 달라집니다:
토큰 계산을 사용하여 특정 PDF의 비용을 추정할 수 있습니다.
최적의 결과를 위해 다음 모범 사례를 따르세요:
대용량 처리의 경우 다음 접근 방식을 고려하세요:
반복되는 쿼리의 성능을 개선하기 위해 PDF를 캐시합니다:
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-4-7",
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": "Analyze this document."},
],
}
],
)대용량 워크플로우를 위해 Message Batches API를 사용합니다:
client = anthropic.Anthropic()
message_batch = client.messages.batches.create(
requests=[
{
"custom_id": "doc1",
"params": {
"model": "claude-opus-4-7",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": pdf_data,
},
},
{"type": "text", "text": "Summarize this document."},
],
}
],
},
}
]
)Was this page helpful?