---
title: 視覺
url: https://platform.claude.com/docs/zh-TW/build-with-claude/vision
description: Claude 的視覺能力讓它能夠理解和分析圖片，為多模態互動開啟了令人興奮的可能性。
---

本指南說明如何將圖片傳送給 Claude、適用的限制與費用，以及在哪裡可以找到[基於座標的工作流程](https://platform.claude.com/docs/zh-TW/build-with-claude/vision-coordinates)的相關指引。

***

## 將圖片傳送給 Claude

您可以透過以下方式使用 Claude 的視覺能力：

* [claude.ai](https://claude.ai/)。像上傳檔案一樣上傳圖片，或直接將圖片拖放到聊天視窗中。
* Claude Console 中的 [Playground](https://platform.claude.com/playground)。直接將圖片新增到任何 User 訊息區塊中。
* API 請求。請參閱以下範例。

在 API 上，請以 `image` 內容區塊的形式將圖片提供給 Claude，並使用以下三種來源類型之一：

1. 嵌入在請求主體中的 base64 編碼圖片
2. 指向線上託管圖片的 URL 參照
3. 由 [Files API](https://platform.claude.com/docs/zh-TW/build-with-claude/files) 傳回的 `file_id`（上傳一次，多次參照）

<Note>
  在 Amazon Bedrock 和 Google Cloud 上，目前僅提供 base64 編碼的來源。
</Note>

<Tip>
  就像在文字提示中[將長文件放在查詢之前](https://platform.claude.com/docs/zh-TW/build-with-claude/prompt-engineering/claude-prompting-best-practices#long-context-prompting)能改善結果一樣，當圖片放在文字之前時，Claude 的表現最佳。放在文字之後或與文字穿插的圖片仍然表現良好，但如果您的使用情境允許，建議優先採用先圖片後文字的結構。
</Tip>

### Base64 編碼圖片範例

<CodeGroup>
  ```bash cURL
  curl https://api.anthropic.com/v1/messages \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d @- <<EOF
  {
    "model": "claude-opus-5-5",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "image",
            "source": {
              "type": "base64",
              "media_type": "image/jpeg",
              "data": "$BASE64_IMAGE_DATA"
            }
          },
          {
            "type": "text",
            "text": "Describe this image."
          }
        ]
      }
    ]
  }
  EOF
  ```

  ```bash CLI
  curl -sSo ./vision-example.jpg \
    https://platform.claude.com/docs/images/vision-example.jpg

  ant messages create <<'YAML'
  model: claude-opus-5-5
  max_tokens: 1024
  messages:
    - role: user
      content:
        - type: image
          source:
            type: base64
            media_type: image/jpeg
            data: "@./vision-example.jpg"
        - type: text
          text: Describe this image.
  YAML
  ```

  ```python Python
  image1_data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC"
  image1_media_type = "image/png"

  client = anthropic.Anthropic()
  message = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      messages=[
          {
              "role": "user",
              "content": [
                  {
                      "type": "image",
                      "source": {
                          "type": "base64",
                          "media_type": image1_media_type,
                          "data": image1_data,
                      },
                  },
                  {"type": "text", "text": "Describe this image."},
              ],
          }
      ],
  )
  print(message)
  ```

  ```typescript TypeScript
  const anthropic = new Anthropic();

  const message = await anthropic.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "image",
            source: {
              type: "base64",
              media_type: "image/jpeg",
              data: imageData // Base64-encoded image data as string
            }
          },
          {
            type: "text",
            text: "Describe this image."
          }
        ]
      }
    ]
  });

  console.log(message);
  ```

  ```csharp C#
  using System.Collections.Generic;
  using Anthropic;
  using Anthropic.Models.Messages;

  AnthropicClient client = new();

  string imageData = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC";

  var message = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Messages =
      [
          new()
          {
              Role = Role.User,
              Content = new MessageParamContent(new List<ContentBlockParam>
              {
                  new ContentBlockParam(new ImageBlockParam(
                      new ImageBlockParamSource(new Base64ImageSource()
                      {
                          Data = imageData,
                          MediaType = MediaType.ImagePng,
                      })
                  )),
                  new ContentBlockParam(new TextBlockParam("Describe this image.")),
              }),
          }
      ]
  });

  Console.WriteLine(message);
  ```

  ```go Go
  client := anthropic.NewClient()

  imageData := "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC"

  message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
  	Model:     anthropic.ModelClaudeOpus5_5,
  	MaxTokens: 1024,
  	Messages: []anthropic.MessageParam{
  		anthropic.NewUserMessage(
  			anthropic.NewImageBlockBase64("image/png", imageData),
  			anthropic.NewTextBlock("Describe this image."),
  		),
  	},
  })
  if err != nil {
  	log.Fatal(err)
  }

  fmt.Println(message)
  ```

  ```java Java
  AnthropicClient client = AnthropicOkHttpClient.fromEnv();
  String imageData =
    "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC";

  List<ContentBlockParam> contentBlockParams = List.of(
    ContentBlockParam.ofImage(
      ImageBlockParam.builder()
        .source(
          Base64ImageSource.builder()
            .mediaType(Base64ImageSource.MediaType.IMAGE_PNG)
            .data(imageData)
            .build()
        )
        .build()
    ),
    ContentBlockParam.ofText(TextBlockParam.builder().text("Describe this image.").build())
  );
  Message message = client
    .messages()
    .create(
      MessageCreateParams.builder()
        .model(Model.CLAUDE_OPUS_5_5)
        .maxTokens(1024)
        .addUserMessageOfBlockParams(contentBlockParams)
        .build()
    );

  IO.println(message);
  ```

  ```php PHP
  $client = new Client();

  $imageData = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC";

  $message = $client->messages->create(
      maxTokens: 1024,
      messages: [
          [
              'role' => 'user',
              'content' => [
                  [
                      'type' => 'image',
                      'source' => [
                          'type' => 'base64',
                          'media_type' => 'image/png',
                          'data' => $imageData,
                      ],
                  ],
                  ['type' => 'text', 'text' => 'Describe this image.'],
              ],
          ],
      ],
      model: 'claude-opus-5-5',
  );

  echo json_encode($message, JSON_PRETTY_PRINT), PHP_EOL;
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  image_data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC"

  message = client.messages.create(
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "image",
            source: {
              type: "base64",
              media_type: "image/png",
              data: image_data
            }
          },
          { type: "text", text: "Describe this image." }
        ]
      }
    ]
  )

  puts message
  ```
</CodeGroup>

### 基於 URL 的圖片範例

<CodeGroup>
  ```bash cURL
  curl https://api.anthropic.com/v1/messages \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d '{
      "model": "claude-opus-5-5",
      "max_tokens": 1024,
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "type": "image",
              "source": {
                "type": "url",
                "url": "https://platform.claude.com/docs/images/vision-example.jpg"
              }
            },
            {
              "type": "text",
              "text": "Describe this image."
            }
          ]
        }
      ]
    }'
  ```

  ```bash CLI
  ant messages create <<'YAML'
  model: claude-opus-5-5
  max_tokens: 1024
  messages:
    - role: user
      content:
        - type: image
          source:
            type: url
            url: https://platform.claude.com/docs/images/vision-example.jpg
        - type: text
          text: Describe this image.
  YAML
  ```

  ```python Python
  client = anthropic.Anthropic()
  message = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      messages=[
          {
              "role": "user",
              "content": [
                  {
                      "type": "image",
                      "source": {
                          "type": "url",
                          "url": "https://platform.claude.com/docs/images/vision-example.jpg",
                      },
                  },
                  {"type": "text", "text": "Describe this image."},
              ],
          }
      ],
  )
  print(message)
  ```

  ```typescript TypeScript
  const anthropic = new Anthropic();

  const message = await anthropic.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "image",
            source: {
              type: "url",
              url: "https://platform.claude.com/docs/images/vision-example.jpg"
            }
          },
          {
            type: "text",
            text: "Describe this image."
          }
        ]
      }
    ]
  });

  console.log(message);
  ```

  ```csharp C#
  using System.Collections.Generic;
  using Anthropic;
  using Anthropic.Models.Messages;

  AnthropicClient client = new();

  var message = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Messages =
      [
          new()
          {
              Role = Role.User,
              Content = new MessageParamContent(new List<ContentBlockParam>
              {
                  new ContentBlockParam(new ImageBlockParam(
                      new ImageBlockParamSource(new UrlImageSource()
                      {
                          Url = "https://platform.claude.com/docs/images/vision-example.jpg",
                      })
                  )),
                  new ContentBlockParam(new TextBlockParam("Describe this image.")),
              }),
          }
      ]
  });

  Console.WriteLine(message);
  ```

  ```go Go
  client := anthropic.NewClient()

  message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
  	Model:     anthropic.ModelClaudeOpus5_5,
  	MaxTokens: 1024,
  	Messages: []anthropic.MessageParam{
  		anthropic.NewUserMessage(
  			anthropic.NewImageBlock(anthropic.URLImageSourceParam{
  				URL: "https://platform.claude.com/docs/images/vision-example.jpg",
  			}),
  			anthropic.NewTextBlock("Describe this image."),
  		),
  	},
  })
  if err != nil {
  	log.Fatal(err)
  }

  fmt.Println(message)
  ```

  ```java Java
  AnthropicClient client = AnthropicOkHttpClient.fromEnv();

  List<ContentBlockParam> contentBlockParams = List.of(
    ContentBlockParam.ofImage(
      ImageBlockParam.builder()
        .source(
          UrlImageSource.builder()
            .url("https://platform.claude.com/docs/images/vision-example.jpg")
            .build()
        )
        .build()
    ),
    ContentBlockParam.ofText(TextBlockParam.builder().text("Describe this image.").build())
  );
  Message message = client
    .messages()
    .create(
      MessageCreateParams.builder()
        .model(Model.CLAUDE_OPUS_5_5)
        .maxTokens(1024)
        .addUserMessageOfBlockParams(contentBlockParams)
        .build()
    );
  System.out.println(message);
  ```

  ```php PHP
  $client = new Client();

  $message = $client->messages->create(
      maxTokens: 1024,
      messages: [
          [
              'role' => 'user',
              'content' => [
                  [
                      'type' => 'image',
                      'source' => [
                          'type' => 'url',
                          'url' => 'https://platform.claude.com/docs/images/vision-example.jpg',
                      ],
                  ],
                  ['type' => 'text', 'text' => 'Describe this image.'],
              ],
          ],
      ],
      model: 'claude-opus-5-5',
  );

  echo json_encode($message, JSON_PRETTY_PRINT), PHP_EOL;
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  message = client.messages.create(
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "image",
            source: {
              type: "url",
              url: "https://platform.claude.com/docs/images/vision-example.jpg"
            }
          },
          { type: "text", text: "Describe this image." }
        ]
      }
    ]
  )

  puts message
  ```
</CodeGroup>

### Files API 圖片範例

對於您會重複使用的圖片，或當您想避免編碼開銷時，請使用 [Files API](https://platform.claude.com/docs/zh-TW/build-with-claude/files)。只需上傳圖片一次，之後在後續訊息中參照傳回的 `file_id`，而不必重新傳送 base64 資料。

<Tip>
  在多輪對話和代理式工作流程中，每個請求都會重新傳送 完整的對話歷史。如果圖片是以 base64 編碼，完整的圖片位元組 會在每一輪都包含在「payload」（酬載）中，隨著對話增長，這可能會大幅增加 請求大小和「latency」（延遲）。將圖片上傳到 Files API 並透過 `file_id` 參照它們，無論對話歷史中累積了多少圖片， 都能讓請求酬載保持精簡。
</Tip>

<CodeGroup>
  ```bash cURL
  # 首先，將您的圖片上傳至 Files API
  FILE_ID=$(curl -sS -X POST https://api.anthropic.com/v1/files \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -F "file=@vision-example.jpg" | jq -r '.id')

  # 接著在您的訊息中使用傳回的 file_id
  curl https://api.anthropic.com/v1/messages \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d '{
      "model": "claude-opus-5-5",
      "max_tokens": 1024,
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "type": "image",
              "source": {
                "type": "file",
                "file_id": "'"$FILE_ID"'"
              }
            },
            {
              "type": "text",
              "text": "Describe this image."
            }
          ]
        }
      ]
    }'
  ```

  ```bash CLI
  curl -sSo vision-example.jpg \
    https://platform.claude.com/docs/images/vision-example.jpg

  # 首先，將您的圖片上傳至 Files API
  FILE_ID=$(ant files upload \
    --file ./vision-example.jpg \
    --transform id --raw-output)

  # 接著在您的訊息中使用傳回的 file_id
  ant messages create \
    --transform content --format yaml <<YAML
  model: claude-opus-5-5
  max_tokens: 1024
  messages:
    - role: user
      content:
        - type: image
          source:
            type: file
            file_id: $FILE_ID
        - type: text
          text: Describe this image.
  YAML
  ```

  ```python Python
  client = anthropic.Anthropic()

  # 上傳圖片檔案
  with open("vision-example.jpg", "rb") as f:
      file_upload = client.files.upload(file=("vision-example.jpg", f, "image/jpeg"))

  # 在訊息中使用已上傳的檔案
  message = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      messages=[
          {
              "role": "user",
              "content": [
                  {
                      "type": "image",
                      "source": {"type": "file", "file_id": file_upload.id},
                  },
                  {"type": "text", "text": "Describe this image."},
              ],
          }
      ],
  )

  print(message.content)
  ```

  ```typescript TypeScript
  import Anthropic, { toFile } from "@anthropic-ai/sdk";
  import fs from "node:fs";

  const anthropic = new Anthropic();

  // 上傳圖片檔案
  const fileUpload = await anthropic.files.upload({
    file: await toFile(fs.createReadStream("vision-example.jpg"), undefined, {
      type: "image/jpeg"
    })
  });

  // 在訊息中使用已上傳的檔案
  const response = await anthropic.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "image",
            source: {
              type: "file",
              file_id: fileUpload.id
            }
          },
          {
            type: "text",
            text: "Describe this image."
          }
        ]
      }
    ]
  });

  console.log(response);
  ```

  ```csharp C#
  using System.Collections.Generic;
  using Anthropic;
  using Anthropic.Core;
  using Anthropic.Models.Files;
  using Anthropic.Models.Messages;

  AnthropicClient client = new();

  // 上傳圖片檔案
  var fileUpload = await client.Files.Upload(new FileUploadParams
  {
      File = new BinaryContent
      {
          Stream = File.OpenRead("vision-example.jpg"),
          FileName = "vision-example.jpg",
          ContentType = new("image/jpeg"),
      },
  });

  // 在訊息中使用已上傳的檔案
  var response = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Messages =
      [
          new()
          {
              Role = Role.User,
              Content = new MessageParamContent(new List<ContentBlockParam>
              {
                  new ContentBlockParam(new ImageBlockParam(
                      new ImageBlockParamSource(new FileImageSource(fileUpload.ID))
                  )),
                  new ContentBlockParam(new TextBlockParam("Describe this image.")),
              }),
          }
      ]
  });

  Console.WriteLine(response);
  ```

  ```go Go
  client := anthropic.NewClient()

  // 上傳圖片檔案
  file, err := os.Open("vision-example.jpg")
  if err != nil {
  	log.Fatal(err)
  }
  defer file.Close()

  fileUpload, err := client.Files.Upload(context.Background(),
  	anthropic.FileUploadParams{
  		File: anthropic.File(file, "vision-example.jpg", "image/jpeg"),
  	})
  if err != nil {
  	log.Fatal(err)
  }

  // 在訊息中使用已上傳的檔案
  message, err := client.Messages.New(context.Background(),
  	anthropic.MessageNewParams{
  		Model:     anthropic.ModelClaudeOpus5_5,
  		MaxTokens: 1024,
  		Messages: []anthropic.MessageParam{
  			anthropic.NewUserMessage(
  				anthropic.NewImageBlock(anthropic.FileImageSourceParam{
  					FileID: fileUpload.ID,
  				}),
  				anthropic.NewTextBlock("Describe this image."),
  			),
  		},
  	})
  if err != nil {
  	log.Fatal(err)
  }

  fmt.Println(message.Content)
  ```

  ```java Java
  import com.anthropic.core.MultipartField;
  import com.anthropic.models.files.FileMetadata;
  import com.anthropic.models.files.FileUploadParams;
  // ...
      AnthropicClient client = AnthropicOkHttpClient.fromEnv();

      // 上傳圖片檔案
      FileMetadata file = client.files().upload(
        FileUploadParams.builder()
          .file(
            MultipartField.<InputStream>builder()
              .value(Files.newInputStream(Path.of("vision-example.jpg")))
              .filename("vision-example.jpg")
              .contentType("image/jpeg")
              .build()
          )
          .build()
      );

      // 在訊息中使用已上傳的檔案
      ImageBlockParam imageParam = ImageBlockParam.builder().fileSource(file.id()).build();

      MessageCreateParams params = MessageCreateParams.builder()
        .model(Model.CLAUDE_OPUS_5_5)
        .maxTokens(1024)
        .addUserMessageOfBlockParams(
          List.of(
            ContentBlockParam.ofImage(imageParam),
            ContentBlockParam.ofText(
              TextBlockParam.builder().text("Describe this image.").build()
            )
          )
        )
        .build();

      Message message = client.messages().create(params);
      System.out.println(message.content());
  ```

  ```php PHP
  use Anthropic\Core\FileParam;

  $client = new Client();

  // 上傳圖片檔案
  $fileUpload = $client->files->upload(
      file: FileParam::fromResource(fopen('vision-example.jpg', 'rb'), contentType: 'image/jpeg'),
  );

  // 在訊息中使用已上傳的檔案
  $message = $client->messages->create(
      maxTokens: 1024,
      messages: [
          [
              'role' => 'user',
              'content' => [
                  [
                      'type' => 'image',
                      'source' => ['type' => 'file', 'fileID' => $fileUpload->id],
                  ],
                  ['type' => 'text', 'text' => 'Describe this image.'],
              ],
          ],
      ],
      model: 'claude-opus-5-5',
  );

  echo json_encode($message, JSON_PRETTY_PRINT), PHP_EOL;
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  # 上傳圖片檔案
  file_upload = client.files.upload(
    file: Anthropic::FilePart.new(
      File.open("vision-example.jpg", "rb"),
      content_type: "image/jpeg"
    )
  )

  # 在訊息中使用已上傳的檔案
  message = client.messages.create(
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "image",
            source: { type: "file", file_id: file_upload.id }
          },
          { type: "text", text: "Describe this image." }
        ]
      }
    ]
  )

  puts message.content
  ```
</CodeGroup>

如需更多範例程式碼和參數詳細資訊，請參閱 [Messages API 範例](https://platform.claude.com/docs/zh-TW/api/messages/create)。

### 多張圖片

您可以在單一請求中包含多張圖片，Claude 會將它們一併分析。這對於比較圖片、詢問差異，或處理一系列內容（例如文件的各個頁面）非常有用。傳送多張圖片時，請為每張圖片加上簡短的文字標籤（`Image 1:`、`Image 2:` 等），以便您在提示和後續輪次中以名稱參照它們。

<CodeGroup>
  ```bash cURL
  curl https://api.anthropic.com/v1/messages \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d '{
      "model": "claude-opus-5-5",
      "max_tokens": 1024,
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "Image 1:"
            },
            {
              "type": "image",
              "source": {
                "type": "base64",
                "media_type": "image/png",
                "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC"
              }
            },
            {
              "type": "text",
              "text": "Image 2:"
            },
            {
              "type": "image",
              "source": {
                "type": "base64",
                "media_type": "image/png",
                "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYPgPAAEDAQAIicLsAAAAAElFTkSuQmCC"
              }
            },
            {
              "type": "text",
              "text": "How are these images different?"
            }
          ]
        }
      ]
    }'
  ```

  ```bash CLI
  ant messages create <<'YAML'
  model: claude-opus-5-5
  max_tokens: 1024
  messages:
    - role: user
      content:
        - type: text
          text: "Image 1:"
        - type: image
          source:
            type: base64
            media_type: image/png
            data: iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC
        - type: text
          text: "Image 2:"
        - type: image
          source:
            type: base64
            media_type: image/png
            data: iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYPgPAAEDAQAIicLsAAAAAElFTkSuQmCC
        - type: text
          text: How are these images different?
  YAML
  ```

  ```python Python
  image1_data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC"
  image2_data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYPgPAAEDAQAIicLsAAAAAElFTkSuQmCC"

  client = anthropic.Anthropic()
  message = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      messages=[
          {
              "role": "user",
              "content": [
                  {"type": "text", "text": "Image 1:"},
                  {
                      "type": "image",
                      "source": {
                          "type": "base64",
                          "media_type": "image/png",
                          "data": image1_data,
                      },
                  },
                  {"type": "text", "text": "Image 2:"},
                  {
                      "type": "image",
                      "source": {
                          "type": "base64",
                          "media_type": "image/png",
                          "data": image2_data,
                      },
                  },
                  {"type": "text", "text": "How are these images different?"},
              ],
          }
      ],
  )
  print(message)
  ```

  ```typescript TypeScript
  const anthropic = new Anthropic();

  const image1Data =
    "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC";
  const image2Data =
    "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYPgPAAEDAQAIicLsAAAAAElFTkSuQmCC";

  const message = await anthropic.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          {
            type: "text",
            text: "Image 1:"
          },
          {
            type: "image",
            source: {
              type: "base64",
              media_type: "image/png",
              data: image1Data
            }
          },
          {
            type: "text",
            text: "Image 2:"
          },
          {
            type: "image",
            source: {
              type: "base64",
              media_type: "image/png",
              data: image2Data
            }
          },
          {
            type: "text",
            text: "How are these images different?"
          }
        ]
      }
    ]
  });

  console.log(message);
  ```

  ```csharp C#
  AnthropicClient client = new();

  string image1Data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC";
  string image2Data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYPgPAAEDAQAIicLsAAAAAElFTkSuQmCC";

  var message = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Messages =
      [
          new()
          {
              Role = Role.User,
              Content = new MessageParamContent(new List<ContentBlockParam>
              {
                  new ContentBlockParam(new TextBlockParam("Image 1:")),
                  new ContentBlockParam(new ImageBlockParam(
                      new ImageBlockParamSource(new Base64ImageSource()
                      {
                          Data = image1Data,
                          MediaType = MediaType.ImagePng,
                      })
                  )),
                  new ContentBlockParam(new TextBlockParam("Image 2:")),
                  new ContentBlockParam(new ImageBlockParam(
                      new ImageBlockParamSource(new Base64ImageSource()
                      {
                          Data = image2Data,
                          MediaType = MediaType.ImagePng,
                      })
                  )),
                  new ContentBlockParam(new TextBlockParam("How are these images different?")),
              }),
          }
      ]
  });

  Console.WriteLine(message);
  ```

  ```go Go
  client := anthropic.NewClient()

  image1Data := "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC"
  image2Data := "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYPgPAAEDAQAIicLsAAAAAElFTkSuQmCC"

  message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
  	Model:     anthropic.ModelClaudeOpus5_5,
  	MaxTokens: 1024,
  	Messages: []anthropic.MessageParam{
  		anthropic.NewUserMessage(
  			anthropic.NewTextBlock("Image 1:"),
  			anthropic.NewImageBlockBase64("image/png", image1Data),
  			anthropic.NewTextBlock("Image 2:"),
  			anthropic.NewImageBlockBase64("image/png", image2Data),
  			anthropic.NewTextBlock("How are these images different?"),
  		),
  	},
  })
  if err != nil {
  	log.Fatal(err)
  }

  fmt.Println(message)
  ```

  ```java Java
  AnthropicClient client = AnthropicOkHttpClient.fromEnv();

  String image1Data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC";
  String image2Data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYPgPAAEDAQAIicLsAAAAAElFTkSuQmCC";

  List<ContentBlockParam> contentBlockParams = List.of(
      ContentBlockParam.ofText(TextBlockParam.builder().text("Image 1:").build()),
      ContentBlockParam.ofImage(
          ImageBlockParam.builder()
              .source(
                  Base64ImageSource.builder()
                      .mediaType(Base64ImageSource.MediaType.IMAGE_PNG)
                      .data(image1Data)
                      .build()
              )
              .build()
      ),
      ContentBlockParam.ofText(TextBlockParam.builder().text("Image 2:").build()),
      ContentBlockParam.ofImage(
          ImageBlockParam.builder()
              .source(
                  Base64ImageSource.builder()
                      .mediaType(Base64ImageSource.MediaType.IMAGE_PNG)
                      .data(image2Data)
                      .build()
              )
              .build()
      ),
      ContentBlockParam.ofText(
          TextBlockParam.builder().text("How are these images different?").build()
      )
  );

  Message message = client
      .messages()
      .create(
          MessageCreateParams.builder()
              .model(Model.CLAUDE_OPUS_5_5)
              .maxTokens(1024)
              .addUserMessageOfBlockParams(contentBlockParams)
              .build()
      );

  IO.println(message);
  ```

  ```php PHP
  $client = new Client();

  $image1Data = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC';
  $image2Data = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYPgPAAEDAQAIicLsAAAAAElFTkSuQmCC';

  $message = $client->messages->create(
      maxTokens: 1024,
      messages: [
          [
              'role' => 'user',
              'content' => [
                  ['type' => 'text', 'text' => 'Image 1:'],
                  [
                      'type' => 'image',
                      'source' => [
                          'type' => 'base64',
                          'media_type' => 'image/png',
                          'data' => $image1Data,
                      ],
                  ],
                  ['type' => 'text', 'text' => 'Image 2:'],
                  [
                      'type' => 'image',
                      'source' => [
                          'type' => 'base64',
                          'media_type' => 'image/png',
                          'data' => $image2Data,
                      ],
                  ],
                  ['type' => 'text', 'text' => 'How are these images different?'],
              ],
          ],
      ],
      model: 'claude-opus-5-5',
  );

  echo $message;
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  image1_data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC"
  image2_data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYPgPAAEDAQAIicLsAAAAAElFTkSuQmCC"

  message = client.messages.create(
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [
      {
        role: "user",
        content: [
          { type: "text", text: "Image 1:" },
          {
            type: "image",
            source: {
              type: "base64",
              media_type: "image/png",
              data: image1_data
            }
          },
          { type: "text", text: "Image 2:" },
          {
            type: "image",
            source: {
              type: "base64",
              media_type: "image/png",
              data: image2_data
            }
          },
          { type: "text", text: "How are these images different?" }
        ]
      }
    ]
  )

  puts message
  ```
</CodeGroup>

在多輪對話中，請以相同方式在後續的 `user` 輪次中新增圖片。Claude 可以存取先前輪次中的每一張圖片，因此像「這些與前兩張相似嗎？」這類後續問題，無需在新輪次的內容中再次包含先前的圖片即可運作。

***

## 圖片限制與費用

### 請求限制

每則訊息或每個請求的圖片數量上限為：

* 在 [claude.ai](https://claude.ai/) 上每則訊息 20 張。
* 在 API 上，對於具有 200k token「context window」（上下文視窗）的模型，每個請求 100 張。
* 在 API 上，對於所有其他模型，每個請求 600 張。

每張圖片的最大尺寸為 8000x8000 px。

如果單一 API 請求包含超過 20 張圖片，則該請求中的每張圖片都會適用更嚴格的單張圖片尺寸限制。請求中的所有 `image` 區塊都會計入此門檻，包括您重新傳送的先前對話輪次中的圖片，以及巢狀於 `tool_result` 內容中的圖片（例如傳回給電腦使用工具的螢幕截圖）。在 Amazon Bedrock 和 Google Cloud 上，PDF 等文件區塊也會計入此門檻。超過較嚴格限制的圖片會被拒絕，並傳回 `invalid_request_error`，其訊息會提及「many-image requests」並說明目前以像素為單位的限制。若要在所有平台上都不超過限制，請將每張圖片調整大小，使其任一邊都不超過 2000 px，或將請求中的圖片和文件區塊數量保持在 20 個以內。

每張圖片的大小上限為：

* 直接使用 Claude API 時為 10 MB（base64 編碼）。
* 在 Amazon Bedrock 和 Google Cloud 上為 5 MB（base64 編碼）。
* 在 [claude.ai](https://claude.ai/) 上為 10 MB。

<Note>
  雖然 API 支援每個請求最多 600 張圖片，但可能會先達到[請求大小限制](https://platform.claude.com/docs/zh-TW/api/overview#request-size-limits)（標準端點為 32 MB；在某些合作夥伴營運的平台上較低，例如 Amazon Bedrock 和 Google Cloud）。對於大量圖片，請考慮使用 [Files API](https://platform.claude.com/docs/zh-TW/build-with-claude/vision#files-api-image-example) 上傳並透過 `file_id` 參照，以保持請求酬載精簡。

  即使使用 Files API，包含許多大型圖片的請求也可能在達到 600 張圖片數量之前就失敗。請在上傳前縮小圖片尺寸或檔案大小（例如透過降低取樣）（請參閱[解析度與 token 費用](https://platform.claude.com/docs/zh-TW/build-with-claude/vision#evaluate-image-size)）。
</Note>

### 支援的格式

Claude 支援 JPEG、PNG、GIF 和 WebP 圖片（`image/jpeg`、`image/png`、`image/gif`、`image/webp`）。不支援動畫，僅會使用第一個影格。

### 解析度與 token 費用

Claude 以區塊（patch）而非像素來檢視圖片。每個區塊是圖片中 28×28 像素的方塊，稱為「visual token」（視覺 token）。因此，一張圖片的費用為 `⌈width / 28⌉ × ⌈height / 28⌉` 個視覺 token。

每個模型都有最大原生圖片解析度，以長邊限制和視覺 token 限制來表示。超過任一限制的圖片會在處理前被縮小；確切規則請參閱 [Claude 如何調整圖片大小和填補圖片](https://platform.claude.com/docs/zh-TW/build-with-claude/vision-coordinates#how-claude-resizes-and-pads-images)。例外情況是您傳回給[電腦使用](https://platform.claude.com/docs/zh-TW/agents-and-tools/tool-use/computer-use-tool#handle-coordinate-scaling-for-higher-resolutions)和[瀏覽器使用](https://platform.claude.com/docs/zh-TW/agents-and-tools/tool-use/browser-use-tool#targets-and-coordinates)工具集的螢幕截圖和縮放圖片：對於超過模型限制的 `tool_result` 圖片，API 會以驗證錯誤拒絕，而不是將其縮小，因此請在傳回這些圖片之前，先在您的應用程式中調整其大小。若要讓任何其他過大的圖片以錯誤拒絕而非被縮小，請設定圖片區塊的 [`transformations` 欄位](https://platform.claude.com/docs/zh-TW/build-with-claude/vision-coordinates#oversized-image-error)。

| 解析度層級 | 模型                | 最大長邊    | 最大視覺 token 數 |
| ----- | ----------------- | ------- | ------------ |
| 高解析度  | Claude 4.7 及更新的模型 | 2576 px | 4784         |
| 標準    | 所有其他模型            | 1568 px | 1568         |

在列出的模型上，高解析度支援會自動啟用，不需要 beta 標頭或用戶端選擇加入。

下表顯示各層級中幾種圖片尺寸的縮小後解析度和視覺 token 費用：

| 圖片尺寸                    | 標準層級：縮小至    | 標準層級：token 數 | 高解析度層級：縮小至   | 高解析度層級：token 數 |
| ----------------------- | ----------- | ------------ | ------------ | -------------- |
| 200x200 px（0.04 百萬像素）   | 未調整大小       | 64           | 未調整大小        | 64             |
| 1000x1000 px（1 百萬像素）    | 未調整大小       | 1296         | 未調整大小        | 1296           |
| 1092x1092 px（1.19 百萬像素） | 未調整大小       | 1521         | 未調整大小        | 1521           |
| 1920x1080 px（2.07 百萬像素） | 1456x819 px | 1560         | 未調整大小        | 2691           |
| 2000x1500 px（3 百萬像素）    | 1269x952 px | 1564         | 未調整大小        | 3888           |
| 3840x2160 px（8.29 百萬像素） | 1456x819 px | 1560         | 2576x1449 px | 4784           |

當圖片被縮小時，Claude 會在保持長寬比的前提下，將其縮放至符合該層級限制的最大尺寸。這會限制 token 費用的上限。如需精確規則和參考實作，請參閱 [Claude 如何調整圖片大小和填補圖片](https://platform.claude.com/docs/zh-TW/build-with-claude/vision-coordinates#how-claude-resizes-and-pads-images)。

若要估算費用，請將 token 數乘以您所使用[模型的每 token 價格](https://claude.com/pricing)。例如，以 Claude Haiku 4.5 每百萬輸入 token $1 USD（標準層級）計算，1000×1000 的圖片每千張約 $1.30 USD。以 Claude Opus 5.5 每百萬 $4 USD（高解析度層級）計算，同一張圖片每千張約 $5.18 USD，而 4K 圖片每千張約 $19.14 USD。

與標準層級模型上的同一張圖片相比，高解析度圖片最多可能使用約三倍的視覺 token。如果您不需要高解析度為電腦使用、螢幕截圖理解和密集文件所提供的額外精確度，請在傳送前降低圖片取樣以控制 token 費用。為了將延遲降到最低並簡化[基於座標的工作流程](https://platform.claude.com/docs/zh-TW/build-with-claude/vision-coordinates)，建議在上傳前先調整圖片大小。

### 圖片品質指引

將圖片提供給 Claude 時，請留意以下事項以獲得最佳結果：

* **圖片清晰度：** 確保圖片清晰，不會過於模糊或像素化。
* **文字：** 如果圖片包含重要文字，請確保文字清晰可讀且不會太小。避免僅為了放大文字而裁切掉關鍵的視覺上下文。
* **調整大小：** 請考量到如果圖片過大，可能會被調整大小（請參閱[解析度與 token 費用](https://platform.claude.com/docs/zh-TW/build-with-claude/vision#evaluate-image-size)）；例如，這可能會使文字較難辨識。請考慮預先調整圖片大小、裁切圖片，或兩者兼行。若要讓過大的圖片以錯誤拒絕而非被調整大小（這對[座標工作流程](https://platform.claude.com/docs/zh-TW/build-with-claude/vision-coordinates)很重要），請在圖片區塊上標記 [`"oversized_image": "error"`](https://platform.claude.com/docs/zh-TW/build-with-claude/vision-coordinates#oversized-image-error)。
* **圖片壓縮：** 在傳送前使用 JPEG 或 WebP（有損模式）等有損格式壓縮圖片，可以透過縮小請求大小來降低延遲。然而，這可能會產生對模型效能不利的壓縮瑕疵，尤其是在套用多次壓縮時。例如，高度的 JPEG 壓縮可能會使文字難以閱讀。請檢查實際傳送到 API 的圖片，以確認您的壓縮設定適合該任務。

***

## 座標與邊界框

關於「bounding box」（邊界框）、點和像素座標，請參閱[座標與邊界框](https://platform.claude.com/docs/zh-TW/build-with-claude/vision-coordinates)。Claude 會傳回相對於其在調整大小後所看到之圖片的絕對像素座標；該指南說明了 Claude 如何調整圖片大小和填補圖片，以及如何預先調整大小或重新縮放，使座標與您的原始圖片對齊。

***

## 限制

雖然 Claude 的圖片理解能力處於領先地位，但仍有一些需要注意的限制：

* **人物辨識：** Claude [不得被用於](https://www.anthropic.com/legal/aup)指認圖片中的人物，並會拒絕這樣做。
* **準確性：** 在解讀低品質、旋轉或小於 200 像素的極小圖片時，Claude 可能會產生幻覺或出錯。
* **空間推理：** Claude 的座標和定位輸出是近似值。請遵循[座標與邊界框](https://platform.claude.com/docs/zh-TW/build-with-claude/vision-coordinates)中的指引，並在依賴輸出之前先加以驗證。
* **計數：** Claude 可以提供圖片中物件的大致數量，但不一定總是精確，尤其是在有大量小型物件時。
* **AI 生成的圖片：** Claude 無法判斷圖片是否由 AI 生成，若被詢問可能會出錯。請勿依賴它來偵測偽造或合成的圖片。
* **不當內容：** Claude 不會處理違反[可接受使用政策](https://www.anthropic.com/legal/aup)的不當或露骨圖片。
* **醫療保健應用：** 雖然 Claude 可以分析一般醫學圖片，但它並非設計用於解讀 CT 或 MRI 等複雜的診斷掃描。Claude 的輸出不應被視為專業醫療建議或診斷的替代品。

請務必仔細審查和驗證 Claude 對圖片的解讀，尤其是在高風險的使用情境中。在沒有人工監督的情況下，請勿將 Claude 用於需要完美精確度或敏感圖片分析的任務。

***

## 常見問題

<AccordionGroup>
  <Accordion title="Claude 支援哪些圖片檔案類型？">
    JPEG、PNG、GIF 和 WebP。請參閱[支援的格式](https://platform.claude.com/docs/zh-TW/build-with-claude/vision#supported-formats)。
  </Accordion>

  <Accordion title="Claude 可以讀取圖片 URL 嗎？">
    可以。在 `image` 內容區塊中使用 `url` 來源類型，而非 `base64`。請參閱[基於 URL 的圖片範例](https://platform.claude.com/docs/zh-TW/build-with-claude/vision#url-based-image-example)。
  </Accordion>

  <Accordion title="我可以上傳的圖片檔案大小有限制嗎？">
    有。請參閱[請求限制](https://platform.claude.com/docs/zh-TW/build-with-claude/vision#request-limits)，了解 Claude API、Amazon Bedrock、Google Cloud 和 claude.ai 上的單張圖片及整體請求大小限制。
  </Accordion>

  <Accordion title="一個請求中可以包含多少張圖片？">
    每個 API 請求最多 600 張（具有 200k token 上下文視窗的模型為 100 張），在 claude.ai 上每輪 20 張。請參閱[請求限制](https://platform.claude.com/docs/zh-TW/build-with-claude/vision#request-limits)以了解詳細資訊，以及超過 20 張圖片時適用的較低單張圖片尺寸限制。
  </Accordion>

  <Accordion title="Claude 會讀取圖片中繼資料嗎？">
    不會，Claude 不會解析或接收傳遞給它的圖片中的任何中繼資料。
  </Accordion>

  <Accordion title="我可以刪除已上傳的圖片嗎？">
    不行。圖片上傳是暫時性的，不會在 API 請求期間之後 儲存。上傳的圖片在處理完成後 會自動刪除。
  </Accordion>

  <Accordion title="在哪裡可以找到有關圖片上傳資料隱私的詳細資訊？">
    請參閱 Anthropic 隱私權政策頁面，了解上傳的 圖片和其他資料的處理方式。Anthropic 不會使用上傳的圖片來 訓練模型。
  </Accordion>

  <Accordion title="如果 Claude 對圖片的解讀似乎有誤怎麼辦？">
    如果 Claude 對圖片的解讀似乎不正確：

    1. 確保圖片清晰、高品質且方向正確。
    2. 嘗試使用提示工程技巧來改善結果。
    3. 如果問題仍然存在，請在 claude.ai 中標記該輸出（按讚/倒讚），或聯繫[支援團隊](https://support.claude.com/)。

    您的回饋有助於改善 Claude！
  </Accordion>

  <Accordion title="Claude 可以生成或編輯圖片嗎？">
    不行，Claude 僅是圖片理解模型。它可以解讀和分析圖片，但無法生成、產出、編輯、操作或建立圖片。
  </Accordion>
</AccordionGroup>

***

## 後續步驟

<CardGroup cols={2}>
  <Card title="多模態 cookbook" icon="image" href="https://platform.claude.com/cookbook/multimodal-getting-started-with-vision">
    取得解讀圖表和從表單擷取內容等任務的技巧與最佳實務。
  </Card>

  <Card title="API 參考" icon="code" href="https://platform.claude.com/docs/zh-TW/api/messages/create">
    查看 Messages API 文件，包括涉及圖片的 API 呼叫範例。
  </Card>
</CardGroup>
