> ## 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 で Recraft V4 Styles Pro Vector を使用する

> Comfy Router 経由で recraft/recraftv4_styles_pro_vector を呼び出します: エンドポイント、リクエスト形状、Router が返すレスポンスについて。

`recraft/recraftv4_styles_pro_vector` の API リファレンス。Comfy Router が Recraft から提供しています。

## クイックスタート

[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:** `recraft/recraftv4_styles_pro_vector`

**エンドポイント:** `POST https://api.comfy.org/v2/models/recraft/recraftv4_styles_pro_vector`

<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(
              "recraft/recraftv4_styles_pro_vector",
              {
                  "n": 1,
                  "prompt": "A single red maple leaf on a plain white background.",
              },
          )

      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("recraft/recraftv4_styles_pro_vector", {
        n: 1,
        prompt: "A single red maple leaf on a plain white background.",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/recraft/recraftv4_styles_pro_vector \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"n\": 1, \"prompt\": \"A single red maple leaf on a plain white background.\"}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Queue and collect later">
    同じボディを `POST https://api.comfy.org/v2/models/recraft/recraftv4-styles-pro-vector/requests` に送信します。Router は実行が受け付けられ次第 `201` と `request_id` を返し、結果は準備が整った時点で、このプロセスからでも別のプロセスからでも取得できます。ステータス、キャンセル、結果の取得の詳細は [Queued delivery](/ja/development/comfy-router/queue) を参照してください。

    <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(
              "recraft/recraftv4_styles_pro_vector",
              {
                  "n": 1,
                  "prompt": "A single red maple leaf on a plain white background.",
              },
          )
          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("recraft/recraftv4_styles_pro_vector", {
        n: 1,
        prompt: "A single red maple leaf on a plain white background.",
      });
      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/recraft/recraftv4_styles_pro_vector/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"n\": 1, \"prompt\": \"A single red maple leaf on a plain white background.\"}"

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

## Schema

### 入力

<ParamField body="controls" type="object">
  生成される画像の制御パラメータ
</ParamField>

<ParamField body="controls.artistic_level" type="integer">
  画像の芸術的なトーンを定義します。シンプルなレベルでは、人物はカメラをまっすぐ見て、静かでクリーンなスタイルになります。ダイナミックでエキセントリックなレベルでは、動きと創造性が導入されます。

  範囲: `0` から `5`
</ParamField>

<ParamField body="controls.background_color" type="object">
  RGB 色の値
</ParamField>

<ParamField body="controls.background_color.rgb" type="integer[]" required />

<ParamField body="controls.colors" type="object[]">
  好ましい色の配列
</ParamField>

<ParamField body="controls.colors[].rgb" type="integer[]" required />

<ParamField body="controls.no_text" type="boolean">
  テキストレイアウトを埋め込まない
</ParamField>

<ParamField body="model" type="string">
  生成に使用するモデル (例: "recraftv3")。このフィールドは enum に制約されません。プロキシは呼び出し元が送信したものをそのまま転送します。Comfy が提供するスペル、つまり Comfy Router が `recraft/<model>` として扱うセットは、recraftv2、recraftv3、recraftv4、recraftv4\_pro、recraftv4\_1、recraftv4\_1\_utility、recraftv4\_1\_pro、recraftv4\_1\_utility\_pro、recraftv4\_styles、recraftv4\_styles\_pro、recraftv4\_1\_vector、recraftv4\_1\_utility\_vector、recraftv4\_1\_pro\_vector、recraftv4\_1\_utility\_pro\_vector、recraftv4\_styles\_vector、recraftv4\_styles\_pro\_vector です。これらを参照ではなくここに列挙しているのは、これらを宣言している RecraftGenerationModel コンポーネントがどこからも `$ref` されておらず、そのため GET /openapi で提供される仕様から除外されているからです。したがって、そこへのポインタは提供されるドキュメント内で宙に浮いた状態になります。また、4 つの `recraftv4_styles*` スペルは追加で `style_id` を必要とします。このフィールドを参照してください。
</ParamField>

<ParamField body="n" type="integer">
  生成する画像の数

  範囲: `1` から `6`
</ParamField>

<ParamField body="prompt" type="string" required>
  生成する画像を記述するテキストプロンプト
</ParamField>

<ParamField body="size" type="string">
  生成される画像のサイズ (例: "1024x1024")
</ParamField>

<ParamField body="style" type="string">
  生成される画像に適用するスタイル (例: "digital\_illustration")
</ParamField>

<ParamField body="style_id" type="string">
  生成される画像に適用するスタイル ID (例: "123e4567-e89b-12d3-a456-426614174000")。style\_id が指定された場合、style は指定しないでください。4 つの `recraftv4_styles*` モデルでは必須です。Recraft は style\_id またはスタイル参照のないものを拒否します。`POST /proxy/recraft/styles` で発行してください。これは同じプロキシが同じ認証情報で提供しています。このルート上ではこのペアリングを強制するものは何もありません。ボディは変更されずに Recraft へ転送されるため、これのない `recraftv4_styles*` 呼び出しはパートナーに到達し、4xx で返ってきます。
</ParamField>

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

### 出力

<ResponseField name="created" type="integer" required>
  生成が作成されたときの Unix タイムスタンプ
</ResponseField>

<ResponseField name="credits" type="integer" required>
  生成に使用されたクレジット数
</ResponseField>

<ResponseField name="data" type="object[]" required>
  生成された画像情報の配列
</ResponseField>

<ResponseField name="data[].image_id" type="string">
  生成された画像の一意の識別子
</ResponseField>

<ResponseField name="data[].url" type="string">
  生成された画像にアクセスするための URL
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "n": 1,
  "prompt": "A single red maple leaf on a plain white background."
}
```

### 出力

```json theme={null}
{
  "created": 1767225600,
  "credits": 1,
  "data": [
    {
      "image_id": "3f7a1b28-5c0d-4e91-8a6f-1b2c3d4e5f60",
      "url": "https://example.invalid/recraft/recraftv3/generated.png"
    }
  ]
}
```

## 出荷前の確認

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>
