多图像转3D API

多图像转3D API 是一项功能,允许您将 Meshy 的多图像转3D能力集成到您自己的应用程序中。在本节中,您将找到开始使用此API所需的所有信息。


POST/openapi/v1/multi-image-to-3d

创建多图像转3D任务

此端点允许您创建一个新的多图像转3D任务。请参阅多图像转3D任务对象以查看多图像转3D任务对象包含哪些属性。

参数

  • Name
    image_urls
    Type
    array
    必选
    Description

    提供1到4张图片用于模型生成。当前支持.jpg.jpeg.png格式。所有图片应为同一物体的不同角度以获得最佳效果。

    每张图片有两种提供方式:

    • 公网可访问的URL:一个可以从公网访问的图片链接。
    • Data URI:图片的base64编码数据URI。例如:data:image/jpeg;base64,<your base64-encoded image data>
  • Name
    ai_model
    Type
    string
    默认值 latest
    Description

    要使用的模型ID。可选值:meshy-5meshy-6latest(Meshy 6)。

  • Name
    should_texture
    Type
    boolean
    默认值 true
    Description

    决定是否生成贴图。设置为 false 时跳过贴图阶段,仅生成网格。

仅当 should_texture = true
  • Name
    enable_pbr
    Type
    boolean
    默认值 false
    Description

    生成PBR贴图(金属度、粗糙度、法线)以及基础色。

  • Name
    texture_prompt
    Type
    string
    Description

    提供文本提示以引导贴图生成。最多600字符。

  • Name
    texture_image_url
    Type
    string
    Description

    提供一张 2D 图像以引导贴图生成。当前支持 .jpg.jpeg.png 格式。

    提供图像有两种方式:

    • 公网可访问的 URL:一个可以从公网访问的图片链接
    • Data URI:图片的 base64 编码数据 URI。例如:data:image/jpeg;base64,<your base64-encoded image data>
  • Name
    should_remesh
    Type
    boolean
    默认值 false (meshy-6), true (others)
    Description

    控制是否启用重建网格阶段。设置为 false 时,API 返回最高精度的三角网格。

仅当 should_remesh = true
  • Name
    topology
    Type
    string
    默认值 triangle
    Description

    指定生成模型的拓扑结构。

    可选值:

    • quad:生成以四边形为主的网格。
    • triangle:生成简化的三角网格。
  • Name
    target_polycount
    Type
    integer
    默认值 30,000
    Description

    指定生成模型的目标面数。实际面数可能会根据几何复杂度有所偏差。

    有效取值范围:100 到 300,000(含)。

  • Name
    decimation_mode
    Type
    integer
    Description

    通过设置面数级别启用自适应减面。设置后,target_polycount 将被忽略。

    可选值:

    • 1:自适应——超高面数。
    • 2:自适应——高面数。
    • 3:自适应——中等面数。
    • 4:自适应——低面数。
  • Name
    save_pre_remeshed_model
    Type
    boolean
    默认值 false
    Description

    设置为 true 时,会在重建网格阶段之前额外保存一份原始 GLB 结果。

  • Name
    symmetry_mode
    Type
    string
    默认值 auto
    Description

    控制生成过程中对称性的行为。

    有效值:

    • off:关闭对称。
    • auto:根据输入几何自动判断并应用对称。
    • on:强制应用对称。
  • Name
    pose_mode
    Type
    string
    默认值 ""
    Description

    指定生成模型的姿态模式。

    可选值:

    • a-pose:生成 A Pose 的模型。
    • t-pose:生成 T Pose 的模型。
    • ""(空字符串):不应用特定姿态。
  • Name
    is_a_t_pose
    Type
    boolean
    已弃用
    默认值 false
    Description

    请使用 pose_mode 代替。是否生成 A/T Pose 的模型。

  • Name
    image_enhancement
    Type
    boolean
    默认值 true
    Description

    对输入图像进行优化以获得更好的生成效果。设置为 false 时,忠实还原输入图像的原始外观。

  • Name
    remove_lighting
    Type
    boolean
    默认值 true
    Description

    移除基础色贴图中的高光和阴影,在自定义光照设置下表现更佳。

  • Name
    moderation
    Type
    boolean
    默认值 false
    Description

    当设置为 true 时,输入内容将自动进行有害内容筛查。image_urlstexture_prompt 的内容都将被筛查。

  • Name
    target_formats
    Type
    string[]
    Description

    指定输出中包含的 3D 文件格式。仅会生成并返回所请求的格式,可减少任务完成时间。

    可选值:glbobjfbxstlusdz3mf

  • Name
    auto_size
    Type
    boolean
    默认值 false
    Description

    当设置为 true 时,服务使用 AI 视觉自动估算物体的真实高度并调整模型大小。原点默认为 bottom,除非显式设置 origin_at

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

    auto_size 启用时的原点位置。可选值:bottomcenter

返回值

响应的result字段包含新建多图像转3D任务的任务id

失败模式

  • Name
    400 - Bad Request
    Description

    请求不合法。常见原因:

    • 图片数量无效image_urls 必须包含 1 到 4 张图片。
    • 图片格式无效image_urls 中的一张或多张图片不是支持的格式。
    • URL 不可访问image_urls 中的一个或多个 URL 无法下载。
  • Name
    401 - Unauthorized
    Description

    认证失败。请检查您的 API 密钥。

  • Name
    402 - Payment Required
    Description

    积分不足,无法执行此任务。

  • Name
    429 - Too Many Requests
    Description

    您已超出请求频率限制。

请求

POST
/openapi/v1/multi-image-to-3d
# 简单请求
curl https://api.meshy.ai/openapi/v1/multi-image-to-3d \
  -X POST \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "image_urls": [
      "<your publicly accessible image url or base64-encoded data URI>",
      "<your second publicly accessible image url or base64-encoded data URI>"
    ]
  }'

# 启用 PBR 贴图和 GLB 格式
curl https://api.meshy.ai/openapi/v1/multi-image-to-3d \
  -X POST \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "image_urls": [
      "<your publicly accessible image url or base64-encoded data URI>",
      "<your second publicly accessible image url or base64-encoded data URI>"
    ],
    "should_texture": true,
    "enable_pbr": true,
    "target_formats": ["glb"]
  }'

响应

{
  "result": "018a210d-8ba4-705c-b111-1f1776f7f578"
}

GET/openapi/v1/multi-image-to-3d/:id

获取多图像转3D任务

此端点允许您通过有效的任务id获取多图像转3D任务。 请参考多图像转3D任务对象查看多图像转3D任务对象包含的属性。

参数

  • Name
    id
    Type
    path
    Description

    要获取的多图像转3D任务的唯一标识符。

返回

响应包含多图像转3D任务对象。查看多图像转3D任务对象部分了解详情。

请求

GET
/openapi/v1/multi-image-to-3d/018a210d-8ba4-705c-b111-1f1776f7f578
curl https://api.meshy.ai/openapi/v1/multi-image-to-3d/018a210d-8ba4-705c-b111-1f1776f7f578 \
  -H "Authorization: Bearer ${YOUR_API_KEY}"

响应

{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "multi-image-to-3d",
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.glb?Expires=***",
    "fbx": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.fbx?Expires=***",
    "obj": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.obj?Expires=***",
    "usdz": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.usdz?Expires=***",
    "stl": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.stl?Expires=***",
    "pre_remeshed_glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/pre_remeshed_model.glb?Expires=***"
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/preview.png?Expires=***",
  "texture_prompt": "",
  "progress": 100,
  "started_at": 1692771667037,
  "created_at": 1692771650657,
  "expires_at": 1692771679037,
  "finished_at": 1692771669037,
  "status": "SUCCEEDED",
  "texture_urls": [
    {
      "base_color": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0.png?Expires=***",
      "metallic": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_metallic.png?Expires=XXX",
      "normal": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_normal.png?Expires=XXX",
      "roughness": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_roughness.png?Expires=XXX"
    }
  ],
  "preceding_tasks": 0,
  "task_error": {
    "message": ""
  }
}

DELETE/openapi/v1/multi-image-to-3d/:id

删除多图像转3D任务

此端点将永久删除一个多图像转3D任务,包括所有相关的模型和数据。此操作不可逆。

路径参数

  • Name
    id
    Type
    path
    Description

    要删除的多图像转3D任务的ID。

返回值

成功则返回 200 OK

请求

DELETE
/openapi/v1/multi-image-to-3d/018a210d-8ba4-705c-b111-1f1776f7f578
curl --request DELETE \
  --url https://api.meshy.ai/openapi/v1/multi-image-to-3d/018a210d-8ba4-705c-b111-1f1776f7f578 \
  -H "Authorization: Bearer ${YOUR_API_KEY}"

响应

// 成功则返回 200 Ok。

GET/openapi/v1/multi-image-to-3d

列出多图像转3D任务

此端点允许您获取多图像转3D任务列表。

参数

可选属性

  • Name
    page_num
    Type
    integer
    Description

    分页页码。从1开始,默认为1

  • Name
    page_size
    Type
    integer
    Description

    每页大小限制。默认为10项。最大允许50项。

  • Name
    sort_by
    Type
    string
    Description

    排序字段。可用值:

    • +created_at: 按创建时间升序排序。
    • -created_at: 按创建时间降序排序。

返回

返回多图像转3D任务对象的分页列表。

请求

GET
/openapi/v1/multi-image-to-3d
curl https://api.meshy.ai/openapi/v1/multi-image-to-3d?page_size=10 \
-H "Authorization: Bearer ${YOUR_API_KEY}"

响应

[
  {
    "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "type": "multi-image-to-3d",
    "model_urls": {
      "glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.glb?Expires=***",
      "fbx": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.fbx?Expires=***",
      "obj": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.obj?Expires=***",
      "usdz": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.usdz?Expires=***",
      "pre_remeshed_glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/pre_remeshed_model.glb?Expires=***"
    },
    "thumbnail_url": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/preview.png?Expires=***",
    "texture_prompt": "",
    "progress": 100,
    "started_at": 1692771667037,
    "created_at": 1692771650657,
    "expires_at": 1692771679037,
    "finished_at": 1692771669037,
    "status": "SUCCEEDED",
    "texture_urls": [
      {
        "base_color": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0.png?Expires=***",
        "metallic": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_metallic.png?Expires=XXX",
        "normal": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_normal.png?Expires=XXX",
        "roughness": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_roughness.png?Expires=XXX"
      }
    ],
    "preceding_tasks": 0,
    "task_error": {
      "message": ""
    }
  }
]

GET/openapi/v1/multi-image-to-3d/:id/stream

流式多图像转3D任务

此端点使用服务器发送事件(SSE)流式传输多图像转3D任务的实时更新。

参数

  • Name
    id
    Type
    path
    Description

    要流式传输的多图像转3D任务的唯一标识符。

返回

以服务器发送事件的形式返回多图像转3D任务对象的流。

对于PENDINGIN_PROGRESS状态的任务,响应流将只包含必要的progressstatus字段。

请求

GET
/openapi/v1/multi-image-to-3d/018a210d-8ba4-705c-b111-1f1776f7f578/stream
curl -N https://api.meshy.ai/openapi/v1/multi-image-to-3d/018a210d-8ba4-705c-b111-1f1776f7f578/stream \
-H "Authorization: Bearer ${YOUR_API_KEY}"

响应流

// 错误事件示例
event: error
data: {
  "status_code": 404,
  "message": "任务未找到"
}

// 消息事件示例说明任务进度
// 对于PENDING或IN_PROGRESS状态的任务,响应流不会包含所有字段
event: message
data: {
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "progress": 0,
  "status": "PENDING"
}

event: message
data: {
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "multi-image-to-3d",
  "model_urls": {
  "glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.glb?Expires=***",
  "fbx": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.fbx?Expires=***",
  "obj": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.obj?Expires=***",
  "usdz": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.usdz?Expires=***",
  "stl": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.stl?Expires=***",
  "pre_remeshed_glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/pre_remeshed_model.glb?Expires=***"
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/preview.png?Expires=***",
  "texture_prompt": "",
  "progress": 100,
  "started_at": 1692771667037,
  "created_at": 1692771650657,
  "expires_at": 1692771679037,
  "finished_at": 1692771669037,
  "status": "SUCCEEDED",
  "texture_urls": [
    {
      "base_color": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0.png?Expires=***",
      "metallic": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_metallic.png?Expires=XXX",
      "normal": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_normal.png?Expires=XXX",
      "roughness": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_roughness.png?Expires=XXX"
    }
  ],
  "preceding_tasks": 0,
  "task_error": {
    "message": ""
  }
}

多图像转3D任务对象

多图像转3D任务对象是Meshy用于追踪从多张图片(1到4张)生成3D模型的工作单元。图片应为同一物体,最好是不同视角或角度。 该对象包含以下属性:

属性

  • Name
    id
    Type
    string
    Description

    任务的唯一标识符。虽然我们使用k-sortable UUID作为任务ID的实现细节,但您不应该对ID的格式做任何假设。

  • Name
    type
    Type
    string
    Description

    多图像转3D任务的类型。值为 multi-image-to-3d

  • 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
      mtl
      Type
      string
      Description

      当生成OBJ且包含贴图时返回的MTL文件下载链接。

    • Name
      stl
      Type
      string
      Description

      STL 文件的可下载链接。

    • Name
      3mf
      Type
      string
      Description

      3MF 文件的可下载链接。仅在通过 target_formats 请求 3mf 时返回。

    • Name
      pre_remeshed_glb
      Type
      string
      Description

      重建网格前的原始GLB下载链接。

  • Name
    thumbnail_url
    Type
    string
    Description

    模型文件缩略图的可下载URL。

  • Name
    texture_prompt
    Type
    string
    Description

    用于指导纹理生成过程的文本提示。

  • Name
    progress
    Type
    integer
    Description

    任务的进度。如果任务尚未开始,此属性将为0。一旦任务成功,这将变为100

  • Name
    started_at
    Type
    timestamp
    Description

    任务开始的时间戳,以毫秒为单位。如果任务尚未开始,此属性将为0

  • Name
    created_at
    Type
    timestamp
    Description

    任务创建的时间戳,以毫秒为单位。

  • Name
    expires_at
    Type
    timestamp
    Description

    任务结果过期的时间戳,以毫秒为单位。

  • Name
    finished_at
    Type
    timestamp
    Description

    任务完成的时间戳,以毫秒为单位。如果任务尚未完成,此属性将为0

  • Name
    status
    Type
    string
    Description

    任务的状态。可能的值包括:PENDING(等待中)、IN_PROGRESS(进行中)、SUCCEEDED(成功)、FAILED(失败)、CANCELED(已取消)。

  • Name
    texture_urls
    Type
    array
    Description

    由任务生成的纹理URL对象数组。通常只包含一个纹理URL对象。每个纹理URL具有以下属性:

    • Name
      base_color
      Type
      string
      Description

      基础颜色贴图的可下载URL。

    • Name
      metallic
      Type
      string
      Description

      金属度贴图的可下载URL。

    • Name
      normal
      Type
      string
      Description

      法线贴图的可下载URL。

    • Name
      roughness
      Type
      string
      Description

      粗糙度贴图的可下载URL。

  • Name
    preceding_tasks
    Type
    integer
    Description

    前置任务的数量。

  • Name
    task_error
    Type
    object
    Description

    如果任务失败,包含错误信息的错误对象。如果任务成功,message属性应为空。详情请参阅 Errors

    • Name
      message
      Type
      string
      Description

      详细的错误信息。

多图像生成3D任务对象示例

{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "multi-image-to-3d",
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.glb?Expires=***",
    "fbx": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.fbx?Expires=***",
    "obj": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.obj?Expires=***",
    "usdz": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.usdz?Expires=***",
    "stl": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.stl?Expires=***",
    "pre_remeshed_glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/pre_remeshed_model.glb?Expires=***"
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/preview.png?Expires=***",
  "texture_prompt": "",
  "progress": 100,
  "started_at": 1692771667037,
  "created_at": 1692771650657,
  "expires_at": 1692771679037,
  "finished_at": 1692771669037,
  "status": "SUCCEEDED",
  "texture_urls": [
    {
      "base_color": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0.png?Expires=***",
      "metallic": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_metallic.png?Expires=XXX",
      "normal": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_normal.png?Expires=XXX",
      "roughness": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0_roughness.png?Expires=XXX"
    }
  ],
  "preceding_tasks": 0,
  "task_error": {
    "message": ""
  },
}