Creative Lab — 方塊小人 API

將原始照片轉換成方塊風格的收藏級 3D 方塊小人,分兩個階段進行: 原型從您的輸入照片生成風格化概念圖片,然後 建造將該概念圖片轉換為帶貼圖的 3D 模型。這兩個階段通過 input_task_id 連接。

  • POST /openapi/creative-lab/brick-figure/v1/prototype
  • POST /openapi/creative-lab/brick-figure/v1/build

POST/openapi/creative-lab/brick-figure/v1/prototype

創建一個方塊小人原型任務

從來源照片生成一個方塊風格的概念圖像。返回的任務 ID 是您作為 input_task_id 傳遞到構建端點的內容。參照 方塊小人原型任務對象 獲取響應結構。

引數

  • Name
    image_url
    Type
    string
    必選
    Description

    Meshy 將來源照片風格化為方塊小人。我們目前支持 .jpg.jpeg.png.webp 格式。

    有兩種方式提供圖像:

    • 公開可訪問的 URL:在互聯網上可訪問的 URL。
    • Data URI:圖像的 base64 編碼的 Data URI。Data URI 的示例:data:image/jpeg;base64,<your base64-encoded image data>
  • Name
    name
    Type
    string
    Description

    用於顯示的可選任務名稱。最多 100 個字符。

返回

響應的 result 屬性包含新創建的方塊小人原型任務的任務 id。輪詢 獲取任務 端點或訂閱 直到任務達到 SUCCEEDED,然後將該 ID 以 input_task_id 傳遞給 構建端點

失敗模式

  • Name
    400 - Bad Request
    Description

    請求不可接受。常見原因:

    • 缺少引數image_url 是必需的。
    • 無效的圖片格式:提供的 image_url 不是支持的格式(.jpg.jpeg.png.webp)。
    • 圖片尺寸超出範圍:圖片太小,超過最大文件大小或超過最大像素數。
    • 無法訪問的 URL:無法下載 image_url (404 或 timeout)。
    • 無效的 Data URI:base64 字符串格式錯誤。
    • 內容被標記:輸入圖片被 NSFW 或知識產權 moderation 標記。
  • Name
    401 - Unauthorized
    Description

    身份驗證失敗。請檢查您的 API key。

  • Name
    402 - Payment Required
    Description

    積分不足,無法執行此任務。

  • Name
    403 - Forbidden
    Description

    輸入圖片被標記為侵犯知識產權。

  • Name
    429 - Too Many Requests
    Description

    您已超出速率限制。

Request

POST
/openapi/creative-lab/brick-figure/v1/prototype
# 第一階段:生成方塊風格的概念圖像
curl https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/prototype \
  -X POST \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "image_url": "<your publicly accessible image url or base64-encoded data URI>"
  }'

Response

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

POST/openapi/creative-lab/brick-figure/v1/build

創建方塊小人構建任務

從成功的原型任務生成最終帶貼圖的 3D 方塊小人。該構建運行與影象生成 3D相同的管道,因此回應對象格式與輸出 URL 列表完全匹配。參考方塊小人構建任務對象了解回應結構。

引數

  • Name
    input_task_id
    Type
    string
    必選
    Description

    通過此相同 OpenAPI 端點創建的原型任務的任務 ID。原型必須使用相同的 API 金鑰創建,必須已達到 SUCCEEDED,並且必須生成確切的一個候選影像。

    通過 webapp 創建的原型任務被接受 —— 構建端點僅接受由 POST /openapi/creative-lab/brick-figure/v1/prototype 生成的原型任務,並將拒絕任何其他來源(返回 404)。

  • Name
    name
    Type
    string
    Description

    用於展示的可選任務名稱。最多 100 個字元。

返回值

回應的 result 屬性包含新創建的方塊小人構建任務的任務 id。輪詢獲取任務端點或訂閱直到任務達到 SUCCEEDED,然後從 model_urls.glb 下載帶貼圖的 GLB(或者如果你的下游管道偏愛 OBJ,則從 model_urls.objmodel_urls.mtl 下載 OBJ + MTL 配對)。

