Creative Lab — 方块小人 API
将源照片转换为方块风格的收藏级3D人偶模型,分为两个阶段:
原型阶段根据您的输入照片生成风格化的概念图,然后
构建阶段将该概念图转换为带贴图的3D模型。这两个阶段
通过 input_task_id 关联。
POST /openapi/creative-lab/brick-figure/v1/prototypePOST /openapi/creative-lab/brick-figure/v1/build
创建方块小人原型任务
根据源照片生成单张方块风格的概念图。返回的任务 ID 就是您在调用构建 endpoint 时需要传入的 input_task_id。有关响应结构,请参阅
方块小人原型任务对象。
参数
- Name
- image_url
- Type
- string
- 必选
- Description
供 Meshy 风格化为方块小人的源照片。目前支持
.jpg、.jpeg、.png和.webp格式。提供图片的方式有两种:
- 可公开访问的 URL:可从公共互联网访问的 URL。
- Data URI:图片的 base64 编码 data URI。Data URI 示例:
data:image/jpeg;base64,<your base64-encoded image data>。
- Name
- name
- Type
- string
- Description
用于展示的可选任务名称。最多 100 个字符。
- Name
- remove_background
- Type
- boolean
- 默认值 false
- Description
设置为
true时,原型图将以移除背景的透明 RGBA PNG 形式返回,方便您将主体合成到任意背景上。
返回值
响应中的 result 属性包含新创建的方块小人原型任务的任务 id。轮询 获取任务 endpoint 或订阅 流式接口,直到任务达到 SUCCEEDED 状态,然后将该 ID 作为 input_task_id 传入 构建 endpoint。
失败模式
- Name
400 - Bad Request- Description
请求无法被接受。常见原因:
- 缺少参数:
image_url为必填项。 - 无效的图片格式:提供的
image_url不是受支持的格式(.jpg、.jpeg、.png、.webp)。 - 图片尺寸超出范围:图片过小、超过最大文件大小限制,或超过最大像素数限制。
- URL 不可访问:无法下载该
image_url(404 或 timeout)。 - 无效的 Data URI:base64 字符串格式有误。
- 内容被标记:输入图片被 NSFW moderation 标记。
- 缺少参数:
- Name
401 - Unauthorized- Description
Authentication 失败。请检查您的 API key。
- Name
402 - Payment Required- Description
credits 不足,无法执行此任务。
- Name
403 - Forbidden- Description
输入图片因涉嫌知识产权侵权而被标记。
- Name
429 - Too Many Requests- Description
您已超出速率限制。
Request
# Stage 1: generate a brick-style concept image
curl https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/prototype \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"image_url": "<your publicly accessible image url or base64-encoded data URI>"
}'
Response
{
"result": "018a210d-8ba4-705c-b111-1f1776f7f578"
}
创建方块小人构建任务
从一个已成功的原型任务生成最终的带贴图 3D 方块小人。构建过程运行与 Image to 3D 相同的图像转 3D 流水线,因此响应对象格式和输出 URL 列表完全一致。响应结构请参阅 方块小人构建任务对象。
参数
- Name
- input_task_id
- Type
- string
- 必选
- Description
通过同一个 OpenAPI endpoint 创建的原型任务的任务 ID。该原型必须使用相同的 API key 创建,必须已达到
SUCCEEDED状态,并且必须只生成了一张候选图片。通过 webapp 创建的原型任务不被接受——构建 endpoint 只接受由
POST /openapi/creative-lab/brick-figure/v1/prototype生成的原型任务,其他来源一律返回404拒绝。
- Name
- name
- Type
- string
- Description
用于显示的可选任务名称。最多 100 个字符。
返回值
响应中的 result 属性包含新创建的方块小人构建任务的任务 id。轮询 获取任务 endpoint 或订阅 流式接口,直到任务达到 SUCCEEDED 状态,然后从 model_urls.glb 下载带贴图的 GLB(如果你的下游流水线更倾向于使用 OBJ,也可以从 model_urls.obj 和 model_urls.mtl 下载 OBJ + MTL 文件对)。
失败情形
- Name
400 - Bad Request- Description
请求内容不可接受。常见原因:
- 缺少参数:
input_task_id为必填项。 - 无效的 UUID:
input_task_id不是有效的 UUID。 - 父任务未成功:所引用的原型任务尚未达到
SUCCEEDED状态。 - 无候选图片:原型任务已成功,但未生成候选图片。
- 缺少参数:
- Name
401 - Unauthorized- Description
身份验证失败。请检查你的 API key。
- Name
402 - Payment Required- Description
credits 不足,无法执行此任务。
- Name
404 - Not Found- Description
所引用的原型任务不存在、属于其他用户,或是通过 webapp 创建的(只有 API 模式下的原型任务才能链式生成构建任务)。
- Name
429 - Too Many Requests- Description
你已超出速率限制。
Request
# Stage 2: chain build off a succeeded prototype task
curl https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/build \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578"
}'
Response
{
"result": "019c320e-9a8f-7a1c-9c11-2a1876f8a9bb"
}
获取方块小人任务
根据有效的任务 id 获取原型(prototype)或构建(build)任务。URL 路径
必须与任务所处的阶段匹配——通过 /prototype/:id 获取构建任务会返回
404,反之亦然。
响应结构请参阅 方块小人原型任务对象 和 方块小人构建任务对象。
参数
- Name
- id
- Type
- path
- Description
要获取的方块小人任务的唯一标识符。
返回
响应包含方块小人任务对象,其结构取决于所请求的阶段。
Request
# Prototype
curl https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/prototype/018a210d-8ba4-705c-b111-1f1776f7f578 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
# Build
curl https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/build/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Prototype Response
{
"id": "018a210d-8ba4-705c-b111-1f1776f7f578",
"type": "creative-lab-brick-figure-prototype",
"name": "",
"status": "SUCCEEDED",
"progress": 100,
"created_at": 1729123456000,
"started_at": 1729123460000,
"finished_at": 1729123486000,
"expires_at": 1729382686000,
"preceding_tasks": 0,
"task_error": null,
"consumed_credits": 6,
"image_urls": [
"https://assets.meshy.ai/***/concept.png?Expires=***"
]
}
Build Response
{
"id": "019c320e-9a8f-7a1c-9c11-2a1876f8a9bb",
"type": "creative-lab-brick-figure-build",
"name": "",
"status": "SUCCEEDED",
"progress": 100,
"created_at": 1729123500000,
"started_at": 1729123510000,
"finished_at": 1729123535000,
"expires_at": 1729382735000,
"preceding_tasks": 0,
"task_error": null,
"consumed_credits": 30,
"prompt": "",
"negative_prompt": "",
"texture_prompt": "",
"texture_image_url": "",
"model_urls": {
"glb": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.glb?Expires=***",
"obj": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.obj?Expires=***",
"mtl": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.mtl?Expires=***"
},
"thumbnail_url": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/preview.png?Expires=***",
"texture_urls": [
{
"base_color": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/texture_0.png?Expires=***"
}
]
}
删除方块小人任务
取消一个方块小人任务。如果任务仍处于 PENDING 状态,创建时消耗的
credits 将被退还。已处于 IN_PROGRESS 状态的任务会被取消但不予退款
(此时工作进程可能已经在消耗资源)。已经达到终止状态
(SUCCEEDED、FAILED、CANCELED)的任务无法被取消。
URL 路径必须与任务所处阶段相匹配 —— 对 /prototype/:buildId 执行
DELETE 操作会返回 404。
路径参数
- Name
- id
- Type
- path
- Description
要取消的方块小人任务的唯一标识符。
返回值
成功时返回 204 No Content,响应体为空。
失败情况
- Name
400 - Bad Request- Description
该任务已处于终止状态,无法被取消。
- Name
404 - Not Found- Description
该任务不存在、属于其他用户,或其所处阶段与 URL 路径不匹配。
Request
curl --request DELETE \
--url https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/prototype/018a210d-8ba4-705c-b111-1f1776f7f578 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
// Returns 204 No Content on success (empty body).
流式获取方块小人任务
通过 Server-Sent Events (SSE) 实时流式获取方块小人任务的更新。
URL 路径必须与任务所处的阶段匹配——在
/prototype/:buildId/stream 处打开流会发出单个 event: error
payload,其中包含 status_code: 404,随后关闭该流。
参数
- Name
- id
- Type
- path
- Description
要进行流式获取的方块小人任务的唯一标识符。
返回
以 Server-Sent Events 的形式返回一个由
方块小人原型(Brick Figure Prototype)
或 方块小人构建(Brick Figure Build) 任务对象组成的流。
对于 PENDING 或 IN_PROGRESS 状态的任务,响应流中只会包含
必要的 progress 和 status 字段。
Request
curl -N https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/build/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/stream \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response Stream
// Error event example (wrong stage or task not found)
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": "019c320e-9a8f-7a1c-9c11-2a1876f8a9bb",
"progress": 0,
"status": "PENDING"
}
event: message
data: {
"id": "019c320e-9a8f-7a1c-9c11-2a1876f8a9bb",
"type": "creative-lab-brick-figure-build",
"status": "SUCCEEDED",
"progress": 100,
"created_at": 1729123500000,
"started_at": 1729123510000,
"finished_at": 1729123535000,
"expires_at": 1729382735000,
"task_error": null,
"consumed_credits": 30,
"prompt": "",
"negative_prompt": "",
"texture_prompt": "",
"texture_image_url": "",
"model_urls": {
"glb": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.glb?Expires=***",
"obj": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.obj?Expires=***",
"mtl": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.mtl?Expires=***"
},
"thumbnail_url": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/preview.png?Expires=***",
"texture_urls": [
{
"base_color": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/texture_0.png?Expires=***"
}
]
}
获取方块小人任务列表
获取单个阶段的方块小人任务的分页列表。URL 路径决定阶段——/prototype 返回原型(prototype)任务;/build
返回构建(build)任务。另一个阶段的任务不会包含在任一响应中。
路径参数
- Name
- stage
- Type
- path
- 必选
- Description
prototype或build之一。该集合仅返回阶段与 URL 匹配的任务——请求/prototype永远不会返回 构建任务,反之亦然。
查询参数
- Name
- page_num
- Type
- integer
- 默认值 1
- Description
用于分页的页码。
- Name
- page_size
- Type
- integer
- 默认值 10
- Description
分页大小限制。最大允许值为
100项。
- Name
- sort_by
- Type
- string
- 默认值 -created_at
- Description
用于排序的字段。可用值:
+created_at:按创建时间升序排序。-created_at:按创建时间降序排序。
返回值
返回按阶段划分的任务对象的分页列表——列出 /prototype 时为
方块小人原型任务对象,
列出 /build 时为
方块小人构建任务对象。
Request
# List prototype tasks
curl https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/prototype?page_size=10 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
# List build tasks
curl https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/build?page_size=10 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response (List Prototype Tasks)
[
{
"id": "018a210d-8ba4-705c-b111-1f1776f7f578",
"type": "creative-lab-brick-figure-prototype",
"name": "",
"status": "SUCCEEDED",
"progress": 100,
"created_at": 1729123456000,
"started_at": 1729123460000,
"finished_at": 1729123486000,
"expires_at": 1729382686000,
"preceding_tasks": 0,
"task_error": null,
"consumed_credits": 6,
"image_urls": [
"https://assets.meshy.ai/***/concept.png?Expires=***"
]
}
]
The Brick Figure Prototype Task Object
Brick Figure Prototype Task 对象是 Meshy 用于跟踪任务的工作单元,用于根据源照片生成方块风格的概念图。此阶段的输出会通过 input_task_id 链接到构建阶段。
属性
- Name
- id
- Type
- string
- Description
任务的唯一标识符。虽然我们在实现细节中使用 k-可排序的 UUID 作为任务 id,但你不应对 id 的格式做任何假设。
- Name
- type
- Type
- string
- Description
任务的类型。该值为
creative-lab-brick-figure-prototype。
- Name
- name
- Type
- string
- Description
创建任务时提供的任务名称。如果未提供名称,则为空字符串。
- Name
- status
- Type
- string
- Description
任务的状态。可能的值为
PENDING、IN_PROGRESS、SUCCEEDED、FAILED、CANCELED之一。
- Name
- progress
- Type
- integer
- Description
任务的 progress。如果任务尚未开始,此属性将为
0。任务成功后,此值将变为100。
- Name
- created_at
- Type
- timestamp
- Description
任务创建时的 timestamp,以毫秒为单位。
timestamp 表示自 1970 年 1 月 1 日 UTC 起经过的毫秒数,遵循 RFC 3339
标准。 例如,格林尼治标准时间 2023 年 9 月 1 日星期五中午 12:00:00 表示为1693569600000。这适用于 Meshy API 中的所有 timestamp。
- Name
- started_at
- Type
- timestamp
- Description
任务开始时的 timestamp,以毫秒为单位。如果任务尚未开始,此属性将为
null。
- Name
- finished_at
- Type
- timestamp
- Description
任务完成时的 timestamp,以毫秒为单位。如果任务尚未完成,此属性将为
null。
- Name
- expires_at
- Type
- timestamp
- Description
任务结果过期时的 timestamp,以毫秒为单位。
- Name
- preceding_tasks
- Type
- integer
- Description
前置任务的数量。
此字段的值仅在任务状态为
PENDING时才有意义。
- Name
- task_error
- Type
- object
- Description
失败任务的错误详情。完整的
task_error对象参考请参阅 Errors。
- Name
- consumed_credits
- Type
- integer
- Description
此任务消耗的 credits 数量。当任务状态为
PENDING、IN_PROGRESS或SUCCEEDED时会显示该字段。对于FAILED任务,返回0(失败时 credits 会被退还)。
- Name
- image_urls
- Type
- array of strings
- Description
此原型任务生成的概念图候选项的可下载 URL。目前 API 始终只返回一个候选项;该字段设计为数组,以便未来版本可以在不产生破坏性变更的情况下呈现多个候选项。
Example Brick Figure Prototype Task Object
{
"id": "018a210d-8ba4-705c-b111-1f1776f7f578",
"type": "creative-lab-brick-figure-prototype",
"name": "",
"status": "SUCCEEDED",
"progress": 100,
"created_at": 1729123456000,
"started_at": 1729123460000,
"finished_at": 1729123486000,
"expires_at": 1729382686000,
"preceding_tasks": 0,
"task_error": null,
"consumed_credits": 6,
"image_urls": [
"https://assets.meshy.ai/***/concept.png?Expires=***"
]
}
方块小人构建任务对象
方块小人构建任务对象是 Meshy 用来跟踪从成功的原型任务生成带贴图的3D 方块小人的工作单元。它运行与 Image to 3D 相同的图像转 3D 流程,因此输出字段与该 endpoint 的任务对象保持一致。
属性
- Name
- id
- Type
- string
- Description
任务的唯一标识符。
- Name
- type
- Type
- string
- Description
任务的类型。取值为
creative-lab-brick-figure-build。
- Name
- name
- Type
- string
- Description
创建任务时提供的任务名称。如果未提供名称,则为空字符串。
- Name
- status
- Type
- string
- Description
任务的状态。可能的取值为
PENDING、IN_PROGRESS、SUCCEEDED、FAILED、CANCELED之一。
- Name
- progress
- Type
- integer
- Description
任务的进度。如果任务尚未开始,此属性为
0。任务成功后,该值将变为100。
- Name
- created_at
- Type
- timestamp
- Description
任务创建时间的 timestamp,单位为毫秒。
- Name
- started_at
- Type
- timestamp
- Description
任务开始时间的 timestamp,单位为毫秒。
- Name
- finished_at
- Type
- timestamp
- Description
任务完成时间的 timestamp,单位为毫秒。
- Name
- expires_at
- Type
- timestamp
- Description
任务结果过期时间的 timestamp,单位为毫秒。
- Name
- preceding_tasks
- Type
- integer
- Description
排在前面的任务数量。仅当状态为
PENDING时该字段才有意义。
- Name
- task_error
- Type
- object
- Description
失败任务的错误详情。完整的
task_error对象参考请参见错误。
- Name
- consumed_credits
- Type
- integer
- Description
此任务消耗的 credits 数量。对于
FAILED任务返回0(失败时会退还 credits)。
- Name
- prompt
- Type
- string
- Description
方块小人构建任务此字段始终为空。为与 Image to 3D 所使用的共享
V2ImageTo3DTaskResponse结构保持跨 endpoint 兼容而保留此字段。
- Name
- negative_prompt
- Type
- string
- Description
方块小人构建任务此字段始终为空。为保持跨 endpoint 兼容而保留此字段。
- Name
- texture_prompt
- Type
- string
- Description
方块小人构建任务此字段始终为空。为保持跨 endpoint 兼容而保留此字段。
- Name
- texture_image_url
- Type
- string
- Description
方块小人构建任务此字段始终为空。为保持跨 endpoint 兼容而保留此字段。
- Name
- model_urls
- Type
- object
- Description
生成的 3D 模型的可下载 URL。方块小人构建会输出一个带贴图的 GLB,以及适用于偏好 Wavefront OBJ 的流程的 OBJ + MTL 组合。该字段的结构与 Image to 3D 的 model_urls 对象一致,因此未来新增格式时不会产生破坏性变更。
- Name
glb- Type
- string
- Description
带贴图 GLB 文件的可下载 URL。
- Name
obj- Type
- string
- Description
Wavefront OBJ 文件(geometry + UV)的可下载 URL。
- Name
mtl- Type
- string
- Description
OBJ 配套 MTL material 文件的可下载 URL。请与
obj及texture_urls[0].base_color中的条目配合使用。
- Name
- thumbnail_url
- Type
- string
- Description
模型文件缩略图的可下载 URL。
- Name
- texture_urls
- Type
- array
- Description
此任务生成的贴图 URL 对象数组。目前仅包含一个带有基础颜色贴图的对象。
- Name
base_color- Type
- string
- Description
基础颜色贴图图像的可下载 URL。
Example Brick Figure Build Task Object
{
"id": "019c320e-9a8f-7a1c-9c11-2a1876f8a9bb",
"type": "creative-lab-brick-figure-build",
"name": "",
"status": "SUCCEEDED",
"progress": 100,
"created_at": 1729123500000,
"started_at": 1729123510000,
"finished_at": 1729123535000,
"expires_at": 1729382735000,
"preceding_tasks": 0,
"task_error": null,
"consumed_credits": 30,
"prompt": "",
"negative_prompt": "",
"texture_prompt": "",
"texture_image_url": "",
"model_urls": {
"glb": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.glb?Expires=***",
"obj": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.obj?Expires=***",
"mtl": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.mtl?Expires=***"
},
"thumbnail_url": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/preview.png?Expires=***",
"texture_urls": [
{
"base_color": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/texture_0.png?Expires=***"
}
]
}