A Node.js server exposing two simple API endpoints for generating images using the Flux2.c library (antirez/flux2.c).
- Flux2.c is optimized for Apple Silicon GPUs (fastest execution) but runs very well on other GPU's of course
- Low memory footprint (~16GB peak), delivering high-quality results.
Before proceeding, ensure you have:
- Installed Flux2.c and followed the official installation guide.
- Apple Silicon users: Compile with
make mpsfor MPS acceleration. - Run Flux for the first time to download the Klein model (~16GB).
- Test a simple image generation to verify setup.
git clone <https://github.com/your-repo/flux2c-api.git>
cd flux2c-api
Adjust the flux binary path in server.js or copy "server" content in flux2.c directory
npm install
node server.js
The API will be available at:
- Open your browser to
<http://localhost:3000>. - Use the interface to generate images (default: 512x512px).
- Performance Note: On an M2 Max MacStudio with 32GB RAM, generation may take ~3 minutes.
-
Copy
Flux2c.pyinto your Tools section in OpenWeb UI and save it. -
Set you FLUX_API_PUBLIC in Valves, your public IP or domain or localhost.
To enable external downloads, configure a reverse proxy (e.g., Nginx) to forward /outputs requests to your Node server:
location /flux-outputs {
proxy_pass <http://localhost:3000>;
}
(Replace flux-outputs with your preferred path.)
Create a custom model with these features:
- Flux2 tool enabled by default
- Disable citations if you don't want comments or log after image generation
- Apply this system prompt or something similar:
"When the user requests an image, they will provide a description of the image to be generated. You must always use the Flux2 tool (generate_image) to generate the image. Your response must consist exclusively of the generated image. Do not include any additional text, explanations, comments, confirmations, or metadata. Do not ask questions. Do not provide alternative outputs. Only return the image produced by the tool."