失敗模式

  • Name
    400 - Bad Request
    Description

    該請求不可接受。常見原因:

    • 缺少引數input_task_id 是必需的。
    • 無效的 UUIDinput_task_id 不是有效的 UUID。
    • 父任務未成功:引用的原型任務尚未達到 SUCCEEDED
    • 無候選:原型任務成功但未生成任何候選影像。
  • Name
    401 - Unauthorized
    Description

    身份驗證失敗。請檢查你的 API 金鑰。

  • Name
    402 - Payment Required
    Description

    積分不足以執行該任務。

  • Name
    404 - Not Found
    Description

    引用的原型任務不存在,屬於不同的用戶,或通過 webapp 創建(僅支持 API 模式的原型任務鏈入構建)。

  • Name
    429 - Too Many Requests
    Description

    你已超過速率限制。

請求

POST
/openapi/creative-lab/brick-figure/v1/build
# 階段 2:從成功的原型任務鏈接構建
curl https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/build \
  -X POST \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578"
  }'

回應

{
  "result": "019c320e-9a8f-7a1c-9c11-2a1876f8a9bb"
}

GET/openapi/creative-lab/brick-figure/v1/(prototype|build)/:id

檢索方塊小人任務

根據有效的任務 id 檢索原型或建設任務。URL 路徑必須匹配任務的階段 — 通過 /prototype/:id 提取的建設任務將返回 404,反之亦然。

請參考 方塊小人原型任務對象方塊小人建設任務對象 了解回應結構。

參數

  • Name
    id
    Type
    path
    Description

    要檢索的方塊小人任務的唯一識別符。

回應

回應包含方塊小人任務對象。形狀取決於請求的階段。

Request

GET
/openapi/creative-lab/brick-figure/v1/prototype/018a210d-8ba4-705c-b111-1f1776f7f578
# 原型
curl https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/prototype/018a210d-8ba4-705c-b111-1f1776f7f578 \
  -H "Authorization: Bearer ${YOUR_API_KEY}"

# 建設
curl https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/build/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb \
  -H "Authorization: Bearer ${YOUR_API_KEY}"

Prototype Response

{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "creative-lab-brick-figure-prototype",
  "name": "",
  "status": "SUCCEEDED",
  "progress": 100,
  "created_at": 1729123456000,
  "started_at": 1729123460000,
  "finished_at": 1729123486000,
  "expires_at": 1729382686000,
  "preceding_tasks": 0,
  "task_error": null,
  "consumed_credits": 6,
  "image_urls": [
    "https://assets.meshy.ai/***/concept.png?Expires=***"
  ]
}

Build Response

{
  "id": "019c320e-9a8f-7a1c-9c11-2a1876f8a9bb",
  "type": "creative-lab-brick-figure-build",
  "name": "",
  "status": "SUCCEEDED",
  "progress": 100,
  "created_at": 1729123500000,
  "started_at": 1729123510000,
  "finished_at": 1729123535000,
  "expires_at": 1729382735000,
  "preceding_tasks": 0,
  "task_error": null,
  "consumed_credits": 30,
  "prompt": "",
  "negative_prompt": "",
  "texture_prompt": "",
  "texture_image_url": "",
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.glb?Expires=***",
    "obj": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.obj?Expires=***",
    "mtl": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.mtl?Expires=***"
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/preview.png?Expires=***",
  "texture_urls": [
    {
      "base_color": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/texture_0.png?Expires=***"
    }
  ]
}

DELETE/openapi/creative-lab/brick-figure/v1/(prototype|build)/:id

刪除方塊小人任務

取消方塊小人任務。如果任務仍在 PENDING 狀態,創建時消耗的積分將退還。已經處於 IN_PROGRESS 狀態的任務會被取消,但不會退還積分(工作者可能已經在消耗資源)。已經達到終端狀態(SUCCEEDEDFAILEDCANCELED)的任務無法取消。

URL 路徑必須匹配任務的階段 — /prototype/:buildId 上的 DELETE 返回 404

路徑參數

  • Name
    id
    Type
    path
    Description

    要取消的方塊小人任務的唯一標識。

返回

成功時返回 204 No Content,且本體為空。

