이 기능은 Zero Data Retention (ZDR)의 적용 대상입니다. 조직에 ZDR 계약이 체결되어 있는 경우, 이 기능을 통해 전송된 데이터는 API 응답이 반환된 후 저장되지 않습니다.
제공하는 PDF의 텍스트, 그림, 차트, 표에 대해 Claude에게 질문할 수 있습니다. 몇 가지 샘플 사용 사례:
Claude는 모든 표준 PDF와 함께 작동합니다. 요청 크기가 다음 요구 사항을 충족하는지 확인하세요:
| 요구 사항 | 제한 |
|---|---|
| 최대 요청 크기 | 32 MB (플랫폼에 따라 다름) |
| 요청당 최대 페이지 수 | 600 (요청의 컨텍스트 윈도우가 1M 토큰 미만인 경우 100) |
| 형식 | 표준 PDF (비밀번호/암호화 없음) |
두 제한 모두 PDF와 함께 전송되는 다른 콘텐츠를 포함한 전체 요청 페이로드에 적용됩니다. 대용량 PDF의 경우, Files API로 업로드하고 file_id로 참조하여 요청 페이로드를 작게 유지하는 것을 고려하세요.
밀도가 높은 PDF(작은 글꼴의 많은 페이지, 복잡한 표 또는 많은 그래픽)는 페이지 제한에 도달하기 전에 컨텍스트 윈도우를 채울 수 있습니다. 대용량 PDF가 포함된 요청은 Files API를 사용하더라도 페이지 제한에 도달하기 전에 실패할 수 있습니다. 문서를 섹션으로 분할해 보세요. 대용량 파일의 경우, 각 페이지가 이미지로 처리되므로 포함된 이미지를 다운샘플링하는 것도 도움이 될 수 있습니다.
PDF 지원은 Claude의 비전 기능에 의존하므로, 다른 비전 작업과 동일한 제한 사항 및 고려 사항이 적용됩니다.
PDF 지원은 Claude API, Claude Platform on AWS, Amazon Bedrock(Amazon Bedrock PDF 지원 참조), Google Cloud, Microsoft Foundry에서 사용할 수 있습니다. 모든 활성 모델이 PDF 처리를 지원합니다.
Claude on Amazon Bedrock (레거시)의 일부인 Converse API를 통해 PDF 지원을 사용할 때, 두 가지 서로 다른 문서 처리 모드가 있습니다:
중요: Converse API에서 Claude의 전체 시각적 PDF 이해 기능에 접근하려면 인용(citations)을 활성화해야 합니다. 인용이 활성화되지 않으면 API는 기본 텍스트 추출만으로 대체됩니다. 인용 작업하기에 대해 자세히 알아보세요.
Converse Document Chat (기존 모드 - 텍스트 추출만)
Claude PDF Chat (새 모드 - 전체 시각적 이해)
Converse API를 사용할 때 Claude가 PDF의 이미지나 차트를 보지 못한다면, 인용 플래그를 활성화해야 할 가능성이 높습니다. 이 플래그가 없으면 Converse는 기본 텍스트 추출만으로 대체됩니다.
이는 Converse API의 알려진 제약 사항입니다. 인용 없이 시각적 PDF 분석이 필요한 애플리케이션의 경우, 대신 InvokeModel API 사용을 고려하세요.
.txt, .csv 또는 .md와 같은 일반 텍스트 파일은 문서 블록에서 직접 사용할 수 있습니다: MIME 타입 text/plain으로 Files API에 업로드하고 file_id로 참조하세요. .xlsx 또는 .docx와 같은 바이너리 형식은 문서 블록에서 지원되지 않으며 먼저 텍스트 또는 PDF로 변환해야 합니다. 다른 파일 형식으로 작업하기를 참조하세요.
Messages API를 사용한 간단한 예제부터 시작하겠습니다. Claude에 PDF를 제공하는 방법은 세 가지입니다:
document 콘텐츠 블록의 base64로 인코딩된 PDF로file_id로Amazon Bedrock 및 Google Cloud에서는 현재 base64로 인코딩된 소스만 사용할 수 있습니다. Microsoft Foundry에서는 Azure에 호스팅된 배포에 대해 Files API가 지원되지 않습니다.
가장 간단한 접근 방식은 URL에서 직접 PDF를 참조하는 것입니다:
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-4-8",
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-4-8",
"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-4-8",
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-4-8",
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의 내용을 참조하여 응답합니다.
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-4-8",
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-4-8",
"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-4-8",
"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의 비전 기능을 통해 이미지를 이해하고 분석할 수 있어 멀티모달 상호작용의 흥미로운 가능성이 열립니다.
쿡북 레시피에서 PDF 처리의 실용적인 예제를 살펴보세요.
PDF 지원에 대한 전체 API 문서를 확인하세요.
Was this page helpful?