> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-stale2000-router-model-pages.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Comfy Router quickstart

> From nothing to a generated image in about five minutes, in Python and TypeScript, against the Comfy Router.

<div className="router-quickstart-marker" />

Comfy Router lets you call partner models through `https://api.comfy.org` with one Comfy API key. Send the model's input to `POST /v2/models/{provider}/{model}` and wait for the finished result. This example generates an image with `bfl/flux-2-pro`.

<Steps>
  <Step title="Create an API key">
    Create a key in [your Comfy workspace](https://platform.comfy.org/profile/api-keys). In a Bash-compatible terminal, set:

    ```bash theme={null}
    export COMFY_API_KEY="comfyui-..."
    ```

    Keep API keys on your server or in your local environment. These examples are for a terminal or server, not browser JavaScript.
  </Step>

  <Step title="Save a key for this request">
    Generate this value once for this image. If you retry the same request, reuse it.

    ```bash theme={null}
    export COMFY_REQUEST_KEY="$(uuidgen)"
    ```

    If `uuidgen` is unavailable, use another UUID generator. Use a new key when you start a new image.
  </Step>

  <Step title="Generate an image">
    Choose your language and run the example. Image generation can take a few minutes.

    <CodeGroup>
      ```bash cURL theme={null}
      curl --max-time 660 \
        https://api.comfy.org/v2/models/bfl/flux-2-pro \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $COMFY_REQUEST_KEY" \
        -H "Content-Type: application/json" \
        -d '{"prompt": "a red teapot on a windowsill, morning light"}'
      ```

      ```python Python theme={null}
      # Python 3.10+
      # Install: python -m pip install "comfy-sdk>=0.1.9"
      # Save as quickstart.py, then run: python quickstart.py

      import os

      from comfy_sdk import Comfy

      # Comfy reads COMFY_API_KEY from the environment.
      with Comfy() as client:
          result = client.models.run(
              "bfl/flux-2-pro",
              {"prompt": "a red teapot on a windowsill, morning light"},
              idempotency_key=os.environ["COMFY_REQUEST_KEY"],
              timeout=660.0,
          )

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

      ```typescript TypeScript theme={null}
      // Node.js 22+
      // Install: npm install @comfyorg/sdk@^0.1.9 --save-dev tsx
      // Save as quickstart.mts, then run: npx tsx quickstart.mts

      import { comfy } from "@comfyorg/sdk";

      // Comfy reads COMFY_API_KEY from the environment.
      type FluxResult = { result: { sample: string } };
      const idempotencyKey = process.env.COMFY_REQUEST_KEY;
      if (!idempotencyKey) throw new Error("Set COMFY_REQUEST_KEY first.");

      const { data } = await comfy.models.run<FluxResult>(
        "bfl/flux-2-pro",
        { prompt: "a red teapot on a windowsill, morning light" },
        { idempotencyKey, timeoutMs: 660_000 },
      );

      console.log("image:", data.result.sample);
      ```
    </CodeGroup>

    Both SDKs read `COMFY_API_KEY` from the environment.
  </Step>

  <Step title="Read and save the result">
    For this model, the image URL is at `result.sample` in the response body. An abbreviated response looks like this; the URL below is illustrative:

    ```json theme={null}
    {
      "status": "Ready",
      "result": { "sample": "https://example.com/generated-image.jpeg" }
    }
    ```

    Open the returned URL or download it:

    ```bash theme={null}
    curl --fail --location "PASTE_IMAGE_URL_HERE" --output teapot.jpg
    ```

    Download promptly. Router can rehost BFL assets on Comfy storage, but URLs expire and a replay does not renew them. A failed rehost can leave a shorter-lived provider URL. See [result assets](/development/comfy-router/reference#result-assets).
  </Step>
</Steps>

## Choose a model

[Browse the models available through Comfy Router](/development/comfy-router/models), inspect their inputs, then replace the model ID in this example.
