[Feature Request] Allow setting BFL API endpoint and key directly in the workflow
Motivation:
This feature proposal aims to provide more flexibility for users who run ComfyUI in various environments, especially on cloud platforms where they might not have direct access to modify configuration files.
- Cloud Environment Constraints: Some users operate ComfyUI in environments provided by cloud vendors. In such scenarios, they often lack the permissions to modify the node's configuration files directly. Their primary method of interaction is by submitting workflows with all necessary parameters embedded.
- Support for Alternative Endpoints: Users may need to connect to non-official or third-party FLUX API endpoints. The current implementation, which relies on a single, statically configured endpoint, makes this difficult.
Allowing the API endpoint and credentials to be set within the workflow itself would solve these issues and make the nodes more versatile.
Proposed Implementation:
I suggest the following changes to enable this functionality while maintaining backward compatibility:
-
New
CreateBFLConfigNode:- Introduce a new node,
CreateBFLConfig, which would have two input fields:base_urlandx_key. - This node would output a
ConfigLoaderobject containing this information.
- Introduce a new node,
-
Modify API Call Nodes:
- Update all existing API call nodes to include an optional
configinput. - If this
configinput is connected, the node will use theConfigLoaderobject to retrieve the API endpoint and key. - If the input is not connected, the node will fall back to the original method of reading from the
config.inifile, ensuring backward compatibility.
- Update all existing API call nodes to include an optional
-
Refactor Authentication Header Logic:
- Refactor the code that reads the API key. Instead of reading the
X_KEYdirectly from environment variables or a config file, it should be accessed via a newmake_headers()method within theConfigLoaderobject. - This
make_headers()method should add both theX-KEYheader (for official BFL compatibility) and anAuthorization: Bearer <key>header to support a wider range of third-party FLUX API providers.
- Refactor the code that reads the API key. Instead of reading the
Potential Risks:
It is important to acknowledge that embedding API keys directly into workflow files could lead to accidental exposure if the image metadata (which often includes the workflow) is shared publicly. However, it can be assumed that users who choose this method are aware of the inherent security risks and will handle their workflows and generated images appropriately. A note in the node's documentation could also serve as a helpful warning.
Next Steps:
I have already implemented these features in my personal fork: Duanyll/ComfyUI-FLUX-BFL-API.
I am happy to open a pull request to contribute this functionality to the main repository. Please let me know if this proposal is aligned with the project's direction.
Thank you for your consideration!
Thank you, @Duanyll.
Thank you for taking the time to outline this proposal in such detail — I really appreciate the clear motivation and backward-compatible design.
I’ve just implemented the requested functionality on my side, although I haven’t been able to run a full test yet. If you have any feedback or further suggestions, I’d be happy to hear them.
Best regards,