Remesh API

Remesh API 讓您能夠對其他 Meshy API(如影象生成 3D 或文字生成 3D)產生的現有 3D 模型進行重構網格,並將其匯出為多種格式。本節將詳細介紹如何使用 Remesh API。


POST/openapi/v1/remesh

建立 Remesh 任務

此端點用於建立一個新的 Remesh 任務。

參數

  • Name
    input_task_id
    Type
    string
    必選
    Description

    您希望進行重拓撲的、已完成的 影象生成 3D 或 文字生成 3D 任務的 ID。 該任務必須是以下任務之一:Text to 3D Preview、Text to 3D Refine、影象生成 3D 或 重新貼圖。此外,其狀態必須為 SUCCEEDED

  • Name
    model_url
    Type
    string
    必選
    Description

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

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

  • Name
    target_formats
    Type
    string[]
    預設值 ["glb"]
    Description

    重拓撲後模型的目標格式清單。若省略,則僅產生 GLB 格式。

    可選值:glbfbxobjusdzblendstl3mf

  • Name
    topology
    Type
    string
    預設值 triangle
    Description

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

    可選值:

    • 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

    將模型尺寸調整為以公尺為單位的特定高度。我們建議改用專用的 Resize API

  • Name
    resize_longest_side
    Type
    number
    已棄用
    預設值 0
    Description

    調整模型尺寸,使其邊界框中最長的一邊等於指定的公尺數值。我們建議改用專用的 Resize API

  • Name
    auto_size
    Type
    boolean
    已棄用
    預設值 false
    Description

    設定為 true 時,服務會使用 AI 視覺自動估算物體的真實世界高度,並據此調整模型尺寸。我們建議改用專用的 Resize API

僅當 auto_size = true
  • Name
    origin_at
    Type
    string
    已棄用
    預設值 bottom
    Description

    原點的位置。我們建議改用專用的 Resize API

    可選值:bottomcenter

  • Name
    convert_format_only
    Type
    boolean
    已棄用
    Description

    如果為 true,服務將僅變更輸入模型檔案的格式,而忽略其他輸入參數,如 topologyresize_heighttarget_polycount。我們建議改用專用的 Convert 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 無效topology 參數無效。
    • 參數互斥auto_sizeresize_height 不能同時設定。
  • Name
    401 - Unauthorized
    Description

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

  • Name
    402 - Payment Required
    Description

    積分不足,無法執行此任務。

  • Name
    429 - Too Many Requests
    Description

    您已超出速率限制。

Request

POST
/openapi/v1/remesh
# Basic remesh with custom formats and resize
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"
  }'

# Quad remesh with auto-size
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
  }'

Response

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

GET/openapi/v1/remesh/:id

取得重構網格任務

此 endpoint 用於根據 ID 取得一個重構網格任務。

參數

  • Name
    id
    Type
    path
    Description

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

回傳

重構網格任務物件。

Request

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

Response

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

刪除重構網格任務

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

路徑參數

  • Name
    id
    Type
    path
    Description

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

回傳值

成功時回傳 200 OK

Request

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

Response

// Returns 200 Ok on success.

GET/openapi/v1/remesh

獲取 Remesh 任務清單

此端點允許您獲取 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:按建立時間降冪排序。

回傳

回傳一個經過分頁的 Remesh 任務物件 清單。

Request

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

Response

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

流式取得重構網格任務

此 endpoint 使用 Server-Sent Events(SSE)串流傳輸重構網格任務的即時更新。

參數

  • Name
    id
    Type
    path
    Description

    要串流傳輸的重構網格任務的唯一識別碼。

回傳值

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

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

Request

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

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

The Remesh Task Object

Remesh Task 物件表示 Meshy 用於將現有 3D 模型重構網格並匯出為多種格式的工作單元。 該物件具有以下屬性:

Properties

  • Name
    id
    Type
    string
    Description

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

  • Name
    type
    Type
    string
    Description

    Remesh 任務的類型。該值為 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 檔案的可下載 URL。僅當透過 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

    任務的 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 物件參考請參見 Errors

  • Name
    consumed_credits
    Type
    integer
    Description

    該任務消耗的積分數量。當任務狀態為 PENDINGIN_PROGRESSSUCCEEDED 時會出現該欄位。對於 FAILED 任務將回傳 0(失敗時積分會被退還)。

Example Remesh Task Object

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