explaingit

vaibhavpandeyvpz/mlex

Analysis updated 2026-05-18

9RustAudience · developerComplexity · 3/5Setup · moderate

TLDR

A dependency free Rust runtime for running quantized LLMs on Apple Silicon GPUs via MLX, with matching Rust and Node.js APIs.

Mindmap

mindmap
  root((mlex))
    What it does
      Runs LLMs on Apple Silicon
      No Python needed
    Interfaces
      Rust crate
      Node.js package
    Features
      Tool calling
      Prompt caching
      Streaming
    Tech stack
      Rust
      MLX
      Metal

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Run a quantized LLM locally on a Mac's GPU without installing Python or PyTorch.

USE CASE 2

Add local LLM chat, tool calling, and streaming to a Rust application.

USE CASE 3

Add the same local LLM features to a Node.js or TypeScript application via mlex.js.

USE CASE 4

Serve a multi-modal model that accepts images, audio, or video alongside text.

What is it built with?

RustApple MLXMetalNode.js

How does it compare?

vaibhavpandeyvpz/mlexarchledger/irlumecodeitlikemiley/waz
Stars999
LanguageRustRustRust
Last pushed2026-07-09
MaintenanceActive
Setup difficultymoderatemoderatemoderate
Complexity3/53/54/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires Apple Silicon hardware and a model checkpoint downloaded from Hugging Face.

In plain English

mlex is a Rust runtime for running large language models on Apple Silicon computers using Apple's MLX framework, built without needing Python, a system MLX install, or PyTorch. Pointing it at a model folder downloaded from the Hugging Face Hub loads that model directly onto the GPU through Apple's Metal graphics technology, ready to generate text, call tools, and in some cases process images, audio, or video. The project is organized as a single Rust crate published as mlex, with a companion Node.js package called mlex.js built from the same underlying code, so the same core logic is usable from either language. It supports a range of model families including several generations of Qwen, Gemma4, NemotronH, and any model shaped like a standard Llama checkpoint, along with a wide variety of quantization formats used to shrink model file size, which it detects automatically by reading each model's own configuration file rather than relying on a hardcoded list. Beyond basic text generation, mlex supports system prompts in the same style as the OpenAI and Anthropic chat APIs, an optional reasoning or thinking mode on models that support it, and tool calling where a program supplies function definitions and receives structured calls back. It also includes an automatic caching system: instead of managing a session handle, a caller sends the whole conversation on every request, and mlex quietly reuses whatever previously computed state matches the shared prefix, even across separate calls that share the same system prompt. Every generation call supports streaming output token by token. Getting started in Rust is a single cargo add command followed by loading a model folder and calling a generate function with a list of chat messages. The Node.js version works the same way with an install through npm and an async generate call, with the same features, including tool calling and multi turn conversations, available in both languages.

Copy-paste prompts

Prompt 1
Help me load a quantized Qwen model with mlex in Rust and generate a response to a prompt.
Prompt 2
Show me how to use mlex.js in Node.js to run a multi-turn conversation with streaming output.
Prompt 3
Explain how mlex's automatic prompt caching works across separate calls.
Prompt 4
Walk me through setting up tool calling with mlex using an OpenAI-style function schema.

Frequently asked questions

What is mlex?

A dependency free Rust runtime for running quantized LLMs on Apple Silicon GPUs via MLX, with matching Rust and Node.js APIs.

What language is mlex written in?

Mainly Rust. The stack also includes Rust, Apple MLX, Metal.

How hard is mlex to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is mlex for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.