Skip to main content

Llama.cpp Provider

Run GGUF-quantized LLaMA models locally via llama.cpp server with zero API costs, complete privacy, and offline capability.

Overview

Quick Start

Prerequisites

Installing llama.cpp

1

Clone Repository

2

Build Server

On macOS (with Metal acceleration):
On Linux (with CUDA):
On Windows (CPU only):
3

Download Model

Download a GGUF-quantized model from Hugging Face:
Q4_0 quantization (4-bit) offers best balance of speed and quality. Q5_K_M is higher quality but slower.
4

Verify Installation

Model Selection

Popular GGUF models for coding and general tasks: Recommended for coding: Qwen3 Coder, LLaMA 3 8B, or Phi-3

Configuration

Default Setup

Custom Configuration

If llama.cpp server runs on different host/port:

Starting llama.cpp Server

Basic Usage

Performance Tuning

Running Multiple Models

Usage Examples

Basic Chat

Model-Specific Usage

Streaming and Output Control

Troubleshooting

Connection Refused

Symptom: Error: connect ECONNREFUSED 127.0.0.1:8080 Causes & Solutions:
  1. Server not running — Start llama.cpp server in separate terminal
  2. Wrong port — Check server is on 8080 or update ANTHROPIC_BASE_URL
  3. Firewall blocked — Allow localhost connections

Model Not Found or Slow Response

Symptom: Invalid model or very slow responses Solutions:

Out of Memory

Symptom: VRAM out of memory or process crash Solutions:
  1. Reduce context — Limit with -c 1024 when starting server
  2. Switch quantization — Use Q4_0 instead of Q5_K_M
  3. Reduce layers on GPU — Use -ngl 30 instead of -ngl 99
  4. Use smaller model — Switch from 70B to 8B variant

Port Already in Use

Symptom: Address already in use Solutions:

Performance Optimization

GPU Acceleration

Memory Management

Batch Size and Threads

Cost Analysis

Common Questions

Q: Can I use llama.cpp with older hardware? A: Yes, but it will be slow. CPU-only inference works on any machine. Consider smaller models like Phi-3 (2.3GB) which runs acceptably on older hardware. Q: How do I update models? A: Download new GGUF files and restart server with -m /path/to/new-model.gguf. Q: Can I run multiple llama.cpp servers for load balancing? A: Yes, start each on a different port and create separate CCS profiles pointing to each. Q: Is llama.cpp compatible with Claude API features? A: Basic chat only. Features like vision, web search, and extended thinking require Claude’s official API.

Storage Locations

Next Steps

API Profiles

Learn how to create and manage API profiles

Ollama Provider

Compare with Ollama (cloud/local models)

Model Models

Explore all available models and providers

Troubleshooting

Common issues and solutions