重構網格 API

重構網格 API 可讓您針對由其他 Meshy API(例如圖片轉 3D 或文字轉 3D)產生的既有 3D 模型進行重構網格,並匯出為多種格式。本節將詳細介紹如何使用重構網格 API。


POST/openapi/v1/remesh

建立重構網格任務

此端點用於建立新的重構網格任務。

參數

  • Name
    input_task_id
    Type
    string
    必选
    Description

    需要重構網格的已完成圖像轉 3D 或文字轉 3D 任務 ID。 該任務必須是以下任務之一:文字轉 3D 預覽、文字轉 3D 精修、圖像轉 3D 或重新紋理。此外,它必須具有 SUCCEEDED 狀態。

  • Name
    model_url
    Type
    string
    必选
    Description

    請透過可公開存取的 URL 或 Data URI 提供一個 3D 模型,以便 Meshy 進行重構網格。 支援的格式:.glb.gltf.obj.fbx.stl

    對於 Data URI,請使用 MIME 類型:application/octet-stream

  • Name
    target_formats
    Type
    string[]
    默认值 ["glb"]
    Description

    重構網格模型的目標格式清單。未指定時僅產生 GLB。

    可選值:glbfbxobjusdzblendstl3mf

  • Name
    topology
    Type
    string
    默认值 triangle
    Description

    指定產生模型的拓撲結構。

    可選值:

    • quad:產生以四邊形為主的網格。
    • triangle:產生簡化的三角網格。
  • Name
    target_polycount
    Type
    integer
    默认值 30,000
    Description

    指定產生模型的目標面數。實際面數可能會依幾何複雜度而有所偏差。

    有效取值範圍依使用者等級而有所不同:

    • 100 到 300,000(含)
  • Name
    decimation_mode
    Type
    integer
    Description

    透過設定面數等級啟用自適應減面。設定後,target_polycount 將被忽略。

    可選值:

    • 1:自適應——超高面數。
    • 2:自適應——高面數。
    • 3:自適應——中等面數。
    • 4:自適應——低面數。
  • Name
    resize_height
    Type
    number
    已弃用
    默认值 0
    Description

    將模型縮放到指定高度(單位:公尺)。建議使用專用的 尺寸調整 API

  • Name
    resize_longest_side
    Type
    number
    已弃用
    默认值 0
    Description

    將模型縮放至最長邊等於指定值(單位:公尺)。建議使用專用的 尺寸調整 API

  • Name
    auto_size
    Type
    boolean
    已弃用
    默认值 false
    Description

    設定為 true 時,服務會使用 AI 視覺自動估算物體的真實高度,並相應調整模型大小。建議使用專用的 尺寸調整 API

仅当 auto_size = true
  • Name
    origin_at
    Type
    string
    已弃用
    默认值 bottom
    Description

    原點位置。建議使用專用的 尺寸調整 API

    可選值:bottomcenter

  • Name
    convert_format_only
    Type
    boolean
    已弃用
    Description

    如果為 true,服務將只變更輸入模型檔案的格式,並忽略其他輸入屬性,例如 topologyresize_heighttarget_polycount 等。建議使用專用的 格式轉換 API

  • Name
    alpha_thumbnail
    Type
    boolean
    默认值 false
    Description

    設定為 true 時,任務會額外算繪一張透明背景(RGBA)的預覽圖,並在 GET 回應的 alpha_thumbnail_url 欄位中返回。原有 thumbnail_url 欄位保持不變。

回傳值

回應的 result 欄位包含新建重構網格任務的 id

失敗模式

  • Name
    400 - Bad Request
    Description

    請求不合法。常見原因:

    • 缺少參數:必須提供 model_urlinput_task_id 其中之一。
    • 輸入任務無效input_task_id 必須引用一個來自支援模型的成功任務。
    • 模型格式無效model_url 指向的檔案副檔名不受支援。
    • URL 無法存取model_url 無法下載。
    • 拓撲結構無效topology 參數無效。
    • 互斥參數衝突auto_sizeresize_height 不能同時設定。
  • Name
    401 - Unauthorized
    Description

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

  • Name
    402 - Payment Required
    Description

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

  • Name
    429 - Too Many Requests
    Description

    您已超出請求頻率限制。

请求

POST
/openapi/v1/remesh
# 使用自定义格式和调整大小的基本重建网格
curl https://api.meshy.ai/openapi/v1/remesh \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
    "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "target_formats": ["glb", "fbx"],
    "topology": "quad",
    "target_polycount": 50000,
    "resize_height": 1.0,
    "origin_at": "bottom"
  }'

# 四边形重建网格并启用自动尺寸
curl https://api.meshy.ai/openapi/v1/remesh \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
    "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "target_formats": ["glb", "fbx"],
    "topology": "quad",
    "target_polycount": 50000,
    "auto_size": true
  }'

响应

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

GET/openapi/v1/remesh/:id

取得重構網格任務

此端點用於透過 ID 取得重構網格任務。

