> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-matt-sdk-0-3-0-run-kind.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Flux 1.1 Pro Ultra Image with Comfy Router

> Python, TypeScript and cURL snippets for calling FLUX 1.1 [pro] Ultra and FLUX 1.1 [pro] over HTTP through Comfy Router, plus the request fields and the result shape

API Reference for Flux 1.1 Pro Ultra Image. FLUX 1.1 \[pro] is a text-to-image model from Black Forest Labs. Ultra mode generates images at up to 4MP resolution.

## Quick start

Create a key in [your Comfy workspace](https://platform.comfy.org/profile/api-keys) and export it as `COMFY_API_KEY`. The Python and TypeScript snippets use the Comfy SDKs (`pip install comfy-sdk`, `npm install @comfyorg/sdk`); the cURL snippet is the same call over raw HTTP.

Pick the model you want to call. Everything below, from the snippets to the schema and examples, follows your choice.

<Tabs>
  <Tab title="FLUX 1.1 [pro] Ultra">
    **Model ID:** `bfl/flux-pro-1.1-ultra`

    **Endpoint:** `POST https://api.comfy.org/v2/models/bfl/flux-pro-1.1-ultra`

    <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(
                  "bfl/flux-pro-1.1-ultra",
                  {
                      "prompt": "a single red maple leaf on a plain white background, studio lighting",
                      "aspect_ratio": "16:9",
                      "raw": False,
                  },
              )

          print("image:", result["result"]["sample"])
          ```

          ```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 = { result: { sample: string } };
          const result = await comfy.models.run<Result>("bfl/flux-pro-1.1-ultra", {
            prompt: "a single red maple leaf on a plain white background, studio lighting",
            aspect_ratio: "16:9",
            raw: false,
          });
          if (result.kind !== "json") throw new Error("expected a JSON result");

          console.log("image:", result.data.result.sample);
          ```

          ```bash cURL theme={null}
          curl https://api.comfy.org/v2/models/bfl/flux-pro-1.1-ultra \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"prompt\": \"a single red maple leaf on a plain white background, studio lighting\", \"aspect_ratio\": \"16:9\", \"raw\": false}"
          ```
        </CodeGroup>
      </Tab>

      <Tab title="Queue and collect later">
        <Note>
          Queued delivery is rolling out per workspace. Until yours is enabled, the submit route answers `403` with `X-Comfy-Error-Type: not_enabled`. Nothing about the request is wrong, and the same body works through the synchronous route in the meantime.
        </Note>

        The same body, sent to `POST https://api.comfy.org/v2/models/bfl/flux-pro-1.1-ultra/requests`. Router answers `201` with a `request_id` as soon as the run is admitted, and the result is collected once it is ready, from this process or another one. [Queued delivery](/development/comfy-router/queue) walks through status, cancellation and collection.

        <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(
                  "bfl/flux-pro-1.1-ultra",
                  {
                      "prompt": "a single red maple leaf on a plain white background, studio lighting",
                      "aspect_ratio": "16:9",
                      "raw": False,
                  },
              )
              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["result"]["sample"])
          ```

          ```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 = { result: { sample: string } };
          const handle = await comfy.models.submit<Result>("bfl/flux-pro-1.1-ultra", {
            prompt: "a single red maple leaf on a plain white background, studio lighting",
            aspect_ratio: "16:9",
            raw: false,
          });
          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.result.sample);
          ```

          ```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/bfl/flux-pro-1.1-ultra/requests \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"prompt\": \"a single red maple leaf on a plain white background, studio lighting\", \"aspect_ratio\": \"16:9\", \"raw\": false}"

          # 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/bfl/flux-pro-1.1-ultra/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/bfl/flux-pro-1.1-ultra/requests/$REQUEST_ID \
            -H "X-API-Key: $COMFY_API_KEY"
          ```
        </CodeGroup>
      </Tab>
    </Tabs>

    <h2>Schema</h2>

    <h3>Input</h3>

    <ParamField body="aspect_ratio" type="string" default="&#x22;16:9&#x22;">
      Aspect ratio of the image between 21:9 and 9:21, e.g. 16:9.
    </ParamField>

    <ParamField body="image_prompt" type="string">
      Optional base64-encoded image to remix.
    </ParamField>

    <ParamField body="image_prompt_strength" type="number" default="0.1">
      Blend between the prompt and the image prompt, from 0 (prompt only) to 1 (image prompt only).

      Range: `0` to `1`
    </ParamField>

    <ParamField body="output_format" type="string" default="&#x22;jpeg&#x22;">
      Output image format.

      Possible values: `jpeg`, `png`, `webp`
    </ParamField>

    <ParamField body="prompt" type="string" required>
      Text prompt for image generation.
    </ParamField>

    <ParamField body="prompt_upsampling" type="boolean" default="false">
      Whether to upsample the prompt. If active, the prompt is automatically modified for more creative generation.
    </ParamField>

    <ParamField body="raw" type="boolean" default="false">
      Generate less processed, more natural-looking images.
    </ParamField>

    <ParamField body="safety_tolerance" type="integer" default="2">
      Tolerance level for input and output moderation, between 0 (most strict) and 6 (least strict).

      Range: `0` to `6`
    </ParamField>

    <ParamField body="seed" type="integer">
      Optional seed for reproducibility. A random seed is used when omitted.
    </ParamField>

    <ParamField body="webhook_secret" type="string">
      Optional secret for webhook signature verification.
    </ParamField>

    <ParamField body="webhook_url" type="string (uri)">
      URL to receive webhook notifications.

      Format: `uri`
    </ParamField>

    Generated from the schema Router serves at `GET /v2/models/bfl/flux-pro-1.1-ultra/openapi.json`, the same document it validates a call against before the request reaches the provider.

    <h3>Output</h3>

    <ResponseField name="cost" type="number">
      Provider-reported cost in credits, populated once the task is Ready.

      Format: `float`
    </ResponseField>

    <ResponseField name="id" type="string" required>
      BFL task identifier.
    </ResponseField>

    <ResponseField name="progress" type="number">
      Optional generation progress reported by BFL.

      Range: `0` to `1`

      Format: `float`
    </ResponseField>

    <ResponseField name="result" type="object" required>
      The finished generation. Not nullable here: this component's `required` entry is a promise that a `200` carries the result, and a nullable `result` would reduce it to a key-presence check.
    </ResponseField>

    <ResponseField name="result.cost" type="number">
      Provider-reported cost of the generation. This is BFL's number, not the Comfy charge.

      Format: `double`
    </ResponseField>

    <ResponseField name="result.duration" type="number">
      Provider-reported generation duration in seconds.

      Format: `double`
    </ResponseField>

    <ResponseField name="result.end_time" type="number">
      Provider-reported completion time of the generation, in seconds since the Unix epoch. `double` for the same reason as `start_time`.

      Format: `double`
    </ResponseField>

    <ResponseField name="result.prompt" type="string">
      The prompt the generation actually ran, after any prompt upsampling.
    </ResponseField>

    <ResponseField name="result.sample" type="string (uri)">
      Signed URL for the generated asset. Router re-hosts the asset onto Comfy storage and rewrites this field, so it is normally a Comfy-hosted URL valid for up to 24 hours - signed for 24 hours when minted, and replayed from a 23-hour memo, so a later poll can hand back one with as little as an hour left; a leaf whose re-host could not be performed keeps BFL's own short-lived delivery URL instead - roughly two hours for video, roughly ten minutes for images. Either way the link expires, so download the asset rather than storing the URL.

      Format: `uri`
    </ResponseField>

    <ResponseField name="result.seed" type="integer">
      The seed the generation used, whether supplied or chosen by the provider. Declared `int64` because BFL returns seeds above 2^31 (e.g. 2784347701), which an unformatted `integer` generates as a 32-bit field in many SDK generators.

      Format: `int64`
    </ResponseField>

    <ResponseField name="result.start_time" type="number">
      Provider-reported start time of the generation, in seconds since the Unix epoch. `double`, not `float`: float32 spacing near a present-day epoch value is \~128 seconds, which collapses a whole generation's span to a single decoded value.

      Format: `double`
    </ResponseField>

    <ResponseField name="status" type="string" required>
      Task status: Pending, Reasoning, Generating, Ready, Request Moderated, Content Moderated, Error, or Task not found.
    </ResponseField>

    <h2>Examples</h2>

    <h3>Input</h3>

    ```json theme={null}
    {
      "prompt": "a single red maple leaf on a plain white background, studio lighting",
      "aspect_ratio": "16:9",
      "raw": false
    }
    ```

    <h3>Output</h3>

    ```json theme={null}
    {
      "id": "0a1b2c3d-...",
      "status": "Ready",
      "result": {
        "sample": "https://.../out.jpeg",
        "prompt": "a single red maple leaf on a plain white background, studio lighting",
        "seed": 1234567890
      }
    }
    ```

    The URL is temporary. Download the image promptly if you need to keep it.
  </Tab>

  <Tab title="FLUX 1.1 [pro]">
    **Model ID:** `bfl/flux-pro-1.1`

    **Endpoint:** `POST https://api.comfy.org/v2/models/bfl/flux-pro-1.1`

    <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(
                  "bfl/flux-pro-1.1",
                  {
                      "prompt": "a single red maple leaf on a plain white background, studio lighting",
                      "width": 1024,
                      "height": 768,
                  },
              )

          print("image:", result["result"]["sample"])
          ```

          ```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 = { result: { sample: string } };
          const result = await comfy.models.run<Result>("bfl/flux-pro-1.1", {
            prompt: "a single red maple leaf on a plain white background, studio lighting",
            width: 1024,
            height: 768,
          });
          if (result.kind !== "json") throw new Error("expected a JSON result");

          console.log("image:", result.data.result.sample);
          ```

          ```bash cURL theme={null}
          curl https://api.comfy.org/v2/models/bfl/flux-pro-1.1 \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"prompt\": \"a single red maple leaf on a plain white background, studio lighting\", \"width\": 1024, \"height\": 768}"
          ```
        </CodeGroup>
      </Tab>

      <Tab title="Queue and collect later">
        <Note>
          Queued delivery is rolling out per workspace. Until yours is enabled, the submit route answers `403` with `X-Comfy-Error-Type: not_enabled`. Nothing about the request is wrong, and the same body works through the synchronous route in the meantime.
        </Note>

        The same body, sent to `POST https://api.comfy.org/v2/models/bfl/flux-pro-1.1/requests`. Router answers `201` with a `request_id` as soon as the run is admitted, and the result is collected once it is ready, from this process or another one. [Queued delivery](/development/comfy-router/queue) walks through status, cancellation and collection.

        <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(
                  "bfl/flux-pro-1.1",
                  {
                      "prompt": "a single red maple leaf on a plain white background, studio lighting",
                      "width": 1024,
                      "height": 768,
                  },
              )
              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["result"]["sample"])
          ```

          ```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 = { result: { sample: string } };
          const handle = await comfy.models.submit<Result>("bfl/flux-pro-1.1", {
            prompt: "a single red maple leaf on a plain white background, studio lighting",
            width: 1024,
            height: 768,
          });
          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.result.sample);
          ```

          ```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/bfl/flux-pro-1.1/requests \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"prompt\": \"a single red maple leaf on a plain white background, studio lighting\", \"width\": 1024, \"height\": 768}"

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

    <h2>Schema</h2>

    <h3>Input</h3>

    <ParamField body="height" type="integer" default="768">
      Height of the generated image in pixels. Must be a multiple of 32.

      Range: `256` to `1440`
    </ParamField>

    <ParamField body="image_prompt" type="string">
      Optional base64-encoded image to use with FLUX Redux.
    </ParamField>

    <ParamField body="output_format" type="string" default="&#x22;jpeg&#x22;">
      Output image format.

      Possible values: `jpeg`, `png`, `webp`
    </ParamField>

    <ParamField body="prompt" type="string" required>
      Text prompt for image generation.
    </ParamField>

    <ParamField body="prompt_upsampling" type="boolean" default="false">
      Whether to upsample the prompt. If active, the prompt is automatically modified for more creative generation.
    </ParamField>

    <ParamField body="safety_tolerance" type="integer" default="2">
      Tolerance level for input and output moderation, between 0 (most strict) and 6 (least strict).

      Range: `0` to `6`
    </ParamField>

    <ParamField body="seed" type="integer">
      Optional seed for reproducibility. A random seed is used when omitted.
    </ParamField>

    <ParamField body="webhook_secret" type="string">
      Optional secret for webhook signature verification.
    </ParamField>

    <ParamField body="webhook_url" type="string (uri)">
      URL to receive webhook notifications.

      Format: `uri`
    </ParamField>

    <ParamField body="width" type="integer" default="1024">
      Width of the generated image in pixels. Must be a multiple of 32.

      Range: `256` to `1440`
    </ParamField>

    Generated from the schema Router serves at `GET /v2/models/bfl/flux-pro-1.1/openapi.json`, the same document it validates a call against before the request reaches the provider.

    <h3>Output</h3>

    <ResponseField name="cost" type="number">
      Provider-reported cost in credits, populated once the task is Ready.

      Format: `float`
    </ResponseField>

    <ResponseField name="id" type="string" required>
      BFL task identifier.
    </ResponseField>

    <ResponseField name="progress" type="number">
      Optional generation progress reported by BFL.

      Range: `0` to `1`

      Format: `float`
    </ResponseField>

    <ResponseField name="result" type="object" required>
      The finished generation. Not nullable here: this component's `required` entry is a promise that a `200` carries the result, and a nullable `result` would reduce it to a key-presence check.
    </ResponseField>

    <ResponseField name="result.cost" type="number">
      Provider-reported cost of the generation. This is BFL's number, not the Comfy charge.

      Format: `double`
    </ResponseField>

    <ResponseField name="result.duration" type="number">
      Provider-reported generation duration in seconds.

      Format: `double`
    </ResponseField>

    <ResponseField name="result.end_time" type="number">
      Provider-reported completion time of the generation, in seconds since the Unix epoch. `double` for the same reason as `start_time`.

      Format: `double`
    </ResponseField>

    <ResponseField name="result.prompt" type="string">
      The prompt the generation actually ran, after any prompt upsampling.
    </ResponseField>

    <ResponseField name="result.sample" type="string (uri)">
      Signed URL for the generated asset. Router re-hosts the asset onto Comfy storage and rewrites this field, so it is normally a Comfy-hosted URL valid for up to 24 hours - signed for 24 hours when minted, and replayed from a 23-hour memo, so a later poll can hand back one with as little as an hour left; a leaf whose re-host could not be performed keeps BFL's own short-lived delivery URL instead - roughly two hours for video, roughly ten minutes for images. Either way the link expires, so download the asset rather than storing the URL.

      Format: `uri`
    </ResponseField>

    <ResponseField name="result.seed" type="integer">
      The seed the generation used, whether supplied or chosen by the provider. Declared `int64` because BFL returns seeds above 2^31 (e.g. 2784347701), which an unformatted `integer` generates as a 32-bit field in many SDK generators.

      Format: `int64`
    </ResponseField>

    <ResponseField name="result.start_time" type="number">
      Provider-reported start time of the generation, in seconds since the Unix epoch. `double`, not `float`: float32 spacing near a present-day epoch value is \~128 seconds, which collapses a whole generation's span to a single decoded value.

      Format: `double`
    </ResponseField>

    <ResponseField name="status" type="string" required>
      Task status: Pending, Reasoning, Generating, Ready, Request Moderated, Content Moderated, Error, or Task not found.
    </ResponseField>

    <h2>Examples</h2>

    <h3>Input</h3>

    ```json theme={null}
    {
      "prompt": "a single red maple leaf on a plain white background, studio lighting",
      "width": 1024,
      "height": 768
    }
    ```

    <h3>Output</h3>

    ```json theme={null}
    {
      "id": "0a1b2c3d-...",
      "status": "Ready",
      "result": {
        "sample": "https://.../out.jpeg",
        "prompt": "a single red maple leaf on a plain white background, studio lighting",
        "seed": 1234567890
      }
    }
    ```

    The URL is temporary. Download the image promptly if you need to keep it.
  </Tab>
</Tabs>

## Before you ship

The SDKs create an `Idempotency-Key` and reuse it for automatic retries. For manual retries, reuse the original key. Router can hold the connection for up to 10 minutes.

When a request fails, Router sends an `X-Comfy-Error-Type` response header explaining why. A `422` means Router rejected the input before calling the provider. Download generated assets promptly because [result URLs can expire](/development/comfy-router/reference#result-assets).

<CardGroup cols={3}>
  <Card title="Headers" icon="list" href="/development/comfy-router/headers">
    Authentication, idempotency, request IDs, error buckets, retry pacing, spend limits.
  </Card>

  <Card title="Using the Router API" icon="code" href="/development/comfy-router/api">
    Model discovery, validation errors, retries, and billing.
  </Card>

  <Card title="Limitations" icon="triangle-exclamation" href="/development/comfy-router/limitations">
    What Router does not do today, and what to use instead.
  </Card>
</CardGroup>
