ComfyPilotComfyPilot
文档 / 开发 / 使用 Jst 2 Scene 与 Comfy Router

使用 Jst 2 Scene 与 Comfy Router

通过 Comfy Router 调用 viggle/jst-2-scene:端点、请求形状以及 Router 返回的响应。

开发 code 更新于 2026-11-25

查看官方原文

使用 Jst 2 Scene 与 Comfy Router

通过 Comfy Router 调用 viggle/jst-2-scene:端点、请求形状以及 Router 返回的响应。

viggle/jst-2-scene 的 API 参考,由 Comfy Router 从 Viggle 提供。

输入: 文本、图像 · 输出: 3D + 图像

快速开始

在你的 Comfy 工作区中创建一个密钥,并将其导出为 COMFY_API_KEY。Python 和 TypeScript 代码片段使用 Comfy SDK(pip install comfy-sdk 和 npm install @comfyorg/sdk);cURL 代码片段则通过原生 HTTP 发起同样的调用。

模型 ID: viggle/jst-2-scene

端点: POST https://api.comfy.org/v2/models/viggle/jst-2-scene

等待结果 ``python Python theme={null} from comfy_sdk import Comfy # 从环境变量读取 COMFY_API_KEY。 # SDK 会自动创建幂等键,并在自动重试时复用它。 with Comfy() as client: result = client.models.run( "viggle/jst-2-scene", { "prompt": "a sunlit atrium with tall plants and a stone floor", "quality": "low", "sessionId": "replace-with-a-new-random-id", }, ) print(result) ` `typescript TypeScript theme={null} import { comfy } from "@comfyorg/sdk"; // 从环境变量读取 COMFY_API_KEY。 // SDK 会自动创建幂等键,并在自动重试时复用它。 const { data } = await comfy.models.run("viggle/jst-2-scene", { prompt: "a sunlit atrium with tall plants and a stone floor", quality: "low", sessionId: "replace-with-a-new-random-id", }); console.log(data); ` `bash cURL theme={null} curl https://api.comfy.org/v2/models/viggle/jst-2-scene \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"prompt\": \"a sunlit atrium with tall plants and a stone floor\", \"quality\": \"low\", \"sessionId\": \"replace-with-a-new-random-id\"}" ``
排队稍后收集 同样的请求体,发送到 POST https://api.comfy.org/v2/models/viggle/jst-2-scene/requests。一旦运行被接纳,Router 就会返回 201 和 request_id,结果就绪后可从此进程或其他进程收集。排队投递会介绍状态查询、取消和收集的完整流程。 ``python Python theme={null} import asyncio from comfy_sdk import AsyncComfy # 从环境变量读取 COMFY_API_KEY。 # 每次 submit() 调用都会生成自己的 Idempotency-Key,并在自动重试时复用它。 async def main(): async with AsyncComfy() as client: handle = await client.models.submit( "viggle/jst-2-scene", { "prompt": "a sunlit atrium with tall plants and a stone floor", "quality": "low", "sessionId": "replace-with-a-new-random-id", }, ) print("request_id:", handle.request_id) # 配合模型 ID,就是另一个进程所需的全部信息 # 轮询直到请求完成,按服务器指定的 Retry-After 等待。 async for update in handle.iter_events(): print(update.status, update.queue_position) # 提供商自己的载荷,与 models.run() 返回的值相同。 # 失败或被取消的请求会在这里抛出对应类型的 Router 错误。 result = await handle.get() print(result) asyncio.run(main()) ` `typescript TypeScript theme={null} import { comfy } from "@comfyorg/sdk"; // 从环境变量读取 COMFY_API_KEY。 // 每次 submit() 调用都会生成自己的 Idempotency-Key,并在自动重试时复用它。 const handle = await comfy.models.submit("viggle/jst-2-scene", { prompt: "a sunlit atrium with tall plants and a stone floor", quality: "low", sessionId: "replace-with-a-new-random-id", }); console.log("requestId:", handle.requestId); // 配合模型 ID,就是另一个进程所需的全部信息 // 轮询直到请求完成,按服务器指定的 Retry-After 等待。 for await (const update of handle.events()) { console.log(update.status, update.queuePosition); } // 与 models.run() 返回的结果相同。失败或被取消的请求会在这里被拒绝。 const result = await handle.get(); console.log(result.data); ` `bash cURL theme={null} # 1. 提交。Router 返回 201,并带上 request_id、status_url、response_url 和 cancel_url。 curl https://api.comfy.org/v2/models/viggle/jst-2-scene/requests \ -H "X-API-Key: $COMFY_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d "{\"prompt\": \"a sunlit atrium with tall plants and a stone floor\", \"quality\": \"low\", \"sessionId\": \"replace-with-a-new-random-id\"}" # 2. 轮询直到 status 为 COMPLETED,每次响应都会指定 Retry-After 秒数,按此等待。 REQUEST_ID="<request_id from the 201 body>" curl -i https://api.comfy.org/v2/models/viggle/jst-2-scene/requests/$REQUEST_ID/status \ -H "X-API-Key: $COMFY_API_KEY" # 3. 收集。200 返回模型的原生输出,仍在运行时则返回 202 和状态正文。 curl https://api.comfy.org/v2/models/viggle/jst-2-scene/requests/$REQUEST_ID \ -H "X-API-Key: $COMFY_API_KEY" ``

