> ## 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 使用 P Image Ideogram

> 通过 Comfy Router 调用 ideogram/p-image-ideogram：endpoint、请求结构以及 Router 返回的响应。

`ideogram/p-image-ideogram` 的 API 参考文档，由 Comfy Router 从 Ideogram 提供。

## 快速开始

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

**模型 ID：** `ideogram/p-image-ideogram`

**端点：** `POST https://api.comfy.org/v2/models/ideogram/p-image-ideogram`

<Tabs>
  <Tab title="Wait for the result">
    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # Reads COMFY_API_KEY from the environment.
      # The SDK automatically creates an idempotency key and reuses it for automatic retries.
      with Comfy() as client:
          result = client.models.run(
              "ideogram/p-image-ideogram",
              {
                  "prompt": "A beautiful mountain landscape",
              },
          )

      print(result)
      ```

      ```typescript TypeScript theme={null}
      import { comfy } from "@comfyorg/sdk";

      // Reads COMFY_API_KEY from the environment.
      // The SDK automatically creates an idempotency key and reuses it for automatic retries.
      const { data } = await comfy.models.run("ideogram/p-image-ideogram", {
        prompt: "A beautiful mountain landscape",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/ideogram/p-image-ideogram \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"prompt\": \"A beautiful mountain landscape\"}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Queue and collect later">
    <CodeGroup>
      ```python Python theme={null}
      from comfy_sdk import Comfy

      # Reads COMFY_API_KEY from the environment.
      # Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
      with Comfy() as client:
          handle = client.models.submit(
              "ideogram/p-image-ideogram",
              {
                  "prompt": "A beautiful mountain landscape",
              },
          )
          print("request_id:", handle.request_id)  # with the model ID, all another process needs

          # Poll until the request completes, waiting the Retry-After the server names.
          for update in handle.iter_events():
              print(update.status, update.queue_position)

          # The provider's own payload, the same value models.run() returns.
          # A request that failed or was cancelled raises the typed Router error here.
          result = handle.get()

      print(result)
      ```

      ```typescript TypeScript theme={null}
      import { comfy } from "@comfyorg/sdk";

      // Reads COMFY_API_KEY from the environment.
      // Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
      const handle = await comfy.models.submit("ideogram/p-image-ideogram", {
        prompt: "A beautiful mountain landscape",
      });
      console.log("requestId:", handle.requestId); // with the model ID, all another process needs

      // Poll until the request completes, waiting the Retry-After the server names.
      for await (const update of handle.events()) {
        console.log(update.status, update.queuePosition);
      }

      // The same result models.run() returns. A request that failed or was cancelled rejects here.
      const result = await handle.get();

      console.log(result.data);
      ```

      ```bash cURL theme={null}
      # 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.
      curl https://api.comfy.org/v2/models/ideogram/p-image-ideogram/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"prompt\": \"A beautiful mountain landscape\"}"

      # 2. Poll until status is COMPLETED, waiting the Retry-After seconds each response names.
      REQUEST_ID="<request_id from the 201 body>"
      curl -i https://api.comfy.org/v2/models/ideogram/p-image-ideogram/requests/$REQUEST_ID/status \
        -H "X-API-Key: $COMFY_API_KEY"

      # 3. Collect. 200 with the model's native output, 202 with the status body while it is still running.
      curl https://api.comfy.org/v2/models/ideogram/p-image-ideogram/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Schema

### 输入

<ParamField body="aspect_ratio" type="string">
  宽高比，格式为 WxH。支持的取值：1x3、3x1、1x2、2x1、9x16、16x9、10x16、16x10、2x3、3x2、3x4、4x3、4x5、5x4、1x1。默认为 1x1。
</ParamField>

<ParamField body="enable_copyright_detection" type="boolean">
  启用生成后的版权检测（Hive 相似度与 logo 检查）。
</ParamField>

<ParamField body="prompt" type="string" required>
  用于图像生成的提示词，可以是自然语言，也可以是 Ideogram 4.0 JSON 结构化提示词。
</ParamField>

<ParamField body="prompt_upsampling" type="string">
  提示词上采样模式。支持的取值为 AUTO、ON 和 OFF。默认为 AUTO。
</ParamField>

<ParamField body="quality" type="string">
  生成质量级别。支持的取值为 VERY\_LOW、LOW、MEDIUM 和 HIGH。默认为 MEDIUM。
</ParamField>

<ParamField body="resolution" type="string">
  输出分辨率。支持的取值为 1K 和 2K。默认为 1K。
</ParamField>

<ParamField body="seed" type="integer">
  用于可复现生成的种子值
</ParamField>

该 Schema 由 Router 在 `GET /v2/models/ideogram/p-image-ideogram/openapi.json` 提供的文档生成，它也是请求到达提供商之前用于校验调用的同一份文档。

### 输出

<ResponseField name="created" type="string (date-time)">
  生成创建时的时间戳。

  格式：`date-time`
</ResponseField>

<ResponseField name="data" type="object[]">
  已生成图像信息的数组。
</ResponseField>

<ResponseField name="data[].is_image_safe" type="boolean">
  表示该图像是否被视为安全。
</ResponseField>

<ResponseField name="data[].prompt" type="string">
  用于生成此图像的提示词。
</ResponseField>

<ResponseField name="data[].resolution" type="string">
  已生成图像的分辨率（例如 '1024x1024'）。
</ResponseField>

<ResponseField name="data[].seed" type="integer">
  本次生成所使用的种子值。
</ResponseField>

<ResponseField name="data[].style_type" type="string">
  生成所使用的风格类型（例如 'REALISTIC'、'ANIME'）。
</ResponseField>

<ResponseField name="data[].url" type="string">
  已生成图像的 URL。
</ResponseField>

## 示例

### 输入

```json theme={null}
{
  "prompt": "A beautiful mountain landscape"
}
```

### 输出

```json theme={null}
{
  "created": "2026-01-01T00:00:00Z",
  "data": [
    {
      "is_image_safe": true,
      "prompt": "A poster for a jazz festival, bold typography, warm colours",
      "resolution": "1024x1024",
      "seed": 918273645,
      "style_type": "REALISTIC",
      "url": "https://example.invalid/ideogram/p-image-ideogram/generated.png"
    }
  ]
}
```

## 发布前须知

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

请求失败时，Router 会发送 `X-Comfy-Error-Type` 响应头说明原因。`422` 表示 Router 在调用提供商之前就拒绝了输入。生成的资源请及时下载，因为[结果链接会过期](/zh/development/comfy-router/reference#结果资产)。

<CardGroup cols={3}>
  <Card title="请求头" icon="list" href="/zh/development/comfy-router/quickstart">
    身份验证、幂等性、请求 ID、错误分类、重试节奏、消费限额。
  </Card>

  <Card title="使用 Router API" icon="code" href="/zh/development/comfy-router/quickstart">
    模型发现、校验错误、重试与计费。
  </Card>

  <Card title="限制" icon="triangle-exclamation" href="/zh/development/comfy-router/limitations">
    Router 目前不支持的功能，以及替代方案。
  </Card>
</CardGroup>
