From 58a539eb54b3486bc4f96fd1100f41cd60652801 Mon Sep 17 00:00:00 2001 From: wei-hai Date: Thu, 23 Jul 2026 09:23:52 -0700 Subject: [PATCH] docs: document get_download_url() and fix API-key/host placeholders The README documented to_file() but not get_download_url(), a public Output method. Adds a concise 'Downloading outputs' section covering to_file/to_bytes, range reads, and get_download_url() (self-authorizing signed URL on cloud, content endpoint on self-hosted). Also corrects two inaccurate placeholders: the API key is comfyui-* (not ck_*), and the __init__ docstring pointed at cloud.comfy.org (api.comfy.org is the Cloud host). Verified live against staging and prod. Co-Authored-By: Claude Opus 4.8 --- README.md | 35 +++++++++++++++++++++++++++++++---- src/comfy_sdk/__init__.py | 2 +- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index dc4a4aa..ce516f6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ deployment — only the base URL and an optional API key change. from comfy_sdk import Comfy client = Comfy("http://127.0.0.1:8189") # self-hosted, no key -# client = Comfy("https://api.comfy.org", api_key="ck_...") # Comfy Cloud +# client = Comfy("https://api.comfy.org", api_key="comfyui-...") # Comfy Cloud wf = client.workflows.from_file("workflow_api.json") @@ -57,8 +57,8 @@ needs the optional `pil` extra: `pip install -e ".[pil]"`. | Serverless deployment | `https://.comfy.org` | Required | ```python -client = Comfy("http://127.0.0.1:8189") # self-hosted -client = Comfy("https://api.comfy.org", api_key="ck_...") # Comfy Cloud / serverless +client = Comfy("http://127.0.0.1:8189") # self-hosted +client = Comfy("https://api.comfy.org", api_key="comfyui-...") # Comfy Cloud / serverless ``` `AsyncComfy` takes the same two arguments. A key is only ever attached to @@ -72,7 +72,7 @@ analytics) — this is request metadata only; no other data is collected. Pass attribute its own traffic: ```python -client = Comfy("https://api.comfy.org", api_key="ck_...", client_info="my-app") +client = Comfy("https://api.comfy.org", api_key="comfyui-...", client_info="my-app") ``` ## Partner (API) node auth @@ -140,6 +140,33 @@ live UI feedback, and `wait()`/`result()`/`run()` for the definitive answer. output handles regardless of which node produced them (`job.get_outputs(node_id)` filters to one node, as in the quickstart above). +## Downloading outputs + +A finished job exposes its results as `Output` handles — `job.outputs`, or +`job.get_outputs(node_id)` to filter to one node. Each output is an asset you +can pull down whichever way suits the caller: + +```python +out = job.get_outputs("13")[0] +out.to_file("result.png") # stream to disk in chunks +data = out.to_bytes() # buffer into memory +out.to_file("head.png", range=(0, 1023)) # range-aware: first 1 KiB only +``` + +`get_download_url()` hands back a fetchable URL instead of transferring the +bytes through your process — give it to a browser, a CDN, or another service: + +```python +link = out.get_download_url() # DownloadUrl(url=..., expires_at=...) +``` + +On Comfy Cloud / serverless the URL is a short-lived, **self-authorizing** +signed storage URL: whoever holds it can read the asset until `expires_at` +with no API key of their own. On a self-hosted proxy it's the content endpoint +(normal auth still applies) and `expires_at` is `None`. It works on every +backend and never downloads the bytes first. (`AsyncOutput` mirrors all of the +above with `await`.) + ## Sync and async `Comfy` and `AsyncComfy` expose the identical surface — swap the import and diff --git a/src/comfy_sdk/__init__.py b/src/comfy_sdk/__init__.py index d308429..49c7237 100644 --- a/src/comfy_sdk/__init__.py +++ b/src/comfy_sdk/__init__.py @@ -13,7 +13,7 @@ from comfy_sdk import Comfy client = Comfy("http://127.0.0.1:8189") # self-hosted, no key - # client = Comfy("https://cloud.comfy.org", api_key="ck_...") + # client = Comfy("https://api.comfy.org", api_key="comfyui-...") wf = client.workflows.from_file("workflow_api.json") asset = client.assets.from_file("photo.png") # lazy; uploaded on use