失敗模式

  • Name
    400 - Bad Request
    Description

    任務已經處於終端狀態,無法取消。

  • Name
    404 - Not Found
    Description

    任務不存在,屬於不同的用戶,或者其階段不匹配 URL 路徑。

Request

DELETE
/openapi/creative-lab/brick-figure/v1/prototype/018a210d-8ba4-705c-b111-1f1776f7f578
curl --request DELETE \
  --url https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/prototype/018a210d-8ba4-705c-b111-1f1776f7f578 \
  -H "Authorization: Bearer ${YOUR_API_KEY}"

Response

// 成功時返回 204 No Content(本體為空)。

GET/openapi/creative-lab/brick-figure/v1/(prototype|build)/:id/stream

串流方塊小人任務

通過伺服器發送事件 (SSE) 串流方塊小人任務的即時更新。 URL 路徑必須與任務階段匹配 —— 在 /prototype/:buildId/stream 打開串流會發出一個 event: error 請求體,status_code: 404 並關閉串流。

參數

  • Name
    id
    Type
    path
    Description

    方塊小人任務的唯一識別碼以進行串流。

返回

返回 方塊小人原型方塊小人構建 任務對象的串流作為伺服器發送事件。對於 PENDINGIN_PROGRESS 任務,回應串流只會包括必要的 progressstatus 欄位。

Request

GET
/openapi/creative-lab/brick-figure/v1/build/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/stream
curl -N https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/build/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/stream \
-H "Authorization: Bearer ${YOUR_API_KEY}"

Response Stream

// 錯誤事件示例(錯誤階段或未找到任務)
event: error
data: {
  "status_code": 404,
  "message": "Task not found"
}

// 範例資訊事件展示任務進度。
// 對於 PENDING 或 IN_PROGRESS 任務,回應串流不會包含所有欄位。
event: message
data: {
  "id": "019c320e-9a8f-7a1c-9c11-2a1876f8a9bb",
  "progress": 0,
  "status": "PENDING"
}

event: message
data: {
  "id": "019c320e-9a8f-7a1c-9c11-2a1876f8a9bb",
  "type": "creative-lab-brick-figure-build",
  "status": "SUCCEEDED",
  "progress": 100,
  "created_at": 1729123500000,
  "started_at": 1729123510000,
  "finished_at": 1729123535000,
  "expires_at": 1729382735000,
  "task_error": null,
  "consumed_credits": 30,
  "prompt": "",
  "negative_prompt": "",
  "texture_prompt": "",
  "texture_image_url": "",
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.glb?Expires=***",
    "obj": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.obj?Expires=***",
    "mtl": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.mtl?Expires=***"
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/preview.png?Expires=***",
  "texture_urls": [
    {
      "base_color": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/texture_0.png?Expires=***"
    }
  ]
}

GET/openapi/creative-lab/brick-figure/v1/(prototype|build)

列出方塊小人任務

獲取單階段的方塊小人任務的分頁列表。URL 路徑選擇階段 — /prototype 返回原型任務;/build 返回構建任務。來自其他階段的任務不包括在任何一個響應中。

路徑參數

  • Name
    stage
    Type
    path
    必選
    Description

    prototypebuild。集合僅返回階段與 URL 匹配的任務 — 獲取 /prototype 從不返回構建任務,反之亦然。

查詢參數

  • Name
    page_num
    Type
    integer
    預設值 1
    Description

    分頁的頁碼。

  • Name
    page_size
    Type
    integer
    預設值 10
    Description

    分頁大小限制。最大允許為 100 項。

  • Name
    sort_by
    Type
    string
    預設值 -created_at
    Description

    排序字段。可用值:

    • +created_at:按創建時間升序排序。
    • -created_at:按創建時間降序排序。

返回值

返回每階段任務對象的分頁列表 — 當列出 /prototype 時,為 方塊小人原型任務對象;當列出 /build 時,為 方塊小人構建任務對象

Request

GET
/openapi/creative-lab/brick-figure/v1/prototype
# 列出原型任務
curl https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/prototype?page_size=10 \
  -H "Authorization: Bearer ${YOUR_API_KEY}"

