Skip to main content

FastAPI backend & desktop launcher for running local models via llama.cpp

Project description

๐Ÿฆ™ LLamaStudio

A desktop chat interface and local server manager for llama.cpp, crafted with FastAPI + HTMX for ultra-lightweight, zero-framework execution.

LLamaStudio is a self-contained local workspace that manages model lifecycles, features a smart VRAM estimator, scans local folders, and lets you search and download models directly from the Hugging Face Hub.


๐Ÿ“ธ Screenshots & Showcase

1. Main Chat Dashboard

A Pop!_OS-harmonized dark interface with streaming, collapsible markdown reasoning (thinking) processes, and real-time agentic tool execution logs. Main Chat Dashboard

2. GGUF Model Browser & Settings

A dynamic local model explorer that scans your directories and lets you adjust context length, GPU offload layers, CPU threads, flash attention, and KV cache quantizations on the fly. GGUF Model Browser

3. Hugging Face Discover Hub

Browse the entire Hugging Face GGUF catalog. Features a Smart VRAM Offload Estimator calibrated to your hardware, and a floating background download progress card with live speed (MB/s), ETA, and cancel controls. Hugging Face Discover Hub


โœจ Key Features

  • โšก Zero Node Modules: Built with HTMX, Tailwind CSS (via CDN), and Vanilla JS. It is incredibly fast, responsive, and has a memory footprint of just a few megabytes.
  • ๐Ÿงญ Hugging Face Discover Tab: Search the public Hugging Face Hub for GGUF models directly inside the app, view readmes, select quantizations, and download files in the background.
  • ๐Ÿš€ Smart VRAM Estimator: calulated specifically for your hardware (fits fully on RTX 5090 32GB VRAM, partial offload warning, or heavy CPU fallback warning).
  • ๐Ÿ“‚ Automatic Model Scanning: Scans standard directories (like ~/.lmstudio/models) automatically on startup or via a one-click rescan button.
  • ๐Ÿช Process Lifecycle Manager: The underlying llama-server process only spins up when you explicitly load a model, releasing all system resources and GPU VRAM instantly when you click "Eject".
  • ๐Ÿ”ง Configurable Workspace Sandboxing: Supports sandboxed agentic tool use (file read/write, commands, etc.) with real-time logs in the UI. Sandboxing boundaries can be easily broadened or bypassed entirely via a .env file or environment variables to grant the model system access.
  • ๐Ÿ–ฅ๏ธ XDG-Compliant Persistence: Conversations and model settings profiles are stored outside the codebase directory in standard ~/.config/llamastudio/ with automated backward-compatible migrations!
  • ๐Ÿ“ฆ Full Linux & macOS Portability: Server binaries and model directories are resolved dynamically on startup.

๐Ÿ› ๏ธ Installation & Setup

LLamaStudio is compatible with Linux and macOS out-of-the-box. Choose your OS and python virtual environment preference below.

๐Ÿง 1. Linux Installation

Prerequisites

  1. Python 3.10+ (Recommended: Python 3.13)
  2. llama.cpp built from source (or pre-compiled binary):
    • By default, the app dynamically looks for the llama-server binary globally on your system PATH or locally inside your home directory at ~/llama.cpp/build/bin/llama-server.

Environment Setup

Option A: Install from PyPI
pip install llamastudio
Option B: Conda / Miniconda from source
# 1. Clone the repository
git clone https://github.com/gnulnx/LlamaStudio.git
cd LlamaStudio

# 2. Create and activate a conda environment
conda create -n llamastudio python=3.13 -y
conda activate llamastudio

# 3. Install LlamaStudio and its dependencies
pip install -e .
Option C: Python Virtualenv (venv) from source
# 1. Clone the repository
git clone https://github.com/gnulnx/LlamaStudio.git
cd LlamaStudio

# 2. Create and activate a python venv environment
python3 -m venv .venv
source .venv/bin/activate

# 3. Install LlamaStudio and its dependencies
pip install -e .

๐Ÿ–ฅ๏ธ Linux Desktop Launcher Integration (Optional)

To integrate LLamaStudio directly into your Linux Application launcher menu (e.g., GNOME / Pop!_OS):

# 1. Copy the desktop file to your local applications directory
cp llamastudio.desktop ~/.local/share/applications/

