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

    每页数量限制。最大允许为 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