多色列印 API

將 3D 模型格式轉換為用於 3D 列印的多色 3MF 格式,調色盤最多可配置 16 種顏色。


POST/openapi/v1/print/multi-color

建立多色 3D 列印任務

此 endpoint 用於建立一個新的多色 3D 列印任務。該任務會將一個 3D 模型轉換為適用於 3D 列印的多色 3MF 檔案。

參數

  • Name
    model_url
    Type
    string
    必選
    Description

    可公開存取的 3D 模型 URL 或 Data URI。目前支援 .glb.fbx 格式。

  • Name
    max_colors
    Type
    integer
    預設值 4
    Description

    輸出調色盤中的最大顏色數量。

    有效範圍:116

  • Name
    style
    Type
    string
    預設值 realistic
    Description

    生成的 3MF 檔案的視覺顏色風格。

    可選值:

    • realistic:直接從模型的 texture 中取樣顏色,呈現精細、照片級真實的細節。生成的檔案較大。
    • cartoon:將顏色扁平化為乾淨、統一的區域,呈現風格化外觀。生成的檔案較小。

回傳值

回應中的 result 屬性包含新建立的 3D 列印任務的 id

失敗模式

  • Name
    400 - Bad Request
    Description

    請求不可接受。常見原因:

    • 缺少參數:必須提供 model_urlinput_task_id 中的一個。
    • 模型格式無效model_url 指向的檔案副檔名不受支援(僅支援 .glb.fbx)。
    • URL 無法存取:無法下載 model_url 指向的檔案。
    • 輸入任務無效input_task_id 必須指向一個成功的任務。
    • max_colors 無效:值必須介於 1 到 16 之間。
    • style 無效:值必須為 realisticcartoon
  • Name
    401 - Unauthorized
    Description

    身分驗證失敗。請檢查您的 API key。

  • Name
    402 - Payment Required
    Description

    credits 不足,無法執行此任務。

  • Name
    429 - Too Many Requests
    Description

    您已超出速率限制。

Request

POST
/openapi/v1/print/multi-color
# Convert a 3D model to multi-color 3MF for printing
curl https://api.meshy.ai/openapi/v1/print/multi-color \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
    "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "max_colors": 8
  }'

Response

{
  "result": "0193bfc5-ee4f-73f8-8525-44b398884ce9"
}

GET/openapi/v1/print/multi-color/:id

取得多色 3D 列印任務

此 endpoint 透過 ID 取得一個多色 3D 列印任務。

參數

  • Name
    id
    Type
    path
    Description

    要取得的 3D 列印任務的 ID。

回傳

3D 列印任務物件。

Request

GET
/openapi/v1/print/multi-color/a43b5c6d-7e8f-901a-234b-567c890d1e2f
curl https://api.meshy.ai/openapi/v1/print/multi-color/a43b5c6d-7e8f-901a-234b-567c890d1e2f \
-H "Authorization: Bearer ${YOUR_API_KEY}"

Response

{
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "type": "print-multi-color",
  "model_urls": {
      "3mf": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.3mf?Expires=***"
},
  "progress": 100,
  "status": "SUCCEEDED",
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": null,
"consumed_credits": 10
}

DELETE/openapi/v1/print/multi-color/:id

刪除多色 3D 列印任務

此 endpoint 會永久刪除一個多色 3D 列印任務,包括所有關聯的模型和資料。此操作無法復原。

路徑參數

  • Name
    id
    Type
    path
    Description

    要刪除的多色 3D 列印任務的 ID。

回傳值

成功時回傳 200 OK

Request

DELETE
/openapi/v1/print/multi-color/a43b5c6d-7e8f-901a-234b-567c890d1e2f
curl --request DELETE \
  --url https://api.meshy.ai/openapi/v1/print/multi-color/a43b5c6d-7e8f-901a-234b-567c890d1e2f \
  -H "Authorization: Bearer ${YOUR_API_KEY}"

Response

// Returns 200 Ok on success.

GET/openapi/v1/print/multi-color

取得多色 3D 列印任務清單

此 endpoint 允許您取得多色 3D 列印任務的清單。

參數

可選屬性

  • Name
    page_num
    Type
    integer
    Description

    用於分頁的頁碼。起始值與預設值皆為 1

  • Name
    page_size
    Type
    integer
    Description

    每頁數量上限。預設值為 10 筆,最大允許值為 50 筆。

  • Name
    sort_by
    Type
    string
    Description

    用於排序的欄位。可用值:

    • +created_at:依建立時間升冪排列。
    • -created_at:依建立時間降冪排列。

回傳

回傳一個分頁清單,內含 3D 列印任務物件