# 2. Copy the custom SVG icon to your local icons directory
mkdir -p ~/.local/share/icons/hicolor/128x128/apps/
cp llamastudio.svg ~/.local/share/icons/hicolor/128x128/apps/

# 3. Update your desktop database and icon cache
update-desktop-database ~/.local/share/applications/
gtk-update-icon-cache -f -t ~/.local/share/icons

Note: If you are using a virtualenv, edit the executable path inside ~/.local/share/applications/llamastudio.desktop to point to your specific .venv/bin/python interpreter.


๐Ÿ 2. macOS Installation

Prerequisites

  1. Python 3.10+
  2. llama.cpp installed globally via Homebrew (highly recommended for macOS):
    brew install llama.cpp
    
    (This automatically places the llama-server binary globally on your system PATH, which LLamaStudio will auto-detect immediately!)

Environment Setup

Option A: Install from PyPI
pip install llamastudio
Option B: Conda / Miniconda from source
# 1. Clone the repository
git clone https://github.com/gnulnx/LlamaStudio.git
cd LlamaStudio

# 2. Create and activate environment
conda create -n llamastudio python=3.13 -y
conda activate llamastudio

# 3. Install LlamaStudio and its dependencies
pip install -e .
Option C: Python Virtualenv (venv) from source
# 1. Clone the repository
git clone https://github.com/gnulnx/LlamaStudio.git
cd LlamaStudio

# 2. Create and activate venv
python3 -m venv .venv
source .venv/bin/activate

# 3. Install LlamaStudio and its dependencies
pip install -e .

๐ŸชŸ 3. Windows Installation

Note: Native Windows execution is currently untested. However, you can run LLamaStudio on Windows seamlessly via WSL2 (Windows Subsystem for Linux) by following the standard Linux Installation guide above.

Pull requests extending native Windows support (e.g., resolving .exe binaries) are highly welcome!


๐Ÿš€ Running the Application

Option A: Via Unified CLI (lls - Recommended)

You can link and install LlamaStudio's CLI utility locally to control the desktop app and server seamlessly:

# Start the desktop application server and open browser UI
lls reload

Option B: Via App Launcher Command

After installing from PyPI or source, run:

llamastudio

Option C: Via Direct Startup Script

When working from a source checkout, activate your virtual environment and run the startup script:

# Activate your env (Conda)
conda activate llamastudio
# OR (Venv)
source .venv/bin/activate

# Start the application
python start.py

This will launch the FastAPI backend on http://127.0.0.1:8765 and automatically open your default browser to the chat dashboard.

Via Application Menu (Linux)

Search for LLamaStudio in your desktop search bar (press Super, type "Llama") and click to launch!


๐Ÿ› ๏ธ Unified Command-Line Interface (lls)

LlamaStudio features a CLI built using rich-click for visual dashboards and operational efficiency.

CLI Subcommands Reference

Command Usage Description
reload lls reload Gracefully starts or restarts the desktop FastAPI application backend.
status lls status Visual dashboard of FastAPI backend status, loaded model parameters, and GPU memory (VRAM).
ls lls ls Prints an elegant table of all GGUF models scanned across local directories.
load lls load [MODEL] Boots the server with a GGUF model. If MODEL is omitted, prompts you with an interactive menu.
eject lls eject Gracefully unloads the active model to free GPU and CPU RAM.
oneshot lls oneshot "prompt" Streams thinking traces, text, and executes agentic tools directly in your terminal.

For example, to boot a model interactively:

$ lls load
Available Scanned Models:
  1. Qwen3.6-35B-A3B-UD-Q5_K_M (25.2 GB)
  2. gemma-4-26B-A4B-it-Q8_0 (25.0 GB)
  3. DeepSeek-R1-Distill-Qwen-32B-Q5_K_M (21.7 GB)

Select a model number to load: 3
Loading model 'DeepSeek-R1-Distill-Qwen-32B-Q5_K_M'...

โš™๏ธ Configuration & Customization

The application runs fully out-of-the-box with no manual configuration. However, you can customize default settings inside app/config.py or by using a local .env file:

  • LLAMA_SERVER_BIN: The absolute path to your llama-server binary (automatically resolved on PATH/home).
  • MODEL_DIRS: List of local directories to scan for GGUF model files (defaults to ~/.lmstudio/models).
  • APP_PORT: FastAPI web server port (defaults to 8765).

