Building an application with llama.cpp? Jump to Build with llama.cpp for mobile, desktop, chat, tool-calling, structured-output, and multimodal guides.
Installation
- Llama App
- macOS/Linux
- Pre-built Binaries
- Build from Source
Install Llama, the desktop app from the llama.cpp team, for macOS and Windows. It runs llama.cpp with one-click model downloads, a built-in chat, and a local OpenAI-compatible API, with no command-line setup.
This guide uses llama.cpp v0.8.0 (b11960) or later, which LFM3 models require.
Downloading GGUF Models
llama.cpp uses the GGUF format, which stores quantized model weights for efficient inference. All LFM models are available in GGUF format on Hugging Face. See the Models page for all available GGUF models. You can download LFM models in GGUF format from Hugging Face as follows:Available quantization levels
Available quantization levels
Q4_0: 4-bit quantization, smallest sizeQ4_K_M: 4-bit quantization, good balance of quality and size (recommended)Q5_K_M: 5-bit quantization, better quality with moderate size increaseQ6_K: 6-bit quantization, excellent quality closer to originalQ8_0: 8-bit quantization, near-original qualityF16: 16-bit float, full precision
Basic Usage
llama.cpp offers two main interfaces for running inference:llama serve (web chat UI and OpenAI-compatible server) and llama cli (interactive CLI).
- llama serve
- llama cli
llama serve starts a web chat UI and an OpenAI-compatible API for serving models locally.Starting the Server:-hf flag downloads the model directly from Hugging Face. Alternatively, use a local model file:-hf: Hugging Face model ID (downloads automatically)-m: Path to local GGUF model file-c: Context length (default: 4096)--port: Server port (default: 9931)-ngl 99: Offload layers to GPU (if available)
http://localhost:9931 in your browser to chat, or use the OpenAI Python client:Generation Parameters
Control text generation behavior using parameters in the OpenAI-compatible API or command-line flags. Key parameters:temperature(float): Controls randomness (0.0 = deterministic, higher = more random). Typical range: 0.1-2.0top_p(float): Nucleus sampling - limits to tokens with cumulative probability ≤ top_p. Typical range: 0.1-1.0top_k(int): Limits to top-k most probable tokens. Typical range: 1-100min_p(float): Filters tokens belowmin_p * max_probability. Typical range: 0.05-0.3max_tokens/--n-predict(int): Maximum number of tokens to generaterepeat_penalty/--repeat-penalty(float): Penalty for repeating tokens (>1.0 = discourage repetition). Typical range: 1.0-1.5. The server ignores therepetition_penaltyname used by vLLM and Transformers.stop(strorlist[str]): Strings that terminate generation when encountered
llama serve (OpenAI-compatible API) example
llama serve (OpenAI-compatible API) example
llama cli, use flags like --temp, --top-p, --top-k, --min-p, --repeat-penalty, and --n-predict.
Vision Models
LFM vision models (LFM3-VL and LFM2.5-VL) take images, and LFM3-VL also takes video. With-hf, llama.cpp downloads the matching vision projector (mmproj) automatically. The examples below use LFM3-VL-2B; the :Q4_0 tag selects its Quantization-Aware Distillation (QAD) checkpoint.
Command Line
--video clip.mp4 instead of --image. Video input needs ffmpeg in PATH. Use --image-max-tokens to cap the number of tokens per image (lower is faster, coarser).
Server
image_url content parts, either a data: URI with base64 bytes or a public URL:
Using local model files
Using local model files
Download the model and the projector, then pass both:
Audio and Omni Models
LFM3-Audio-2B and LFM3-Omni-2B take audio input, and LFM3-Omni-2B also takes images and video. With-hf, llama.cpp downloads the audio and vision projector automatically.
Speech Recognition
PassPerform ASR in <language>. as a system prompt with -sys, and mark where the audio goes with -p "<__media__>". As a regular prompt, the model describes the audio instead of transcribing it.
-p.
Server
--reasoning off. Send audio as OpenAI input_audio content parts (WAV, MP3, or FLAC):
arecord -f S16_LE -r 16000 -c 1 -d 5 speech.wav on Linux. For live audio, the server also handles real-time voice conversations, including tool calls, on its /v1/realtime WebSocket API.
Speech Synthesis
Thellama command has no TTS subcommand, so speech synthesis uses the separate llama-tts program, which ships with llama.cpp:
llama serve also exposes a POST /tts endpoint. See the LFM3-Audio-2B and LFM3-Omni-2B pages for more examples, including image and video input with LFM3-Omni-2B.
Speculative Decoding
Some LFM2.5 models have DSpark draft models that make generation faster without changing the output. In llama.cpp, the drafter is a GGUF sidecar that you load next to the target with-hfd (or -md for a local file):
timings report draft_n and draft_n_accepted. See Speculative Decoding for which models have drafters.
Converting Custom Models
If you have a finetuned model or need to create a GGUF from a Hugging Face model:--outtype to specify the quantization level (e.g., q4_0, q4_k_m, q5_k_m, q6_k, q8_0, f16).
Building Applications
The guides below cover embedding llama.cpp in your own software — from a mobile app calling the C API to a desktop app driving the llama.cpp server:iOS & Android
Link the XCFramework or NDK build and run LFM GGUFs in-process.
Desktop & Server Apps
llama-server as a sidecar, or Python / Node.js / .NET bindings.
Chat & Streaming
Multi-turn conversations, sampling parameters, prompt caching.
Function Calling & Agents
OpenAI-style tools with native LFM2.5 tool-call parsing.
Structured Output
JSON schema and GBNF grammar constrained generation.
Vision & Audio
LFM2.5-VL and LFM2.5-Audio in your own apps.