Comfy-Org / Comfy-Org/ComfyUI

Use API_KEY_COMFY_ORG env var for server-side API key in _helpers.py

Open
#12,542 0 comments 0 reactions 0 assignees View on GitHub
Feature
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 7h
Merged PRs (30d)
158

Description

### Feature Idea

Hey,

For most AI provider modules (openai, replicate etc), API keys are typically provided via environment variables rather than passed from the frontend. This approach makes deployments cleaner, simplifies configuration, and aligns ComfyUI with common practices.

**File:** `comfy_api_nodes/util/_helpers.py`

**Proposed change:**

* Check for `API_KEY_COMFY_ORG` in the environment first.
* Use it as the `X-API-KEY` header if present.
* Fall back to `node_cls.hidden` only if the env var is missing.

**Example implementation:**

```python
import os

def get_auth_header(node_cls):
env_api_key = os.getenv("API_KEY_COMFY_ORG")

if env_api_key:
return {"X-API-KEY": env_api_key}

if node_cls.hidden.auth_token_comfy_org:
return {"Authorization": f"Bearer {node_cls.hidden.auth_token_comfy_org}"}

if node_cls.hidden.api_key_comfy_org:
return {"X-API-KEY": node_cls.hidden.api_key_comfy_org}

return {}
```

This preserves self-hosted workflows while providing a standard environment-variable method for API keys, consistent with other AI provider modules. Unless I missed some other risk doing this?

Cheers,
Joe

### Existing Solutions

_No response_

### Other

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.