Remesh API
Remesh API 允许您对其他 Meshy API(如 Image to 3D 或 Text to 3D)生成的现有 3D 模型进行重拓扑,并将其导出为多种格式。本节将详细介绍如何使用 Remesh API。
创建 Remesh 任务
此 endpoint 用于创建一个新的 Remesh 任务。
如需进行格式转换和尺寸调整,请使用专用的 Convert API 和 Resize API。以下已弃用的参数仍可继续使用,但我们建议新的集成使用新的 endpoint。
参数
input_task_id 和 model_url 中只需提供一个,即为必填。如果两者都提供,则 input_task_id 具有更高优先顺序。
- Name
- input_task_id
- Type
- string
- 必选
- Description
您希望进行重拓扑的、已完成的 Image to 3D 或 Text to 3D 任务的 ID。 该任务必须是以下任务之一:Text to 3D Preview、Text to 3D Refine、Image to 3D 或 Retexture。此外,其状态必须为
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 格式。
可选值:
glb、fbx、obj、usdz、blend、stl、3mf。
- Name
- topology
- Type
- string
- 默认值 triangle
- Description
指定生成模型的 topology(拓扑结构)。
可选值:
quad:生成以四边形为主的 mesh。triangle:生成经过精简的三角形 mesh。
- Name
- target_polycount
- Type
- integer
- 默认值 30,000
- Description
指定生成模型中的目标多边形数量。实际的多边形数量可能会根据 geometry 的复杂程度与目标值有所偏差。
有效值范围因用户等级而异:
- 100 到 300,000(含边界值)
- Name
- decimation_mode
- Type
- integer
- Description
通过设置 polycount 级别来启用自适应精简。设置该参数后,
target_polycount将被忽略。可选值:
1:自适应 — 超高 polycount。2:自适应 — 高 polycount。3:自适应 — 中等 polycount。4:自适应 — 低 polycount。
- Name
- resize_height
- Type
- number
- ⚠ 已弃用
- 默认值 0
- Description
将模型尺寸调整为以米为单位的特定高度。我们建议改用专用的 Resize API。
auto_size、resize_height和resize_longest_side互斥,不能同时设置。
- Name
- resize_longest_side
- Type
- number
- ⚠ 已弃用
- 默认值 0
- Description
调整模型尺寸,使其边界框中最长的一边等于指定的米数值。我们建议改用专用的 Resize API。
auto_size、resize_height和resize_longest_side互斥,不能同时设置。
- Name
- auto_size
- Type
- boolean
- ⚠ 已弃用
- 默认值 false
- Description
设置为
true时,服务会使用 AI 视觉自动估算物体的真实世界高度,并据此调整模型尺寸。我们建议改用专用的 Resize API。auto_size、resize_height和resize_longest_side互斥,不能同时设置。
auto_size = true- Name
- origin_at
- Type
- string
- ⚠ 已弃用
- 默认值 bottom
- Description
origin(原点)的位置。我们建议改用专用的 Resize API。
可选值:
bottom、center。
- Name
- convert_format_only
- Type
- boolean
- ⚠ 已弃用
- Description
如果为
true,服务将仅更改输入模型文件的格式,而忽略其他输入参数,如topology、resize_height和target_polycount。我们建议改用专用的 Convert API。如果
convert_format_only设置为true,则必须提供target_formats。
- Name
- alpha_thumbnail
- Type
- boolean
- 默认值 false
- Description
设置为
true时,该任务会额外渲染一个透明背景(RGBA)版本的预览图,并在 GET 响应中以alpha_thumbnail_url的形式返回。现有的thumbnail_url字段保持不变。
返回值
响应中的 result 属性包含新创建的重拓扑任务的 id。
失败模式
- Name
400 - Bad Request- Description
请求不可接受。常见原因:
- 缺少参数:必须提供
model_url或input_task_id其中之一。 - 输入任务无效:
input_task_id必须指向来自受支持模型的成功任务。 - 模型格式无效:
model_url指向的文件扩展名不受支持。 - URL 无法访问:无法下载
model_url所指向的文件。 - topology 无效:
topology参数无效。 - 参数互斥:
auto_size和resize_height不能同时设置。
- 缺少参数:必须提供
- Name
401 - Unauthorized- Description
身份验证失败。请检查您的 API key。
- Name
402 - Payment Required- Description
credits 不足,无法执行此任务。
- Name
429 - Too Many Requests- Description
您已超出速率限制。
Request
# 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"
}
获取 Remesh 任务
此 endpoint 用于根据 ID 获取一个 remesh 任务。
参数
- Name
- id
- Type
- path
- Description
要获取的 remesh 任务的 ID。
返回
Remesh 任务对象。
Request
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,
}
删除 Remesh 任务
此 endpoint 将永久删除一个 remesh 任务,包括所有相关的模型和数据。此操作不可撤销。
路径参数
- Name
- id
- Type
- path
- Description
要删除的 remesh 任务的 ID。
返回值
成功时返回 200 OK。
Request
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.
获取 Remesh 任务列表
此 endpoint 允许您获取 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
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
}
]
流式获取 Remesh 任务
此 endpoint 使用 Server-Sent Events(SSE)流式传输 Remesh 任务的实时更新。
参数
- Name
- id
- Type
- path
- Description
要流式传输的 Remesh 任务的唯一标识符。
返回值
以 Server-Sent Events 的形式返回 Remesh 任务对象 的流。
对于 PENDING 或 IN_PROGRESS 状态的任务,响应流将仅包含必要的 progress 和 status 字段。
Request
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
任务的进度。如果任务尚未开始,该属性为
0。任务成功后,该值将变为100。
- Name
- status
- Type
- string
- Description
任务的状态。可能的值为
PENDING、IN_PROGRESS、SUCCEEDED、FAILED之一。
- Name
- preceding_tasks
- Type
- integer
- Description
排在前面的任务数量。
该字段的值仅在任务状态为
PENDING时才有意义。
- 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
该任务消耗的积分数量。当任务状态为
PENDING、IN_PROGRESS或SUCCEEDED时会出现该字段。对于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
}