MFLUX is a line-by-line MLX port of several state-of-the-art generative image models from the Huggingface Diffusers and Huggingface Transformers libraries. All models are implemented from scratch in MLX, using only tokenizers from the Huggingface Transformers library. MFLUX is purposefully kept minimal and explicit, @karpathy style.
After installation, the following command shows all available MFLUX CLI commands:
uv tool list
To generate your first image using, for example, the z-image-turbo model, run
mflux-generate-z-image-turbo \
--prompt "A puffin standing on a cliff" \
--width 1280 \
--height 500 \
--seed 42 \
--steps 9 \
-q 8
The first time you run this, the model will automatically download which can take some time. See the model section for the different options and features, and the common README for shared CLI patterns and examples.
Python API
Create a standalone generate.py script with inline uv dependencies:
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "mflux",
# ]
# ///
from mflux.models.z_image import ZImageTurbo
model = ZImageTurbo(quantize=8)
image = model.generate_image(
prompt="A puffin standing on a cliff",
seed=42,
num_inference_steps=9,
width=1280,
height=500,
)
image.save("puffin.png")
Run it with:
uv run generate.py
For more Python API inspiration, look at the CLI entry points for the respective models.
⚠️ Troubleshooting: hf_transfer error
If you encounter a ValueError: Fast download using 'hf_transfer' is enabled (HF_HUB_ENABLE_HF_TRANSFER=1) but 'hf_transfer' package is not available, you can install MFLUX with the hf_transfer package included:
Single-stream DiT from OpenMOSS with a Qwen3.5 text encoder. Takes natural-language, tag and JSON-layout prompts. Renders English and Chinese text. 50 steps with CFG, or 8 or 4 steps with a community step-distilled LoRA.
Anime and illustration model from CircleStone Labs and Comfy Org on Cosmos-Predict2, with a Qwen3 text encoder. Danbooru tags and natural language. 10 steps Turbo, 30 steps with CFG for Aesthetic and Base.
Trained on long structured JSON captions for precise control; renders text. Text-to-image and editing of 1 to 5 images, with masks. 50 steps with CFG; Edit Turbo runs 4 without.
LoRA support (multi-LoRA, scales, library lookup), including LyCORIS LoKr on FLUX.1 and FLUX.2
Metadata export + reuse, plus prompt file support
Float16 compute for Apple M1-family GPUs on FLUX.2, FLUX 3 Image Klein, Z-Image, Qwen-Image 2.1 and Anima (--compute-precision float16, see the common README)
Model-specific highlights
Text-to-image and image-to-image generation.
LoRA finetuning
In-context editing, multi-image editing, and virtual try-on
ControlNet (Canny for FLUX.1, Union for Z-Image and Qwen-Image-2.1, depth for Krea 2), depth conditioning, fill/inpainting, and Redux
Upscaling (SeedVR2 and Flux ControlNet)
Depth map extraction and FIBO prompt tooling (VLM inspire/refine)
See the common README for detailed usage and examples, and use the model section above to browse specific models and capabilities.
[!NOTE]
As MFLUX supports a wide variety of CLI tools and options, the easiest way to navigate the CLI in 2026 is to use a coding agent (like Cursor, Claude Code, or similar). Ask questions like: “Can you help me generate an image using z-image?”
🦄 Contributors
MFlux was originally created by Filip Strand in August 2024 and moved to this organisation in August 2026. It is maintained by:
Everyone else who fixed, tested and reviewed is in the contributor graph.
🌱 Related projects
Build a UI under mflux.web
We welcome independently distributed mflux.web.* implementations using Gradio,
FastAPI, FastHTML, or any other UI framework. Each project can choose its own
framework, dependencies, release schedule, and launch command.
mflux owns the parent initializer and inference implementation. Its package
path extends across installed distributions, including separate editable
checkouts. mflux.web is an implicit namespace package: Python combines the
mflux/web/ directories contributed by independently installed UI packages.
No intermediate distribution is required; neither core nor UI packages need to
depend on mflux-web. The mflux-web
distribution reserves the generic mflux-web name on PyPI; it does not provide
the shared namespace and does not need to be installed. Its optional demo is
just another child module, mflux.web.demo.
Your UI distribution owns a unique child, for example
src/mflux/web/example_ui/__init__.py. With uv_build, configure
module-name = "mflux.web.example_ui". Declare mflux and your chosen framework
as dependencies with versions your UI supports. The minimum mflux version for
split-directory installs must include this parent path extension.
Do not ship mflux/__init__.py, which belongs to core, or
mflux/web/__init__.py, which must remain absent for the implicit namespace.
Choose a unique child name to avoid collisions. PyPI distribution names can use
hyphens; Python child names must be valid identifiers, such as example_ui.
Reserving a PyPI distribution name does not reserve a Python namespace.
After installation in the same environment, consumers can use
import mflux.web.example_ui. Installing a UI does not automatically launch it,
discover applications, or mount routes. UI framework dependencies belong to the
individual UI distributions; this namespace support adds none to mflux.
Extras under mflux.extras
Plugins are optional packages that install next to mflux, put their code under
mflux.extras and add their own commands. mflux's own commands do not change.
The mflux-community plugins live in
mflux-plugins. To find,
install or write one, see Plugins - User Manual.
mfluxible — streaming HTTP API server for mflux models with a browser harness, an MCP tool and an OpenAI-compatible endpoint, by @wesbiggs
mlx-taef — TAESD/TAEF tiny-autoencoder live previews and low-memory FLUX decode for mflux, by @IonDen
mlx-teacache — TeaCache step skipping for FLUX.1 dev and Krea, FLUX.2 Klein base, Z-Image base and Qwen-Image (original checkpoint) in mflux, by @IonDen
MLXBits Image Studio - A native macOS Swift app for FLUX, Krea 2, Z-Image and more!
🙏 Acknowledgements
MFLUX would not be possible without the great work of: