oMLX
The flyteplugins-omlx plugin serves LLMs with oMLX, an OpenAI-compatible inference server built on Apple’s MLX framework. OMLXAppEnvironment runs omlx serve as a Flyte app on the Mac’s Apple Silicon GPU, through a devbox started with --apple-silicon.
Use it to serve a model locally on a Mac. oMLX runs only on macOS with Apple Silicon, so an oMLX endpoint can’t run in a Linux container or on a remote cluster. To serve a model on a cluster, use vLLM, SGLang, Ollama, or llama.cpp.
Installation
On the Mac:
- Install oMLX by following the oMLX installation guide. oMLX isn’t published to PyPI.
- Install the plugin with
pip install flyteplugins-omlx. - Start a devbox with
flyte start devbox --apple-silicon. For its requirements, see Using the Apple Silicon GPU.
The app looks for oMLX in this order:
- An
omlxcommand on the app’sPATH, which holds only thebindirectory of the environment the app runs in. That environment hasimage’s pip packages. /opt/homebrew/bin/omlx, then/usr/local/bin/omlx.- The
omlx.climodule, imported from the app’s environment.
An oMLX installed with pip into another Python environment is found only if its omlx command is in /opt/homebrew/bin or /usr/local/bin. If none of these finds oMLX, the server exits with code 127 and prints that oMLX is not installed, with the install commands.
Basic oMLX endpoint
Define the app by importing OMLXAppEnvironment from flyteplugins.omlx and creating one with a name, for example OMLXAppEnvironment(name="omlx-local"). With no other settings, it:
- Requests
gpu="AppleSilicon", so the app runs natively on the Mac. - Runs
omlx serve --host 127.0.0.1 --port 8000. - Uses a default image with
flyteplugins-omlxinstalled. oMLX itself isn’t in the image. - Adds an oMLX Models link to the app, pointing at
/v1/models.
To serve it, point the flyte CLI at the devbox with flyte create config --devbox. Then, in a script, call flyte.init_from_config() and pass the environment to flyte.serve(). The returned app’s url is the endpoint’s address. This is how the plugin’s own example, examples/accelerators/omlx_serve.py in flyte-sdk, serves it.
oMLX serves the MLX-format models in its model directory. Without model_dir, the plugin passes no --model-dir, and oMLX uses its own default, which the plugin’s documentation gives as ~/.omlx/models. See the oMLX documentation for where your oMLX version looks.
Configuration
| Field | Description |
|---|---|
port |
Port oMLX listens on. Default 8000. |
model_dir |
Directory of MLX models on the Mac, passed as --model-dir. Use an absolute path. |
model_id |
A name for the model, stored on the environment. It doesn’t change which models oMLX serves. |
api_key |
Key oMLX requires from callers, passed as --api-key. |
extra_args |
More omlx serve flags, as a string or a list. See omlx serve --help. |
resources |
Defaults to gpu="AppleSilicon". If you set resources without a GPU, the plugin adds gpu="AppleSilicon". |
image |
The pip packages installed into the environment the app runs in. Override it only to add packages. |
Values with spaces are quoted for you. An argument of the form $MY_VAR isn’t quoted.
To accept connections on every interface, pass --host 0.0.0.0 in extra_args, with --host as a separate argument. It replaces the default --host 127.0.0.1.
The app runs natively on the Mac, outside the devbox, whose ports are published on 127.0.0.1 only. With --host 0.0.0.0, oMLX itself listens on the Mac’s network interfaces, so anyone who can reach the Mac can call it directly, without going through the app’s URL. Set api_key before you do this.
Call the endpoint
oMLX’s API is OpenAI-compatible. The plugin’s documentation points OpenAI clients at the app’s URL with /v1 appended, and lists the model ids to pass as model at /v1/models, which the oMLX Models link opens. See the oMLX documentation for the routes your oMLX version serves.
If you set api_key, oMLX requires that key, so pass it as the client’s api_key. OMLXAppEnvironment also keeps the app default requires_auth=True, so where the app’s URL enforces Flyte auth, a caller needs Flyte credentials too. Set requires_auth=False to serve the endpoint without Flyte auth.
Limitations
OMLXAppEnvironmentsets its own command. Passingargsraises aValueError, so useextra_argsinstead.- Requesting any accelerator other than Apple Silicon, such as
gpu="L4:1", raises aValueError. - An app that requests Apple Silicon runs only on a devbox started with
--apple-silicon. For what happens elsewhere, see Using the Apple Silicon GPU.
API reference
See the oMLX API reference.