Generative image and video model runtimes for MLX.
Project description
MLX-Gen
MLX-Gen is a local image and video generation runtime for Apple Silicon and MLX. It exposes one
mlxgen command for text-to-image, image-to-image, text-to-video, image-to-video, model download,
model preparation, quantized local folders, and application progress callbacks.
[!IMPORTANT] MLX-Gen started as a fork of mflux. Most credit for the current codebase goes to Filip Strand and the original mflux contributors. This project keeps that attribution visible while publishing independently as
mlx-genand evolving themlxgencommand surface for current Apple Silicon workflows.
What It Does
MLX-Gen runs supported Hugging Face and prepared MLX-Gen model folders without starting network downloads during generation. You explicitly download or prepare models first, then generation is a cache-only operation suitable for desktop apps, workflow engines, and long-running local jobs.
The main capabilities are:
- text-to-image generation with Qwen Image, FLUX.2 Klein, Z-Image, ERNIE Image Turbo, Bonsai Image, FIBO, and related prepared folders;
- image-to-image modes, including latent img2img, instruction/reference edits, and multi-reference edits where the selected model supports them;
- Wan2.2 text-to-video and image-to-video, including A14B T2V/I2V prepared BF16 and mixed q8/BF16 packages;
- explicit
downloadandprepareworkflows for reproducible local model folders; - JSON model capability inspection before starting a heavy run;
- shared progress events for applications embedding MLX-Gen.
Install
Install with uv:
uv tool install --upgrade mlx-gen
Or install into an environment:
python -m pip install -U mlx-gen
Check the command surface:
mlxgen --help
First Commands
Download model files explicitly:
mlxgen download --model AbstractFramework/flux.2-klein-9b-8bit
Generate an image:
mlxgen generate \
--model AbstractFramework/flux.2-klein-9b-8bit \
--prompt "A cinematic wide shot of a compact sci-fi spaceship resting in deep snow on a frozen alien planet" \
--width 768 \
--height 432 \
--steps 24 \
--guidance 1.0 \
--seed 6107 \
--output spaceship.png
Inspect model capabilities before a run:
mlxgen capabilities --model AbstractFramework/flux.2-klein-9b-8bit
Create a reusable local prepared folder:
mlxgen prepare \
--model Qwen/Qwen-Image \
--path ./models/qwen-image-8bit \
--quantize 8
mlxgen generate does not download missing files. If something is not cached, MLX-Gen raises a
clear DownloadRequiredError with the command to run.
Reproducible Example
The docs include a complete model-backed spaceship workflow:
- T2I: generate a spaceship in the snow.
- I2I edit: turn it into a pencil sketch.
- I2I edit: crash the same spaceship in the snow.
- I2I multi-reference: combine the crash layout and pencil-sketch style.
- T2V A14B: generate a spaceship taking off from a snow planet.
- I2V A14B: animate the generated spaceship taking off from the source image.
See docs/examples/spaceship-snow.md for the exact commands and included assets.
Published Models
Prepared MLX-Gen model folders are published under the AbstractFramework organization on Hugging Face. Current published examples include:
AbstractFramework/flux.2-klein-4b-4bitAbstractFramework/flux.2-klein-4b-8bitAbstractFramework/flux.2-klein-9b-4bitAbstractFramework/flux.2-klein-9b-8bitAbstractFramework/qwen-image-2512-4bitAbstractFramework/qwen-image-2512-8bitAbstractFramework/qwen-image-edit-2511-4bitAbstractFramework/qwen-image-edit-2511-8bitAbstractFramework/z-image-turbo-4bitAbstractFramework/z-image-turbo-8bitAbstractFramework/ernie-image-turbo-4bitAbstractFramework/ernie-image-turbo-8bitAbstractFramework/wan2.2-ti2v-5b-diffusers-8bitAbstractFramework/wan2.2-t2v-a14b-diffusers-bf16AbstractFramework/wan2.2-t2v-a14b-diffusers-8bitAbstractFramework/wan2.2-i2v-a14b-diffusers-bf16AbstractFramework/wan2.2-i2v-a14b-diffusers-8bit
Use mlxgen download --model <repo-id> to cache a published model, or pass the repository id
directly to mlxgen generate after it is cached.
Wan A14B Measurements
Wan A14B was measured on an Apple M5 Max with 128 GB unified memory. The published-card validation uses small, repeatable low-RAM runs and records full-process Darwin physical footprint, RSS, MLX allocator peak, and generation time. These are validation-profile measurements, not a guarantee for every full-size production prompt.
| Model | Package | Disk | Physical Peak | Max RSS | MLX Peak | Time | Profile |
|---|---|---|---|---|---|---|---|
| Wan2.2 T2V-A14B | BF16 | 64.3 GiB | 33.0 GiB | 31.8 GiB | 27.7 GiB | 152.7 s | 384x224, 33 frames, 12 steps, 8 fps |
| Wan2.2 T2V-A14B | mixed q8/BF16 | 39.7 GiB | 20.7 GiB | 19.5 GiB | 15.5 GiB | 154.8 s | 384x224, 33 frames, 12 steps, 8 fps |
| Wan2.2 I2V-A14B | BF16 | 64.1 GiB | 33.7 GiB | 31.8 GiB | 28.2 GiB | 228.2 s | 384x384, 33 frames, 12 steps, 8 fps |
| Wan2.2 I2V-A14B | mixed q8/BF16 | 39.7 GiB | 21.5 GiB | 19.6 GiB | 15.9 GiB | 242.2 s | 384x384, 33 frames, 12 steps, 8 fps |
In these runs, mixed q8/BF16 reduces disk usage by about 38% versus prepared BF16 folders and reduces full-process physical peak memory by about 36-37%. It is not documented as a speed improvement. See docs/quantization.md for model-family quantization details.
Ecosystem
MLX-Gen is used as the local Apple Silicon generation backend for:
- AbstractVision, the vision/generation layer of the AbstractFramework ecosystem;
- AbstractFramework, the broader framework for local agentic and generative workflows;
- AbstractFlow, a visual orchestration layer that can compose generative capabilities with persistent agentic tasks.
MLX-Gen remains useful as a standalone CLI package, but its cache-only runtime behavior, capability inspection, prepared model folders, and progress callbacks are designed so applications can embed it without surprise network transfers or ambiguous model routing.
Documentation
- Getting started: installation and first runs.
- API and CLI: command surface, router behavior, image-to-image modes, Wan video sizes, capabilities, and Python entry points.
- Example workflow: reproducible image and video commands.
- Model management: download, prepare, cache-only runtime policy.
- Quantization: q8/q4/BF16 policies and measurements.
- Python integration: embedding, progress callbacks, and AbstractVision notes.
- FAQ: recurring questions, image-to-image mode selection, outpaint/reframe status, Wan resolutions, and usage limits.
- Troubleshooting: common setup and runtime failures.
- Acknowledgements: upstream mflux and model-community credits.
License
MLX-Gen is MIT licensed. Model weights remain governed by their original licenses and access terms.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mlx_gen-0.18.10.tar.gz.
File metadata
- Download URL: mlx_gen-0.18.10.tar.gz
- Upload date:
- Size: 866.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e338e747dc1eab34ac178995a974478f7ab87ec3be024d0ec2ed7fe22d976107
|
|
| MD5 |
207cb7742726a217bd8058a4460b7f4a
|
|
| BLAKE2b-256 |
a702df9083422bd9e728d81f05ac16a8e18ac35ee17e5ee118f39199138bccaa
|
Provenance
The following attestation bundles were made for mlx_gen-0.18.10.tar.gz:
Publisher:
release.yml on lpalbou/mlx-gen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mlx_gen-0.18.10.tar.gz -
Subject digest:
e338e747dc1eab34ac178995a974478f7ab87ec3be024d0ec2ed7fe22d976107 - Sigstore transparency entry: 1719597146
- Sigstore integration time:
-
Permalink:
lpalbou/mlx-gen@9091cf263137d716c431a1c5898c4f6c1d3dfafc -
Branch / Tag:
refs/tags/v0.18.10 - Owner: https://github.com/lpalbou
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9091cf263137d716c431a1c5898c4f6c1d3dfafc -
Trigger Event:
push
-
Statement type:
File details
Details for the file mlx_gen-0.18.10-py3-none-any.whl.
File metadata
- Download URL: mlx_gen-0.18.10-py3-none-any.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
366e18236f91d5f588b8ba6821712b234cc009c1ae9a49bab2f01eb1fb914ec2
|
|
| MD5 |
c55a663a511bf2770ba695f83cd166a3
|
|
| BLAKE2b-256 |
8f3bb376d0837c2f7857694383cdee77d885d7ad714072073931bd9365de1fce
|
Provenance
The following attestation bundles were made for mlx_gen-0.18.10-py3-none-any.whl:
Publisher:
release.yml on lpalbou/mlx-gen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mlx_gen-0.18.10-py3-none-any.whl -
Subject digest:
366e18236f91d5f588b8ba6821712b234cc009c1ae9a49bab2f01eb1fb914ec2 - Sigstore transparency entry: 1719597394
- Sigstore integration time:
-
Permalink:
lpalbou/mlx-gen@9091cf263137d716c431a1c5898c4f6c1d3dfafc -
Branch / Tag:
refs/tags/v0.18.10 - Owner: https://github.com/lpalbou
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9091cf263137d716c431a1c5898c4f6c1d3dfafc -
Trigger Event:
push
-
Statement type: