創意工坊 — 燈罩 API

將文字描述或一張照片變成可 3D 列印的燈罩,分成兩個階段:prototype 生成一張 霧面白色的概念圖,build 再把概念圖轉成中空的 STL 燈罩(可選擇附帶一片 搭配光源的底座圓盤)。兩個階段透過 input_task_id 串聯。

  • POST /openapi/creative-lab/lamp/v1/prototype
  • POST /openapi/creative-lab/lamp/v1/build

POST/openapi/creative-lab/lamp/v1/prototype

建立燈罩 Prototype 任務

產生一張燈罩的霧面白色概念圖 —— 可來自文字提示詞(text-to-3D),也可以 來自參考圖片(image-to-3D)。回傳的任務 ID 會作為後續 build 端點的 input_task_id。回應結構詳見後文 燈罩 Prototype 任務物件 章節。

參數

  • Name
    text
    Type
    string
    必选
    Description

    描述燈罩主題的文字提示詞。未提供 image_url 時必須傳入。最長 800 個字元。

  • Name
    image_url
    Type
    string
    必选
    Description

    Meshy 用作燈罩視覺參考的來源照片。未提供 text 時必須傳入。目前支援 .jpg.jpeg.png.webp 格式。

    可透過兩種方式提供圖片:

    • 公開網路可存取 URL:可從公開網路存取的 URL。
    • Data URI:圖片的 base64 編碼 data URI,範例:data:image/jpeg;base64,<your base64-encoded image data>
  • Name
    image_subject
    Type
    string
    默认值 character
    Description

    以圖生 3D 路徑下的主題類別提示。可選值:

    • character(預設)— 單一角色 / 物體主題(公仔、動物、吉祥物等)。
    • landscape — 戶外場景 / 全景主題(山脈、城市天際線、森林等)。

    在以文生 3D 路徑下會被忽略。

  • Name
    name
    Type
    string
    Description

    選填的任務名稱,僅用於顯示。最長 100 個字元。

回傳值

回應的 result 欄位會回傳新建立的燈罩 prototype 任務的 id。輪詢 查詢任務 端點或訂閱 串流訂閱任務,直到任務狀態變為 SUCCEEDED,再將該 ID 作為 build 端點的 input_task_id 傳入。

失敗情境

  • Name
    400 - Bad Request
    Description

    請求不合法,常見原因:

    • 缺少參數textimage_url 必須傳入其中之一。
    • 兩者同時傳入textimage_url 互斥,不能同時存在。
    • 圖片格式不支援image_url 不是支援的格式(.jpg.jpeg.png.webp)。
    • 圖片尺寸不合法:圖片過小、檔案超過最大大小上限,或像素數超過上限。
    • URL 無法存取image_url 下載失敗(404 或逾時)。
    • Data URI 不合法:base64 字串格式錯誤。
    • 內容遭審核攔截:圖片被 NSFW 或智慧財產權審核標記。
    • 文字過長text 超過 800 個字元。
    • image_subject 取值非法:不在 character / landscape 中。
  • Name
    401 - Unauthorized
    Description

    身分驗證失敗,請檢查 API key。

  • Name
    402 - Payment Required
    Description

    點數不足,無法建立任務。

  • Name
    429 - Too Many Requests
    Description

    請求超出速率限制。

请求

POST
/openapi/creative-lab/lamp/v1/prototype
# Stage 1(图生 3D):生成哑光白色灯罩概念图
curl https://api.meshy.ai/openapi/creative-lab/lamp/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>",
    "image_subject": "character"
  }'

# Stage 1(文生 3D):从文字提示词生成
curl https://api.meshy.ai/openapi/creative-lab/lamp/v1/prototype \
  -X POST \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "text": "a stylized owl perched on a tree branch under moonlight"
  }'

响应

{
  "result": "018a210d-8ba4-705c-b111-1f1776f7f578"
}
Prototype 示例
从源照片开始,生成灯罩 build 阶段会使用的 prototype 图。
作為 Creative Lab 燈罩輸入的貓咪來源照片
Prototype 输入
由來源照片產生的 Creative Lab 燈罩 prototype 輸出圖
Prototype 输出

POST/openapi/creative-lab/lamp/v1/build

建立燈罩 Build 任務

根據已成功的 prototype 任務,生成最終可 3D 列印的燈罩。Build 會以 prototype 概念圖 執行圖生 3D 管線,再把網格交給 lamp processor 進行中空化、頂面平整、可選的底部切口;當 light_source_preset 選用某個夾具時,還會額外輸出一塊適配光源的底座圓盤。回應 結構詳見後文 燈罩 Build 任務物件 章節。

