lowpoly 将于 2026年10月30日 下线。 meshy-7 作为 3D 生成模型将于 2026年12月31日 下线;作为贴图模型仍可使用。 请在这些日期前切换模型,以免请求报错。 查看所有弃用信息

Image to 3D API

将一张图片转换为 3D 模型,可选择是否带 texture,并指定所需的输出格式。


POST/openapi/v2/image-to-3d

创建 Image to 3D 任务

创建一个 Image to 3D 任务,并返回任务对象。任务在后台运行。要读取其结果,请参见获取结果。关于任务通常需要多长时间,请参见处理时间。

预览修改“试用并预览”中的值即可更新
面数834,512
费用30 积分
请求
curl https://api.meshy.ai/openapi/v2/image-to-3d \
  -X POST \
  -H "Authorization: Bearer ${MESHY_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "image_url": "https://cdn.meshy.ai/webapp-assets/doc/try-it/v2/inputs/santa.3dbe655f9980.jpg",
    "ai_model": "meshy-7.1",
    "should_texture": true,
    "texture_model": "meshy-7"
  }'
响应
加载中…

参数

  • Name
    image_url
    Type
    string
    必选
    Description

    除非你发送 input_task_id,否则此项为必填。要转换为模型的图片,可以是公开 URL 或 data URI(data:image/png;base64,...)。

    该图片必须是 JPG、JPEG、PNG 或 WebP 文件,大小不超过 20 MB,每边至少 32 像素,且不超过 178,956,970 像素(宽 × 高)。

  • Name
    input_task_id
    Type
    string
    必选
    Description

    除非你发送 image_url,否则此项为必填。用作输入的 Text to Image 或 Image to Image 任务的 ID。该任务必须是你通过 API 创建的,状态为 SUCCEEDED,且只生成了一张图片。如果你同时发送 image_url 和 input_task_id,Meshy 会使用 input_task_id。

    对于多视图图片任务,请使用 Multi-Image to 3D。

  • Name
    ai_model
    Type
    string
    默认值 latest
    Description

    生成 3D 模型的模型。这是唯一的模型设置项。

    试用并预览

    标准模型:

    • latest:Meshy 7.1
    • meshy-7.1
    • meshy-6
    • meshy-6-lite
    • meshy-standard-latest:与 latest 相同

    Smart Topology 模型会按照你通过 target_polycount 设置的面数,构建干净的三角形 mesh:

    • meshy-t2.5:为游戏资产提供更锐利的细节
    • meshy-t2
    • meshy-smart-topology-latest:Meshy T2.5,最新的 Smart Topology 模型。新模型发布时,结果可能会改变。如果希望结果保持不变,请发送 meshy-t2.5。

    有关哪种模型适合你的项目(例如游戏角色或 3D 打印),请参见模型。

  • Name
    geometry_resolution
    Type
    string
    默认值 standard
    Description

    要生成多少 geometry 细节。

    试用并预览

    可用值:

    • standard
    • 2k:增加 Ultra 处理流程
    • 4k:增加 Ultra 处理流程,然后再进行超分辨率处理

    2k 和 4k 需要 meshy-7.1 或 latest。使用其他模型时会返回 400。

  • Name
    should_texture
    Type
    boolean
    默认值 true
    Description

    是否生成 texture。true 返回带贴图的模型,false 返回不带贴图的 mesh。设置为 false 时,Meshy 会忽略 texture_model 及其他 texture 参数。

    试用并预览
仅当 should_texture = true
  • Name
    texture_model
    Type
    string
    必选
    Description

    除非 should_texture 为 false,否则此项为必填。在同一任务中为 3D 模型生成 texture 的模型。每个 ai_model 都可以接受以下每个值。

    可用值:

    • meshy-7:Meshy 7,带 PBR 贴图、文本 prompt,支持高达 8K 的 texture
    • meshy-n1:Meshy N1,仅根据参考图像生成 2K 基础色 texture
    • meshy-6-lite:Meshy 6 Lite,2K texture

    未指定 texture_model 的带贴图请求会返回 400,texture 模型不支持的选项也会返回 400。texture 模型不会改变 积分 消耗。请参见Texture 模型。

  • Name
    enable_pbr
    Type
    boolean
    默认值 false
    Description

    是否同时生成金属度、粗糙度和法线贴图。使用 texture_model: "meshy-n1" 时,设置为 true 会返回 400。

    试用并预览
  • Name
    texture_resolution
    Type
    string
    默认值 2k
    Description

    基础色 texture 的尺寸。

    试用并预览

    可用值:

    • 2k
    • 4k
    • 8k

    4k 和 8k 需要 texture_model: "meshy-7"。使用 meshy-n1 或 meshy-6-lite 时会返回 400。

  • Name
    texture_prompt
    Type
    string
    Description

    用于指导 texture 的文本,最多 800 个字符。超出长度会返回 400。请发送 texture_prompt 或 texture_image_url,不要同时发送两者。同时发送会返回 400。使用 texture_model: "meshy-n1" 时,发送此参数会返回 400。

  • Name
    texture_image_url
    Type
    string
    Description

    用于指导 texture 的图片,可以是公开 URL 或 data URI。其格式和大小规则与 image_url 相同。使用 texture_model: "meshy-n1" 时,Meshy 会将该图片作为正面视图生成 texture;若未提供,则使用输入图像。

  • Name
    target_formats
    Type
    string[]
    默认值 ["glb"]
    Description

    要生成的文件格式。Meshy 只会生成你列出的格式。

    可用值:

    • glb
    • obj
    • fbx
    • stl
    • usdz
    • 3mf

    Meshy 会将 STL 和 3MF 文件缩放到最长边不超过 150 mm。

  • Name
    should_remesh
    Type
    boolean
    默认值 true (meshy-6-lite), false (other models)
    Description

    是否在生成后对模型进行 remesh。false 会保持生成时的 mesh 不变。Smart Topology 模型会忽略此设置。

    试用并预览
仅当 should_remesh = true
  • Name
    topology
    Type
    string
    默认值 triangle
    Description

    重新生成 mesh 后的模型面类型,triangle 或 quad。Smart Topology 模型只生成三角形,因此在 Smart Topology 模型上使用 quad 会返回 400。使用 texture_model: "meshy-n1" 时,如果模型被 remesh(meshy-6-lite 默认会执行),quad 会返回 400。

    试用并预览

    在 ai_model 为 meshy-7.1 且 should_remesh 为 true 时生效。选择一个值会同时设置它。

  • Name
    decimation_mode
    Type
    integer
    Description

    按级别设置的自适应面数。设置此项时,Meshy 会忽略 target_polycount。

    可用值:

    • 1:极致
    • 2:高
    • 3:中
    • 4:低
  • Name
    save_pre_remeshed_model
    Type
    boolean
    默认值 false
    Description

    是否同时在 output.model_urls.pre_remeshed_glb 中返回 remesh 之前的 GLB。

  • Name
    target_polycount
    Type
    integer
    Description

    目标面数。其取值范围和默认值取决于 mesh 的构建方式:

    Mesh范围默认值
    Remeshed100 至 30000030000
    meshy-t2.5 或 meshy-smart-topology-latest100 至 3000015000
    meshy-t2100 至 150004000

    超出范围的值会返回 400。

    对于 low-poly 的游戏资产,建议使用 Smart Topology 模型,而不是对标准模型进行 remesh。请参见模型。

  • Name
    auto_polycount
    Type
    boolean
    Description

    设为 true 时,Meshy 会在 meshy-t2.5 的取值范围内,根据输入图像自动选择面数。此选项仅适用于 meshy-t2.5(或解析为该模型的 meshy-smart-topology-latest)。使用其他 ai_model,或与 target_polycount 同时使用时,请求会返回 400(parameters_conflict)。

    如果 Meshy 无法为该图像推荐面数,任务会使用 meshy-t2.5 的默认值;请求仍会成功。任务的 output.target_polycount 会显示任务实际使用的面数。默认为 false。

  • Name
    pose_mode
    Type
    string
    Description

    角色模型的姿势,a-pose 或 t-pose。留空表示不设置姿势。

    试用并预览
  • Name
    image_enhancement
    Type
    boolean
    默认值 true
    Description

    是否在生成前对输入图像进行清理。false 会完全按原样使用图像。meshy-6-lite 和 Smart Topology 模型会忽略此设置。

  • Name
    remove_lighting
    Type
    boolean
    默认值 true
    Description

    是否从基础色 texture 中移除高光和阴影。texture_model 所支持的 texture 模型不使用此设置,因此 Meshy 会忽略它。

  • Name
    moderation
    Type
    boolean
    默认值 false
    Description

    是否在生成前对以下输入进行有害内容审查:

    • 输入图像
    • texture_image_url
    • texture_prompt
  • Name
    auto_size
    Type
    boolean
    默认值 false
    Description

    是否估算物体的真实世界高度,并据此缩放模型。

仅当 auto_size = true
  • Name
    origin_at
    Type
    string
    默认值 bottom
    Description

    模型 origin 的放置位置,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 上的 URL
  • Retry-After:首次读取前需要等待的秒数