# 列出構建任務
curl https://api.meshy.ai/openapi/creative-lab/brick-figure/v1/build?page_size=10 \
  -H "Authorization: Bearer ${YOUR_API_KEY}"

Response (List Prototype Tasks)

[
  {
    "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "type": "creative-lab-brick-figure-prototype",
    "name": "",
    "status": "SUCCEEDED",
    "progress": 100,
    "created_at": 1729123456000,
    "started_at": 1729123460000,
    "finished_at": 1729123486000,
    "expires_at": 1729382686000,
    "preceding_tasks": 0,
    "task_error": null,
    "consumed_credits": 6,
    "image_urls": [
      "https://assets.meshy.ai/***/concept.png?Expires=***"
    ]
  }
]

方塊小人原型任務對象

方塊小人原型任務對象是一個工作單位,Meshy 會追蹤以從來源照片生成方塊風格的概念圖像。此階段的輸出通過 input_task_id 鏈接到構建階段

屬性

  • Name
    id
    Type
    string
    Description

    任務的唯一識別符。我們使用一個 k-sortable 的 UUID 作為任務 id 的實現細節,但您不應對 id 的格式做任何假設。

  • Name
    type
    Type
    string
    Description

    任務的類型。其值為 creative-lab-brick-figure-prototype

  • Name
    name
    Type
    string
    Description

    創建任務時提供的任務名稱。如果未提供名稱,則為空字符串。

  • Name
    status
    Type
    string
    Description

    任務的狀態。可能的值為 PENDINGIN_PROGRESSSUCCEEDEDFAILEDCANCELED 之一。

  • Name
    progress
    Type
    integer
    Description

    任務的進度。如果任務尚未開始,此屬性將為 0。一旦任務成功,這將變為 100

  • Name
    created_at
    Type
    timestamp
    Description

    任務創建的時間戳,以毫秒表示。

  • Name
    started_at
    Type
    timestamp
    Description

    任務開始的時間戳,以毫秒表示。如果任務尚未開始,此屬性將為 null

  • Name
    finished_at
    Type
    timestamp
    Description

    任務完成的時間戳,以毫秒表示。如果任務尚未完成,此屬性將為 null

  • Name
    expires_at
    Type
    timestamp
    Description

    任務結果過期的時間戳,以毫秒表示。

  • Name
    preceding_tasks
    Type
    integer
    Description

    前置任務的數量。

  • Name
    task_error
    Type
    object
    Description

    失敗任務的錯誤詳情。請查看 Errors 了解完整的 task_error 物件參考。

  • Name
    consumed_credits
    Type
    integer
    Description

    該任務消耗的積分數量。在任務狀態為 PENDINGIN_PROGRESSSUCCEEDED 時存在。對於 FAILED 任務返回 0(失敗時積分會被退還)。

  • Name
    image_urls
    Type
    array of strings
    Description

    下載概念圖片候選者的 URL,由此原型任務生成。目前 API 總是返回正好一個候選者;該欄位是一個數組,因此未來版本可以在不造成破壞性的更改下顯示多個候選者。

Example Brick Figure Prototype Task Object

{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "creative-lab-brick-figure-prototype",
  "name": "",
  "status": "SUCCEEDED",
  "progress": 100,
  "created_at": 1729123456000,
  "started_at": 1729123460000,
  "finished_at": 1729123486000,
  "expires_at": 1729382686000,
  "preceding_tasks": 0,
  "task_error": null,
  "consumed_credits": 6,
  "image_urls": [
    "https://assets.meshy.ai/***/concept.png?Expires=***"
  ]
}

The Brick Figure Build Task Object

方塊小人建立任務物件是一個工作單元,Meshy 會跟蹤這個單元,以從成功的原型任務生成具有貼圖的 3D 方塊小人。它運行與 影象生成 3D 相同的圖片到 3D 管線,因此輸出欄位反映該端點的任務物件

