多色列印 API

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


POST/openapi/v1/print/multi-color

建立多色 3D 列印任務

此端點會建立一個新的多色 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
    max_depth
    Type
    integer
    默认值 4
    Description

    四叉樹深度,用於顏色精度。較高的值會產生更精細的顏色邊界,但會增加檔案大小。

    有效範圍:36

回傳值

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

失敗模式

  • Name
    400 - Bad Request
    Description

    請求無效。常見原因:

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

    驗證失敗。請檢查您的 API 金鑰。

  • Name
    402 - Payment Required
    Description

    點數不足,無法執行此任務。

  • Name
    429 - Too Many Requests
    Description

    您已超出頻率限制。

Request

POST
/openapi/v1/print/multi-color
# 将 3D 模型转换为多色 3MF 用于打印
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,
    "max_depth": 5
  }'

Response

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

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

擷取多色 3D 列印任務

此端點會透過 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 列印任務

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

路徑參數

  • Name
    id
    Type
    path
    Description

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

回傳值

成功則回傳 200 OK

请求

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}"

响应

// 成功则返回 200 Ok。

GET/openapi/v1/print/multi-color

多色 3D 列印任務列表

此端點可讓您取得多色 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 列印任務物件列表。

请求

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}"

响应

[
  {
    "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 列印任務

此端點透過 Server-Sent Events (SSE) 以串流方式傳回多色 3D 列印任務的即時進度更新。

參數

  • Name
    id
    Type
    path
    Description

    要以串流方式取得之多色 3D 列印任務的唯一識別碼。

傳回值

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

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

请求

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}"

响应流

// 错误事件示例
event: error
data: {
  "status_code": 404,
  "message": "Task not found"
}

// 消息事件示例展示任务进度。
// 对于 PENDING 或 IN_PROGRESS 状态的任务,响应流不会包含所有字段。
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-sortable 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

    任務的進度。如果任務尚未開始,此屬性將為 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(失敗時積分會被退還)。

3D 打印任务对象

{
  "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
}