How jundot/omlx works
1. Two deployment surfaces, one inference core
oMLX ships as both a CLI/server product and a native macOS menu-bar app. The inference runtime is the Python package under omlx/; the macOS app lives under packaging/omlx_app/ and is mainly a control plane around the same server process.
2. Primary external entry points
The server exposes OpenAI-compatible APIs under /v1, Anthropic-compatible messages under /v1/messages, embeddings/rerank/audio routes, and an admin surface under /admin. The admin UI also provides chat, model management, benchmarking, downloads, and settings.
3. Request routing and protocol adaptation
API-facing code in omlx/api/ translates external request shapes into internal model requests. The openai and anthropic adapters, plus SSE formatting and tool/thinking/structured-output helpers, are the boundary between client protocols and the engine layer.
4. Model discovery and configuration
model_discovery.py, model_registry.py, and model_settings.py determine what is available from the configured model directory, classify models by type, and apply per-model overrides. Settings are persisted to ~/.omlx/settings.json, while CLI flags and admin changes feed into the same config path.
5. Multi-model engine orchestration
engine_pool.py is the central runtime coordinator. It manages loaded models across LLM, VLM, embedding, reranker, and audio engines, handling load/unload, pinning, TTL-based eviction, and LRU pressure relief. This is the main boundary between “which model should answer” and “how inference is executed.”
6. Inference execution layer
The concrete execution code sits in omlx/engine/ and omlx/models/. BatchedEngine handles continuous batching for text LLMs, while specialized engines cover VLM, embeddings, reranking, STT/TTS/STS, and audio utilities. Model wrappers in omlx/models/ encapsulate model-specific behavior and input/output shapes.
7. Scheduler and process-level resource control
scheduler.py controls concurrent request admission and batch execution. process_memory_enforcer.py, memory_monitor.py, and server_metrics.py form the runtime guardrails that keep the process below memory limits and expose health/usage signals for the admin dashboard and menu-bar app.
8. Tiered KV cache is a major subsystem
The cache stack under omlx/cache/ is a core architectural feature. It includes a hot in-memory tier, a cold SSD tier (paged_ssd_cache.py), prefix sharing, copy-on-write, recovery, and type-specific handlers. Cache state can survive restarts and be restored from disk, making cache behavior a first-class part of the serving path rather than a transient optimization.
9. VLM and vision-specific paths
Vision support is not bolted on; it has its own engine, adapter, and cache support. Image handling utilities, VLM model adapters, and vision-feature cache components allow multi-image inputs, OCR-style prompting, and tool calling with visual context.
10. Tool calling, structured output, and model-specific parsing
omlx/adapter/ and parts of omlx/api/ handle model-family-specific output parsing and tool-call formatting. This includes adapters for formats such as Gemma and Harmony, plus shared parsing logic that converts raw generation into structured tool calls or validated JSON-like outputs.
11. Admin dashboard as an operational plane
omlx/admin/ contains the server-side routes, auth, downloader/uploader, benchmark tools, model-status views, and localized templates/static assets for the dashboard. It is a separate operational interface for downloads, benchmarking, chat, model tuning, and runtime monitoring, not just a UI skin over the API.
12. Integrations and MCP
omlx/integrations/ provides setup hooks for external coding agents such as OpenCode, OpenClaw, and Codex. omlx/mcp/ adds Model Context Protocol client/manager/executor tooling so the server can expose or consume tools beyond plain chat completion.
13. Packaging and update management
The packaging/ tree wraps the server in a native app experience with server lifecycle management, preferences, welcome flow, and updater logic. The Homebrew formula and GitHub workflow support distribution and automated formula refresh, but they do not change the runtime architecture of inference itself.
14. Evaluation and benchmarking are first-class
omlx/eval/ holds benchmark datasets and scoring logic, while admin benchmarking and accuracy tools reuse similar concepts for live model evaluation. This makes performance and quality measurement part of the repository’s architecture, not a separate tooling repo.
Main entry points: routes.py Admin API · server.py Server · engine_pool.py Engine pool · __init__.py API routes
Components 20
Runtime core
Server-side inference and serving path.
- Server · Main serving process and route assembly.
omlx/server.py - API routes · OpenAI-compatible, Anthropic-compatible, audio, embedding, rerank, MCP, and responses endpoints.
omlx/api/__init__.py - API adapters · OpenAI and Anthropic request adaptation plus SSE and tool/output helpers.
omlx/api/adapters/openai.py - Engine pool · Coordinates loaded models, eviction, pinning, and engine selection.
omlx/engine_pool.py - Scheduler · Controls concurrent request admission and batch execution.
omlx/scheduler.py - Batched engine · Continuous batching runtime for text generation workloads.
omlx/engine/batched.py - Specialized engines · Embedding, reranker, VLM, STT, TTS, and STS execution paths.
omlx/engine/embedding.py - Model wrappers · Model-specific wrappers and input/output shaping.
omlx/models/base_model.py - Guardrails · Memory monitoring, process enforcement, and server metrics.
omlx/process_memory_enforcer.py
Control surfaces
CLI, admin dashboard, and macOS app controls.
- CLI/server · Command-line entry and server startup.
omlx/cli.py - Admin API · Operational routes for chat, models, benchmark, settings, and downloads.
omlx/admin/routes.py - Dashboard UI · Templates, static assets, and localized admin interface.
omlx/admin/templates/dashboard.html - Mac app · macOS menu-bar control plane around the server.
packaging/omlx_app/app.py - Server manager · Starts, stops, and monitors the bundled server process.
packaging/omlx_app/server_manager.py
Supporting subsystems
Model discovery, cache, evaluation, and integrations.
- Model mgmt · Discovery, registry, and per-model settings persisted in the shared config path.
omlx/model_registry.py - KV cache · Hot/cold cache stack with recovery, prefix sharing, and vision feature caching.
omlx/cache/hybrid_cache.py - Evaluation · Benchmark datasets and scoring for model evaluation.
omlx/eval/base.py - Integrations · Hooks for external coding agents and related setup flows.
omlx/integrations/base.py - MCP · Model Context Protocol client, manager, executor, and tool types.
omlx/mcp/manager.py - Utilities · Hardware, tokenizer, image, install, and model-loading helpers used across the stack.
omlx/utils/model_loading.py
Connections 23
- CLI/server → Server: starts · CLI launches the server process.
- Mac app → Server manager: controls · Native app manages server lifecycle.
- Server manager → Server: runs · App wrapper starts and stops the shared server.
- Server → API routes: exposes · Server mounts public API surfaces.
- Server → Admin API: exposes · Server mounts operational dashboard routes.
- Admin API → Dashboard UI: renders · Dashboard backend serves templates and static assets.
- API routes → API adapters: adapts · Routes delegate protocol translation and response shaping.
- API adapters → Engine pool: dispatches · Protocol layer converts requests into engine calls.
- Engine pool → Scheduler: coordinates · Pool hands execution to the scheduler.
- Scheduler → Batched engine: runs · Scheduler executes work on the batched text engine.
- Scheduler → Specialized engines: runs · Scheduler executes work on specialized modality engines.
- Batched engine → Model wrappers: wraps · Text execution relies on model-specific wrappers.
- Specialized engines → Model wrappers: wraps · Specialized execution relies on model-specific wrappers.
- Engine pool → Model mgmt: selects · Pool uses discovery and settings to choose models.
- Model mgmt → Utilities: uses · Discovery and loading rely on shared helpers.
- Engine pool → KV cache: uses · Serving path relies on tiered KV and vision caches.
- Server → Guardrails: monitors · Server exposes health and resource controls.
- Admin API → Guardrails: reports · Dashboard reads metrics and memory state.
- Admin API → Model mgmt: edits · Admin changes feed back into shared model settings.
- Admin API → Evaluation: benchmarks · Dashboard runs model evaluation workflows.
- API routes → MCP: integrates · API surface includes MCP-related tooling.
- Integrations → MCP: extends · External agent setup hooks connect to MCP/tooling.
- Mac app → Admin API: opens · App presents the operational dashboard surface.