제공하는 PDF의 텍스트, 그림, 차트, 표에 대해 Claude에게 질문할 수 있습니다. 몇 가지 사용 사례 예시:
Claude는 모든 표준 PDF와 함께 작동합니다. 요청 크기가 다음 요구 사항을 충족하는지 확인하세요:
| 요구 사항 | 제한 |
|---|---|
| 최대 요청 크기 | 32 MB (플랫폼에 따라 다름) |
| 요청당 최대 페이지 수 | 600 (요청의 컨텍스트 윈도우가 1M 토큰 미만인 경우 100) |
| 형식 | 표준 PDF (비밀번호/암호화 없음) |
두 제한 모두 PDF와 함께 전송되는 다른 콘텐츠를 포함한 전체 요청 페이로드에 적용됩니다. 대용량 PDF의 경우, Files API로 업로드하고 file_id로 참조하여 요청 페이로드를 작게 유지하는 것을 고려하세요.
PDF 지원은 Claude의 비전 기능에 의존하기 때문에 다른 비전 작업과 동일한 제한 사항 및 고려 사항이 적용됩니다.
PDF 지원은 Claude API, Amazon Bedrock(Amazon Bedrock PDF 지원 참조), Claude Platform on AWS, Google Cloud, Microsoft Foundry에서 사용할 수 있습니다. 모든 활성 모델이 PDF 처리를 지원합니다.
Claude on Amazon Bedrock (Opus 4.6 및 이전 버전)의 일부인 Converse API를 통해 PDF 지원을 사용할 때, 두 가지 서로 다른 문서 처리 모드가 있습니다:
Converse Document Chat (기존 모드 - 텍스트 추출만)
Claude PDF Chat (새 모드 - 전체 시각적 이해)
Converse API를 사용할 때 Claude가 PDF의 이미지나 차트를 보지 못한다면, 인용 플래그를 활성화해야 할 가능성이 높습니다. 이 플래그가 없으면 Converse는 기본 텍스트 추출만으로 대체됩니다.
Messages API를 사용한 간단한 예제로 시작하세요. Claude에 PDF를 제공하는 방법은 세 가지입니다:
document 콘텐츠 블록에 base64로 인코딩된 PDF로file_id로가장 간단한 방법은 URL에서 직접 PDF를 참조하는 것입니다:
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-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)응답은 Claude의 분석을 content의 텍스트 블록으로 반환하며, 토큰 소비량은 usage에 포함됩니다:
{
"id": "msg_01Hfp8YuFjQ55VgWbpdHDehB",
"type": "message",
"role": "assistant",
"model": "claude-opus-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
}
}로컬 시스템에서 PDF를 보내야 하거나 URL을 사용할 수 없는 경우:
import base64
import httpx
# 먼저 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, follow_redirects=True).content
).decode("utf-8")
# 대안: 로컬 파일에서 로드
# with open("document.pdf", "rb") as f:
# pdf_data = base64.standard_b64encode(f.read()).decode("utf-8")
# base64 인코딩을 사용하여 Claude에 전송
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-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)반복적으로 사용할 PDF이거나 인코딩 오버헤드를 피하고 싶은 경우, Files API(베타)를 사용하세요:
client = anthropic.Anthropic()
# PDF 파일 업로드
with open("/path/to/document.pdf", "rb") as f:
file_upload = client.beta.files.upload(file=("document.pdf", f, "application/pdf"))
# 업로드된 파일을 메시지에서 사용
message = client.beta.messages.create(
model="claude-opus-5",
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의 비용을 추정할 수 있습니다.
최적의 결과를 위해 다음 모범 사례를 따르세요:
대용량 처리를 위해 다음 접근 방식을 고려하세요:
프롬프트 캐싱으로 PDF를 캐시하여 반복 쿼리의 성능을 향상시키세요:
import base64
import httpx
# 먼저 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, follow_redirects=True).content
).decode("utf-8")
# 캐시된 문서로 메시지를 생성합니다
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-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)Message Batches API를 사용하여 하나의 요청으로 많은 PDF를 처리하세요:
import base64
import httpx
# 먼저 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, follow_redirects=True).content
).decode("utf-8")
# 문서를 사용하는 요청 배치를 생성합니다
client = anthropic.Anthropic()
message_batch = client.messages.batches.create(
requests=[
{
"custom_id": "my-first-request",
"params": {
"model": "claude-opus-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",
"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)배치는 비동기적으로 처리됩니다. 진행 상황을 확인하고 처리가 끝난 후 결과를 검색하려면 배치 처리를 참조하세요.
Claude의 비전 기능을 통해 이미지를 이해하고 분석할 수 있어 멀티모달 상호작용의 흥미로운 가능성이 열립니다.
Claude Cookbook 레시피에서 PDF 처리의 실용적인 예제를 살펴보세요.
PDF 지원에 대한 전체 API 문서를 확인하세요.
Was this page helpful?