Multi-Image to 3D API
将同一物体在不同角度拍摄的一到四张图片,转换为一个 3D 模型。
从 v1 迁移?Multi-Image to 3D 的主要变化如下:
target_formats默认值为 GLB。- 要生成带贴图的模型,需要将
texture_model设置为meshy-7或meshy-n1。 - 同时发送
texture_prompt和texture_image_url会返回400。 - 结果位于
output中。
创建 Multi-Image to 3D 任务
curl https://api.meshy.ai/openapi/v2/multi-image-to-3d \
-X POST \
-H "Authorization: Bearer ${MESHY_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"image_urls": [
"https://cdn.meshy.ai/webapp-assets/doc/try-it/v2/inputs/santa-views-0.f420446ba36c.webp",
"https://cdn.meshy.ai/webapp-assets/doc/try-it/v2/inputs/santa-views-1.c0886f07c59b.webp",
"https://cdn.meshy.ai/webapp-assets/doc/try-it/v2/inputs/santa-views-2.f0993cae9467.webp"
],
"should_texture": true,
"ai_model": "meshy-7.1",
"texture_model": "meshy-7"
}'参数
- Name
- image_urls
- Type
- string[]
- 必选
- Description
除非你发送
input_task_id,否则此参数为必填项。同一物体的一到四张图片,每张以公开 URL 或 data URI(data:image/png;base64,...)的形式提供。请将正视图放在第一位。Meshy 会将第一张图片作为正视图。使用meshy-7.1或latest时,其余图片的顺序无关紧要。超过四张图片会返回400。每张图片必须是 JPG、JPEG、PNG 或 WebP 文件,大小最多 20 MB,每边至少 32 像素,像素总数(宽 × 高)最多为 178,956,970。
- Name
- input_task_id
- Type
- string
- 必选
- Description
除非你发送
image_urls,否则此参数为必填项。用作输入的 Text to Image 或 Image to Image 任务的 ID,包括多视图任务。该任务必须是你通过 API 创建的,且状态为SUCCEEDED。Meshy 会使用其图片(一到四张)作为输入。如果你同时发送image_urls和input_task_id,Meshy 会使用input_task_id。
- Name
- ai_model
- Type
- string
- 默认值 latest
- Description
生成 3D 模型所使用的模型。
可用值:
latest:Meshy 7.1meshy-7.1meshy-6meshy-6-litemeshy-standard-latest:与latest相同
Smart Topology 模型不适用于 Multi-Image to 3D,使用会返回
400。有关哪种模型适合你的项目(例如真实物体或 3D 打印件),请参阅模型。
- Name
- geometry_resolution
- Type
- string
- 默认值 standard
- Description
生成多少几何细节。
试用并预览可用值:
standard2k:添加 Ultra 处理步骤
2k需要meshy-7.1或latest。使用其他模型时会返回400。Multi-Image to 3D 没有4k,因此4k会返回400。
- Name
- should_texture
- Type
- boolean
- 默认值 true
- Description
是否生成贴图。
true会返回带贴图的模型,false会返回不带贴图的 mesh。设为false时,Meshy 会忽略texture_model及其他贴图相关参数。试用并预览
should_texture = true- Name
- texture_model
- Type
- string
- 必选
- Description
除非
should_texture为false,否则此参数为必填项。用于在同一任务中为 3D 模型生成贴图的模型。每个ai_model都接受以下每个值。可用值:
meshy-7:Meshy 7,带 PBR 贴图、文本 prompt,贴图最高可达 8Kmeshy-n1:Meshy N1,仅根据参考图像生成 2K 基础色贴图
Multi-Image to 3D 仅支持从多个视角绘制贴图的贴图模型,因此任何其他值都会返回
400。带贴图的请求若未提供texture_model,会返回400;贴图模型不支持的选项同样会返回400。贴图模型不会改变积分消耗。请参阅贴图模型。
- Name
- enable_pbr
- Type
- boolean
- 默认值 false
- Description
是否同时生成金属度、粗糙度和法线贴图。使用
texture_model: "meshy-n1"时,设为true会返回400。试用并预览
- Name
- texture_resolution
- Type
- string
- 默认值 2k
- Description
基础色贴图的尺寸。
试用并预览可用值:
2k4k8k
4k和8k需要texture_model: "meshy-7"。使用meshy-n1时会返回400。
- Name
- texture_prompt
- Type
- string
- Description
用于指导贴图生成的文本,最多 800 个字符。超出长度会返回
400。使用texture_model: "meshy-n1"时,发送此参数会返回400。
- Name
- texture_image_url
- Type
- string
- Description
一张用于指导贴图的图片,以公开 URL 或 data URI 形式提供。其格式和尺寸规则与
image_urls中的图片相同。使用texture_model: "meshy-n1"时,Meshy 会将此图片作为正视图进行贴图处理。
- Name
- texture_image_urls
- Type
- string[]
- Description
用于指导贴图的一到四张物体图片。其格式和尺寸规则与
image_urls中的图片相同,且可以与image_urls不同。Meshy 会将第一张图片作为正视图。其余视图(左视图、背视图、右视图)的顺序无关紧要。空列表或超过四张图片会返回
400。
texture_prompt、texture_image_url 和 texture_image_urls 中最多只能发送一个。发送两个或以上会返回 400。
- Name
- target_formats
- Type
- string[]
- 默认值 ["glb"]
- Description
要生成的文件格式。Meshy 只会生成你列出的格式。
可用值:
glbobjfbxstlusdz3mf
Meshy 会将 STL 和 3MF 文件缩放至最长边最多 150 毫米。
- Name
- should_remesh
- Type
- boolean
- 默认值 true (meshy-6-lite), false (other models)
- Description
生成后是否对模型进行 remesh。
false会保留生成时的 mesh。试用并预览
should_remesh = true- Name
- topology
- Type
- string
- 默认值 triangle
- Description
remesh 后模型的面类型,
triangle或quad。使用texture_model: "meshy-n1"时,quad会返回400。试用并预览在
should_remesh为true时生效。选择一个值会同时设置它。
- Name
- target_polycount
- Type
- integer
- 默认值 30000
- Description
目标面数,范围从
100到300000。超出范围的值会返回400。
- Name
- decimation_mode
- Type
- integer
- Description
按级别划分的自适应面数。设置此参数时,Meshy 会忽略
target_polycount。可用值:
1:ultra2:high3:medium4:low
- Name
- save_pre_remeshed_model
- Type
- boolean
- 默认值 false
- Description
是否同时在
output.model_urls.pre_remeshed_glb中返回 remesh 之前的 GLB。
- Name
- pose_mode
- Type
- string
- Description
角色模型的姿势,
a-pose或t-pose。不填则不应用姿势。试用并预览
- Name
- image_enhancement
- Type
- boolean
- 默认值 true
- Description
是否在生成前清理输入图片。
false会原样使用图片。meshy-6-lite会忽略此设置。
- Name
- remove_lighting
- Type
- boolean
- 默认值 true
- Description
是否从基础色贴图中去除高光和阴影。
texture_model所接受的贴图模型不使用此设置,因此 Meshy 会忽略它。
- Name
- moderation
- Type
- boolean
- 默认值 false
- Description
是否在生成前对以下输入内容进行有害内容筛查:
- 输入图片
texture_image_url或texture_image_urlstexture_prompt
- Name
- auto_size
- Type
- boolean
- 默认值 false
- Description
是否估算物体的真实世界高度,并据此缩放模型。
auto_size = true- Name
- origin_at
- Type
- string
- 默认值 bottom
- Description
将模型原点放置在何处,
bottom或center。
- Name
- multi_view_thumbnails
- Type
- boolean
- 默认值 false
- Description
是否同时渲染正面、右侧、背面和左侧预览图,结果返回在
output.thumbnail_urls中。这会使任务多耗时约 5 秒。
- Name
- thumbnail_resolution
- Type
- integer
- 默认值 512
- Description
任务预览图的宽度和高度(以像素为单位):
512或1024。它适用于output.thumbnail_url以及你所请求的任何可选预览图。其他任何值都会返回400。
返回值
202 Accepted,包含任务对象。任务初始状态为 PENDING,input 中为你的请求内容,output 设为 null。
两个响应头有助于你读取任务:
Location:该任务在 Tasks 上的 URLRetry-After:首次读取前应等待的秒数
失败模式
- Name
400 - Bad Request- Description
请求无法运行。例如:
- 既未发送
image_urls也未发送input_task_id - 图片数量超过四张
- 带贴图的请求未发送
texture_model,或发送了meshy-6-lite - 发送了两种贴图输入
- 某张图片无法下载、超过 20 MB,或超出像素限制
geometry_resolution对该模型不可用- 贴图模型不支持请求中的某个选项,例如对
meshy-n1设置enable_pbr: true或请求4k贴图 ai_model是 Smart Topology 模型
错误消息会说明发现的具体问题。请参阅 Errors。
- 既未发送
- Name
401 - Unauthorized- Description
API key 缺失或无效。请检查
Authorization请求头。
- Name
402 - Payment Required- Description
以下情况之一适用:
- 账户积分不足。
- 账户达到了积分限额。
- 账户处于免费计划。
请检查你的积分和计划,然后重试。
- Name
403 - Forbidden- Description
内容审核拦截了 prompt 或某张输入图片。请修改输入内容,然后重试。
- Name
404 - Not Found- Description
input_task_id与你的任何任务都不匹配。
- Name
429 - Too Many Requests- Description
达到了以下限制之一:
- 你发送的请求过多。请等待
Retry-After中给出的秒数,然后重试。 - 你排队中或正在运行的任务过多。请等待部分任务完成后重试。
- 在没有积分的无限制计划下,你已达到无需积分可运行的任务数上限。请等待某个任务完成,或增加积分。
- 你发送的请求过多。请等待
获取结果
读取 Multi-Image to 3D 任务的方式与其他 v2 任务相同,均通过 Tasks 路由进行。若只想列出 Multi-Image to 3D 任务,可按 type=multi-image-to-3d 进行筛选。
| 操作 | 调用 |
|---|---|
| 获取单个任务 | GET /openapi/v2/tasks/{id} |
| 等待更新 | GET /openapi/v2/tasks/{id}/stream 或使用 webhook |
| 列出你的任务 | GET /openapi/v2/tasks?type=multi-image-to-3d |
| 删除任务 | DELETE /openapi/v2/tasks/{id} |
Multi-Image to 3D output
任务成功后,output 中会包含以下字段。任务对象的其余部分对每种任务类型都是相同的。output 中的 URL 会在 expires_at 后失效。
curl https://api.meshy.ai/openapi/v2/tasks/01a1af0f-8a85-7643-bcbe-d825acfe77d2 \
-H "Authorization: Bearer ${MESHY_API_KEY}"加载中…- Name
- model_urls
- Type
- object
- Description
指向生成文件的签名 URL,
target_formats中的每种格式对应一个,以格式作为键。还可能出现另外两个键:mtl:带贴图的obj的材质文件pre_remeshed_glb:当你发送了save_pre_remeshed_model: true且模型经过了 remesh 时,remesh 之前的 GLB 文件
- Name
- thumbnail_url
- Type
- string
- Description
指向模型 PNG 预览图的签名 URL,背景透明。
- Name
- thumbnail_urls
- Type
- object | null
- Description
指向预览图的签名 URL,以视角为键:
frontrightbackleft
除非你发送了
multi_view_thumbnails: true,否则该字段为null。渲染失败的视角会被省略。
- Name
- texture_urls
- Type
- array
- Description
每个贴图集对应一项,其中包含以下各个贴图的签名 URL:
base_colormetallicroughnessnormalmetallic_roughnessemission
未生成的贴图为
null。对于未贴图的模型,该数组为空。