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

任务

通过 /openapi/v2/tasks 下的四个路由获取、列出、流式传输和删除每个 v2 任务。每个创建任务的 v2 endpoint 都会返回相同的任务对象。


任务对象

你可以从以下地方获取该对象:

只有 input 和 output 取决于任务类型。

A task in progress

{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "image-to-3d",
  "status": "IN_PROGRESS",
  "progress": 42,
  "created_at": 1791846275575,
  "started_at": 1791846275578,
  "finished_at": null,
  "expires_at": null,
  "preceding_tasks": 0,
  "consumed_credits": 30,
  "task_error": null,
  "input": {
    "image_url": "https://docs.meshy.ai/images/api/quick-start/source-photo.webp",
    "texture_model": "meshy-7"
  },
  "output": null
}

A succeeded task

{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "image-to-3d",
  "status": "SUCCEEDED",
  "progress": 100,
  "created_at": 1791846275575,
  "started_at": 1791846275578,
  "finished_at": 1791846334536,
  "expires_at": 1792105534536,
  "preceding_tasks": 0,
  "consumed_credits": 30,
  "task_error": null,
  "input": {
    "image_url": "https://docs.meshy.ai/images/api/quick-start/source-photo.webp",
    "texture_model": "meshy-7"
  },
  "output": {
    "model_urls": {
      "glb": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/model.glb?Expires=***"
    },
    "thumbnail_url": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/preview.png?Expires=***",
    "thumbnail_urls": null,
    "texture_urls": [
      {
        "base_color": "https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/texture_0.png?Expires=***",
        "metallic": null,
        "roughness": null,
        "normal": null,
        "metallic_roughness": null,
        "emission": null
      }
    ]
  }
}

A failed task

{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "convert",
  "status": "FAILED",
  "progress": 0,
  "created_at": 1790911760868,
  "started_at": 1790911760873,
  "finished_at": 1790911770684,
  "expires_at": null,
  "preceding_tasks": 0,
  "consumed_credits": 0,
  "task_error": {
    "type": "invalid_input",
    "code": "invalid_input",
    "message": "No valid objects found in uploaded model. The file may be empty or contain no importable geometry.",
    "doc_url": "https://docs.meshy.ai/en/api/v2/errors#invalid-input"
  },
  "input": {
    "model_url": "https://example.com/model.glb",
    "target_formats": ["fbx"]
  },
  "output": null
}
  • Name
    id
    Type
    string
    Description

    任务 ID。在本页面的路由中使用它。

  • Name
    type
    Type
    string
    Description

    任务类型,由创建该任务的 endpoint 设置。参见任务类型。Meshy 会为每个新 endpoint 添加一个类型,因此请跳过或记录你代码未处理的类型。

  • Name
    status
    Type
    string
    Description

    任务的状态。参见任务如何运行。

    可用值:

    • PENDING:正在队列中等待
    • IN_PROGRESS:正在生成结果
    • SUCCEEDED:终态,结果在 output 中
    • FAILED:终态,原因在 task_error 中
    • CANCELED:终态,没有结果
  • Name
    progress
    Type
    integer
    Description

    已完成工作的百分比,取值从 0 到 100。任务成功时为 100。

  • Name
    created_at
    Type
    integer
    Description

    任务的创建时间,以 Unix 毫秒表示。

  • Name
    started_at
    Type
    integer | null
    Description

    工作进程开始处理任务的时间,以 Unix 毫秒表示。在此之前为 null。

  • Name
    finished_at
    Type
    integer | null
    Description

    任务达到终态的时间,以 Unix 毫秒表示。在此之前为 null。

  • Name
    expires_at
    Type
    integer | null
    Description

    output 中签名 URL 失效的时间,以 Unix 毫秒表示。它是 finished_at 之后的 3 天。

    在任务成功之前为 null。对于 Text to 3D 任务,以及会无限期保留文件的企业版计划,始终为 null。参见资产保留期。

  • Name
    preceding_tasks
    Type
    integer
    Description

    任务处于 PENDING 状态时在队列中的位置。1 表示下一个开始执行。任务离开队列后为 0,在列表结果中始终为 0。

  • Name
    consumed_credits
    Type
    integer | null
    Description

    该任务扣除的积分数量(已计入任何退款)。失败任务为 0。如果 Meshy 无法读取扣费信息,则为 null。此时请重新获取该任务。

  • Name
    task_error
    Type
    object | null
    Description

    任务失败的原因,包含以下字段:

    • type
    • code
    • message
    • doc_url

    除非 status 为 FAILED,否则为 null。参见 Errors。

  • Name
    input
    Type
    object | null
    Description

    你在创建任务时发送的 参数,与你发送时的内容一致。Meshy 不会补全你省略的默认值,并且会省略该 endpoint 不接受的键。

    如果你以 Data URI 形式发送的图片,返回时会变为指向 Meshy 副本的签名 URL;若没有副本,则会被截短。在 v1 上创建的任务会保留其 v1 参数名称。

    当 Meshy 没有保存该请求的副本时为 null。这种情况会出现在任务刚创建后的短暂时间内,以及部分较旧的任务中。

  • Name
    output
    Type
    object | null
    Description

    结果,其结构由 type 决定。在任务成功之前为 null。每个 endpoint 页面都会描述其输出,任务类型中列出了相应字段。