Request

GET
/openapi/v1/print/multi-color
curl https://api.meshy.ai/openapi/v1/print/multi-color?page_size=10 \
-H "Authorization: Bearer ${YOUR_API_KEY}"

Response

[
  {
    "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
    "type": "print-multi-color",
    "model_urls": {
      "3mf": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.3mf?Expires=***"
    },
    "progress": 100,
    "status": "SUCCEEDED",
    "preceding_tasks": 0,
    "created_at": 1699999999000,
    "started_at": 1700000000000,
    "finished_at": 1700000001000,
    "task_error": null,
  "consumed_credits": 10
  }
]

GET/openapi/v1/print/multi-color/:id/stream

流式取得多色 3D 列印任務

此 endpoint 使用 Server-Sent Events(SSE)串流傳輸多色 3D 列印任務的即時更新。

參數

  • Name
    id
    Type
    path
    Description

    欲進行串流傳輸的多色 3D 列印任務的唯一識別碼。

回傳

以 Server-Sent Events 的形式回傳 3D 列印任務物件 的串流。

對於 PENDINGIN_PROGRESS 的任務,回應串流將僅包含必要的 progressstatus 欄位。

Request

GET
/openapi/v1/print/multi-color/a43b5c6d-7e8f-901a-234b-567c890d1e2f/stream
curl -N https://api.meshy.ai/openapi/v1/print/multi-color/a43b5c6d-7e8f-901a-234b-567c890d1e2f/stream \
-H "Authorization: Bearer ${YOUR_API_KEY}"

Response Stream

// Error event example
event: error
data: {
  "status_code": 404,
  "message": "Task not found"
}

// Message event examples illustrate task progress.
// For PENDING or IN_PROGRESS tasks, the response stream will not include all fields.
event: message
data: {
  "id": "a43b5c6d-7e8f-901a-234b-567c890d1e2f",
  "progress": 0,
  "status": "PENDING"
}

event: message
data: {
  "id": "a43b5c6d-7e8f-901a-234b-567c890d1e2f",
  "type": "print-multi-color",
  "model_urls": {
    "3mf": "https://assets.meshy.ai/***/tasks/a43b5c6d-7e8f-901a-234b-567c890d1e2f/output/model.3mf?Expires=***"
  },
  "progress": 100,
  "status": "SUCCEEDED",
  "preceding_tasks": 0,
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": null,
"consumed_credits": 10
}

3D 列印任務物件

  • Name
    id
    Type
    string
    Description

    任務的唯一識別碼。雖然我們在實作細節中使用可 k 排序的 UUID 作為任務 id,但你不應對 id 的格式做任何假設。

  • Name
    type
    Type
    string
    Description

    3D 列印任務的類型。該值為 print-multi-color

  • Name
    model_urls
    Type
    object
    Description

    Meshy 生成的 3D 模型檔案的可下載 URL。如果某種格式未生成,則不會返回該格式對應的屬性,而不是返回空字串。

    • Name
      3mf
      Type
      string
      Description

      多色 3MF 檔案的可下載 URL。

  • Name
    progress
    Type
    integer
    Description

    任務的 progress。如果任務尚未開始,此屬性值將為 0。任務成功後,該值將變為 100

  • Name
    status
    Type
    string
    Description

    任務的狀態。可能的取值為 PENDINGIN_PROGRESSSUCCEEDEDFAILED 之一。

  • Name
    preceding_tasks
    Type
    integer
    Description

    排在前面的任務數量。

  • Name
    created_at
    Type
    timestamp
    Description

    任務建立時的時間戳,單位為毫秒。

  • Name
    started_at
    Type
    timestamp
    Description

    任務開始時的時間戳,單位為毫秒。如果任務尚未開始,此屬性值將為 0

  • Name
    finished_at
    Type
    timestamp
    Description

    任務完成時的時間戳,單位為毫秒。如果任務尚未完成,此屬性值將為 0

  • Name
    task_error
    Type
    object
    Description

    失敗任務的錯誤詳情。完整的 task_error 物件參考請參見 錯誤

  • Name
    consumed_credits
    Type
    integer
    Description

    該任務消耗的積分數量。當任務狀態為 PENDINGIN_PROGRESSSUCCEEDED 時會顯示此欄位。對於 FAILED 的任務,返回 0(失敗時會退還積分)。

The 3D Print Task Object

{
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "type": "print-multi-color",
  "model_urls": {
      "3mf": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.3mf?Expires=***"
},
  "progress": 100,
  "status": "SUCCEEDED",
  "preceding_tasks": 0,
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": null,
"consumed_credits": 10
}