> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-chore-sync-comfy-api-v2-spec.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Comfy Router で Patina を使う

> Comfy Router を通して fal/patina を呼び出す: エンドポイント、リクエストの形状、Router が返すレスポンス。

`fal/patina` の API リファレンス。fal から Comfy Router が提供します。

## クイックスタート

[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:** `fal/patina`

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

<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(
              "fal/patina",
              {
                  "image_url": "https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png",
              },
          )

      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("fal/patina", {
        image_url: "https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/fal/patina \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"image_url\": \"https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png\"}"
      ```
    </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(
              "fal/patina",
              {
                  "image_url": "https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png",
              },
          )
          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("fal/patina", {
        image_url: "https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png",
      });
      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/fal/patina/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"image_url\": \"https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png\"}"

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

## スキーマ

### 入力

<ParamField body="enable_safety_checker" type="boolean" default="true">
  画像の安全チェッカーを有効にします。
</ParamField>

<ParamField body="image_url" type="string" required>
  入力画像（写真またはレンダリング）の URL。
</ParamField>

<ParamField body="maps" type="string[]" default="[&#x22;basecolor&#x22;,&#x22;normal&#x22;,&#x22;roughness&#x22;,&#x22;metalness&#x22;,&#x22;height&#x22;]">
  予測する PBR マップ。デフォルトでは 5 つすべてです。
</ParamField>

<ParamField body="output_format" type="string" default="&#x22;png&#x22;">
  出力画像のフォーマット: jpeg、png、webp のいずれか。
</ParamField>

<ParamField body="seed" type="integer">
  再現可能な denoise のためのランダムシード。
</ParamField>

<ParamField body="sync_mode" type="boolean" default="false">
  true の場合、CDN の URL ではなくデータ URI として画像を返します。
</ParamField>

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

### 出力

<ResponseField name="images" type="object[]">
  生成されたタイル状テクスチャ画像と、予測された PBR マテリアルマップ。ベーステクスチャには url のみが含まれ、各マップのエントリには map\_type も含まれます。
</ResponseField>

<ResponseField name="images[].map_type" type="string">
  PBR マップの種類（basecolor、normal、roughness、metalness、height）。ベーステクスチャ画像の場合には存在しません。
</ResponseField>

<ResponseField name="images[].url" type="string">
  生成された画像の URL。
</ResponseField>

<ResponseField name="prompt" type="string">
  テクスチャ生成に使用されたプロンプト（展開されている場合があります）。
</ResponseField>

<ResponseField name="seed" type="integer">
  テクスチャ生成に使用されたシード。
</ResponseField>

<ResponseField name="timings" type="object">
  エンドツーエンドの所要時間の内訳（秒）。
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "image_url": "https://storage.googleapis.com/falserverless/gallery/patina-blog-hero-render.png"
}
```

### 出力

```json theme={null}
{
  "images": [
    {
      "map_type": "basecolor",
      "url": "https://example.invalid/fal/patina/basecolor.png"
    },
    {
      "map_type": "normal",
      "url": "https://example.invalid/fal/patina/normal.png"
    },
    {
      "map_type": "roughness",
      "url": "https://example.invalid/fal/patina/roughness.png"
    }
  ],
  "prompt": "weathered copper roof tiles",
  "seed": 1234567,
  "timings": {
    "inference": 6.25
  }
}
```

## 出荷前の確認

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>
