10.7K ·GitHub
What is this?
'llama-cpp-python' provides Python bindings for the llama.cpp C/C++ library, giving both low-level ctypes access and a high-level API for running GGUF language models locally for text completion, chat, embeddings and more.
Is this just a library, or does it come with a server too?
It's primarily a Python library (ctypes bindings plus a high-level Llama class), but it also ships an OpenAI-compatible web server you can run as a drop-in API replacement or local Copilot alternative.
Do I need a C compiler before installing?
Yes: Python 3.8+ plus a C compiler — gcc or clang on Linux, Visual Studio or MinGW on Windows, Xcode on MacOS.
Any install gotchas I should know about?
Windows builds can fail to find 'nmake' or CMAKE_C_COMPILER unless you add w64devkit to CMAKE_ARGS, and on Apple Silicon you must use an arm64 Python build or the x86 version will run 10x slower.
Which GPU backends can I enable for faster inference?
CUDA, Metal (Apple GPUs), HIP/ROCm for AMD cards, Vulkan, SYCL and RPC are all supported, each enabled by setting the matching CMAKE_ARGS environment variable before pip install.
Can it act as a drop-in replacement for the OpenAI API?
Yes, it includes a web server that mimics the OpenAI API, plus createChatCompletionOpenaiV1 for pydantic-typed responses compatible with OpenAI clients.
Does it support function calling?
Yes, through the functionary pre-trained models or the generic chatml-function-calling chat format, including parallel function calls.
Can it work with vision/multi-modal models?
Yes, it supports multi-modal models like LLaVA, MiniCPM-V, Qwen2.5-VL and Gemma, letting the model read both text and images via dedicated chat handlers.
Can I load models directly from Hugging Face?
Yes, the Llama.from_pretrained method downloads GGUF models straight from the Hugging Face Hub (requires the huggingface-hub package).
What are similar projects?
project-maya, Janus, rizzo-flow, mesh-llm, Bonsai-demo, vllm, CLM, GLM-5.3-Flash-EXL3-2x-DGX-Sparks-TensorFold
Which topics is it in?
function-calling, llamacpp, amd-gpu, gguf, langchain, vulkan, embeddings, llm-inference, openai-compatible, inference, nvidia, huggingface