可列印性修復 API

修復 3D 模型以達到 FDM 可列印性——修復非流形邊、退化面、孔洞以及其他 topology 問題,使 mesh 達到可列印狀態。


POST/openapi/v1/print/repair

建立可列印性修復任務

此 endpoint 用於建立一個新的可列印性修復任務。該任務會對 3D 模型執行 topology 修復,並回傳一個水密(watertight)的、可直接列印的版本。

輸出格式與輸入格式一致。如果你透過 model_url 提交了一個 .stl 檔案,回應中的 model_urls.stl 將包含修復後的 mesh,其他格式欄位將為空。input_task_id 路徑一律讀取來源任務的 GLB,因此輸出為 .glb

參數

  • Name
    model_url
    Type
    string
    必選
    Description

    要修復的 3D 模型的 URL。支援的格式:.glb.gltf.obj.fbx.stl。最大檔案大小:100 MB。必須使用 httphttpsdata: URL(data URL 會略過副檔名檢查)。

  • Name
    alpha_thumbnail
    Type
    boolean
    預設值 false
    Description

    當設定為 true 時,任務會額外算繪一個透明背景(RGBA)版本的預覽圖,並在 GET 回應中以 alpha_thumbnail_url 回傳。現有的 thumbnail_url 欄位不受影響。

回傳值

回應中的 result 屬性包含新建立的可列印性修復任務的 id

失敗模式

  • Name
    400 - Bad Request
    Description

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

    • 缺少參數:未提供 input_task_idmodel_url
    • UUID 無效input_task_id 不是有效的 UUID。
    • 模型 URL 無效model_url 格式錯誤、使用了不受支援的協定,或檔案副檔名不受支援。
    • 模型檔案過大model_url 指向的內容超過了 100 MB。
    • 任務未成功:引用的任務仍處於等待中、進行中或已失敗狀態。
    • 缺少 GLB:引用的任務沒有可供修復的 GLB 資產。
  • Name
    401 - Unauthorized
    Description

    身份驗證失敗。請檢查你的 API 金鑰。

  • Name
    402 - Payment Required
    Description

    常見原因:

    • 免費方案:建立任務需要付費方案。請在 訂閱頁面升級。
    • 積分不足:工作區的積分額度已用完。
  • Name
    404 - Not Found
    Description

    引用的任務不存在,或歸屬於其他使用者。

  • Name
    429 - Too Many Requests
    Description

    你已超出待處理任務配額或速率限制。

Request

POST
/openapi/v1/print/repair
# Repair an existing task
curl https://api.meshy.ai/openapi/v1/print/repair \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
    "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578"
  }'

# Or repair a model URL directly
curl https://api.meshy.ai/openapi/v1/print/repair \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
    "model_url": "https://example.com/model.stl"
  }'

Response

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

GET/openapi/v1/print/repair/:id

取得可列印性修復任務

此 endpoint 用於根據 ID 取得可列印性修復任務。

參數

  • Name
    id
    Type
    path
    Description

    要取得的可列印性修復任務的 ID。

回傳值

可列印性修復任務物件。在任務達到 SUCCEEDED 狀態之前,model_urls 部分為空。只有與輸入格式相符的 model_urls 欄位會被填入。

Request

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

Response

{
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "type": "print-repair",
  "status": "SUCCEEDED",
  "progress": 100,
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000030000,
  "expires_at": 1715725401000,
  "task_error": null,
  "model_urls": {
    "glb": "",
    "gltf": "",
    "fbx": "",
    "obj": "",
    "stl": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.stl?Expires=***",
    "usdz": "",
    "3mf": "",
    "mtl": ""
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/preview.png?Expires=***",
  "texture_urls": [],
  "consumed_credits": 10
}

DELETE/openapi/v1/print/repair/:id

刪除可列印性修復任務

此 endpoint 將永久刪除一個可列印性修復任務及其修復後的輸出結果。此操作不可復原。

路徑參數

  • Name
    id
    Type
    path
    Description

    要刪除的可列印性修復任務的 ID。

回傳值

成功時回傳 200 OK

Request

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

Response

// Returns 200 Ok on success.

GET/openapi/v1/print/repair

獲取可列印性修復任務列表

此 endpoint 允許您獲取可列印性修復任務的列表。

參數

可選屬性

  • 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:按建立時間降序排序。

返回

返回一個分頁的可列印性修復任務物件列表。

Request

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

Response

[
  {
    "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
    "type": "print-repair",
    "status": "SUCCEEDED",
    "progress": 100,
    "preceding_tasks": 0,
    "created_at": 1699999999000,
    "started_at": 1700000000000,
    "finished_at": 1700000030000,
    "expires_at": 1715725401000,
    "task_error": null,
    "model_urls": {
      "glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
      "gltf": "",
      "fbx": "",
      "obj": "",
      "stl": "",
      "usdz": "",
      "3mf": "",
      "mtl": ""
    },
    "thumbnail_url": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/preview.png?Expires=***",
    "texture_urls": [],
    "consumed_credits": 10
  }
]

GET/openapi/v1/print/repair/:id/stream

流式取得可列印性修復任務

此端點使用 Server-Sent Events (SSE) 串流傳輸可列印性修復任務的即時更新。

參數

  • Name
    id
    Type
    path
    Description

    要進行串流傳輸的可列印性修復任務的唯一識別碼。

回傳

以 Server-Sent Events 的形式回傳可列印性修復任務物件串流。

對於 PENDINGIN_PROGRESS 狀態的任務,回應串流將僅包含必要的 progressstatus 欄位。model_urls 部分僅在任務達到 SUCCEEDED 狀態後才會傳送。

Request

GET
/openapi/v1/print/repair/a43b5c6d-7e8f-901a-234b-567c890d1e2f/stream
curl -N https://api.meshy.ai/openapi/v1/print/repair/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-repair",
  "status": "SUCCEEDED",
  "progress": 100,
  "preceding_tasks": 0,
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000030000,
  "expires_at": 1715725401000,
  "task_error": null,
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/a43b5c6d-7e8f-901a-234b-567c890d1e2f/output/model.glb?Expires=***",
    "gltf": "",
    "fbx": "",
    "obj": "",
    "stl": "",
    "usdz": "",
    "3mf": "",
    "mtl": ""
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/a43b5c6d-7e8f-901a-234b-567c890d1e2f/output/preview.png?Expires=***",
  "texture_urls": [],
  "consumed_credits": 10
}

