pdf-support changedbuild-with-claude/pdf-support
Nearest release: v2.1.238, published under an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+28added
Lines−46removed
From line
704
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits14to this page, all time
The whole hunk
from line 704, old and new numbered
/
from line 704
704704
705705#### Option 3: Files API
706706
707For PDFs you'll use repeatedly, or when you want to avoid encoding overhead, use the [Files API](https://platform.claude.com/docs/en/build-with-claude/files). These examples send the `anthropic-beta: files-api-2025-04-14` header, which the API accepts but doesn't require:
707For PDFs you'll use repeatedly, or when you want to avoid encoding overhead, use the [Files API](https://platform.claude.com/docs/en/build-with-claude/files):
708708
709709<CodeGroup>
710710 ```bash cURL
from line 712
712712 FILE_ID=$(curl -sS -X POST https://api.anthropic.com/v1/files \
713713 -H "x-api-key: $ANTHROPIC_API_KEY" \
714714 -H "anthropic-version: 2023-06-01" \
715 -H "anthropic-beta: files-api-2025-04-14" \
717716
718717 # Then use the returned file_id in your message
from line 719
720719 -H "content-type: application/json" \
721720 -H "x-api-key: $ANTHROPIC_API_KEY" \
722721 -H "anthropic-version: 2023-06-01" \
723 -H "anthropic-beta: files-api-2025-04-14" \
724722 -d @- <<EOF
725723 {
726724 "model": "claude-opus-5",
from line 743
745743
746744 ```bash CLI
747745 # First, upload your PDF to the Files API
748 FILE_ID=$(ant beta:files upload \
746 FILE_ID=$(ant files upload \
749747 --file ./document.pdf \
750748 --transform id \
751749 --raw-output)
752750
753751 # Then use the returned file_id in your message
754 ant beta:messages create \
755 --beta files-api-2025-04-14 \
752 ant messages create \
756753 --transform content \
757754 --format yaml <<YAML
758755 model: claude-opus-5
from line 771
774771
775772 # Upload the PDF file
776773 with open("/path/to/document.pdf", "rb") as f:
777 file_upload = client.beta.files.upload(file=("document.pdf", f, "application/pdf"))
774 file_upload = client.files.upload(file=("document.pdf", f, "application/pdf"))
778775
779776 # Use the uploaded file in a message
780 message = client.beta.messages.create(
777 message = client.messages.create(
781778 model="claude-opus-5",
782779 max_tokens=1024,
783 betas=["files-api-2025-04-14"],
784780 messages=[
785781 {
786782 "role": "user",
from line 801
805801 const anthropic = new Anthropic();
806802
807803 // Upload the PDF file
808 const fileUpload = await anthropic.beta.files.upload({
804 const fileUpload = await anthropic.files.upload({
809805 file: await toFile(fs.createReadStream("/path/to/document.pdf"), undefined, {
810806 type: "application/pdf"
811807 })
from line 808
812808 });
813809
814810 // Use the uploaded file in a message
815 const response = await anthropic.beta.messages.create({
811 const response = await anthropic.messages.create({
816812 model: "claude-opus-5",
817813 max_tokens: 1024,
818 betas: ["files-api-2025-04-14"],
819814 messages: [
820815 {
821816 role: "user",
from line 835
840835 ```
841836
842837 ```csharp C#
843 using Messages = Anthropic.Models.Messages;
844
845838 var client = new AnthropicClient();
846839
847840 // Upload the PDF file
848 var fileUpload = await client.Beta.Files.Upload(new FileUploadParams
841 var fileUpload = await client.Files.Upload(new FileUploadParams
849842 {
850843 File = new BinaryContent
851844 {
from line 849
856849 });
857850
858851 // Use the uploaded file in a message
859 var message = await client.Beta.Messages.Create(new MessageCreateParams
852 var message = await client.Messages.Create(new MessageCreateParams
860853 {
861 Model = Messages::Model.ClaudeOpus5,
854 Model = Model.ClaudeOpus5,
862855 MaxTokens = 1024,
863 Betas = [AnthropicBeta.FilesApi2025_04_14],
864856 Messages =
865857 [
866858 new()
867859 {
868860 Role = Role.User,
869 Content = new List<BetaContentBlockParam>
861 Content = new List<ContentBlockParam>
870862 {
871 new BetaRequestDocumentBlock
863 new DocumentBlockParam
872864 {
873 Source = new BetaFileDocumentSource { FileID = fileUpload.ID },
865 Source = new FileDocumentSource { FileID = fileUpload.ID },
874866 },
875 new BetaTextBlockParam("What are the key findings in this document?"),
867 new TextBlockParam("What are the key findings in this document?"),
876868 },
877869 },
878870 ],
from line 883
891883 }
892884 defer pdfFile.Close()
893885
894 fileUpload, err := client.Beta.Files.Upload(context.TODO(), anthropic.BetaFileUploadParams{
886 fileUpload, err := client.Files.Upload(context.TODO(), anthropic.FileUploadParams{
895887 File: anthropic.File(pdfFile, "document.pdf", "application/pdf"),
896888 })
897889 if err != nil {
from line 891
899891 }
900892
901893 // Use the uploaded file in a message
902 message, err := client.Beta.Messages.New(context.TODO(), anthropic.BetaMessageNewParams{
894 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
903895 Model: anthropic.ModelClaudeOpus5,
904896 MaxTokens: 1024,
905 Betas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaFilesAPI2025_04_14},
906 Messages: []anthropic.BetaMessageParam{
907 anthropic.NewBetaUserMessage(
908 anthropic.NewBetaDocumentBlock(anthropic.BetaFileDocumentSourceParam{
897 Messages: []anthropic.MessageParam{
898 anthropic.NewUserMessage(
899 anthropic.NewDocumentBlock(anthropic.FileDocumentSourceParam{
909900 FileID: fileUpload.ID,
910901 }),
911 anthropic.NewBetaTextBlock("What are the key findings in this document?"),
902 anthropic.NewTextBlock("What are the key findings in this document?"),
912903 ),
913904 },
914905 })
from line 915
924915
925916 // Upload the PDF file
926917 FileMetadata file = client
927 .beta()
928918 .files()
929919 .upload(FileUploadParams.builder().file(Path.of("/path/to/document.pdf")).build());
930920
from line 921
931921 // Use the uploaded file in a message
932922 MessageCreateParams params = MessageCreateParams.builder()
933923 .model(Model.CLAUDE_OPUS_5)
934 .addBeta(AnthropicBeta.FILES_API_2025_04_14)
935924 .maxTokens(1024)
936 .addUserMessageOfBetaContentBlockParams(
925 .addUserMessageOfBlockParams(
937926 List.of(
938 BetaContentBlockParam.ofDocument(
939 BetaRequestDocumentBlock.builder()
940 .source(
941 BetaFileDocumentSource.builder()
942 .fileId(file.id())
943 .build()
944 )
945 .build()
927 ContentBlockParam.ofDocument(
928 DocumentBlockParam.builder().fileSource(file.id()).build()
946929 ),
947 BetaContentBlockParam.ofText(
948 BetaTextBlockParam.builder()
930 ContentBlockParam.ofText(
931 TextBlockParam.builder()
949932 .text("What are the key findings in this document?")
950933 .build()
951934 )
from line 936
953936 )
954937 .build();
955938
956 BetaMessage message = client.beta().messages().create(params);
939 Message message = client.messages().create(params);
957940 System.out.println(message.content());
958941 ```
959942
from line 983
1000983
1001984 # Upload the PDF file
1002985 file_upload = File.open("/path/to/document.pdf", "rb") do |f|
1003 anthropic.beta.files.upload(
986 anthropic.files.upload(
1004987 file: Anthropic::FilePart.new(f, filename: "document.pdf", content_type: "application/pdf")
1005988 )
1006989 end
1007990
1008991 # Use the uploaded file in a message
1009 message = anthropic.beta.messages.create(
992 message = anthropic.messages.create(
1010993 model: "claude-opus-5",
1011994 max_tokens: 1024,
1012 betas: ["files-api-2025-04-14"],
1013995 messages: [
1014996 {
1015997 role: "user",
No line in this hunk matches that.