skillfed

llama-cpp-python

Python bindings for the llama.cpp library

llama-cpp-python v0.3.34 732.9K downloads/30d#5,200 on PyPI10,551
Permissive license MIT Active released

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 on this page — 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

llama-cpp-python on PyPI

pip

pip install llama-cpp-python

uv

uv add llama-cpp-python

poetry

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 the current Python release (>=3.8)
Install friction high — source build required
Runtime dependencies 4 — typing-extensions, numpy, diskcache, jinja2
Maintenance actively maintained — 33 days since the last release
Last repo commit
First released
Downloads 732,904/month — #5,200 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: llama_cpp_python-0.3.34.tar.gz

Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

local llm inference pythonllama.cpp python bindingsrun language models locallyopenai-compatible llm apicpu gpu accelerated inferencelangchain llamaindex integrationtext completion api
llm-inferencelocal-modelsgpu-acceleration

More Artificial Intelligence packages

litellm

LiteLLM provides a unified Python interface to…

permissive · top 100 on PyPI

huggingface-hub

Client library and CLI tool for downloading,…

permissive · top 100 on PyPI

langchain

LangChain provides a framework for building…

permissive · top 1,000 on PyPI

hf-xet

hf-xet provides chunk-based deduplication and…

permissive · top 1,000 on PyPI

tokenizers

Tokenizers converts raw text into token…

permissive · top 1,000 on PyPI

transformers

Transformers provides a unified framework for…

permissive · top 1,000 on PyPI

gguf

Reads and writes binary files in the GGUF (GGML…

permissive · top 5,000 on PyPI

llama-index-llms-openai-like

Provides a thin wrapper to use…

permissive · top 15,000 on PyPI

abstract-hugpy-dev

A self-hosted LLM console and OpenAI-compatible…

unclear · top 15,000 on PyPI

llama-index-llms-langchain

Bridges LlamaIndex with LangChain LLM…

permissive · top 15,000 on PyPI

ipex-llm

Accelerates large language model inference on…

permissive · top 15,000 on PyPI

llama-index-program-openai

Integrates OpenAI-powered program synthesis…

permissive · top 5,000 on PyPI

sgl-kernel

sgl-kernel provides optimized CUDA compute…

permissive · top 15,000 on PyPI

sglang-kernel

sglang-kernel provides optimized CUDA compute…

permissive · top 15,000 on PyPI

llama-index-agent-openai

Integrates OpenAI language models with…

permissive · top 5,000 on PyPI

llama-index-multi-modal-llms-openai

Integrates OpenAI's multi-modal language models…

permissive · top 5,000 on PyPI