Schema

输入

panoramaUri string

用于构建场景的 360° 全景图的 http(s) URL。

prompt string

场景描述,最多 1,000 个字符。

quality string

全景质量:low(默认)、medium 或 high。仅在提供 prompt 时使用。

referenceImages string[]

最多 8 个用于引导全景图生成的 http(s) 图像 URL。仅在提供 prompt 时使用。

sessionId string required

保存该场景的会话:1 到 128 个字母、数字、_ 或 -。每个场景请使用一个新的随机值。

根据 Router 在 GET /v2/models/viggle/jst-2-scene/openapi.json 提供的 schema 生成,这也是它在请求到达提供商之前验证调用所用的同一份文档。

输出

completedAt integer

格式:int64

createdAt integer

格式:int64

credits number

任务被扣除的 Viggle 积分;未达到 ready 状态的任务退款后为 0。

error object

Viggle 的错误对象,在作业失败时设置。

error.code string

error.message string

error.request\_id string

error.retryable boolean

id string

场景任务 ID(scn_ 前缀)。

operation string

任务类型:pano、generate 或 reconstruct。

queuePosition integer

排队时排在该任务前面的任务数量。

result object

场景输出,仅在任务处于 ready 状态时设置。

result.newViewCount integer

result.operation string

result.outputBatch object

任务添加到会话的图像批处理。

result.outputBatch.batchId string

result.outputBatch.createdAt number

result.outputBatch.kind string

result.outputBatch.manifest object

result.outputBatch.manifest.url string

下载 URL,有效期 3 小时。

result.outputBatch.views object[]

result.outputBatch.views\[].c2w number[][]

4 × 4 相机到世界矩阵。

result.outputBatch.views\[].index integer

result.outputBatch.views\[].intrinsic number[]

相机内参。

result.outputBatch.views\[].url string

视图图像的下载 URL,有效期 3 小时。

result.panorama object

result.panorama.url string

下载 URL,有效期 3 小时。

result.preview object

result.preview\.url string

下载 URL,有效期 3 小时。

result.referenceViewCount integer

result.sessionId string

result.spz object

result.spz.url string

下载 URL,有效期 3 小时。

sessionId string

status string

状态:queued、processing、ready、failed 或 cancelled。

示例

输入

{
  "prompt": "a sunlit atrium with tall plants and a stone floor",
  "quality": "low",
  "sessionId": "replace-with-a-new-random-id"
}

输出

{
  "credits": 6,
  "error": null,
  "id": "scn_0199f0c2-6a1e-7c3d-9b2a-4f5e6d7c8b9a.replace-with-a-new-random-id",
  "operation": "pano",
  "result": {
    "newViewCount": 6,
    "operation": "pano",
    "outputBatch": {
      "batchId": "3f0a6c1e-8d2b-4b7a-9e5c-1a2b3c4d5e6f",
      "kind": "initial",
      "views": [
        {
          "index": 0,
          "url": "https://example.invalid/viggle/view-0.png"
        }
      ]
    },
    "panorama": {
      "url": "https://example.invalid/viggle/panorama.png"
    },
    "referenceViewCount": 0,
    "sessionId": "replace-with-a-new-random-id",
    "spz": {
      "url": "https://example.invalid/viggle/scene.spz"
    }
  },
  "sessionId": "replace-with-a-new-random-id",
  "status": "ready"
}

发布前须知

SDK 会生成 Idempotency-Key 并在自动重试中复用它。手动重试时,请复用原始 key。Router 最长可保持连接 10 分钟。

请求失败时,Router 会发送 X-Comfy-Error-Type 响应头说明原因。422 表示 Router 在调用提供商之前就拒绝了输入,413 表示请求体超出了 Router 可接受的大小。已生成的资源请及时下载,因为结果 URL 会过期。

上文任何字段描述中提到的尺寸限制,都是提供商对该字段自身的限定,引自提供商的规范。Router 会对整个请求体另行设置上限,base64 编码的媒体内容也计入其中:参见请求体大小。

本页记录的是通过 Comfy Router 调用的某一个合作伙伴模型。同一个 comfy-sdk / @comfyorg/sdk 包还提供第二个客户端,用于在 Comfy Cloud 上运行完整的 ComfyUI 工作流图:Comfy(api_key=...) / new Comfy({ apiKey }),并带有 client.workflows、client.assets 和 client.jobs。请参阅 Comfy SDKs。

请求头 身份验证、幂等性、请求 ID、错误分类、重试节奏、消费限额。
使用 Router API 模型发现、验证错误、重试与计费。
限制 Router 目前不支持的功能,以及替代方案。