跳至內容

Segment Anything Model 3

整合

模型 id sam-3/image
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/sam-3/image?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"

此請求: ≈$0.005 5 API 點數 在此頁面執行

取得 API 金鑰
Meta 圖像編輯 #segmentation#mask#real-time

使用文字、點或框提示進行影像分割,回傳遮罩影像,可選回傳分數和框

Meta · 圖像

您的第一個結果會顯示在這裡

在下方建立請求,並使用您的 API 金鑰執行。輸出會複製到我們的儲存空間,可永久保留或免費保留 7 天。

建立請求

控制項是根據模型結構描述生成的。變更設定時,程式碼和價格會同步更新。

預設 wheel

引導分割的文字指示。

•必填 image_url
拖放檔案,或

指向要進行分割之圖像的 URL。

進階 text_prompt · output_format · max_masks · apply_mask · return_multiple_masks · include_scores · include_boxes · point_prompts · box_prompts

[DEPRECATED] 為了向後相容而保留的舊版輸入;請改用 'prompt'。

output_format 預設 png

生成圖像的檔案格式。

預設 3

啟用 `return_multiple_masks` 時回傳遮罩的上限。

預設 []

點提示詞集合。

預設 []

物件 ID 決定分組方式的框提示詞:相符的 ID 會將框關聯至同一物件,空白 ID 則代表不同物件。可提供多個框,每個框使用座標 (x_min, y_min, x_max, y_max)。

POST /run/sam-3/image?wait=20 報價 → $0.005
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/sam-3/image?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"

執行此請求

您的金鑰會保留在此瀏覽器中:只會傳送至 Doitong API,且只有在勾選「記住」時才會儲存至 localStorage。 取得 API 金鑰

關於 Segment Anything Model 3

使用文字 `prompt`、`point_prompts` 或 `box_prompts`,透過 SAM 3 分割影像。啟用 `return_multiple_masks` 後,最多回傳 `max_masks` 個遮罩(1 到 32)。可選擇加入信心分數和邊界框。輸出格式為 jpeg、png 或 webp。

參數

請傳送標準名稱或原生名稱其中之一,不要同時傳送兩者。 標準名稱

名稱類型 預設值允許值 說明
image_url必填 image
類型url · image
指向要進行分割之圖像的 URL。
prompt選填
類型string
預設值wheel
引導分割的文字指示。
text_prompt選填
類型string | null
[DEPRECATED] 為了向後相容而保留的舊版輸入;請改用 'prompt'。
point_prompts選填
類型object[]
預設值[]
點提示詞集合。
point_prompts[].x選填
類型integer | null
提示詞在 X 軸上的位置。
point_prompts[].y選填
類型integer | null
提示詞在 Y 軸上的位置。
point_prompts[].label選填
類型enum
01
前景或背景標籤:1 表示前景;0 表示背景。
point_prompts[].object_id選填
類型integer | null
將用於細化單一物件的提示詞分組之選用識別碼。如果也提供文字作為提示詞,此識別碼會決定這些點要細化哪個偵測到的物件。
point_prompts[].frame_index選填
類型integer | null
識別互動影格的索引。
box_prompts選填
類型object[]
預設值[]
物件 ID 決定分組方式的框提示詞:相符的 ID 會將框關聯至同一物件,空白 ID 則代表不同物件。可提供多個框,每個框使用座標 (x_min, y_min, x_max, y_max)。
box_prompts[].x_min選填
類型integer | null
框的最小 x 座標。
box_prompts[].y_min選填
類型integer | null
框的最小 y 座標。
box_prompts[].x_max選填
類型integer | null
框的最大 X 座標。
box_prompts[].y_max選填
類型integer | null
框的最大 Y 座標。
box_prompts[].object_id選填
類型integer | null
將用於細化單一物件的框分組之選用識別碼。
box_prompts[].frame_index選填
類型integer | null
識別互動影格的索引。
apply_mask選填
類型boolean
預設值true
控制是否對圖像套用遮罩。
output_format選填
類型enum
預設值png
jpegpngwebp
生成圖像的檔案格式。
return_multiple_masks選填
類型boolean
預設值false
多遮罩回傳選項:啟用後會使用 `max_masks` 決定要上傳並納入回應的生成遮罩數量。
max_masks選填
類型integer
預設值3
1 – 32
啟用 `return_multiple_masks` 時回傳遮罩的上限。
include_scores選填
類型boolean
預設值false
控制是否納入遮罩的信賴分數。
include_boxes選填
類型boolean
預設值false
控制是否在可用時納入每個遮罩的邊界框。
必填 標準名稱,也可使用

檔案參數接受公開的 https:// URL、最大 10 MB 的 data: URI,或上傳檔案的 file_url。 檔案

輸出

GET /requests/req_8k2m4q7x1z9c3v5b6n0p2r4t
{
  "id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
  "object": "request",
  "model": "sam-3/image",
  "status": "succeeded",
  "created_at": "2026-10-20T12:00:00Z",
  "started_at": "2026-10-20T12:00:02Z",
  "completed_at": "2026-10-20T12:00:09Z",
  "queue_position": null,
  "cost": {
    "credits": 5,
    "usd": "0.005",
    "charged": 5,
    "refunded": 0
  },
  "input": {
    "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  },
  "output": {
    "image": {
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_name": "0-output.jpeg",
      "file_size": 1843200,
      "width": 1024,
      "height": 768
    },
    "masks": [
      {
        "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
        "content_type": "image/jpeg",
        "file_name": "0-output.jpeg",
        "file_size": 1843200,
        "width": 1024,
        "height": 768
      }
    ],
    "metadata": [
      {
        "index": 1,
        "score": 1.0,
        "box": [
          1.0
        ]
      }
    ],
    "scores": [
      1.0
    ],
    "boxes": [
      [
        1.0
      ]
    ]
  },
  "outputs": [
    {
      "type": "image",
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_size": 1843200,
      "width": 1024,
      "height": 768,
      "stored": true
    }
  ],
  "error": null,
  "metrics": {
    "inference_seconds": 6.8
  },
  "urls": {
    "self": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
    "cancel": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
  }
}
您的檔案,由您選擇每個 outputs[].url 都是儲存空間中的副本:可永久保留(按 GB-月計費),或免費保留 7 天;可透過帳戶設定或 ?storage= 設定。
所有模型使用相同結構圖片、影片和音訊皆包含 type、url、content_type、width、height 和 duration。output 是模型自己的結果物件。
輸出欄位
image
object {url, content_type, file_name, file_size, width, height} | null顯示主要分割遮罩的預覽。
masks
array of object {url, content_type, file_name, file_size, width, height}包含分割遮罩的圖像。
metadata
array of object {index, score, box} | null每個遮罩的中繼資料,包括其分數和框。
scores
array of number | null每個遮罩的信心分數,僅在要求時提供。
boxes
array of array of number | null每個遮罩的正規化框,以 [cx, cy, w, h] 表示,僅在要求時提供。

更多模型:圖像編輯

給 AI 代理程式:此頁面的 Markdown 位於 https://doitong.com/zh-TW/developers/models/sam-3/image.md. 所有模型與指南: https://doitong.com/developers/llms.txt