--- id: llama-cpp-python version: "0.3.34" license: MIT license_treatment: permissive maintenance: active --- # llama-cpp-python — Python bindings for the llama.cpp library License: permissive · Maintenance: active · Downloads: 732.9K/mo ## What it is and what it does llama-cpp-python wraps the llama.cpp C library to bring efficient local language model inference to Python. It provides both a low-level ctypes interface to the C API and a high-level Python API that mimics OpenAI's completion endpoints, making it easy to integrate into existing workflows. The package supports multiple hardware acceleration backends including CUDA, Metal, ROCm, Vulkan, and CPU-only inference, with pre-built wheels available to avoid compilation overhead. The library is designed for developers who want to run large language models on their own hardware without cloud dependencies. It includes an OpenAI-compatible web server for local API access, function calling support, vision model capabilities, and multi-model serving. Installation requires a C compiler and can be complex depending on your target hardware backend, but active maintenance and comprehensive documentation help mitigate setup friction. Use it for: - Run private language models locally without sending data to cloud APIs - Build OpenAI-compatible applications that work offline or on restricted networks - Integrate local inference into existing application frameworks for RAG or agent workflows - Deploy a local code completion server for development environments - Serve multiple models simultaneously via the built-in web server for multi-tenant inference - Accelerate inference on specific hardware (GPU, Apple Silicon) for production workloads ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Python bindings for llama.cpp that enable running large language models locally with CPU or GPU acceleration, offering both low-level C API access and high-level text completion APIs compatible with OpenAI, LangChain, and LlamaIndex. Yes, with conditions. Install if you need local language model inference with hardware acceleration and can handle a non-trivial build process. The package is actively maintained, has no known vulnerabilities, and integrates well with popular frameworks. However, expect high install friction due to C compilation requirements—use pre-built wheels where available to reduce setup complexity. Not recommended if you need a quick, zero-configuration solution. ## Install pip install llama-cpp-python uv add llama-cpp-python poetry add llama-cpp-python ## Installing llama-cpp-python Before you install: Installation requires a C compiler and builds llama.cpp from source, which is computationally intensive and may fail without proper toolchain setup. Pre-built wheels are available for multiple backends to reduce build friction. The package is actively maintained with recent releases. License in practice: MIT license permits commercial use, modification, and distribution with minimal restrictions, making it suitable for proprietary projects. Quickstart: pip install llama-cpp-python from llama_cpp_python import Llama llm = Llama(model_path="/path/to/model.gguf") response = llm("Hello, how are you?") Requires a C compiler (gcc/clang on Linux, Visual Studio/MinGW on Windows, Xcode on macOS) and a compatible GGUF-format model file; build may fail without proper toolchain configuration. Verify before relying: - Whether pre-built wheels significantly reduce installation time compared to source builds - Performance characteristics across different hardware backends (CPU vs CUDA vs Metal vs ROCm) - Memory requirements for running models of different sizes - Latency and throughput benchmarks for typical inference workloads ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: high - Maintenance: active - Downloads: 732.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags local llm inference python, llama.cpp python bindings, run language models locally, openai-compatible llm api, cpu gpu accelerated inference, langchain llamaindex integration, text completion api, llm-inference, local-models, gpu-acceleration [View on SkillFed](https://skillfed.io/packages/llama-cpp-python) · [View on PyPI](https://pypi.org/project/llama-cpp-python/)