Properties

  • Name
    id
    Type
    string
    Description

    任務的唯一識別碼。

  • Name
    type
    Type
    string
    Description

    任務的類型。值為 creative-lab-brick-figure-build

  • Name
    name
    Type
    string
    Description

    創建任務時提供的任務名稱。如果未提供名稱,則為空字符串。

  • Name
    status
    Type
    string
    Description

    任務的狀態。可能的值包括 PENDINGIN_PROGRESSSUCCEEDEDFAILEDCANCELED

  • Name
    progress
    Type
    integer
    Description

    任務的進度。如果任務尚未開始,此屬性將為 0。一旦任務成功,這將變為 100

  • Name
    created_at
    Type
    timestamp
    Description

    任務創建時的時間戳,單位為毫秒。

  • Name
    started_at
    Type
    timestamp
    Description

    任務開始時的時間戳,單位為毫秒。

  • Name
    finished_at
    Type
    timestamp
    Description

    任務完成時的時間戳,單位為毫秒。

  • Name
    expires_at
    Type
    timestamp
    Description

    任務結果過期時的時間戳,單位為毫秒。

  • Name
    preceding_tasks
    Type
    integer
    Description

    前置任務的數量。僅在狀態為 PENDING 時有意義。

  • Name
    task_error
    Type
    object
    Description

    失敗任務的錯誤詳情。參見錯誤以獲取完整的 task_error 對象參考。

  • Name
    consumed_credits
    Type
    integer
    Description

    該任務消耗的積分數。對於 FAILED 任務,返回 0(失敗時積分會退回)。

  • Name
    prompt
    Type
    string
    Description

    對於方塊小人建造始終為空。存在於跨端點與共享的 V2ImageTo3DTaskResponse 形狀的兼容性中,用於影象生成 3D

  • Name
    negative_prompt
    Type
    string
    Description

    對於方塊小人建造始終為空。存在於跨端點的兼容性中。

  • Name
    texture_prompt
    Type
    string
    Description

    對於方塊小人建造始終為空。存在於跨端點的兼容性中。

  • Name
    texture_image_url
    Type
    string
    Description

    對於方塊小人建造始終為空。存在於跨端點的兼容性中。

  • Name
    model_urls
    Type
    object
    Description

    所生成 3D 模型的可下載 URL。方塊小人建造會生成一個具有貼圖的 GLB,此外還包括適用於偏愛 Wavefront OBJ 的管線的 OBJ + MTL 組合。欄位形狀匹配 影象生成 3D model_urls 對象,因此未來格式的添加不會導致破壞性變更。

    • Name
      glb
      Type
      string
      Description

      帶貼圖的 GLB 文件的可下載 URL。

    • Name
      obj
      Type
      string
      Description

      Wavefront OBJ 文件(幾何體 + UV)的可下載 URL。

    • Name
      mtl
      Type
      string
      Description

      OBJ 伴隨的 MTL 材質文件的可下載 URL。與 obj 和來自 texture_urls[0].base_color 的項目配對。

  • Name
    thumbnail_url
    Type
    string
    Description

    模型文件縮圖的可下載 URL。

  • Name
    texture_urls
    Type
    array
    Description

    此任務生成的貼圖 URL 對象的數組。目前包含一個帶有基底色彩圖的對象。

    • Name
      base_color
      Type
      string
      Description

      基底色彩圖像的可下載 URL。

Example Brick Figure Build Task Object

{
  "id": "019c320e-9a8f-7a1c-9c11-2a1876f8a9bb",
  "type": "creative-lab-brick-figure-build",
  "name": "",
  "status": "SUCCEEDED",
  "progress": 100,
  "created_at": 1729123500000,
  "started_at": 1729123510000,
  "finished_at": 1729123535000,
  "expires_at": 1729382735000,
  "preceding_tasks": 0,
  "task_error": null,
  "consumed_credits": 30,
  "prompt": "",
  "negative_prompt": "",
  "texture_prompt": "",
  "texture_image_url": "",
  "model_urls": {
    "glb": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.glb?Expires=***",
    "obj": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.obj?Expires=***",
    "mtl": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/model.mtl?Expires=***"
  },
  "thumbnail_url": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/preview.png?Expires=***",
  "texture_urls": [
    {
      "base_color": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/texture_0.png?Expires=***"
    }
  ]
}