๐Ÿ›ก๏ธ Workspace Sandboxing & Embodiment

By default, LlamaStudio restricts agent tools (like reading, writing, and listing files) to the repository directory to prevent accidental path traversals.

If you want to grant your model more control (e.g., to act as a system embodiment or write to external directories), you can customize these boundaries by placing a .env file in the root directory:

  • Broaden the Sandbox Root (e.g., allow the agent access to your entire home directory):
    LLAMASTUDIO_WORKSPACE_ROOT=/home/username
    
  • Completely Disable Sandboxing (gives the agent full filesystem control based on the running process's permissions):
    LLAMASTUDIO_DISABLE_SANDBOX=true
    

Restart or reload the backend (lls reload) after modifying the .env file to apply changes.


๐Ÿงช Testing Suite

LlamaStudio features both standard unit tests and comprehensive GGUF integration tests.

1. Standard Unit Tests

Verify local installation and confirm backend routing, regex parsing, and sandboxing safety behaviors by running our mock-based test suite:

python -m unittest discover tests

2. GGUF Model Integration Tests

For local environments containing active GPUs and downloaded models, you can run the full multi-model GGUF tool-calling integration suite to verify real-time execution robustness across various chat templates:

# Run GGUF model integration tests locally
./tests/test_all.sh

(These tests are automatically skipped in standard CI/CD environments and default pytest runs using @pytest.mark.skipif to keep pipeline checks fast.)


๐Ÿ—๏ธ Project Structure

LlamaStudio/
โ”œโ”€โ”€ start.py               # Main entrypoint (starts FastAPI + opens browser)
โ”œโ”€โ”€ pyproject.toml         # Package metadata, CLI entrypoint, and dependencies
โ”œโ”€โ”€ llamastudio.desktop    # GNOME/Linux desktop launcher metadata
โ”œโ”€โ”€ llamastudio.svg        # Custom application vector icon
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ config.py          # Settings & dynamic path configurations
โ”‚   โ”œโ”€โ”€ main.py            # FastAPI backend endpoints & routing
โ”‚   โ”œโ”€โ”€ chat.py            # Conversations registry, templates & chat streaming
โ”‚   โ”œโ”€โ”€ downloader.py      # Async background download manager (chunked writes)
โ”‚   โ”œโ”€โ”€ model_manager.py   # Scans local paths and Hugging Face Hub
โ”‚   โ”œโ”€โ”€ server_manager.py  # llama-server subprocess process lifecycle controller
โ”‚   โ”œโ”€โ”€ logger.py          # Centralized logger
โ”‚   โ”œโ”€โ”€ tools.py           # Sandboxed local workspace tools for LLM agent use
โ”‚   โ””โ”€โ”€ templates/
โ”‚       โ””โ”€โ”€ index.html     # Interactive HTMX frontend interface
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_downloader.py # Comprehensive mocked test cases (100% passing)
โ””โ”€โ”€ imgs/
    โ”œโ”€โ”€ chat_interface.png # Screenshot: Main Chat interface
    โ”œโ”€โ”€ model_settings.png # Screenshot: Model explorer & settings
    โ””โ”€โ”€ discover_models.png# Screenshot: HF Discover & Downloader panel

๐Ÿ“„ License

LLamaStudio is open-source software licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llamastudio-1.0.0.tar.gz (75.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llamastudio-1.0.0-py3-none-any.whl (67.1 kB view details)

Uploaded Python 3

File details

Details for the file llamastudio-1.0.0.tar.gz.

File metadata

  • Download URL: llamastudio-1.0.0.tar.gz
  • Upload date:
  • Size: 75.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for llamastudio-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bc87f41545e67c02a361d9c3a15e7d4bfba96f574e7557fc9aec869a887ff7a3
MD5 dc4e433fe9d495f56026f235ed47acc0
BLAKE2b-256 51f336fea70619a3633ba00b7ace0407ce9d42af9f50635a360b6fde7a11d479

See more details on using hashes here.

File details

Details for the file llamastudio-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: llamastudio-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 67.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for llamastudio-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 488e1d0444da8c4bc67de20edbb1b131503f42083d8a80be26ef03b49332ec3e
MD5 27a46b4f10bb680088f061a3ced873cd
BLAKE2b-256 846226c97f9ff899fe6d050c2c093c62c5659854b9f5efeecfb23010c21b5a8a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page