參數

  • Name
    input_task_id
    Type
    string
    必填
    Description

    透過同一個 OpenAPI 端點建立的 prototype 任務 ID。該 prototype 必須由同一 API 金鑰建立、狀態已變為 SUCCEEDED,且輸出恰好一張候選圖。

    透過 webapp 建立的 prototype 任務接受 —— build 端點只接受由 POST /openapi/creative-lab/lamp/v1/prototype 產生的任務,其他來源一律返回 404

  • Name
    name
    Type
    string
    Description

    可選的任務名稱,僅用於顯示。最長 100 個字元。

options

燈罩幾何的可選調校參數。每個欄位都有合理的預設值 —— 只需要傳入想覆寫的那些欄位。

  • Name
    diameter_mm
    Type
    number
    預設值 80
    Description

    燈罩包圍盒的目標最大尺寸,單位為毫米。網格會按比例均勻縮放以適配。取值範圍:[50, 400]

  • Name
    thickness_mm
    Type
    number
    預設值 1.5
    Description

    中空燈罩的壁厚,單位為毫米。取值範圍:(0, 10]

  • Name
    cut_amount_percent
    Type
    number
    預設值 35
    Description

    燈罩頂部被切平的高度百分比,讓列印件能穩定放在列印床上。取值範圍:[1, 100]

  • Name
    light_source_preset
    Type
    string
    預設值 bambu_mh001_60mm
    Description

    光源夾具預設,決定是否(以及輸出什麼樣的)底座圓盤。可選值:

    • bambu_mh001_60mm(預設)— 輸出一塊直徑 60mm、適配相容光源夾具的底座圓盤。結果包含 model_urls.base_stl
    • none — 不帶夾具,不輸出底座圓盤。model_urls.base_stl 省略。
  • Name
    fixture_offset_x_mm
    Type
    number
    預設值 0
    Description

    夾具切口相對於燈罩中心的 X 軸水平偏移,單位為毫米。僅當 light_source_presetnone 時生效。取值範圍:[-80, 80]

  • Name
    fixture_offset_z_mm
    Type
    number
    預設值 0
    Description

    夾具切口相對於燈罩底部的 Z 軸垂直偏移,單位為毫米。取值範圍:[-80, 80]

  • Name
    rotate_x_deg
    Type
    number
    預設值 0
    Description

    在處理前對匯入網格施加的繞 X 軸旋轉角度,單位為度。取值範圍:[-360, 360]

  • Name
    rotate_y_deg
    Type
    number
    預設值 0
    Description

    在處理前對匯入網格施加的繞 Y 軸旋轉角度,單位為度。取值範圍:[-360, 360]

  • Name
    rotate_z_deg
    Type
    number
    預設值 0
    Description

    在處理前對匯入網格施加的繞 Z 軸旋轉角度,單位為度。取值範圍:[-360, 360]

  • Name
    include_result_json
    Type
    boolean
    預設值 false
    Description

    當為 trueoutput.formatzip 時,在打包內包含 lamp processor 的 result.json(含測量到的網格指標與最終生效的 option 集合)。output.formatstl 時會被忽略。

output

可選的輸出格式選擇。預設為 stl

  • Name
    format
    Type
    string
    預設值 stl
    Description

    Build 返回的產物形態。可選值:

    • stl(預設)— 燈罩本體放在 model_urls.lamp_stl;當 light_source_presetnone 時同時返回 model_urls.base_stl
    • zip — 把 processor 輸出的全部檔案(lamp.stl、可選的 base.stl、可選的 result.json)打包成單一 zip,返回在 model_urls.bundle_zip

返回值

回應的 result 欄位會返回新建立的燈罩 build 任務的 id。輪詢 查詢任務 端點或訂閱 串流訂閱任務 直到任務狀態變為 SUCCEEDED,即可從 model_urls 中下載產物。

失敗情境

  • Name
    400 - Bad Request
    Description

    請求不合法,常見原因:

    • 缺少參數input_task_id 必傳。
    • UUID 不合法input_task_id 不是合法 UUID。
    • 父任務未成功:引用的 prototype 任務尚未達到 SUCCEEDED
    • 沒有候選圖:prototype 任務雖然成功,但未產出任何候選圖。
    • options 欄位超出範圍:某個 options 欄位超出允許的範圍或列舉集合。
  • Name
    401 - Unauthorized
    Description

    身分驗證失敗,請檢查 API 金鑰。

  • Name
    402 - Payment Required
    Description

    點數不足,無法建立任務。

  • Name
    404 - Not Found
    Description

    引用的 prototype 任務不存在、屬於其他使用者,或是由 webapp 建立的(只接受 API 模式的 prototype 任務)。

  • Name
    429 - Too Many Requests
    Description

    請求超出速率限制。

請求

POST
/openapi/creative-lab/lamp/v1/build
# Stage 2:基于已成功的 prototype 任务串联 build
curl https://api.meshy.ai/openapi/creative-lab/lamp/v1/build \
  -X POST \
  -H "Authorization: Bearer ${YOUR_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
    "input_task_id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "options": {
      "diameter_mm": 120,
      "thickness_mm": 2,
      "light_source_preset": "bambu_mh001_60mm",
      "cut_amount_percent": 30
    },
    "output": {
      "format": "stl"
    }
  }'

响应

{
  "result": "019c320e-9a8f-7a1c-9c11-2a1876f8a9bb"
}
Build 範例
Build 任務會把選中的 prototype 圖轉成可列印的燈罩模型。
Creative Lab 燈罩 build 模型預覽圖
Build 模型預覽

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

查詢燈罩任務

根據有效的任務 id 查詢一個 prototype 或 build 任務。URL 路徑必須與任務階段一致 —— 使用 /prototype/:id 擷取 build 任務會返回 404,反之亦然。

回應結構請參閱 燈罩 Prototype 任務物件燈罩 Build 任務物件 章節。

參數

  • Name
    id
    Type
    path
    Description

    要查詢的燈罩任務的唯一識別碼。

回傳值

回應包含燈罩任務物件,形式取決於請求的階段。

请求

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

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

Prototype 响应

{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "creative-lab-lamp-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 响应

{
  "id": "019c320e-9a8f-7a1c-9c11-2a1876f8a9bb",
  "type": "creative-lab-lamp-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,
  "model_urls": {
    "lamp_stl": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/lamp.stl?Expires=***",
    "base_stl": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/base.stl?Expires=***"
  }
}

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

刪除燈罩任務

取消一個燈罩任務。若任務仍在 PENDING,建立時消耗的點數會退還;已經 IN_PROGRESS 的任務會被取消但退還(worker 可能已經在消耗資源);已經處於 最終狀態(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 路徑不一致。

请求

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

响应

// 成功时返回 204 No Content(空响应体)。

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

串流訂閱燈罩任務

透過 Server-Sent Events (SSE) 即時訂閱燈罩任務進度。URL 路徑必須與任務階段一致 —— 對 /prototype/:buildId/stream 開啟串流會發出一則 event: errorstatus_code: 404) 然後關閉串流。

參數

  • Name
    id
    Type
    path
    Description

    要訂閱的燈罩任務的唯一識別碼。

回傳值

回傳 燈罩 Prototype燈罩 Build 任務物件的 SSE 串流。 對於 PENDING / IN_PROGRESS 狀態的任務,串流中只包含必要的 progressstatus 欄位。

请求

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

响应流

// 错误事件示例(stage 不匹配或任务不存在)
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-lamp-build",
  "status": "SUCCEEDED",
  "progress": 100,
  "created_at": 1729123500000,
  "started_at": 1729123510000,
  "finished_at": 1729123535000,
  "expires_at": 1729382735000,
  "task_error": null,
  "consumed_credits": 30,
  "model_urls": {
    "lamp_stl": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/lamp.stl?Expires=***",
    "base_stl": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/base.stl?Expires=***"
  }
}

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

列出燈罩任務

依階段分頁列出目前 API key 底下的燈罩任務。URL 路徑決定階段 —— /prototype 會回傳 prototype 任務;/build 會回傳 build 任務。跨階段的任務不會出現在另一邊的回應中。

路徑參數

  • Name
    stage
    Type
    path
    必选
    Description

    prototypebuild。集合僅會回傳與 URL 階段相符的任務 —— 拉取 /prototype 不會回傳 build 任務,反之亦然。

查詢參數

  • Name
    page_num
    Type
    integer
    默认值 1
    Description

    分頁頁碼。

  • Name
    page_size
    Type
    integer
    默认值 10
    Description

    每頁筆數。允許的最大值為 50

  • Name
    sort_by
    Type
    string
    默认值 -created_at
    Description

    排序欄位。可選值:

    • +created_at:依建立時間遞增排序。
    • -created_at:依建立時間遞減排序。

