> ## Documentation Index
> Fetch the complete documentation index at: https://docs.comfy.org/llms.txt
> Use this file to discover all available pages before exploring further.

# 通过 Comfy Router 使用 Jst 2 Scene View

> 通过 Comfy Router 调用 viggle/jst-2-scene-view：端点、请求结构以及 Router 返回的响应。

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

**输入：** 3D · **输出：** 图像

## 快速开始

在[你的 Comfy 工作区](https://platform.comfy.org/profile/api-keys?onboarding=router)中创建一个密钥，并将其导出为 `COMFY_API_KEY`。Python 与 TypeScript 片段使用 Comfy SDK（`pip install comfy-sdk` 和 `npm install @comfyorg/sdk`）；cURL 片段则是通过原始 HTTP 发出的同一个调用。

**模型 ID:** `viggle/jst-2-scene-view`

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

> [tab] 等待结果
>
> ```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-view",
>         {
>             "projection": "perspective",
>             "referenceBatchIds": ["3f0a6c1e-8d2b-4b7a-9e5c-1a2b3c4d5e6f"],
>             "sessionId": "replace-with-a-new-random-id",
>             "targetPosition": {
>                 "pitch": 0,
>                 "position": [0.3, 0, 0],
>                 "yaw": 30,
>             },
>         },
>     )
>
> 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-view", {
>   projection: "perspective",
>   referenceBatchIds: ["3f0a6c1e-8d2b-4b7a-9e5c-1a2b3c4d5e6f"],
>   sessionId: "replace-with-a-new-random-id",
>   targetPosition: {
>     pitch: 0,
>     position: [0.3, 0, 0],
>     yaw: 30,
>   },
> });
>
> console.log(data);
> ```
>
> ```bash cURL theme={null}
> curl https://api.comfy.org/v2/models/viggle/jst-2-scene-view \
>   -H "X-API-Key: $COMFY_API_KEY" \
>   -H "Idempotency-Key: $(uuidgen)" \
>   -H "Content-Type: application/json" \
>   -d "{\"projection\": \"perspective\", \"referenceBatchIds\": [\"3f0a6c1e-8d2b-4b7a-9e5c-1a2b3c4d5e6f\"], \"sessionId\": \"replace-with-a-new-random-id\", \"targetPosition\": {\"pitch\":0,\"position\":[0.3,0,0],\"yaw\":30}}"
> ```

> [tab] 排队并稍后收集
>
> 相同的请求体，发送到 `POST https://api.comfy.org/v2/models/viggle/jst-2-scene-view/requests`。运行一旦被接收，Router 就会返回 `201` 和 `request_id`；结果准备就绪后即可收集，无论来自本进程还是其他进程。[队列投递](https://docs.comfy.org/zh/development/comfy-router/queue.md) 会逐步介绍状态查询、取消与结果收集。
>
> ```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-view",
>             {
>                 "projection": "perspective",
>                 "referenceBatchIds": ["3f0a6c1e-8d2b-4b7a-9e5c-1a2b3c4d5e6f"],
>                 "sessionId": "replace-with-a-new-random-id",
>                 "targetPosition": {
>                     "pitch": 0,
>                     "position": [0.3, 0, 0],
>                     "yaw": 30,
>                 },
>             },
>         )
>         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-view", {
>   projection: "perspective",
>   referenceBatchIds: ["3f0a6c1e-8d2b-4b7a-9e5c-1a2b3c4d5e6f"],
>   sessionId: "replace-with-a-new-random-id",
>   targetPosition: {
>     pitch: 0,
>     position: [0.3, 0, 0],
>     yaw: 30,
>   },
> });
> 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-view/requests \
>   -H "X-API-Key: $COMFY_API_KEY" \
>   -H "Idempotency-Key: $(uuidgen)" \
>   -H "Content-Type: application/json" \
>   -d "{\"projection\": \"perspective\", \"referenceBatchIds\": [\"3f0a6c1e-8d2b-4b7a-9e5c-1a2b3c4d5e6f\"], \"sessionId\": \"replace-with-a-new-random-id\", \"targetPosition\": {\"pitch\":0,\"position\":[0.3,0,0],\"yaw\":30}}"
>
> # 2. 轮询直到状态为 COMPLETED，每次响应都会指定需要等待的 Retry-After 秒数。
> REQUEST_ID="<request_id from the 201 body>"
> curl -i https://api.comfy.org/v2/models/viggle/jst-2-scene-view/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-view/requests/$REQUEST_ID \
>   -H "X-API-Key: $COMFY_API_KEY"
> ```

## Schema

### 输入

**fov** `number`

视场角，单位为度，范围为 20 到 140。

**projection** `string`

perspective（默认，1 个视图）或 pano（360° 全景，6 个视图）。

**referenceBatchIds** `string[]` *required*

会话的 1 到 35 个批处理 ID，来自 `result.outputBatch.batchId`。

**seed** `integer`

生成种子。

Format: `int64`

**sessionId** `string` *required*

场景所属的会话。

**targetPosition** `object` *required*

以位置和两个角度表示的相机。

**targetPosition.pitch** `number`

上下角度，单位为度，范围为 -90 到 90；正值表示向上看。

**targetPosition.position** `number[]` *required*

相机位置 `[x, y, z]`。

**targetPosition.yaw** `number`

绕世界 +Y 轴的角度，单位为度；正值表示向左转。

此文档根据 Router 在 `GET /v2/models/viggle/jst-2-scene-view/openapi.json` 提供的 schema 生成，Router 在请求到达提供商之前也会用同一份文档来验证调用。

### 输出

**completedAt** `integer`

Format: `int64`

**createdAt** `integer`

Format: `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`

场景输出，仅在任务就绪时设置。

**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。

## 示例

### 输入

```json theme={null}
{
  "projection": "perspective",
  "referenceBatchIds": [
    "3f0a6c1e-8d2b-4b7a-9e5c-1a2b3c4d5e6f"
  ],
  "sessionId": "replace-with-a-new-random-id",
  "targetPosition": {
    "pitch": 0,
    "position": [
      0.3,
      0,
      0
    ],
    "yaw": 30
  }
}
```

### 输出

```json theme={null}
{
  "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 会过期](https://docs.comfy.org/zh/development/comfy-router/reference.md#结果资产)。

上文任何字段描述中提到的尺寸限制，都是提供商对该字段自身的限定，引自提供商的规范。Router 会对整个请求体另行设置上限，base64 编码的媒体内容也计入其中：参见[请求体大小](https://docs.comfy.org/zh/development/comfy-router/limitations.md)。

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

> [card] [请求头](https://docs.comfy.org/zh/development/comfy-router/headers.md)
>
> 身份验证、幂等性、请求 ID、错误分类、重试节奏、消费限额。

> [card] [使用 Router API](https://docs.comfy.org/zh/development/comfy-router/api.md)
>
> 模型发现、验证错误、重试与计费。

> [card] [限制](https://docs.comfy.org/zh/development/comfy-router/limitations.md)
>
> Router 目前不支持的功能，以及替代方案。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.