Skip to content

feat(run): add --api-key / COMFY_API_KEY for API Nodes#451

Merged
bigcat88 merged 1 commit into
mainfrom
feat/x-api-key-support
May 15, 2026
Merged

feat(run): add --api-key / COMFY_API_KEY for API Nodes#451
bigcat88 merged 1 commit into
mainfrom
feat/x-api-key-support

Conversation

@bigcat88

@bigcat88 bigcat88 commented May 15, 2026

Copy link
Copy Markdown
Contributor
  • Adds --api-key flag and COMFY_API_KEY env var to comfy run for forwarding the Comfy API key to API Nodes (Partner Nodes such as OpenAI, Recraft, Gemini, etc.).
  • Embeds the key in extra_data.api_key_comfy_org of the POST /prompt body, matching ComfyUI_frontend/src/scripts/api.ts. ComfyUI threads it to each Partner Node as Hidden.api_key_comfy_org.
  • Whitespace in the key is stripped; whitespace-only collapses to no-key. Value is redacted in Mixpanel telemetry via a new SENSITIVE_TRACKING_KEYS filter.

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2c239665-8556-42a8-a998-c30732bb2a7b

📥 Commits

Reviewing files that changed from the base of the PR and between 2a0f4c2 and d65ac96.

📒 Files selected for processing (6)
  • comfy_cli/cmdline.py
  • comfy_cli/command/run.py
  • comfy_cli/tracking.py
  • tests/comfy_cli/command/test_command.py
  • tests/comfy_cli/command/test_run.py
  • tests/comfy_cli/test_tracking.py

📝 Walkthrough

Walkthrough

The PR adds end-to-end API key support to the comfy run command. Users can provide credentials via --api-key flag or COMFY_API_KEY environment variable. The value is normalized and piped through the execute pipeline into WorkflowExecution, which embeds it in queued workflow requests. Separately, telemetry tracking is updated to redact the API key, preventing secrets from being sent to analytics—no "key" oversight here!

Changes

API Key Propagation and Telemetry Protection

Layer / File(s) Summary
CLI Parameter Acceptance and Normalization
comfy_cli/cmdline.py, tests/comfy_cli/command/test_command.py
The run command now accepts api_key via --api-key flag or COMFY_API_KEY environment variable. Whitespace is trimmed and empty values normalize to None. Tests verify env var usage, flag override, and whitespace handling.
Workflow Execution and Request Embedding
comfy_cli/command/run.py, tests/comfy_cli/command/test_run.py
The execute() function signature adds api_key parameter and passes it to WorkflowExecution constructor. When queueing workflows, WorkflowExecution embeds the api_key in the request payload under extra_data["api_key_comfy_org"]. Tests validate request composition and propagation through UI workflow execution.
Telemetry Redaction for Secrets
comfy_cli/tracking.py, tests/comfy_cli/test_tracking.py
Introduces SENSITIVE_TRACKING_KEYS constant marking api_key as redactable. The track_command() decorator filters kwargs to replace sensitive values with "<redacted>" before reaching the tracking provider. Tests verify redaction behavior and None preservation.
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/x-api-key-support
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/x-api-key-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented May 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main     #451      +/-   ##
==========================================
+ Coverage   80.65%   80.96%   +0.30%     
==========================================
  Files          36       36              
  Lines        5216     5222       +6     
==========================================
+ Hits         4207     4228      +21     
+ Misses       1009      994      -15     
Files with missing lines Coverage Δ
comfy_cli/cmdline.py 61.59% <100.00%> (+3.56%) ⬆️
comfy_cli/command/run.py 80.68% <100.00%> (+2.52%) ⬆️
comfy_cli/tracking.py 89.47% <100.00%> (+0.14%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bigcat88 bigcat88 marked this pull request as ready for review May 15, 2026 13:11
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels May 15, 2026
@bigcat88 bigcat88 merged commit b7fb203 into main May 15, 2026
15 checks passed
@bigcat88 bigcat88 deleted the feat/x-api-key-support branch May 15, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant