可列印性修復 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。必須使用 http、https 或 data: 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_id 也未提供 model_url。
    • UUID 無效:input_task_id 不是有效的 UUID。
    • 模型 URL 無效:model_url 格式錯誤、使用了不受支援的通訊協定,或檔案副檔名不受支援。
    • 模型檔案過大:model_url 對應的內容超過 100 MB。
    • 任務未成功:所引用的任務仍處於待處理、進行中或失敗狀態。
    • 缺少 GLB:所引用的任務沒有可供修復的 GLB asset。
  • Name
    401 - Unauthorized
    Description

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

  • Name
    402 - Payment Required
    Description

    常見原因:

    • 免費方案:建立任務需要付費方案。請前往 subscription 頁面升級。
    • credits 不足:已達到 workspace 的 credit 限額。
  • 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

取得可列印性修復任務

此端點用於根據 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。

任務狀態

仍處於 PENDING 狀態的任務會被刪除,並且建立時消耗的 credits 會被退還。

已處於 IN_PROGRESS 狀態的任務無法刪除:請求會被拒絕並返回 409 Conflict,任務將繼續執行。工作程序已經開始處理的任務所消耗的 credits 不可退還,因此在執行過程中刪除該任務會讓你同時損失 credits 和結果。請等待任務到達 SUCCEEDED、FAILED 或 CANCELED 狀態後再刪除。

處於終態(SUCCEEDED、FAILED 或 CANCELED)的任務在刪除時不會退款。

回傳

成功時返回 200 OK;當任務處於 IN_PROGRESS 狀態時返回 409 Conflict。

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

// 200 OK on success, with an empty body.
//
// 409 Conflict when the task is IN_PROGRESS — the task is left running:
{
  "message": "Task is IN_PROGRESS and cannot be deleted. Credits for a task the worker has already started are not refundable; wait for it to reach SUCCEEDED, FAILED or CANCELED, then delete it."
}

GET/openapi/v1/print/repair

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

此端點允許你取得可列印性修復任務的列表。

參數

可選屬性

  • Name
    page_num
    Type
    integer
    Description

    用於分頁的頁碼。起始值及預設值均為 1。

  • Name
    page_size
    Type
    integer
    Description

    每頁數量限制。預設值為 10 筆。允許的最大值為 100 筆。

  • 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

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

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

參數

  • Name
    id
    Type
    path
    Description

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

回傳

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

每一幀都攜帶該階段的完整任務物件——與 Get endpoint 回傳的結構相同——因此當任務處於 PENDING 或 IN_PROGRESS 狀態時,輸出欄位尚未被填入(為 null、[] 或 {}),且 finished_at 為 null。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.
// Every frame is the full task object; fields not yet populated are null / empty.
// The PENDING frame below is abbreviated to the fields that change.
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-可排序 UUID 作為任務 id,但你不應對 id 的格式做任何假設。

  • Name
    type
    Type
    string
    Description

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

  • Name
    status
    Type
    string
    Description

    任務的狀態。可能的值為 PENDING、IN_PROGRESS、SUCCEEDED、FAILED、CANCELED 之一。

  • 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。更多詳情請參見錯誤。

    • 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

    始終為空陣列。修復僅保留輸入的 geometry,不會重新烘焙材質貼圖。

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