尺寸调整 API
尺寸调整 API 允许您将现有的 3D 模型调整为现实世界的尺寸。您可以指定一个精确的高度、最长边约束,或者让 AI 自动估算合适的尺寸。
创建尺寸调整任务
此endpoint创建一个新的尺寸调整任务。
参数
input_task_id或model_url中只有一个是必需的。如果两者都提供,则input_task_id优先。
- Name
- input_task_id
- Type
- string
- 必选
- Description
您希望调整尺寸的已完成Meshy任务的ID。 任务的状态必须为
SUCCEEDED。 输出格式将为GLB。
- Name
- model_url
- Type
- string
- 必选
- Description
指向3D模型文件的公开可访问URL或数据URI。 支持的格式:
.glb、.gltf、.obj、.fbx、.stl。 对于数据URI,请使用MIME type:application/octet-stream。 输出格式将保留输入模型的原始格式。
恰好需要一个尺寸调整模式:resize_height、resize_longest_side或auto_size。这三个参数是互斥的。
- 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的位置。
可用值:
bottom、center。
返回
响应的result属性包含新创建的尺寸调整任务的id。
失败模式
400 - Bad Request
请求不可接受。常见原因:
- 缺少参数:必须提供
model_url或input_task_id之一。 - 缺少尺寸调整模式:必须指定
resize_height、resize_longest_side或auto_size之一。 - 互斥参数:
resize_height、resize_longest_side和auto_size不能组合使用。 - 无效的输入任务:
input_task_id必须引用一个成功的任务。 - 无效的模型格式:
model_url指向一个不支持的扩展名文件。 - 无法访问的URL:无法下载
model_url。
401 - Unauthorized
认证失败。请检查您的API key。
402 - Payment Required
积分不足以执行此任务。
429 - Too Many Requests
您已超出速率限制。
Request
# 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"
}
检索尺寸调整任务
此endpoint通过ID检索尺寸调整任务。
参数
- Name
- id
- Type
- path
- Description
要检索的尺寸调整任务的ID。
返回
尺寸调整任务对象。
Request
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
}
删除尺寸调整任务
此endpoint永久删除一个尺寸调整任务,包括所有相关的模型和数据。此操作不可逆。
路径参数
- Name
- id
- Type
- path
- Description
要删除的尺寸调整任务的ID。
返回值
成功时返回 200 OK。
Request
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.
列出尺寸调整任务
此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:按创建时间降序排序。
返回
返回尺寸调整任务对象的分页列表。
请求
curl https://api.meshy.ai/openapi/v1/resize?page_size=10 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
响应
[
{
"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
}
]
流式传输尺寸调整任务
此endpoint使用服务器发送事件(SSE)流式传输尺寸调整任务的实时更新。
参数
- Name
- id
- Type
- path
- Description
要流式传输的尺寸调整任务的唯一标识符。
返回值
返回尺寸调整任务对象的流作为服务器发送事件。
对于PENDING或IN_PROGRESS任务,响应流将仅包含必要的progress和status字段。
请求
curl -N https://api.meshy.ai/openapi/v1/resize/a43b5c6d-7e8f-901a-234b-567c890d1e2f/stream \
-H "Authorization: Bearer ${YOUR_API_KEY}"
响应流
// 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
任务的状态。可能的值:PENDING,IN_PROGRESS,SUCCEEDED,FAILED,CANCELED。
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。