llama.cpp CLI
$ llama-cli Community Low Riskllama-cli from llama.cpp runs local GGUF models on CPU, Apple Metal, or CUDA without a background daemon. Its -j / --json-schema and -jf / --json-schema-file flags compile JSON Schemas into GBNF grammars so outputs strictly match schema.
brew install llama.cpp Zero-daemon offline GGUF inference directly from shell; pass --no-display-prompt and -n to keep stdout strictly bounded.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Grammar-constrained -j/--json-schema guarantees valid JSON, though agents must pass --single-turn, -n, and --no-display-prompt to avoid interactive mode and banner noise.
- Supports
-j/--json-schema,-jf/--json-schema-file, and--single-turn
Offline local execution with no cloud data egress; GGUF files are local artifacts.
- Pure local inference with zero external network calls by default
Easily installed via brew install llama.cpp or release binaries, though requires local GGUF model weights and GPU/RAM.
- Packaged in Homebrew and GitHub Releases; requires GGUF model files
Fast C++ inference with GBNF schema guarantees, though repeated cold-loads of multi-GB GGUF files are slower than hitting llama-server or ollama.
- Native Metal/CUDA acceleration and grammar-enforced JSON
Core ggml-org/llama.cpp project under MIT license with massive contributor velocity.
- Official
ggml-org/llama.cpprepository
Detailed --help, though CLI flags evolve rapidly across llama.cpp releases.
- Extensive
--helpandtools/mainREADME
Security, Auth & Guardrails
Fully offline local inference; optional -hf Hugging Face downloads honor standard HF_TOKEN if gated.
Free, MIT open-source C++ binary; requires local GGUF model files.
# llama-cli Agent Rules - Always pass `--single-turn` (or `-no-cnv`) and `-n <max_tokens>` so `llama-cli` does not enter interactive conversation mode or generate forever. - Redirect stderr (`2>/dev/null`) or use `--log-disable` when piping `-j` JSON output, because `llama-cli` logs hardware timings to stderr.
Agent-Ready Command Recipes
Safe Read-Only Queries
llama-cli -m ./model.gguf -p 'Extract name and age for Ada, 36.' -j '{"type":"object","properties":{"name":{"type":"string"},"age":{"type":"integer"}},"required":["name","age"]}' -n 128 --no-display-prompt --single-turn Enforces exact JSON Schema output via -j, caps tokens (-n 128), and exits after one turn (--single-turn).
Controlled Writes & Previews
llama-cli -m ./model.gguf -f prompt.txt -jf schema.json -n 256 --no-display-prompt --single-turn > out.json
Reads prompt and JSON schema from files (-f, -jf) and writes constrained JSON to out.json.
Strengths for Agents
- +
-j/--json-schemaguarantees syntactically valid JSON via GBNF grammar constraints. - + Runs completely offline with Apple Metal, CUDA, or CPU without requiring a daemon.
Caveats & Pitfalls
- ! Each cold invocation reloads the entire GGUF model from disk (use
llama-serverfor high-frequency calls). - ! Flags change relatively fast across releases and stderr prints verbose ggml initialization logs.