回傳值

回傳依階段篩選的任務物件分頁清單 —— 列出 /prototype 時會回傳 燈罩 Prototype 任務物件; 列出 /build 時會回傳 燈罩 Build 任務物件

请求

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

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

响应(列出 Prototype 任务)

[
  {
    "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
    "type": "creative-lab-lamp-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=***"
    ]
  }
]

燈罩 Prototype 任務物件

燈罩 Prototype 任務是 Meshy 用來追蹤「從文字提示詞或來源照片生成霧面白色概念圖」 這一階段的工作單元。它的產出會透過 input_task_id 串接至 Build 階段

欄位

  • Name
    id
    Type
    string
    Description

    任務的唯一識別碼。目前實作使用 k-sortable UUID 作為任務 ID,但請勿對其格式做任何假設。

  • Name
    type
    Type
    string
    Description

    任務類型。固定為 creative-lab-lamp-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

    任務開始時間戳,單位為毫秒。尚未開始時為 0

  • Name
    finished_at
    Type
    timestamp
    Description

    任務結束時間戳,單位為毫秒。尚未結束時為 0

  • Name
    expires_at
    Type
    timestamp
    Description

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

  • Name
    preceding_tasks
    Type
    integer
    Description

    前置任務數量。

  • Name
    task_error
    Type
    object
    Description

    失敗任務的錯誤詳細資訊。完整物件結構請參閱 錯誤

  • Name
    consumed_credits
    Type
    integer
    Description

    此任務消耗的積分數。PENDINGIN_PROGRESSSUCCEEDED 狀態下會顯示;FAILED 狀態會回傳 0(失敗時積分會退還)。

  • Name
    image_urls
    Type
    array of strings
    Description

    此 prototype 任務產生的候選概念圖下載 URL 陣列。目前 API 一律回傳剛好一張候選圖;欄位以陣列形式回傳,便於未來在不破壞相容性的前提下擴充多個候選圖。

灯罩 Prototype 任务对象示例

{
  "id": "018a210d-8ba4-705c-b111-1f1776f7f578",
  "type": "creative-lab-lamp-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 任務物件

燈罩 Build 任務是 Meshy 用來追蹤「從成功完成的 prototype 任務生成最終可 3D 列印燈罩」 這一階段的工作單元。Build 會在 prototype 概念圖上執行以圖生 3D 草模 + 貼圖管線,再把網格 交給 lamp processor 完成中空化、頂部平整化、可選的夾具底切等後處理。

欄位

  • Name
    id
    Type
    string
    Description

    任務的唯一識別碼。

  • Name
    type
    Type
    string
    Description

    任務類型。固定為 creative-lab-lamp-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

    失敗任務的錯誤詳細資訊。完整物件結構請參閱 錯誤

  • Name
    consumed_credits
    Type
    integer
    Description

    該任務消耗的積分數。FAILED 狀態回傳 0(失敗時會退還積分)。

  • Name
    model_urls
    Type
    object
    Description

    生成的產出物下載 URL,以產出物名稱作為 key。實際會出現哪些 key 取決於 output.formatoptions.light_source_preset

    • Name
      lamp_stl
      Type
      string
      Description

      燈罩本體 lamp.stl 的下載 URL。當 output.formatstl(預設)時呈現。

    • Name
      base_stl
      Type
      string
      Description

      夾具底座 base.stl 的下載 URL。僅當 output.formatstl options.light_source_preset 不是 none 時呈現。夾具預設為 none 時不會出現。

    • Name
      bundle_zip
      Type
      string
      Description

      processor 的所有產出物(lamp.stl、可選的 base.stl,以及當 options.include_result_jsontrue 時的 result.json)壓縮成單一 zip 的下載 URL。當 output.formatzip 時呈現。此時 lamp_stl / base_stl 不會出現。

灯罩 Build 任务对象示例

{
  "id": "019c320e-9a8f-7a1c-9c11-2a1876f8a9bb",
  "type": "creative-lab-lamp-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,
  "model_urls": {
    "lamp_stl": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/lamp.stl?Expires=***",
    "base_stl": "https://assets.meshy.ai/***/tasks/019c320e-9a8f-7a1c-9c11-2a1876f8a9bb/output/base.stl?Expires=***"
  }
}