Skip to main content
Use llama.cpp v0.8.0 (b11960) or later for LFM3; the server examples were checked with b12359. Start with LFM3-1.7B for new text applications. The API shape also applies to supported older GGUF models, with their own sampling and template settings. On laptops, desktops, and servers there are two ways to embed llama.cpp. Pick one per application: Both consume the same GGUF files from Hugging Face, so you can switch later.

Sidecar: llama-server

  1. Bundle the binary. Download the prebuilt archive for each platform you ship from llama.cpp releases (macos-arm64, win-cpu-x64 / win-cuda-*, ubuntu-x64, ubuntu-vulkan-x64, …) and place llama-server plus its shared libraries in your app’s resources. See the install guide for the supported build and platform choices.
  2. Launch it on startup with a free port and the model path, and wait for GET /health to return {"status":"ok"}.
  3. Call /v1/chat/completions with any OpenAI client. Everything in Chat & Streaming, Function Calling, Structured Output, and Vision & Audio applies unchanged.
  4. Kill the child process when your app exits.
Complete sample applications built this way:

In-process bindings

These bindings package their own llama.cpp builds. The examples below retain LFM2.5; check the binding’s vendored runtime for LFM3 support before changing the model. For the tested LFM3 path, use the sidecar server above.
create_chat_completion mirrors the OpenAI request shape (messages, tools, response_format, stream). The package bundles its own llama.cpp build, so upgrade it to pick up new architectures.
Other maintained bindings β€” Rust (llama-cpp-2), Go (go-llama.cpp), Java (java-llama.cpp), Dart/Flutter, and more β€” are listed in the llama.cpp README.

Hybrid on-device + cloud routing

Because llama-server speaks the OpenAI protocol, one client can target a local model and a cloud model interchangeably: route short, latency-sensitive, or private prompts to the local endpoint and fall back to a hosted deployment (for example vLLM or a cloud provider) for the rest.
The messages format, tool definitions, and streaming code are identical on both sides β€” only the base URL and the penalty field name (repeat_penalty for llama.cpp, repetition_penalty for vLLM/SGLang) differ.

Packaging checklist

  • Model download on first launch, not at install time: GGUF files are hundreds of MB to several GB. Show progress, verify the file size, and store it in the user data directory.
  • Use -hf only in development. In production pin the exact file (-m) so a model-card update cannot change behavior under your users.
  • Choose the binary per machine. CPU builds run everywhere; ship GPU variants (Metal is built into the macOS binary; CUDA / Vulkan on Windows and Linux) when you have tested them.
  • Memory-map, don’t read. llama.cpp uses mmap by default; keep the model on local disk (not a network share) for fast cold starts.
  • Benchmark with llama-bench on representative hardware before deciding on quantization and context size. See Hardware Evaluation.
Last modified on November 18, 2026