失败情形

  • Name
    400 - Bad Request
    Description

    请求无法运行。例如:

    • 既没有发送 image_url 也没有发送 input_task_id
    • 带贴图的请求未发送 texture_model
    • 同时发送了 texture_prompt 和 texture_image_url
    • 图像无法下载、超过 20 MB,或超出像素限制
    • 该模型不支持所选 geometry_resolution
    • texture 模型不支持请求中的某个选项,例如 enable_pbr: true,或在 meshy-n1 上使用 4k texture

    错误信息会说明具体发现的问题。请参见 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 中指定的秒数,然后重试。
    • 你排队或正在运行的任务过多。请等待部分任务完成后再重试。
    • 在积分用尽的无限额套餐上,你已达到可在无 积分 情况下运行的任务数量上限。请等待某个任务完成,或增加 积分。

Texture models

ai_model 用于选择构建 mesh 的模型,texture_model 用于选择为其绘制贴图的模型。texture_model 没有默认值,因此每个需要 texture 的请求都必须传入它。要为你的项目选择合适的组合,请参阅 Models。

下表展示了每个 ai_model 在每个 endpoint 上可配合使用的 texture 模型。任何其他组合都会返回 400。

ai_modelImage to 3DMulti-Image to 3DText to 3D
meshy-7.1、latest 或 meshy-standard-latestmeshy-7、meshy-n1 或 meshy-6-litemeshy-7 或 meshy-n1meshy-7、meshy-n1 或 meshy-6-lite
meshy-6meshy-7、meshy-n1 或 meshy-6-litemeshy-7 或 meshy-n1meshy-7、带 texture_image_url 的 meshy-n1,或 meshy-6-lite
meshy-6-litemeshy-7、meshy-n1 或 meshy-6-litemeshy-7 或 meshy-n1meshy-7、带 texture_image_url 的 meshy-n1,或 meshy-6-lite
meshy-t2.5、meshy-t2 或 meshy-smart-topology-latestmeshy-7、meshy-n1 或 meshy-6-lite无。Multi-Image to 3D 没有 Smart Topology 模型。meshy-7、meshy-n1 或 meshy-6-lite

Retexture 对任何模型都接受 meshy-7、meshy-n1 或 meshy-6-lite。

每个 texture 模型支持一组不同的选项,下表列出了这些选项。如果请求向某个 texture 模型提出了它不支持的选项,将返回 400。

选项meshy-7meshy-n1meshy-6-lite
texture_resolution2k、4k 或 8k2k2k
enable_pbr: true支持不支持支持
texture_prompt支持不支持支持
texture_image_url支持支持,作为正视图支持
多张参考图:texture_image_urls 或 multiview_image_urls支持支持不支持
对已 remesh 的模型使用 topology: "quad"支持不支持支持

Meshy N1 可为最多 7,999,999 个三角面的模型生成 texture。如果生成的模型超过该大小,任务会失败,Meshy 会退还其 积分。

texture 模型不会改变价格。一个带 texture 的任务的费用为 mesh 费用加上对应分辨率的 texture 费用。请参阅 Pricing。


获取结果

读取 Image to 3D 任务的方式与其他所有 v2 任务相同,均通过 Tasks 路由完成。若只想列出 Image to 3D 任务,可使用 type=image-to-3d 进行筛选。


Image to 3D 输出

当任务成功后,output 中包含以下字段。task object 的其余部分对每种任务类型都是一样的。output 中的 URL 会在 expires_at 之后失效。

请求
curl https://api.meshy.ai/openapi/v2/tasks/01a1aeac-afb0-77bf-a47b-47a43ee563bc \
  -H "Authorization: Bearer ${MESHY_API_KEY}"
响应
加载中…
  • Name
    model_urls
    Type
    object
    Description

    生成文件的签名 URL,target_formats 中每种格式对应一个,以格式作为键。还可能出现两个额外的键:

    • mtl:带贴图的 obj 的 material 文件
    • 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,以视角作为键:

    • front
    • right
    • back
    • left

    除非你发送了 multi_view_thumbnails: true,否则为 null。渲染失败的视角会被省略。

  • Name
    texture_urls
    Type
    array
    Description

    每个 texture 集一项,其中包含以下每张贴图的签名 URL:

    • base_color
    • metallic
    • roughness
    • normal
    • metallic_roughness
    • emission

    未生成的贴图为 null。对于没有 texture 的模型,该数组为空。

  • Name
    target_polycount
    Type
    integer
    Description

    Smart Topology 任务(meshy-t2 或 meshy-t2.5)生成时使用的面数:可能是你发送的 target_polycount、auto_polycount 选定的值,或模型的默认值。其他任务类型不包含此字段。