How to Generate AI Images From the Mac Command Line With mflux
uv tool install --upgrade mflux, then run mflux-generate-z-image-turbo with a prompt, and the model downloads itself on the first run. With an 8 bit copy of Z-Image Turbo saved to disk, a 1024 by 1024 image peaks at about 7.5 GB of memory, so it fits on a 16 GB Mac and leaves most of a 64 GB Mac free for everything else.
What mflux Is and Why Use It
So mflux is an open source project that rewrote the popular image models in MLX, which is Apple's own machine learning framework for Apple Silicon. That matters because most image tools were written for NVIDIA cards first and then patched to run on a Mac, and the patched route is where the odd errors and slow runs come from. mflux was written for the Mac from the start, so there is no PyTorch install, no "MPS fallback" settings and no CUDA anything, you install 1 package and you get commands.
It covers around 20 model families now, including Z-Image, FLUX.2, Krea 2, Qwen Image 2.1, FLUX 3 Image Klein, Ideogram 4 and an upscaler called SeedVR2. Each one has its own command, like mflux-generate-z-image-turbo or mflux-generate-flux2, and they all share the same basic flags for prompt, size, seed, steps and quantization. It also trains LoRAs, which is covered in how to train a LoRA on a Mac.
Now the case where mflux is the wrong pick, if you want to click around, paint masks and browse a gallery, it is a command line tool and it will feel bare. That is what Draw Things is for. mflux basically means "I want a command I can script" and an app means "I want to look at pictures while I work".
What You Need First
An Apple Silicon Mac, meaning any M1, M2, M3, M4 or M5 chip. Intel Macs are out, MLX does not run on them. For memory, 16 GB is the practical floor for the small and mid sized models, and the real question is which model fits which machine, which has its own page at best local image models by RAM. You also want disk space, each model is a download of somewhere between 6 and 25 GB, and they add up fast when you start trying several.
Step by Step
brew install uv
# or, without Homebrew
curl -LsSf https://astral.sh/uv/install.sh | sh
uv tool install --upgrade mflux
uv tool list
If a download later fails with an error about hf_transfer not being available, reinstall with that package included: uv tool install --upgrade mflux --with hf_transfer.
mflux-generate-z-image-turbo \
--prompt "A puffin standing on a cliff" \
--width 1280 \
--height 500 \
--seed 42 \
--steps 9 \
-q 8
The -q 8 at the end is quantization, which means the model's numbers are stored in 8 bits each. Smaller numbers, smaller model in memory, and at 8 bits the quality loss is very hard to see. mflux accepts 3, 4, 5, 6 and 8, and for most built in models it downloads a copy that is already quantized at that level, which is a much smaller download than the full weights.
mflux-save writes an 8 bit copy of the model into a folder, and you point later runs at that folder with --model.
mflux-save \
--path "$HOME/models/z-image-turbo_8bit" \
--model z-image-turbo \
--quantize 8
mflux-generate-z-image-turbo \
--model "$HOME/models/z-image-turbo_8bit" \
--prompt "A puffin standing on a cliff" \
--steps 9
The mflux docs publish measured numbers for this on a 64 GB Mac at 1024 by 1024 and 9 steps. From a saved 8 bit copy, 1 image peaks at 7.5 GB. Loaded straight from the Hugging Face cache, the same image peaks at about 26 GB, because the transformer weights there are stored as 32 bit floats and get converted while loading. So that is roughly 3 and a half times the memory for the same picture, just from where the model was loaded.
--output sets the file name.
mflux-generate-z-image-turbo \
--model "$HOME/models/z-image-turbo_8bit" \
--prompt "Flat vector illustration of a red fox, white background" \
--width 1024 --height 1024 \
--seed 1 2 3 4 \
--steps 9 \
--output ./outputs/fox.png
Steps are the number of passes the model makes. Turbo and other distilled models are built for a low fixed count (9 for Z-Image Turbo, 4 for FLUX.2 klein), and adding more does not help much. The base models are the opposite, base Z-Image wants around 50 steps with --guidance 4, so the same picture takes 5 times longer or more.
--low-ram trades speed for a smaller footprint, and --mlx-cache-limit-gb caps the cache MLX keeps around between operations.
mflux-generate-z-image-turbo \
--model "$HOME/models/z-image-turbo_8bit" \
--prompt "a portrait" \
--steps 9 \
--low-ram \
--mlx-cache-limit-gb 2.5
To find out whether a run fit in memory or spilled into swap, check before and after with the tools macOS already has:
sysctl vm.swapusage
vm_stat | grep Swapouts
If the swap in use grows or the Swapouts count climbs during a run, the model is paging to the SSD, which is slow and wears the drive. Close other apps, drop the resolution, or move down a quantization level.
Trying Other Models
Once the first model works, every other one follows the same pattern with a different command name. FLUX.2 klein is the other good starting point, the 4B version is the smallest and fastest thing in the list, and the 9B version is the step up:
mflux-generate-flux2 \
--model flux2-klein-9b \
--prompt "Photorealistic close-up of a hummingbird near red flowers" \
--steps 4 \
--width 1024 \
--height 560
FLUX.2 does not take a negative prompt, and the distilled versions use --guidance 1.0. Each model has its own short list of rules like that, and the model's README in the mflux repo is where they live, so read that page before assuming a flag from one model works on another.
Using a LoRA
A LoRA is a small add on file that changes the style or teaches the model a subject. You pass it with --lora-paths, either a local .safetensors file or a Hugging Face repo name, and set its strength with --lora-scales, where 1.0 is full strength and 0.5 to 0.8 is the usual range.
mflux-generate-z-image-turbo \
--model "$HOME/models/z-image-turbo_8bit" \
--steps 9 \
--prompt "a portrait" \
--lora-paths "/path/to/lora.safetensors" \
--lora-scales 0.8
A LoRA only works on the model family it was trained for, so a FLUX.2 LoRA does nothing useful on Z-Image. That is the first thing to check when a LoRA seems to have no effect.
From Commands to a Tool
Once the commands above work, the next step is usually a wrapper, so a script or an AI assistant can ask for "a header image for this page" and get back a finished file. sitepix is a free MIT licensed tool that does that on top of mflux, with named sizes, WebP output and a memory check before each run, and how it works is explained in calling a local image model from a script.
Common Problems
The first run sits there with no output. It is downloading. A model is many GB and the progress output can be quiet, so give it time before deciding it is stuck.
The process gets killed. That is macOS running out of memory. Save an 8 bit copy with mflux-save and load from it, add --low-ram, or pick a smaller model.
It is slow on an M1. The M1 family has no native support for the number format these models use by default, and mflux has a flag for it, --compute-precision float16, supported on the FLUX.2, FLUX 3 Image Klein, Z-Image and Qwen Image 2.1 commands. The mflux docs measured it on an M1 Max at 1024 by 1024, Z-Image Turbo at 4 bit went from 10.7 seconds per step to 7.5, so a 9 step image drops from around 96 seconds to around 68. On newer chips it does much less, 4% to 6% on an M4 Max and no change on an M5 Max, so it is an M1 and M2 setting.
The command is not found after install. Open a new terminal window so the path refreshes, or run uv tool update-shell once.