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

Text to 3D API

通过一次调用,将文本 prompt 转换为 3D 模型。


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

创建 Text to 3D 任务

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

预览修改“试用并预览”中的值即可更新
面数1,147,770
费用30 积分
请求
curl https://api.meshy.ai/openapi/v2/text-to-3d \
  -X POST \
  -H "Authorization: Bearer ${MESHY_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "prompt": "a stylized adult male explorer with short brown hair and a stubble beard, wearing an orange jacket, beige cargo pants and brown boots, full body, standing",
    "ai_model": "meshy-7.1",
    "should_texture": true,
    "texture_model": "meshy-7"
  }'
响应
加载中…

参数

  • Name
    should_texture
    Type
    boolean
    默认值 true
    Description

    是否为模型生成 texture。true 返回带 texture 的模型,false 则只返回 mesh。设为 false 时,Meshy 会忽略 texture_model 以及其他 texture 相关参数。如果想在生成 texture 之前先检查 mesh,可以发送 false,然后用 Retexture 对已完成的任务进行贴图,将其 id 用作 input_task_id。如果同时发送了 mode,Meshy 会忽略此设置。

    试用并预览
  • Name
    mode
    Type
    string
    ⚠ 已弃用
    Description

    两步式任务中的步骤,供已经使用 preview 和 refine 的集成方使用。请改为发送 should_texture。

    可选值:

    • preview:生成未带 texture 的 mesh
    • refine:为 preview 任务的 mesh 添加 texture
  • Name
    prompt
    Type
    string
    必选
    Description

    一次性(one-call)任务和 preview 任务为必填项。描述要生成的模型的文本,最多 800 个字符。超出长度将返回 400。refine 会改用其对应 preview 的 prompt。

  • Name
    preview_task_id
    Type
    string
    必选
    ⚠ 已弃用
    Description

    请改为发送 should_texture: true,或使用 Retexture 为现有任务添加 texture。refine 任务为必填项。待贴图的 preview 任务的 ID。该任务必须是你自己的 preview 任务,且状态为 SUCCEEDED。

  • 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 打印件),请参阅模型。

    在 refine 中,ai_model 选择的是 texture 模型,因为 mesh 来自 preview。留空则使用与 preview 相匹配的模型进行贴图。关于 refine 可接受的取值,请参阅 Legacy preview 和 refine。

  • Name
    model_type
    Type
    string
    ⚠ 已弃用
    Description

    请留空。由 ai_model 选择模型。

  • Name
    geometry_resolution
    Type
    string
    默认值 standard
    Description

    生成多少 geometry 细节。仅适用于一次性(one-call)任务和 preview 任务。带此参数的 refine 会返回 400。

    试用并预览

    可选值:

    • standard
    • 2k:增加 Ultra pass
    • 4k:增加 Ultra pass,然后再增加超分辨率 pass

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

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

    生成后是否对模型进行 remesh。false 保持生成时的 mesh 不变。仅适用于一次性(one-call)任务和 preview 任务。Smart Topology 模型会忽略此设置。

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

    重新生成 mesh 后模型的面类型,triangle 或 quad。Smart Topology 模型只生成三角形,因此在 Smart Topology 模型下使用 quad 会返回 400。使用 texture_model: "meshy-n1" 时,quad 会返回 400。

    试用并预览

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

  • Name
    decimation_mode
    Type
    integer
    Description

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

    可选值:

    • 1:ultra
    • 2:high
    • 3:medium
    • 4:low
  • Name
    target_polycount
    Type
    integer
    Description

    目标面数。仅适用于一次性(one-call)任务和 preview 任务。取值范围和默认值取决于 mesh 的构建方式:

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

    超出范围的值将返回 400。

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

  • Name
    pose_mode
    Type
    string
    Description

    角色模型的姿势,a-pose 或 t-pose。留空表示不设置姿势。仅适用于一次性(one-call)任务和 preview 任务。

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

    除非 should_texture 为 false,否则为必填项。为一次性(one-call)任务生成 texture 的模型。每个 ai_model 都接受以下各个值。

    可选值:

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

    使用 meshy-6 或 meshy-6-lite 时,meshy-n1 需要 texture_image_url,因为这些模型不会根据 prompt 生成参考图像。未提供 texture_model 的带贴图请求会返回 400,texture 模型不支持的选项也会返回 400。设置了 mode 时,Meshy 会忽略 texture_model。请参阅 Texture 模型。

  • Name
    texture_prompt
    Type
    string
    Description

    用于指导 texture 生成的文本,最多 800 个字符。超出长度将返回 400。请只发送 texture_prompt 或 texture_image_url 其中之一,不要同时发送两者。同时发送会返回 400。使用 meshy-n1 时发送此参数会返回 400。

  • Name
    texture_image_url
    Type
    string
    Description

    用于指导 texture 生成的图像,可以是公开 URL 或 Data URI(data:image/png;base64,...)。使用 meshy-n1 时,Meshy 会以该图像作为正视图来生成 texture。当一次性(one-call)任务使用 texture_model: "meshy-n1",且 ai_model 为 meshy-6 或 meshy-6-lite 时,此参数为必填项。

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

  • Name
    enable_pbr
    Type
    boolean
    默认值 false
    Description

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

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

    基础色 texture 的尺寸。带此参数的 preview 会返回 400。

    试用并预览

    可选值:

    • 2k
    • 4k
    • 8k

    无论是在一次性(one-call)任务中由 texture_model 选定,还是在 refine 中由 ai_model 选定,使用 meshy-n1 或 meshy-6-lite 时 4k 和 8k 都会返回 400。

  • Name
    remove_lighting
    Type
    boolean
    默认值 true
    Description

    是否从基础色 texture 中移除高光和阴影。只有 meshy-6 使用此设置。Meshy 7 和 Smart Topology 模型会忽略它。使用 meshy-6-lite 时发送此参数会返回 400。

  • Name
    target_formats
    Type
    string[]
    默认值 ["glb", "obj", "fbx", "stl", "usdz"]
    Description

    要生成的文件格式。

    可选值:

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

    Text to 3D 不会应用其他 v2 endpoint 对打印文件所用的 150 mm 上限。STL 文件会保留模型原始尺寸,而 Meshy 会将 3mf 文件缩放至 75 mm 高。

  • Name
    alpha_thumbnail
    Type
    boolean
    默认值 false
    Description

    是否同时渲染一张背景透明的预览图,结果会返回在 output.alpha_thumbnail_url 中。

  • Name
    thumbnail_resolution
    Type
    integer
    默认值 512
    Description

    任务预览图的宽高(像素):512 或 1024。该设置适用于 output.thumbnail_url 以及你请求的任何可选预览图。其他任何值都会返回 400。

  • Name
    moderation
    Type
    boolean
    默认值 false
    Description

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

    • prompt
    • texture_prompt
    • texture_image_url
  • Name
    auto_size
    Type
    boolean
    默认值 false
    Description

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

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

    模型原点的放置位置,bottom 或 center。

返回值

返回 202 Accepted,包含任务对象。任务起始状态为 PENDING,input 中包含你的请求内容,output 为 null。响应中还包含 result,其值与 id 相同,供 v2 之前编写的客户端使用。

以下响应头可帮助你跟踪任务:

  • Retry-After:首次读取任务前应等待的秒数
  • Location:/openapi/v2/text-to-3d/{id},这是一个legacy 路由。请改用 Tasks 来读取任务。

失败模式

  • Name
    400 - Bad Request
    Description

    请求无法运行。例如:

    • 缺少 prompt
    • 带 texture 的一次性(one-call)任务未发送 texture_model
    • 一次性(one-call)任务发送了 texture_model: "meshy-n1",并使用 meshy-6 或 meshy-6-lite,但未提供 texture_image_url
    • texture 模型不支持请求中的某个选项,例如对 meshy-n1 使用 enable_pbr: true
    • preview_task_id 与你任何状态为 SUCCEEDED 的 preview 任务都不匹配。错误消息会说明该任务不存在、尚未完成,还是不是 preview 任务
    • 同时发送了 texture_prompt 和 texture_image_url
    • 在 preview 中发送了 texture_resolution
    • 在 refine 中发送了 geometry_resolution,或该参数发送给了不支持它的模型
    • 一次性(one-call)任务请求了 meshy-7(请改为发送 meshy-7.1)
    • 一次性(one-call)任务发送了 Text to 3D 未定义的参数,例如拼写错误的参数名。设置了 mode 时,Meshy 会忽略它。

    错误消息会说明具体发现的问题。请参阅Errors。

  • Name
    401 - Unauthorized
    Description

    API key 缺失或无效。请检查 Authorization 请求头。

  • Name
    402 - Payment Required
    Description

    以下情况之一适用:

    • 账户 credits 不足。
    • 账户已达到 credits 限额。
    • 账户使用的是免费套餐。

    请检查你的 credits 和套餐,然后重试。

  • Name
    403 - Forbidden
    Description

    内容审核拦截了 prompt 或输入图像。请修改输入内容后重试。

  • Name
    429 - Too Many Requests
    Description

    达到以下限制之一:

    • 你发送的请求过多。请等待 Retry-After 中给出的秒数后重试。
    • 你排队或正在运行的任务过多。请等待部分任务完成后重试。
    • 在无限制套餐下且 credits 已用尽时,达到了无需 credits 即可运行的任务数量上限。请等待某个任务完成,或增加 credits。

获取结果

读取 Text to 3D 任务的方式与其他所有 v2 任务相同,均通过 Tasks 路由完成。要列出 Text to 3D 任务,可按 type 进行筛选:

  • text-to-3d:全部三种 Text to 3D 任务
  • text-to-3d-preview:仅 preview 任务
  • text-to-3d-refine:仅 refine 任务

单次调用任务没有自己的筛选条件。


Text to 3D output

当任务成功后,output 会包含以下字段。task 对象的其余部分对所有任务类型都是一样的。

对于 Text to 3D,expires_at 始终为 null。Meshy 仍会在任务完成 3 天后删除该任务,因此请在此期限内下载文件。企业账户的任务会被保留。参阅资产保留期。

请求
curl https://api.meshy.ai/openapi/v2/tasks/01a1aeae-2720-72bd-952d-008784fbd525 \
  -H "Authorization: Bearer ${MESHY_API_KEY}"
响应
加载中…
  • Name
    model_urls
    Type
    object
    Description

    生成文件的签名 URL,按格式分类存放。target_formats 中的每种格式都会对应一个 URL,若未指定该字段,则对应默认格式。带贴图的 obj 还会附带一个 mtl 键,用于存放其材质文件的 URL。

  • Name
    thumbnail_url
    Type
    string
    Description

    模型预览图的签名 URL。

  • Name
    alpha_thumbnail_url
    Type
    string | null
    Description

    带透明背景的预览图签名 URL。除非你发送了 alpha_thumbnail: true,否则该值为 null。

  • Name
    texture_urls
    Type
    array
    Description

    每个贴图集对应一项,其中包含以下各贴图的签名 URL:

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

    未生成的贴图为 null。对于预览以及未贴图的一次性调用任务,该数组为空。


旧版 preview 和 refine

mode 已deprecated,但对于已经使用它的集成仍然可以正常工作。新的集成使用 should_texture 通过一次调用生成模型,其花费与一次 preview 加一次 refine 相同。

  1. 使用 "mode": "preview"、你的 prompt 以及 geometry 参数(例如 geometry_resolution 和 should_remesh)创建一个 preview。preview 会生成未上贴图的 mesh。
  2. 等待该 preview 的状态变为 SUCCEEDED。
  3. 使用 "mode": "refine"、将该 preview 的 id 作为 preview_task_id,以及 texture 参数,创建一个 refine。refine 会沿用该 preview 的 prompt 和 mesh。不设置 ai_model 时,将使用与该 preview 相匹配的模型进行 texture 处理;对于 Smart Topology 的 preview,这即是 Meshy 7。

在 refine 中,ai_model 指定 texture 模型,Meshy 会忽略 texture_model:

  • meshy-7:Meshy 7
  • latest:最新的 texture 模型,目前为 Meshy 7
  • meshy-6:Meshy 6
  • meshy-6-lite:Meshy 6 Lite
  • meshy-n1:Meshy N1,仅根据参考图生成 2K 的 base color texture

Smart Topology 的 preview(meshy-t2、meshy-t2.5)不支持 Meshy 6 Lite 贴图:对其使用 meshy-6-lite 进行 refine 时,会改用 Meshy 6 进行 texture 处理,因此在 enable_pbr: true 时也会返回一张 emission map。对 Meshy 6、Meshy 6 Lite 或 Meshy 7 的 preview 使用 meshy-6-lite 进行 refine 则不会返回 emission map,对未设置 ai_model 的 Smart Topology preview 进行 refine 同样不会返回。

要使用 Meshy N1 进行 refine,请发送 "ai_model": "meshy-n1"。Meshy 会根据 texture_image_url,或根据 meshy-7.1 或 latest 的 preview 所保存的参考图进行 texture 处理。任何其他 preview 在未发送 texture_image_url 的情况下都会返回 400。Meshy N1 仅生成 2K 的 base color texture。同时发送以下任意一项都会返回 400:

  • texture_prompt
  • enable_pbr: true
  • remove_lighting: true
  • texture_resolution 为 4k 或 8k

preview 的三角面数最多为 7,999,999。对已 remesh 为四边形网格的 preview 进行此操作会返回 400。要对一次调用的任务使用 Meshy N1 进行 texture 处理,请使用 Retexture。

在 preview 被删除之前,你可以对同一个 preview 进行多次 refine,例如使用不同的 texture prompt。你无法对一次调用的任务进行 refine。Meshy 会在 Text to 3D 任务完成 3 天后将其删除,Enterprise 账户则会保留其任务。对已删除的 preview 进行 refine 会返回 400;在保留期结束后,还会附带错误码 input_task_expired。请参阅资产保留期。


Legacy routes

v2 之前的 Text to 3D 读取路由仍然可用,因此你现有的代码可以继续运行。对于新代码,请使用 Tasks。

路由替代方案
GET /openapi/v2/text-to-3d/{id}GET /openapi/v2/tasks/{id}
GET /openapi/v2/text-to-3d/{id}/streamGET /openapi/v2/tasks/{id}/stream
GET /openapi/v2/text-to-3dGET /openapi/v2/tasks?type=text-to-3d
DELETE /openapi/v2/text-to-3d/{id}DELETE /openapi/v2/tasks/{id}

这些路由返回原始 Text to 3D 任务对象的字段,其中 task_error 采用其 v2 形式。它们还会返回以下字段,与 Tasks 相同:

  • input
  • output
  • expires_at

列表路由返回一个普通数组,不包含 has_more。

/v2/text-to-3d 下(不带 /openapi)的相同路由已被 deprecated。它们的响应中带有 Deprecation 标头,以及一个指向 /openapi/v2/text-to-3d 路由的 Link 标头。