← all repositories
abetlen/llama-cpp-python

Python bindings that turn local LLMs into OpenAI clones

It exists so you can run quantized LLMs locally through a Python API that drops into existing OpenAI, LangChain, or LlamaIndex workflows.

llama-cpp-python
Not currently ranked — collecting fresh signals.
star history

What it does

llama-cpp-python wraps llama.cpp in a Python package, exposing both low-level ctypes access to the C API and a high-level Llama class for text and chat completion. It also ships an OpenAI-compatible web server that supports function calling, vision models, and loading multiple models at once. You can pull GGUF models directly from Hugging Face Hub via from_pretrained.

The interesting bit

The real value isn’t just the bindings—it’s the compatibility layer. By mimicking OpenAI’s API and plugging into LangChain and LlamaIndex, it lets you swap a local model into an existing stack without rewriting client code. The project also handles the messy build configuration for hardware acceleration backends (CUDA, Metal, Vulkan, ROCm, SYCL) through CMake environment variables.

Key highlights

  • OpenAI-compatible completions and chat completions out of the box
  • Built-in web server with function calling, vision API, and multi-model support
  • Direct model downloads from Hugging Face Hub using from_pretrained
  • Hardware acceleration via CUDA, Metal, Vulkan, ROCm, OpenBLAS, SYCL, and RPC
  • Pre-built wheels available for CPU, CUDA, and Metal to skip compilation

Caveats

  • Installation requires a C compiler and often manual CMAKE_ARGS to enable GPU backends; it builds from source by default.
  • On Apple Silicon, installing under an x86 Python build silently produces a binary that runs 10× slower.
  • Windows users may need to wrestle with compiler detection (nmake, MinGW) or set paths manually.

Verdict Worth a look if you want to self-host LLMs behind an OpenAI-shaped API without leaving Python. Skip it if you need a pure-Python inference engine or one-click installation across exotic hardware.

Frequently asked

What is abetlen/llama-cpp-python?
It exists so you can run quantized LLMs locally through a Python API that drops into existing OpenAI, LangChain, or LlamaIndex workflows.
Is llama-cpp-python open source?
Yes — abetlen/llama-cpp-python is open source, released under the MIT license.
What language is llama-cpp-python written in?
abetlen/llama-cpp-python is primarily written in Python.
How popular is llama-cpp-python?
abetlen/llama-cpp-python has 10.6k stars on GitHub.
Where can I find llama-cpp-python?
abetlen/llama-cpp-python is on GitHub at https://github.com/abetlen/llama-cpp-python.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.