尺寸調整 API

尺寸調整 API 讓您可以將現有的 3D 模型調整為真實世界的尺寸。您可以指定精確的高度、最長邊約束,或是讓 AI 自動估算合適的尺寸。


POST/openapi/v1/resize

建立尺寸調整任務

此 endpoint 用於建立一個新的尺寸調整任務。

參數

  • Name
    input_task_id
    Type
    string
    必選
    Description

    您希望調整尺寸的模型所對應的已完成 Meshy 任務的 ID。 該任務的狀態必須為 SUCCEEDED。 輸出格式將為 GLB。

  • Name
    model_url
    Type
    string
    必選
    Description

    指向 3D 模型檔案的公開可存取 URL 或 data URI。 支援的格式:.glb.gltf.obj.fbx.stl。 對於 Data URI,請使用 MIME type:application/octet-stream。 輸出格式將保留輸入模型的原始格式。

  • Name
    resize_height
    Type
    number
    Description

    將模型調整為以公尺為單位測量的特定高度。

  • Name
    resize_longest_side
    Type
    number
    Description

    調整模型尺寸,使其最長邊與此值(以公尺為單位測量)相符。會保持長寬比不變。

  • Name
    auto_size
    Type
    boolean
    Description

    設為 true 時,服務會使用 AI 視覺自動估算物體的真實高度,並據此調整模型尺寸。除非明確設定了 origin_at,否則 origin 將預設為 bottom

  • Name
    origin_at
    Type
    string
    預設值 bottom
    Description

    調整尺寸後 origin 的位置。

    可用值:bottomcenter

回傳值

回應中的 result 屬性包含新建立的尺寸調整任務的 id

失敗模式

  • 400 - Bad Request

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

  • 缺少參數:必須提供 model_urlinput_task_id
  • 缺少尺寸調整 mode:必須指定 resize_heightresize_longest_sideauto_size 中的至少一個。
  • 參數互斥resize_heightresize_longest_sideauto_size 不能組合使用。
  • 無效的輸入任務input_task_id 必須指向一個成功的任務。
  • 無效的模型格式model_url 指向的檔案副檔名不受支援。
  • URL 無法存取:無法下載 model_url 指向的內容。
  • 401 - Unauthorized

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

  • 402 - Payment Required

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

  • 429 - Too Many Requests

您已超出速率限制。

Request

POST
/openapi/v1/resize
# Simple: resize to a specific height
curl https://api.meshy.ai/openapi/v1/resize \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
    "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "resize_height": 1.8
  }'

# Advanced: resize longest side with custom origin
curl https://api.meshy.ai/openapi/v1/resize \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
    "model_url": "https://example.com/model.glb",
    "resize_longest_side": 2.0,
    "origin_at": "center"
  }'

Response

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

GET/openapi/v1/resize/:id

檢索尺寸調整任務

此 endpoint 用於根據 ID 檢索尺寸調整任務。

參數

  • Name
    id
    Type
    path
    Description

    要檢索的尺寸調整任務的 ID。

回傳

尺寸調整任務物件。

Request

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

Response

{
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "type": "resize",
  "model_urls": {
      "glb": "https://assets.meshy.ai/.../model.glb?Expires=..."
  },
  "progress": 100,
  "status": "SUCCEEDED",
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": null,
  "consumed_credits": 1
}

DELETE/openapi/v1/resize/:id

刪除尺寸調整任務

此 endpoint 將永久刪除某個尺寸調整任務,包括所有相關的模型和資料。此操作不可逆。

路徑參數

  • Name
    id
    Type
    path
    Description

    要刪除的尺寸調整任務的 ID。

回傳值

成功時回傳 200 OK

Request

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

Response

// Returns 200 Ok on success.

GET/openapi/v1/resize

獲取尺寸調整任務列表

此 endpoint 允許您檢索尺寸調整任務列表。

參數

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

返回值

返回分頁的尺寸調整任務物件列表。

Request

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

Response

[
  {
    "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
    "type": "resize",
    "model_urls": {
      "glb": "https://assets.meshy.ai/.../model.glb?Expires=..."
    },
    "progress": 100,
    "status": "SUCCEEDED",
    "created_at": 1699999999000,
    "started_at": 1700000000000,
    "finished_at": 1700000001000,
    "task_error": null,
    "consumed_credits": 1
  }
]

GET/openapi/v1/resize/:id/stream

流式取得尺寸調整任務

此 endpoint 使用 Server-Sent Events (SSE) 串流傳輸尺寸調整任務的即時更新。

參數

  • Name
    id
    Type
    path
    Description

    要進行串流傳輸的尺寸調整任務的唯一識別碼。

回傳

以 Server-Sent Events 的形式回傳尺寸調整任務物件的串流。

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

Request

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

Response Stream

// Message event examples illustrate task progress.
event: message
data: {
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "progress": 0,
  "status": "PENDING"
}

event: message
data: {
  "id": "0193bfc5-ee4f-73f8-8525-44b398884ce9",
  "type": "resize",
  "model_urls": {
    "glb": "https://assets.meshy.ai/.../model.glb?Expires=..."
  },
  "progress": 100,
  "status": "SUCCEEDED",
  "created_at": 1699999999000,
  "started_at": 1700000000000,
  "finished_at": 1700000001000,
  "task_error": null,
  "consumed_credits": 1
}

尺寸調整任務物件

尺寸調整任務物件表示一個尺寸調整作業。

Properties

  • id · string

任務的唯一識別碼。

  • type · string

任務的類型。此值為 resize

  • model_urls · object

尺寸調整後模型檔案的可下載 URL。使用 input_task_id 時,輸出始終為 GLB。使用 model_url 時,輸出會保留原始格式。

  • progress · integer

任務的進度(0-100)。

  • status · string

任務的狀態。可能的值:PENDINGIN_PROGRESSSUCCEEDEDFAILEDCANCELED

  • preceding_tasks · integer

排在前面的任務數量。僅在狀態為 PENDING 時有意義。

  • created_at · timestamp

任務建立時的時間戳,單位為毫秒。

  • started_at · timestamp

任務開始時的時間戳,單位為毫秒。若尚未開始,則為 0

  • finished_at · timestamp

任務完成時的時間戳,單位為毫秒。若尚未完成,則為 0

  • task_error · object

任務失敗時的錯誤物件。更多詳情請參見 Errors

  • consumed_credits · integer

此任務消耗的積分數量(每個尺寸調整任務消耗 1 積分)。若任務狀態為 FAILED,則回傳 0