# What is llama.cpp?

> llama.cpp is an open-source C/C++ engine for running LLMs on your own hardware, with GGUF model files, quantization and an OpenAI-compatible server.

Source: https://www.honeyhive.ai/learn/llama-cpp (updated 2026-11-19)

llama.cpp is an open-source inference engine, written in C/C++, that runs large language models on your own hardware. Its [README](https://github.com/ggml-org/llama.cpp) says the main goal is LLM (and multimodal) inference with minimal setup and state-of-the-art performance on a wide range of hardware, locally and in the cloud. It is built on the ggml tensor library and released under the MIT license.

Its maintainers [write](https://huggingface.co/blog/ggml-org/llama-cpp-v1) that many downstream applications already depend on it, so it helps to know what it does and which settings matter. For the general idea of running a model, see [LLM inference](/learn/llm-inference).

## What you get

The project ships a command-line chat tool, a completion tool and an HTTP server. The README's quick start downloads a model from Hugging Face and runs it with `llama cli -hf`, and starts an OpenAI-compatible API server with `llama serve -hf`. Installs come from an install script, Docker, prebuilt binaries or a source build.

The server is where most application work happens. Its [documentation](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md) lists:

- OpenAI-compatible chat completions, responses and embeddings routes
- Anthropic Messages API compatible chat completions
- parallel decoding for several users, with continuous batching
- multimodal input
- schema-constrained JSON output and function calling (see [structured output](/learn/structured-output-llm) and [function calling](/learn/function-calling-llm))
- speculative decoding, a reranking endpoint and monitoring endpoints
- a built-in chat app

The function-calling [doc](https://github.com/ggml-org/llama.cpp/blob/master/docs/function-calling.md) says `llama-server` uses it with the `--jinja` flag, which the [server docs](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md) list as enabled by default.

## GGUF and quantization

llama.cpp loads models in GGUF. The [GGUF spec](https://github.com/ggml-org/ggml/blob/master/docs/gguf.md) describes a binary format for fast loading that succeeds GGML, GGMF and GGJT, supports `mmap`, and keeps everything needed to load the model in one file. Models are usually trained in PyTorch or another framework and then converted.

Quantization is a second step. The [quantize docs](https://github.com/ggml-org/llama.cpp/blob/master/tools/quantize/README.md) describe two phases: convert the original model to GGUF with `convert_hf_to_gguf.py`, then run `llama-quantize` on it, for example to `Q4_K_M`. Lower precision shrinks the file and can speed up inference. It may also lose accuracy, which the docs say is usually measured in perplexity or KL divergence and can be reduced with an importance-matrix file. See [perplexity](/learn/perplexity-metric) for what that number means.

When you use `-hf`, the [server docs](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md) say the quant defaults to `Q4_K_M`, or the first file in the repo if that one does not exist. Ready-made GGUF files for many [open-weight models](/learn/open-weight-models) are published on Hugging Face.

## Settings that decide whether a model fits

Local inference is mostly a memory problem. These flags from the server docs are the ones to know:

| Flag | What it controls |
|---|---|
| `-ngl`, `--n-gpu-layers` | How many layers go into GPU memory. Default is `auto`. |
| `-c`, `--ctx-size` | Prompt [context window](/learn/context-window) size. `0` loads it from the model. |
| `-ctk`, `-ctv` | Data type of the [KV cache](/learn/kv-cache) keys and values. Default `f16`; `q8_0` and `q4_0` are among the allowed values. |
| `--cpu-moe`, `--n-cpu-moe` | Keep mixture-of-experts weights on the CPU. |
| `--moe-cache-mib` | GPU cache for experts kept on the CPU. Default `0`, disabled. |
| `-fit` | Adjusts unset arguments to fit device memory. Default `on`. |
| `-sm`, `--split-mode` | How to split a model across several GPUs. |

A quantized KV cache stores values at lower precision, so it trades quality for memory in the same way weight quantization does.

## Version 1.0

In November 2026 the project's maintainers [announced](https://huggingface.co/blog/ggml-org/llama-cpp-v1) llama.cpp v1.0.0, released together with ggml v1.0.0. The post says breaking changes to the public API and ABI will now be marked with major-version bumps. Under its semantic-versioning rules, a major release means a breaking change to the public C API, a minor one covers compatible features, backend updates and model support, and a patch is a bug fix.

The same post says the project supports more than 150 architecture variants and all mainstream speculative decoding methods. It is signed by the llama.cpp team at Hugging Face, which also points readers to Llama desktop apps for macOS and Windows. If you build on the C library, the practical effect is that you can pin to a major version.

## Hardware

ggml is [designed](https://huggingface.co/blog/ggml-org/llama-cpp-v1) to run on virtually any hardware, and each backend can be built as a dynamic library and loaded at runtime. The [build guide](https://github.com/ggml-org/llama.cpp/blob/master/docs/build.md) covers CPU, BLAS, Metal, SYCL, CUDA and MUSA builds, among others. Pick the backend that matches your machine when you build, or take a prebuilt binary.

## When to use it

llama.cpp fits when you want to run a model yourself: on a laptop, an edge device or your own server, without sending prompts to a hosted API. Hosted APIs and other self-hosted engines trade differently on throughput, setup and cost, which [LLM inference](/learn/llm-inference) compares. It also helps for [LLM cost optimization](/learn/llm-cost-optimization) work where you want to test a smaller quantized model against your own cases before you commit to it.

## Tracing a local model

Because `llama serve` exposes OpenAI-compatible routes, an app can call it with an OpenAI-style client by changing the base URL. HoneyHive's [tracing quickstart](https://docs.honeyhive.ai/v2/introduction/tracing-quickstart) instruments an OpenAI call and sends a first trace. Check that your instrumentation honors a custom base URL, then compare the local model's outputs, latency and [time to first token](/learn/time-to-first-token) against a hosted one on the same traces.

## FAQ

### What is llama.cpp used for?

Running LLM inference on your own machine or server. Its [README](https://github.com/ggml-org/llama.cpp) states the goal as inference with minimal setup and state-of-the-art performance on a wide range of hardware, locally and in the cloud.

### What is the GGUF format?

A binary file format for storing models for inference with GGML-based executors such as llama.cpp. The [GGUF spec](https://github.com/ggml-org/ggml/blob/master/docs/gguf.md) says it is built for fast loading and holds all the information needed to load a model in a single file.

### Does llama.cpp have an OpenAI-compatible API?

Yes. The [server docs](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md) list OpenAI-compatible chat completions, responses and embeddings routes, plus Anthropic Messages API compatible chat completions.

### What does quantization do in llama.cpp?

It lowers the precision of model weights, for example from 32-bit floats to 4-bit integers. The [quantize docs](https://github.com/ggml-org/llama.cpp/blob/master/tools/quantize/README.md) say this shrinks the model and can speed up inference, but may introduce some accuracy loss.

### Is llama.cpp free to use commercially?

The project's [README](https://github.com/ggml-org/llama.cpp) shows an MIT license badge. The model you load has its own license, which you must check separately.
