llama-cpp-python

llama-cpp-python

★ 4.2 🔖 4000 saves 💰 Free GitHub

llama-cpp-python provides official-style Python bindings for llama.cpp, the hugely popular inference engine for running large language models efficiently on local hardware. With over 10,000 stars on GitHub and active development continuing into 2026, it is the standard way to embed fast, self-hosted LLM inference directly inside Python applications — no separate server process or cloud API required.

Overview

The package wraps llama.cpp’s C/C++ core with both a low-level ctypes API and a simple high-level interface modeled on the OpenAI API. You load a quantized GGUF model once and then call familiar methods for text completion, chat completion, and embeddings. Because it builds on llama.cpp, it inherits broad hardware support — CPU, Apple Metal, CUDA, and Vulkan backends — plus aggressive quantization formats that let surprisingly large models run on consumer laptops. It also ships an OpenAI-compatible web server, so existing OpenAI client code can be pointed at a local model. Prebuilt wheels cover the common platforms, and the package can be compiled with specific backend support — for example CUDA or Metal acceleration — when you need maximum throughput on your hardware.

Key Features

  • High-level Llama class with completion, chat, and embedding endpoints
  • OpenAI-compatible API server for drop-in replacement of cloud calls
  • GGUF model support with 4-bit and 5-bit quantization for small memory footprints
  • GPU offloading through llama.cpp backends including Metal, CUDA, and Vulkan
  • Function calling, JSON-mode, and grammar-constrained output
  • Streaming responses and multi-modal (vision) model support via mtmd
  • Integrations for LangChain, LlamaIndex, and other popular frameworks

💳 Pricing

Free. llama-cpp-python is open source under the MIT license. You only supply the model files and your own hardware — there are no API fees, subscriptions, or hosted tiers.

Who Is It For

Python developers building private, offline, or cost-sensitive LLM features — local chatbots, document processing, RAG back ends, and prototypes — who want OpenAI-style ergonomics without sending data to a third-party API.

🚀 Visit llama-cpp-python Official Site

🚩 Report an issue