上述列表中的每个字段始终存在。尚不存在的值为 null,绝不会是 0 或 "",数组也绝不会是 null,但 intended_print 对象中的 dimensions_mm 除外。

有两种任务类型可能会多出一个顶层字段:

Meshy 可能随时添加新字段,因此请忽略你未使用的字段。


任务类型

type 字段以及 List tasks 中的 type 过滤器使用以下值。每个 endpoint 页面都会详细描述其 output。

type创建方式output 字段
text-to-3d-previewText to 3D,previewmodel_urls、thumbnail_url、alpha_thumbnail_url、texture_urls
text-to-3d-refineText to 3D,refinemodel_urls、thumbnail_url、alpha_thumbnail_url、texture_urls
text-to-3dText to 3D,一次调用完成model_urls、thumbnail_url、alpha_thumbnail_url、texture_urls
image-to-3dImage to 3Dmodel_urls、thumbnail_url、thumbnail_urls、texture_urls
multi-image-to-3dMulti-Image to 3Dmodel_urls、thumbnail_url、thumbnail_urls、texture_urls
remeshRemeshmodel_urls、thumbnail_url、texture_urls
convertConvertmodel_urls、texture_urls
resizeResizemodel_urls、texture_urls
uv-unwrapUV Unwrapmodel_urls、thumbnail_url
rigRiggingrigged_character_glb_url、rigged_character_fbx_url、basic_animations
rig-checkRigging Checkriggable、animation_type、animatable、reasons
animateAnimationanimation_glb_url、animation_fbx_url、processed_usdz_url、processed_armature_fbx_url、processed_animation_fps_fbx_url
text-to-motionText to Motionmotion_url、motion_format、duration_ms、mode
retextureRetexturemodel_urls、thumbnail_url、texture_urls
text-to-imageText to Imageimage_urls
image-to-imageImage to Imageimage_urls
print-multi-colorMulti-Color Printmodel_urls
print-analyzeAnalyze Printabilityprintability
print-repairRepair Printabilitymodel_urls、thumbnail_url、print_repair_report
print-splitAuto Splitmodel_urls、thumbnail_url、part_count
reliefReliefmodel_urls、texture_urls、depth_map_url、thumbnail_url

以下几条规则适用于所有类型:

  • model_urls 为任务生成的每种文件格式提供一个键,例如 glb 或 fbx。任务未生成的格式则不会出现对应的键。
  • texture_urls 中的每一项都包含以下全部六种贴图,若任务未生成某种贴图,其值为 null:
    • base_color
    • metallic
    • roughness
    • normal
    • metallic_roughness
    • emission
  • 每个 URL 都经过签名,并在 expires_at 后失效。请在此之前下载所需文件。参见 Asset retention。

Creative Lab 任务不属于 API v2,因此不会出现在这些路由中。请通过它们专属的 Creative Lab 路由来获取。


任务如何运行

创建请求会立即返回任务对象,而不会等待任务运行。任务随后会在后台运行。要跟踪任务,可以使用以下方式之一:

创建请求会以 PENDING 状态启动一个任务。worker 会接手处理,任务随之进入 IN_PROGRESS 状态,这也是任务耗时最长的阶段。任务最终会以 SUCCEEDED 或 FAILED 结束,终态永远不会再改变。
创建请求
PENDING
在队列中等待
IN_PROGRESS
正在生成结果
SUCCEEDED
下载 output 中的文件
FAILED
积分已退还

下表展示了在每种状态下你的代码应该执行的操作。

状态你的代码应执行的操作
PENDING继续等待。preceding_tasks 表示任务在队列中的位置,1 表示该任务是下一个即将开始的。
IN_PROGRESS继续等待。progress 表示已完成工作的百分比。
SUCCEEDED在 expires_at 之前下载 output 中的文件。
FAILED读取 task_error,然后修正输入或创建另一个任务。请参阅 Errors。
CANCELED停止等待。该任务不会产生结果。目前没有任何 v2 任务类型会使用此状态,但应将其视为终态处理。

从你的代码角度看,整个流程如下所示:

创建一个任务,然后持续从 Tasks 路由获取该任务,直到任务完成。
  1. 请求: POST/image-to-3d

  2. 响应: 202{ "id": "<task_id>","status": "PENDING" }Location: /tasks/<task_id>任务已创建

  3. 等待 Retry-After 秒后重复
    1. 请求: GET/tasks/<task_id>

    2. 响应: 200{ "status": "IN_PROGRESS","progress": 45 }Retry-After: 5

  4. 请求: GET/tasks/<task_id>

  5. 响应: 200{ "status": "SUCCEEDED","output": { "model_urls": { "glb": "…" } } }

所有 endpoint 都以这种方式工作。如果你的应用停止等待,任务仍会继续运行。之后可以使用相同的任务 ID 再次获取该任务。

有两个响应头可以帮助你跟踪任务:

  • Location:读取任务的路径,即 /openapi/v2/tasks/{id}。该响应头出现在创建请求的响应中。
  • Retry-After:表示在下一次轮询前应等待的秒数。该响应头出现在创建请求的响应中,以及每次读取处于 PENDING 或 IN_PROGRESS 状态任务的响应中。该值只是一个参考值,当任务即将开始或完成时,这个值会更短。已经完成的任务不会带有 Retry-After,例如当可打印性分析直接返回缓存结果时就是如此。如果响应头缺失,请等待 5 秒。轮询请求也会计入你的速率限制。

关于典型的处理时间,以及你的代码在放弃等待之前应该等待多久,请参阅处理时间。即使你的代码停止等待,任务仍会继续运行。

如果想通过通知的方式获取结果而不是轮询,可以在 Webhooks 页面中设置 Payload 版本为 v2 的 webhook。每次投递都会携带该任务对象,并带有请求头 Meshy-Webhook-Version: v2。详见 Webhooks。


GET/openapi/v2/tasks/:id

获取任务

返回任意类型的一个任务,包括你在 v1 上创建的任务。Creative Lab 任务在此处不可用。

当任务处于 PENDING 或 IN_PROGRESS 状态时,Retry-After 响应头会告诉你在再次获取该任务之前需要等待多少秒。

Request

GET
/openapi/v2/tasks/018a210d-8ba4-705c-b111-1f1776f7f578
# Get one task by its ID
curl https://api.meshy.ai/openapi/v2/tasks/018a210d-8ba4-705c-b111-1f1776f7f578 \
  -H "Authorization: Bearer ${MESHY_API_KEY}"

Response headers

HTTP/2 200
Content-Type: application/json; charset=utf-8
Retry-After: 5

参数

  • Name
    id
    Type
    path
    必选
    Description

    来自创建响应的任务 ID。

返回值

任务对象。

Errors

  • Name
    400 - Bad Request
    Description

    该 ID 不是有效的任务 ID(request_invalid)。请发送创建响应中返回的 id。

  • Name
    404 - Not Found
    Description

    你的账户下没有此 ID 对应的任务(task_not_found)。

    已删除的任务、超过保留期限的任务,以及 Creative Lab 任务也会返回 404。请检查该 ID,并使用创建该任务的账户对应的 API key。


GET/openapi/v2/tasks

List tasks

返回您的任务,默认按最新排序。

Request

GET
/openapi/v2/tasks?type=image-to-3d&page_size=2
# List your two newest Image to 3D tasks
curl "https://api.meshy.ai/openapi/v2/tasks?type=image-to-3d&page_size=2" \
  -H "Authorization: Bearer ${MESHY_API_KEY}"

Response (task objects shortened)

{
  "data": [
    {
      "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
      "type": "image-to-3d",
      "status": "SUCCEEDED",
      "progress": 100,
      "...": "..."
    },
    {
      "id": "018a2110-7a91-7c2e-9b10-5d6e7f8a9b0c",
      "type": "image-to-3d",
      "status": "IN_PROGRESS",
      "progress": 42,
      "...": "..."
    }
  ],
  "has_more": true
}

参数

  • Name
    type
    Type
    string
    Description

    要列出的任务类型。text-to-3d 匹配所有三种 Text to 3D 类型。留空则列出所有类型的任务。

  • Name
    page_num
    Type
    integer
    默认值 1
    Description

    要返回的页码,从 1 到 255。0 返回第一页。超出 0 到 255 范围的值会返回 400。

  • Name
    page_size
    Type
    integer
    默认值 10
    Description

    每页的任务数量,最多 100。101 到 255 之间的值会返回 100 个任务,0 则使用默认值。超出 0 到 255 范围的值会返回 400。

  • Name
    sort_by
    Type
    string
    默认值 -created_at
    Description

    排序方式。

    可选值:

    • -created_at:最新优先
    • +created_at:最早优先

