尺寸调整 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

authentication 失败。请检查您的 API key。

  • 402 - Payment Required

credits 不足,无法执行此任务。

  • 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

    每页数量限制。最大允许为 100 项。

  • 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 使用服务器推送事件(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
}

尺寸调整任务对象

尺寸调整任务对象表示一个尺寸调整作业。

属性

  • 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

此任务消耗的 credits 数量(每个尺寸调整任务消耗 1 credit)。对于 FAILED 的任务,返回 0