Local LLMs on Apple Silicon with Ollama MLX

    by Drizzt Studio

    1

    Run MLX-format models in Ollama on Apple Silicon, plus how to diagnose Cloudflare Tunnel 403s — including Ollama's Host header check, which is one common cause but not the only one.

    Free

    Security scanned

    Works with the AI Agents you already use

    Local LLMs on Apple Silicon with Ollama MLX

    Example session with this skill installed

    I need to deploy Qwen3.8-27B-Uncensored-MLX on my Mac Studio and make it accessible to my remote agent via a Cloudflare Tunnel. Help me with the import and the tunnel 403 fix.

    • Read your context and instructions
    • Compiled the local llms on
    1. Prereqs: ollama --version shows 0.19 or newer; xcode-select --install; python3 -m pip install --user -U "huggingface_hub[cli]".
    2. Download: python3 -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='orcarouter/Qwen3.8-27B-Uncensored-MLX', allow_patterns='6-bit/*', local_dir='~/models/qwen3.8-mlx-6bit')" — the repo folders are hyphenated (6-bit/, not 6bit/); a wrong pattern silently fetches 0 files, so confirm the tree first. 6-bit is about 22.8GB.
    3. Import: echo "FROM ~/models/qwen3.8-mlx-6bit/6-bit" > ~/Modelfile then ollama create --experimental qwen3.8-27b-mlx -f ~/Modelfile. Without --experimental it fails with Error: unknown data type: U32; success prints the imported layer count.
    4. Benchmark from the API, not by feel: curl http://localhost:11434/api/chat -d '{"model":"qwen3.8-27b-mlx","messages":[{"role":"user","content":"Say hello in one sentence."}],"stream":false}', then tok/s = eval_count / (eval_duration / 1e9).
    5. Diagnose before editing any config — three checks: (a) curl -sS -o /dev/null -w '%{http_code}' https://ollama.example.com/api/tags with no extra headers; (b) the same call straight to http://<host>:11434/api/tags should return 200; (c) re-request through the tunnel with a bogus Host header and compare response body sizes — Cloudflare Access/WAF 403s return HTML, an Ollama Host-check 403 returns an empty body.
    6. Only if it is the Host check: in config.yml set the ingress rule (hostname ollama.example.com, service http://localhost:11434, originRequest: httpHostHeader: "localhost:11434") with a final catch-all http_status: 404, then run cloudflared tunnel ingress validate and restart the tunnel.
    7. Verify: the /api/tags call from step 5 now returns 200 and ollama ps shows the model loaded.
    8. Reverse test: stop the tunnel (or hit the host from outside directly) and confirm it is NOT reachable — otherwise you have only proven it works, not that it is closed. If the endpoint stays public, add authentication and rate limiting.
    9. Persist: launchctl setenv OLLAMA_KEEP_ALIVE -1 (or export in ~/.zshrc) and restart Ollama so the model stays loaded.
    10. Agent side: point an OpenAI-compatible provider's base_url at https://ollama.example.com/v1.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    How to run LLMs on Apple Silicon with Ollama 0.19 or newer, which has a built-in MLX engine — and why GGUF models on a Mac stay on the llama.cpp/Metal path and never get MLX acceleration. The guide covers the install (download the official script with curl -fsSL https://ollama.com/install.sh -o /tmp/ollama-install.sh, review it, then sh /tmp/ollama-install.sh, or use the official .dmg), downloading MLX safetensors from Hugging Face, importing them with ollama create --experimental (without the flag the import fails with unknown data type: U32), measuring real throughput from eval_count/eval_duration, and diagnosing Cloudflare Tunnel 403s. On the 403 side it starts with a three-step check (direct request, LAN request, bogus Host header comparison — Cloudflare Access/WAF 403s carry HTML, Ollama's Host check returns an empty body) before changing anything, then the httpHostHeader ingress fix and a reverse test to prove the endpoint is not exposed to the world. Example models use uncensored/abliterated Qwen MLX packs; they are optional suggestions, and tool-calling support varies by release. Knowledge only — one document, no bundled installer, scripts, or weights.

    Requires an Apple Silicon Mac; Intel Macs and Windows/Linux are outside this guide. Ollama 0.19 or newer is required for the built-in MLX engine. MLX acceleration only applies to MLX-format weights — GGUF models run on the llama.cpp/Metal path here (a 27B GGUF measured ~6.2 tok/s) and get no benefit. Imports need the --experimental flag on ollama create, and the Xcode Command Line Tools (roughly 2GB) on first python3 use. Expect large downloads (the 6-bit 27B pack is about 22.8GB), and keep in mind that a Cloudflare Tunnel 403 has several possible causes — the Host header fix only covers one of them.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 16 days ago

    • Free with an Agensi account

    Mac only

    Accounts
    Hugging Face
    Software
    Ollama 0.19+Xcode CLT (~2GB)
    Optional
    huggingface_hubCloudflare Tunnel

    Knowledge-only: one SKILL.md, no scripts or weights. Covers Ollama 0.19+ MLX on Apple Silicon, importing MLX safetensors with --experimental, tok/s measurement, and Cloudflare Tunnel 403s from Ollama's Host header check. GGUF sees no MLX speedup. Host header is one cause, not all; add auth first.

    Permissions

    Terminal / Shell
    Network Access
    Read Files
    Write Files

    Allowed Hosts

    ollama.com
    ollama.example.com
    huggingface.co
    Listed16 days ago

    What's inside

    Frequently Asked Questions

    It targets Ollama 0.19+, which ships a built-in Apple MLX engine, and covers importing MLX safetensors instead of GGUF. On a 27B model the guide measured ~33 tok/s generation for the MLX build versus ~6.2 tok/s for GGUF on a Mac; Ollama's own benchmark reports decode roughly doubling (58 to 112 tok/s on a 35B MoE on M5 Max). Results depend on model size, quantization and chip.

    It shows how to diagnose one specific 403 — Ollama's DNS-rebinding Host header check — by setting `httpHostHeader` in the Cloudflare Tunnel ingress. That is a troubleshooting step, not a security control: the guide explicitly tells you to run a reverse test and add authentication and rate limiting before leaving the endpoint reachable from the internet.

    An Apple Silicon Mac (M-series) running macOS, with Ollama 0.19+. The official Ollama benchmark cited in the guide was run on an M5 Max; the guide's own measurements don't name a specific chip. Intel Macs, Windows and Linux are not covered.

    A single knowledge document (one SKILL.md): install commands, the download command and folder-name gotcha, the one-line Modelfile and `ollama create --experimental` import, the API benchmarking recipe, a `config.yml` ingress snippet for Cloudflare Tunnel, and a 403 diagnostic plus reverse-test checklist. No scripts, binaries, installers or model weights are bundled.

    Ollama 0.19 or newer, needed for the built-in MLX engine. MLX safetensors import requires the `--experimental` flag; that flag is what avoids the `unknown data type: U32` error, not the Ollama version itself.

    The worked examples are Qwen3.8-27B MLX packs (uncensored and abliterated variants), but the workflow applies to any Hugging Face repo that ships MLX-format safetensors. Two caveats: the sub-folder names must match exactly or the download silently fetches 0 files, and tool-calling support varies by model release — verify it for the pack you pick.

    New in LLM Ops

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for LLM Ops.

    Free