Returns

一个包含两个字段的对象:

  • Name
    data
    Type
    array
    Description

    本页的任务,每个都是完整的任务对象。没有任务时为空数组,绝不会是 null。

  • Name
    has_more
    Type
    boolean
    Description

    是否还有下一页。若为 true,请用 page_num 加一来请求下一页。最后一页时为 false。

响应中不包含总数。

Errors

  • Name
    400 - Bad Request
    Description

    以下某个查询参数无效:

    • type 不是已知的任务类型。错误信息中会列出有效值。
    • page_num 或 page_size 不是 0 到 255 之间的整数。
    • sort_by 不是 -created_at 或 +created_at。

    修正该参数后重新发送请求。


GET/openapi/v2/tasks/:id/stream

流式获取任务更新

以 Server-Sent Events 的形式流式传输任务的更新,直到任务到达最终状态。

Request

GET
/openapi/v2/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/stream
# Stream a task's updates until it finishes
curl -N https://api.meshy.ai/openapi/v2/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/stream \
  -H "Authorization: Bearer ${MESHY_API_KEY}"

Events (task objects shortened)

event:message
data:{"id":"018a210d-8ba4-705c-b111-1f1776f7f578","type":"image-to-3d","status":"IN_PROGRESS","progress":42,...}

event:message
data:{"id":"018a210d-8ba4-705c-b111-1f1776f7f578","type":"image-to-3d","status":"SUCCEEDED","progress":100,...,"output":{"model_urls":{"glb":"..."},...}}

参数

  • Name
    id
    Type
    path
    必选
    Description

    创建响应中返回的任务 ID。

返回值

一个 text/event-stream,包含两种事件:

  • Name
    message
    Description

    完整的任务对象。第一个事件会立即到达,之后每当任务发生变化时都会再次发送。Meshy 还会每 10 秒重复发送最新状态,因此即使连接处于静默状态也会收到事件。流会在带有最终状态的事件之后关闭。

  • Name
    error
    Description

    error 对象,外加 status_code。例如,{"type": "not_found", "code": "task_not_found", "message": "Task not found", "doc_url": "https://docs.meshy.ai/en/api/v2/asset-retention", "status_code": 404}。流会在此事件之后关闭。

    流打开后,HTTP 状态码会一直保持 200,因此需要从事件中读取错误信息。而在流打开之前发生的错误,例如缺少 API key,则是普通的 HTTP 错误。

流会在大约 21 分钟后关闭,即使任务尚未完成。网络中断可能会导致流更早关闭。如果流在没有最终状态的情况下关闭,请重新打开它,或获取任务。


DELETE/openapi/v2/tasks/:id

删除任务

删除任意类型的任务。删除操作无法撤销,已删除的任务在所有路由上都会返回 404。Creative Lab 任务无法在此处删除,会像 获取任务 中一样返回 404。

删除一个 PENDING 任务会退还其积分。IN_PROGRESS 的任务无法删除,请等待最终状态后再删除。

Request

DELETE
/openapi/v2/tasks/018a210d-8ba4-705c-b111-1f1776f7f578
# Delete a task
curl -X DELETE https://api.meshy.ai/openapi/v2/tasks/018a210d-8ba4-705c-b111-1f1776f7f578 \
  -H "Authorization: Bearer ${MESHY_API_KEY}"

409 Conflict

{
  "type": "conflict",
  "code": "task_in_progress",
  "message": "Task is IN_PROGRESS and cannot be deleted. Credits for a task the worker has already started are not refundable; wait for it to reach SUCCEEDED, FAILED or CANCELED, then delete it.",
  "doc_url": null
}

参数

  • Name
    id
    Type
    path
    必选
    Description

    要删除的任务的 ID。

返回值

200,响应体为空。

Errors

  • Name
    400 - Bad Request
    Description

    该 ID 不是有效的任务 ID(request_invalid)。请发送创建响应中的 id。

  • Name
    404 - Not Found
    Description

    没有任务的该 ID 属于您的账户,或该任务已被删除(task_not_found)。

    Creative Lab 任务也会返回 404。请检查 ID,并使用创建该任务的账户的 API key。

  • Name
    409 - Conflict
    Description

    该任务处于 IN_PROGRESS 状态。一旦工作进程开始处理,其积分将不可退还。请等待状态变为 SUCCEEDED 或 FAILED 后再删除。