llamafile
Run or ship an LLM as one portable file: the llamafile runtime (llama.cpp built with Cosmopolitan Libc) plus GGUF weights and default arguments, or the bare runtime with external weights.
Scope: this one product: running pre-built or self-made llamafiles, the server API, GPU setup, packaging with zipalign, sandboxing, updates and troubleshooting. Whisperfile and the other bundled programs are covered briefly. Other engines belong to choosing-inference-engine; a full llama.cpp deployment belongs to llama-cpp.
Work through the steps in order. Load a reference only when a step names it.
Discover first
Inspect the live system before changing anything. Every command is read-only and never prints secrets.
uname -sm; command -v llamafile; ls -lh ./*.llamafile ~/llamafile* 2>/dev/null | head
./llamafile --version 2>&1 | head -2 # or ./Model.llamafile --version
grep -o -m1 -w -E 'avx2|avx512f|avx' /proc/cpuinfo 2>/dev/null | head -1
nvidia-smi --query-gpu=name,memory.total --format=csv 2>&1 | head -3
command -v vulkaninfo >/dev/null && vulkaninfo --summary 2>&1 | head -5
ls -d "${TMPDIR:-/tmp}"/.ape-* ~/.llamafile 2>/dev/null
cat /proc/sys/fs/binfmt_misc/APE 2>/dev/null | head -2 # APE binfmt registration, if any
ss -ltnp 2>/dev/null | grep -E ':8080\b'
curl -s -m 3 http://127.0.0.1:8080/health
Decision flow
- Is llamafile the right tool? Choose it for zero-install, portable, single-file distribution, offline demos, or running one model on whatever machine is at hand. For multi-user throughput, many models or tuned GPU serving use
vllm,llama-cpporollama. - Which file? A pre-built
*.llamafile(weights bundled), or thellamafileruntime from the release plus a GGUF (-m). Windows runs only executables under 4 GB, so use external weights there (references/install.md). - Which mode? No flag starts combined mode (terminal chat plus server on 8080). Use
--serverfor a service,--cli -pfor scripts,--chatfor a terminal UI (references/serve-config.md). - GPU?
-ngl 999offloads on NVIDIA and AMD; Metal is on by default on Apple silicon. Pick the backend with--gpuand note the sandbox is skipped on GPU (references/performance-tuning.md,references/security-and-sandbox.md). - Serve securely. Loopback by default; add
--api-key-filebefore any--host 0.0.0.0; never enable--toolson a reachable server without a key (references/security-and-sandbox.md). - Package your own with
zipalignand an.argsfile (references/building-llamafiles.md). - Broken?
references/troubleshooting.md.
Rules
- Ask before changing the system. Multi-GB downloads,
binfmt_miscregistrations, services, firewall or Gatekeeper changes and exposure need approval. Never suggestspctl --master-disableas a fix. - Only run llamafiles you trust. A llamafile is an executable; its author controls whether it sandboxes itself. Prefer the official
mozilla-aireleases and Hugging Face org, and check the sha256 when one is published. - Secrets never touch output. Keep the API key in a
0600file and use--api-key-file, not--api-key(the latter shows inps). KeepHF_TOKENin the environment. - Bind loopback unless needed. Combined mode and
--toolschange the risk: see the security reference. CORS is not authentication. - Flags are version scoped. Each mode has its own
--help; use the help of the file you run. Old--mmap,--no-mmapand--mlockare translated to--load-modewith a warning. - Verify upstream. Verified against llamafile 0.10.6 (main
a3ccf09) on 2026-10-11. The 0.10.* line is a rebuild; some 0.9 features are missing (references/updating.md).
Workflows
- Get a llamafile or the runtime and GGUF ->
references/install.md - Run in chat, CLI, server or combined mode ->
references/serve-config.md - Choose models and quantizations ->
references/models-and-formats.md - Smoke test the API ->
references/api.md - GPU backends, offload, multi-GPU, memory ->
references/performance-tuning.md,references/parallelism-multinode.md - Tools, multimodal, embeddings, whisperfile ->
references/features.md - Sandbox, auth, exposure ->
references/security-and-sandbox.md - Build your own llamafile ->
references/building-llamafiles.md - LiteLLM, SDK, systemd ->
references/integrations.md,templates/ - Health, metrics, logs ->
references/observability.md - Update or pin a version ->
references/updating.md - Verify:
/healthis ok,/v1/modelslists the model, a chat completion returns text, and the startup log shows the expected backend and layers offloaded.
Quick smoke test
curl -LO https://huggingface.co/mozilla-ai/llamafile_0.10/resolve/main/Qwen3.5-0.8B-Q8_0.llamafile # upstream quick start model, 1.6 GB
chmod +x Qwen3.5-0.8B-Q8_0.llamafile # Windows: rename to .exe
./Qwen3.5-0.8B-Q8_0.llamafile --server --host 127.0.0.1 --port 8080 &
curl -s http://127.0.0.1:8080/v1/chat/completions -H 'Content-Type: application/json' \
-d '{"model":"local-model","messages":[{"role":"user","content":"Say OK"}],"max_tokens":16}' \
| jq -r '.choices[0].message.content'
Reference index
references/install.md: release files,llamafilevs-thin, external weights, OS and CPU support, Windows 4 GB limit.references/serve-config.md: modes, common flags,.args, load mode, router mode.references/models-and-formats.md: GGUF, pre-built list, third-party model stores, quantization notes.references/parallelism-multinode.md: multi-GPU split,--rpc, what is not supported.references/features.md: tools, agent mode, multimodal, embeddings, rerank, structured output, whisperfile.references/api.md: endpoints, auth headers, tool calling shapes.references/performance-tuning.md: GPU backends and libraries, offload, context, threads, slots.references/security-and-sandbox.md: pledge, confine-reads, tools, exposure.references/building-llamafiles.md: zipalign,.args, source build, distribution.references/integrations.md: LiteLLM, OpenAI SDK, systemd, containers.references/observability.md: health, metrics, slots, logs.references/updating.md: versions, 0.9 to 0.10 differences, pinning.references/troubleshooting.md: symptom to fix table.templates/:llamafile.service,model.args,litellm-llamafile.yaml.
Companion skills
choosing-inference-engine: compare engines. Install:npx skills add ScaleDockHQ/llm-skills --skill choosing-inference-engine.llama-cpp: the engine inside llamafile. Install:npx skills add ScaleDockHQ/llm-skills --skill llama-cpp.whisper-cpp: the engine behind whisperfile. Install:npx skills add ScaleDockHQ/llm-skills --skill whisper-cpp.ollama: model-manager alternative. Install:npx skills add ScaleDockHQ/llm-skills --skill ollama.litellm: gateway and keys. Install:npx skills add ScaleDockHQ/llm-skills --skill litellm.self-hosted-llms: the end-to-end stack. Install:npx skills add ScaleDockHQ/llm-skills --skill self-hosted-llms.