The whole hunk
from line 541, old and new numbered
/
lines
from line 541
541541 FILE_ID=$(curl -sS -X POST https://api.anthropic.com/v1/files \
542542 -H "x-api-key: $ANTHROPIC_API_KEY" \
543543 -H "anthropic-version: 2023-06-01" \
544 -H "anthropic-beta: files-api-2025-04-14" \
546545
547546 # Then use the returned file_id in your message
from line 547
548547 curl https://api.anthropic.com/v1/messages \
549548 -H "x-api-key: $ANTHROPIC_API_KEY" \
550549 -H "anthropic-version: 2023-06-01" \
551 -H "anthropic-beta: files-api-2025-04-14" \
552550 -H "content-type: application/json" \
553551 -d @- <<EOF
554552 {
from line 579
581579 https://platform.claude.com/docs/images/vision-example.jpg
582580
583581 # First, upload your image to the Files API
584 FILE_ID=$(ant beta:files upload \
582 FILE_ID=$(ant files upload \
585583 --file ./vision-example.jpg \
586584 --transform id --raw-output)
587585
588586 # Then use the returned file_id in your message
589 ant beta:messages create \
590 --beta files-api-2025-04-14 \
587 ant messages create \
591588 --transform content --format yaml <<YAML
592589 model: claude-opus-5
593590 max_tokens: 1024
from line 605
608605
609606 # Upload the image file
610607 with open("vision-example.jpg", "rb") as f:
611 file_upload = client.beta.files.upload(file=("vision-example.jpg", f, "image/jpeg"))
608 file_upload = client.files.upload(file=("vision-example.jpg", f, "image/jpeg"))
612609
613610 # Use the uploaded file in a message
614 message = client.beta.messages.create(
611 message = client.messages.create(
615612 model="claude-opus-5",
616613 max_tokens=1024,
617 betas=["files-api-2025-04-14"],
618614 messages=[
619615 {
620616 "role": "user",
from line 635
639635 const anthropic = new Anthropic();
640636
641637 // Upload the image file
642 const fileUpload = await anthropic.beta.files.upload({
638 const fileUpload = await anthropic.files.upload({
643639 file: await toFile(fs.createReadStream("vision-example.jpg"), undefined, {
644640 type: "image/jpeg"
645641 })
from line 642
646642 });
647643
648644 // Use the uploaded file in a message
649 const response = await anthropic.beta.messages.create({
645 const response = await anthropic.messages.create({
650646 model: "claude-opus-5",
651647 max_tokens: 1024,
652 betas: ["files-api-2025-04-14"],
653648 messages: [
654649 {
655650 role: "user",
from line 669
674669 ```
675670
676671 ```csharp C#
672 using System.Collections.Generic;
677673 using Anthropic;
674 using Anthropic.Core;
675 using Anthropic.Models.Files;
676 using Anthropic.Models.Messages;
678677
679 var client = new AnthropicClient();
678 AnthropicClient client = new();
680679
681680 // Upload the image file
682 var fileUpload = await client.Beta.Files.Upload(
683 new FileUploadParams { File = File.OpenRead("vision-example.jpg") });
681 var fileUpload = await client.Files.Upload(new FileUploadParams
682 {
683 File = new BinaryContent
684 {
685 Stream = File.OpenRead("vision-example.jpg"),
686 FileName = "vision-example.jpg",
687 ContentType = new("image/jpeg"),
688 },
689 });
684690
685691 // Use the uploaded file in a message
686 var response = await client.Beta.Messages.Create(
687 new MessageCreateParams
688 {
689 Model = "claude-opus-5",
690 MaxTokens = 1024,
691 Betas = new[] { "files-api-2025-04-14" },
692 Messages = new[]
692 var response = await client.Messages.Create(new MessageCreateParams
693 {
694 Model = Model.ClaudeOpus5,
695 MaxTokens = 1024,
696 Messages =
697 [
698 new()
693699 {
694 new BetaMessageParam
700 Role = Role.User,
701 Content = new MessageParamContent(new List<ContentBlockParam>
695702 {
696 Role = "user",
697 Content = new object[]
698 {
699 new
700 {
701 type = "image",
702 source = new { type = "file", file_id = fileUpload.Id }
703 },
704 new { type = "text", text = "Describe this image." }
705 }
706 }
703 new ContentBlockParam(new ImageBlockParam(
704 new ImageBlockParamSource(new FileImageSource(fileUpload.ID))
705 )),
706 new ContentBlockParam(new TextBlockParam("Describe this image.")),
707 }),
707708 }
708 });
709 ]
710 });
709711
710712 Console.WriteLine(response);
711713 ```
from line 722
720722 }
721723 defer file.Close()
722724
723 fileUpload, err := client.Beta.Files.Upload(context.Background(),
724 anthropic.BetaFileUploadParams{
725 File: file,
725 fileUpload, err := client.Files.Upload(context.Background(),
726 anthropic.FileUploadParams{
727 File: anthropic.File(file, "vision-example.jpg", "image/jpeg"),
726728 })
727729 if err != nil {
728730 log.Fatal(err)
from line 731
729731 }
730732
731733 // Use the uploaded file in a message
732 message, err := client.Beta.Messages.New(context.Background(),
733 anthropic.BetaMessageNewParams{
734 message, err := client.Messages.New(context.Background(),
735 anthropic.MessageNewParams{
734736 Model: anthropic.ModelClaudeOpus5,
735737 MaxTokens: 1024,
736 Betas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaFilesAPI2025_04_14},
737 Messages: []anthropic.BetaMessageParam{
738 anthropic.NewBetaUserMessage(
739 anthropic.NewBetaImageBlock(anthropic.BetaFileImageSourceParam{
738 Messages: []anthropic.MessageParam{
739 anthropic.NewUserMessage(
740 anthropic.NewImageBlock(anthropic.FileImageSourceParam{
740741 FileID: fileUpload.ID,
741742 }),
742 anthropic.NewBetaTextBlock("Describe this image."),
743 anthropic.NewTextBlock("Describe this image."),
743744 ),
744745 },
745746 })
from line 752
751752 ```
752753
753754 ```java Java
754 import com.anthropic.models.beta.files.FileMetadata;
755 import com.anthropic.models.beta.files.FileUploadParams;
755 import com.anthropic.core.MultipartField;
756 import com.anthropic.models.files.FileMetadata;
757 import com.anthropic.models.files.FileUploadParams;
756758 // ...
757759 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
758760
759761 // Upload the image file
760 FileMetadata file = client
761 .beta()
762 .files()
763 .upload(
764 FileUploadParams.builder()
765 .file(Files.newInputStream(Path.of("vision-example.jpg")))
766 .build()
767 );
762 FileMetadata file = client.files().upload(
763 FileUploadParams.builder()
764 .file(
765 MultipartField.<InputStream>builder()
766 .value(Files.newInputStream(Path.of("vision-example.jpg")))
767 .filename("vision-example.jpg")
768 .contentType("image/jpeg")
769 .build()
770 )
771 .build()
772 );
768773
769774 // Use the uploaded file in a message
770775 ImageBlockParam imageParam = ImageBlockParam.builder().fileSource(file.id()).build();
from line 796
791796
792797 // Upload the image file
793798 $fileUpload = $client->beta->files->upload(
794 file: fopen('vision-example.jpg', 'r'),
799 FileParam::fromResource(fopen('vision-example.jpg', 'rb'), contentType: 'image/jpeg'),
795800 );
796801
797802 // Use the uploaded file in a message
from line 825
820825 client = Anthropic::Client.new
821826
822827 # Upload the image file
823 file_upload = client.beta.files.upload(
824 file: File.open("vision-example.jpg", "rb")
828 file_upload = client.files.upload(
829 file: Anthropic::FilePart.new(
830 File.open("vision-example.jpg", "rb"),
831 content_type: "image/jpeg"
832 )
825833 )
826834
827835 # Use the uploaded file in a message
828 message = client.beta.messages.create(
836 message = client.messages.create(
829837 model: "claude-opus-5",
830838 max_tokens: 1024,
831 betas: ["files-api-2025-04-14"],
832839 messages: [
833840 {
834841 role: "user",