> ## 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 で Ideogram 4.0 を使用する

> Comfy Router 経由で HTTP を使って Ideogram 4.0 で画像を生成するための Python、TypeScript、cURL スニペット、およびリクエストフィールドと結果の形状

Ideogram 4.0 の API リファレンス。Ideogram 4.0 は 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/ideogram-v4`

**エンドポイント:** `POST https://api.comfy.org/v2/models/ideogram/ideogram-v4`

<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/ideogram-v4",
              {
                  "text_prompt": "a single red maple leaf on a plain white background, studio lighting",
                  "resolution": "1024x1024",
                  "rendering_speed": "DEFAULT",
              },
          )

      print("image:", result["data"][0]["url"])
      ```

      ```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.
      type Result = { data: { url: string }[] };
      const { data } = await comfy.models.run<Result>("ideogram/ideogram-v4", {
        text_prompt: "a single red maple leaf on a plain white background, studio lighting",
        resolution: "1024x1024",
        rendering_speed: "DEFAULT",
      });

      console.log("image:", data.data[0].url);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/ideogram/ideogram-v4 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"text_prompt\": \"a single red maple leaf on a plain white background, studio lighting\", \"resolution\": \"1024x1024\", \"rendering_speed\": \"DEFAULT\"}"
      ```
    </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/ideogram-v4",
              {
                  "text_prompt": "a single red maple leaf on a plain white background, studio lighting",
                  "resolution": "1024x1024",
                  "rendering_speed": "DEFAULT",
              },
          )
          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("image:", result["data"][0]["url"])
      ```

      ```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.
      type Result = { data: { url: string }[] };
      const handle = await comfy.models.submit<Result>("ideogram/ideogram-v4", {
        text_prompt: "a single red maple leaf on a plain white background, studio lighting",
        resolution: "1024x1024",
        rendering_speed: "DEFAULT",
      });
      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();
      if (result.kind !== "json") throw new Error("expected a JSON result");

      console.log("image:", result.data.data[0].url);
      ```

      ```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/ideogram-v4/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"text_prompt\": \"a single red maple leaf on a plain white background, studio lighting\", \"resolution\": \"1024x1024\", \"rendering_speed\": \"DEFAULT\"}"

      # 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/ideogram-v4/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/ideogram-v4/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="enable_copyright_detection" type="boolean">
  生成後の著作権検出（Hive による類似性チェックとロゴチェック）を有効にします。
</ParamField>

<ParamField body="json_prompt" type="object">
  構造化された V4 プロンプト。Magic Prompt を無効化し、そのまま使用されます。text\_prompt または json\_prompt のいずれか一方のみを指定してください。
</ParamField>

<ParamField body="rendering_speed" type="string" default="&#x22;DEFAULT&#x22;">
  生成速度と品質のトレードオフを制御するレンダリング速度の設定

  指定可能な値: `DEFAULT`、`TURBO`、`QUALITY`
</ParamField>

<ParamField body="resolution" type="string">
  WIDTHxHEIGHT 形式の出力解像度。省略すると、モデルがアスペクト比を選択します。サポートされる 2K の値: 2048x2048, 1440x2880, 2880x1440, 1664x2496, 2496x1664, 1792x2240, 2240x1792, 1440x2560, 2560x1440, 1600x2560, 2560x1600, 1728x2304, 2304x1728, 1296x3168, 3168x1296, 1152x2944, 2944x1152, 1248x3328, 3328x1248, 1280x3072, 3072x1280。
</ParamField>

<ParamField body="text_prompt" type="string">
  自然言語のプロンプト。Magic Prompt が自動的に有効になります。text\_prompt または json\_prompt のいずれか一方のみを指定してください。
</ParamField>

Router が `GET /v2/models/ideogram/ideogram-v4/openapi.json` で提供するスキーマから生成されています。これは、リクエストがプロバイダーに到達する前に Router が呼び出しの検証に使用するのと同じドキュメントです。

### 出力

<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}
{
  "text_prompt": "a single red maple leaf on a plain white background, studio lighting",
  "resolution": "1024x1024",
  "rendering_speed": "DEFAULT"
}
```

### 出力

```json theme={null}
{
  "response_type": "url",
  "created": "2026-08-27T21:00:00Z",
  "data": [
    {
      "url": "https://.../image.png",
      "prompt": "a single red maple leaf on a plain white background, studio lighting",
      "resolution": "1024x1024",
      "seed": 1234567890,
      "is_image_safe": true
    }
  ]
}
```

URL は一時的なものです。画像を保持する必要がある場合は、速やかにダウンロードしてください。

## 出荷前の確認

SDK は `Idempotency-Key` を生成し、自動リトライで再利用します。手動リトライでは元のキーを再利用してください。Router は最大 10 分間接続を保持できます。

リクエストが失敗すると、Router は理由を示す `X-Comfy-Error-Type` レスポンスヘッダーを送信します。`422` は、プロバイダーを呼び出す前に Router が入力を拒否したことを意味します。生成されたアセットは [結果 URL の有効期限](/ja/development/comfy-router/reference#結果アセット) があるため、早めにダウンロードしてください。

<CardGroup cols={3}>
  <Card title="ヘッダー" icon="list" href="/ja/development/comfy-router/quickstart">
    認証、冪等性、リクエスト ID、エラー分類、リトライ間隔、支出上限。
  </Card>

  <Card title="Router API の利用" icon="code" href="/ja/development/comfy-router/quickstart">
    モデルの検出、バリデーションエラー、リトライ、課金。
  </Card>

  <Card title="制限事項" icon="triangle-exclamation" href="/ja/development/comfy-router/limitations">
    Router が現在対応していないことと、代替手段。
  </Card>
</CardGroup>