參數

  • Name
    id
    Type
    path
    Description

    要取得的重構網格任務 ID。

回傳值

回傳重構網格任務物件。

请求

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

响应

{
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "type": "remesh",
  "model_urls": {
      "glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
      "fbx": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.fbx?Expires=***",
      "obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***",
      "usdz": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.usdz?Expires=***",
      "blend": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.blend?Expires=***",
      "stl": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.stl?Expires=***"
},
  "progress": 100,
  "status": "SUCCEEDED",
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": null,
}

DELETE/openapi/v1/remesh/:id

刪除重構網格 任務

此端點可永久刪除一個重構網格 任務,包括所有相關的模型與資料。此操作無法復原。

路徑參數

  • Name
    id
    Type
    path
    Description

    要刪除的重構網格 任務 ID。

回傳值

成功時會回傳 200 OK

请求

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

响应

// 成功则返回 200 Ok。

GET/openapi/v1/remesh

列出重構網格 任務

此端點可讓您取得重構網格 任務清單。

參數

  • Name
    page_num
    Type
    integer
    默认值 1
    Description

    分頁的頁碼。

  • Name
    page_size
    Type
    integer
    默认值 10
    Description

    每頁回傳的任務數量。允許的最大值為50

  • Name
    sort_by
    Type
    string
    Description

    排序欄位。

    可選值:

    • +created_at:依建立時間遞增排序。
    • -created_at:依建立時間遞減排序。

回傳值

回傳分頁的重構網格 任務物件清單。

请求

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

响应

[
  {
    "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
    "type": "remesh",
    "model_urls": {
      "glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
      "fbx": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.fbx?Expires=***",
      "obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***",
      "usdz": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.usdz?Expires=***",
      "blend": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.blend?Expires=***",
      "stl": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.stl?Expires=***"
    },
    "progress": 100,
    "status": "SUCCEEDED",
    "created_at": 1699999999000,
    "started_at": 1700000000000,
    "finished_at": 1700000001000,
    "task_error": null
  }
]

GET/openapi/v1/remesh/:id/stream

串流式重構網格任務

此端點會透過 Server-Sent Events (SSE) 串流回傳重構網格任務的即時進度更新。

參數

  • Name
    id
    Type
    path
    Description

    要以串流方式取得的重構網格任務 ID。

回傳值

回傳重構網格任務物件的串流式 Server-Sent Events。

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

请求

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

响应流

// 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": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "progress": 0,
  "status": "PENDING"
}

event: message
data: {
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "type": "remesh",
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
    "fbx": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.fbx?Expires=***",
    "obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***",
    "usdz": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.usdz?Expires=***",
    "blend": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.blend?Expires=***",
    "stl": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.stl?Expires=***"
  },
  "progress": 100,
  "status": "SUCCEEDED",
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": null,
}

重構網格 任務物件

重構網格 任務物件代表 Meshy 用於對現有 3D 模型進行重構網格並匯出為多種格式的工作單元。 此物件包含以下屬性:

屬性

  • Name
    id
    Type
    string
    Description

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

  • Name
    type
    Type
    string
    Description

    重構網格任務的類型。值為 remesh

  • Name
    model_urls
    Type
    object
    Description

    Meshy 產生的帶有貼圖 3D 模型檔案的可下載 URL。如果未產生某種格式,該格式的屬性會被省略,而不是回傳空字串。

    • Name
      glb
      Type
      string
      Description

      GLB 檔案的可下載 URL。

    • Name
      fbx
      Type
      string
      Description

      FBX 檔案的可下載 URL。

    • Name
      obj
      Type
      string
      Description

      OBJ 檔案的可下載 URL。

    • Name
      usdz
      Type
      string
      Description

      USDZ 檔案的可下載 URL。

    • Name
      blend
      Type
      string
      Description

      Blender 檔案的可下載 URL。

    • Name
      stl
      Type
      string
      Description

      STL 檔案的可下載 URL。

    • Name
      3mf
      Type
      string
      Description

      3MF 檔案的可下載連結。僅在透過 target_formats 要求 3mf 時回傳。

  • Name
    thumbnail_url
    Type
    string
    Description

    從重構網格後的模型渲染出的預覽圖可下載 URL。

  • Name
    alpha_thumbnail_url
    Type
    string
    Description

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

  • 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(失敗時積分會被退還)。

重建网格任务对象示例

{
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "type": "remesh",
  "model_urls": {
      "glb": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.glb?Expires=***",
      "fbx": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.fbx?Expires=***",
      "obj": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.obj?Expires=***",
      "usdz": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.usdz?Expires=***",
      "blend": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.blend?Expires=***",
      "stl": "https://assets.meshy.ai/***/tasks/0193bfc5-ee4f-73f8-8525-44b398884ce9/output/model.stl?Expires=***"
  },
  "progress": 100,
  "status": "SUCCEEDED",
  "preceding_tasks": 0,
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": {

    "message": ""

  },

  "consumed_credits": 5
}