可列印性修復任務物件

  • Name
    id
    Type
    string
    Description

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

  • Name
    type
    Type
    string
    Description

    可列印性修復任務的類型。值為 print-repair

  • Name
    status
    Type
    string
    Description

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

  • Name
    progress
    Type
    integer
    Description

    任務的進度。如果任務尚未開始,此屬性值為 0。一旦任務成功完成,此值將變為 100

  • 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
    expires_at
    Type
    timestamp
    Description

    任務結果將從系統中過期的時間戳,以毫秒為單位。如果任務尚未完成,則為 0

  • Name
    task_error
    Type
    object
    Description

    任務失敗時的錯誤資訊。如果任務未失敗,此屬性為 null。更多詳情請參見 Errors

    • Name
      message
      Type
      string
      Description

      描述出錯原因的錯誤訊息。

  • Name
    model_urls
    Type
    object
    Description

    指向修復後 3D 模型的可下載 URL。僅與輸入格式相符的欄位會被填入;其他格式欄位均為空字串。

    • Name
      glb
      Type
      string
      Description

      指向修復後 GLB 的可下載 URL。當輸入為 GLB 或使用了 input_task_id 時會被填入。

    • Name
      gltf
      Type
      string
      Description

      指向修復後 GLTF 的可下載 URL。當輸入為 GLTF 上傳時會被填入。

    • Name
      fbx
      Type
      string
      Description

      指向修復後 FBX 的可下載 URL。當輸入為 FBX 上傳時會被填入。

    • Name
      obj
      Type
      string
      Description

      指向修復後 OBJ 的可下載 URL。當輸入為 OBJ 上傳時會被填入。

    • Name
      stl
      Type
      string
      Description

      指向修復後 STL 的可下載 URL。當輸入為 STL 上傳時會被填入。

    • Name
      usdz
      Type
      string
      Description

      為 USDZ 輸出保留。在可列印性修復任務中始終為空字串。

    • Name
      3mf
      Type
      string
      Description

      為 3MF 輸出保留。在可列印性修復任務中始終為空字串。

    • Name
      mtl
      Type
      string
      Description

      為 MTL 輸出保留。在可列印性修復任務中始終為空字串。

  • Name
    thumbnail_url
    Type
    string
    Description

    根據修復後模型渲染出的預覽圖 URL。

  • Name
    alpha_thumbnail_url
    Type
    string
    Description

    指向 thumbnail_url 透明背景(RGBA)版本的可下載 URL。僅當任務建立時設定了 alpha_thumbnail: true 且透明預覽渲染成功時才會出現;否則此欄位會被省略。

  • Name
    texture_urls
    Type
    array
    Description

    始終為空陣列。修復僅保留輸入的幾何體,不會重新生成貼圖。

  • Name
    consumed_credits
    Type
    integer
    Description

    此任務消耗的積分數。一旦任務達到 SUCCEEDED 狀態,值為 10。對於 FAILED 任務回傳 0(失敗時積分會被退還)。

The Repair Printability Task Object

{
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "type": "print-repair",
  "status": "SUCCEEDED",
  "progress": 100,
  "preceding_tasks": 0,
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000030000,
  "expires_at": 1715725401000,
  "task_error": null,
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
    "gltf": "",
    "fbx": "",
    "obj": "",
    "stl": "",
    "usdz": "",
    "3mf": "",
    "mtl": ""
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/preview.png?Expires=***",
  "texture_urls": [],
  "consumed_credits": 10
}