Skip to content

feat: add workflows.from_example and client.check for a first run - #235

Draft
deepme987 wants to merge 1 commit into
mainfrom
deepme987/sdk-onboarding-examples
Draft

deepme987 wants to merge 1 commit into
mainfrom
deepme987/sdk-onboarding-examples

Conversation

@deepme987

Copy link
Copy Markdown
Contributor

What

Two additions for a developer's first five minutes with the SDK:

  • client.workflows.from_example(name, **inputs) builds one of three built-in workflows: text-to-image (Z-Image Turbo), image-to-video and text-to-video (Wan 2.2 5B). Inputs have names (prompt, seed, image, width, ...), so nobody has to know node ids. client.workflows.examples() lists them all.
  • client.check() (sync and async) confirms the key and the address without running anything. It returns CheckResult(base_url, authenticated), raises Unauthorized for a rejected key, and raises ComfyError(code="not_a_comfy_api") when COMFY_BASE_URL points at something that isn't a v2 deployment.

Why

Today the first thing a new user is told to run is client.workflows.from_file("workflow_api.json"). They don't have that file, so the snippet fails locally before it reaches us. With this change the copy-paste snippet can run without any changes:

from comfy_sdk import Comfy

client = Comfy()          # COMFY_API_KEY
client.check()
job = client.run(client.workflows.from_example("text-to-image", prompt="a lighthouse at dusk"))
job.outputs[0].to_file("lighthouse.png")

How check() works

There's no whoami or balance route in the v2 contract. check() looks up the job id 00000000-0000-0000-0000-000000000000:

  • That lookup is authenticated like every v2 route, creates nothing and costs nothing.
  • Its only healthy answer is 404 job_not_found.
  • A bare 404, or a 200 that isn't JSON (a web page), means the address is wrong, not the key.

It works the same on Cloud, serverless and the self-hosted proxy. It doesn't check balance or subscription. That needs a server route.

Verified live on Comfy Cloud

Result
check() with a valid key CheckResult(base_url='https://cloud.comfy.org', authenticated=True) in 0.26s
check() with a bogus key Unauthorized
text-to-image succeeded, 7.2s
image-to-video (fed the PNG above) succeeded, 53.6s, 1280x704 MP4
text-to-video succeeded, 51.8s

Note: run() on Cloud currently fails at the first poll for every SDK version. Cloud returns http:// follow-up URLs, and the SDK correctly won't send the key there. The fix is server-side and in review. The live runs above simulated that fix by rewriting the URLs in the test harness. This PR changes nothing about follow-up URLs.

Tests

  • tests/test_check.py: pass, keyless, rejected key, bare 404, web page, a 200 job for the probe id, 5xx passthrough, and the key never appearing in the result. Each runs on both sync and async.
  • tests/test_examples.py: every input lands on an existing node and field, every link resolves, each example ends in the right save node, plus naming, defaults, seed randomness, template immutability, error messages, and submit through the stub.
  • ruff, ruff format, mypy, the hygiene check and the full suite (1316 passed) all pass locally.

Companion: the same API in the TypeScript SDK (linked below once open).

from_example builds one of three built-in workflows (text-to-image,
image-to-video, text-to-video) with named inputs, so a new user can run
something before they have a workflow_api.json of their own.

check() confirms the key and the address with one authenticated read
that runs nothing: a lookup of a job id no deployment issues, whose only
healthy answer is 404 job_not_found.
@deepme987 deepme987 self-assigned this Nov 16, 2026
@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@deepme987

Copy link
Copy Markdown
Contributor Author

Companion TypeScript PR: Comfy-Org/comfy-typescript-sdk#221 (same API, graphs generated from this PR's definitions).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant