# Run a GGUF model with llama.cpp

GGUF is the file format most people download when they run open language models on their own hardware, often in a smaller "quantized" version such as `Q4_K_M` that needs less memory. [llama.cpp](https://github.com/ggml-org/llama.cpp) runs these files fast on a GPU. It is open-source software under the MIT licence. The **llama.cpp server (GGUF models)** template starts it with a chat page and an OpenAI-compatible API. This guide is for people who already know which GGUF model they want, or want a light server for a small one. You need an account with credit; you do not need an SSH key.

If you just want to chat and do not mind which software runs the model, Quick start's **Chat with an AI model** is the shortest path: see [Run a chat model with Open WebUI + Ollama](/docs/tutorial-open-webui-chat).

## What it costs

You pay for the server by the second while it runs, plus its disk for as long as the server exists. A smaller quantization fits a smaller, cheaper GPU. The review step shows the price **Per hour** before anything starts; the [pricing page](/pricing) has the current prices of every GPU.

## 1. Choose a model

The template downloads the model named in `LLAMA_ARG_HF_REPO` at the first start. The default is `ggml-org/gemma-3-1b-it-GGUF`, a small Gemma 3 model (Gemma terms of use), good for a first test. To use another one, find a GGUF repository on [Hugging Face](https://huggingface.co/models?library=gguf) and note its name, optionally with a quantization after a colon, for example `bartowski/Qwen2.5-7B-Instruct-GGUF:Q4_K_M` (Qwen2.5 is under the Apache 2.0 licence). Check the model's own licence before you use it in a product.

As a rule of thumb, the GGUF file must fit in the GPU memory with some room to spare. [Which GPU do I need?](/docs/tutorial-which-gpu) shows how to estimate it.

## 2. Start the server

Never started a server? [Your first GPU server](/docs/tutorial-first-gpu-server) shows adding credit and **Quick start** step by step. For llama.cpp, use the full setup:

1. Open **Deploy**. Under **Sort by**, choose **Price, low to high** and pick a configuration with at least 8 GB of **VRAM** (12 GB is recommended). Select **Continue**.
2. Above the template cards, select **Serve an API**, then the **llama.cpp server (GGUF models)** card, then **Continue**.
3. Name the server, for example `gguf-chat`. Under **Environment variables**, change `LLAMA_ARG_HF_REPO` if you chose another model. Leave `LLAMA_API_KEY` empty: the platform creates a key for this server.
4. Select **Continue**, check **Per hour** and keep the automatic stop under **Automation (optional)** on for a first try. Select **Start my server**.

Some new servers are reviewed by our team before they start; you are not charged until the server runs. The page answers once the model has downloaded and loaded; a bigger model takes longer.

## 3. Find the key and chat

1. Open **Servers**, select the server and open the **Connect** tab.
2. Under **Sign in with**, show and copy the **API key**.
3. Select **Open app**. The llama.cpp chat page opens in a new tab.
4. Open the page's settings, paste the key as the API key and save. Then type a message.

## 4. Call the API

Copy the **App address** from the **Connect** tab. Below it is `SERVER_ADDRESS`, and the key is `YOUR_KEY`. The ready command under **Try it from a terminal** lists the loaded model. Ask a question:

```bash
curl http://SERVER_ADDRESS/v1/chat/completions \
  -H "Authorization: Bearer YOUR_KEY" -H "Content-Type: application/json" \
  -d '{"messages": [{"role": "user", "content": "Explain a GPU in one sentence."}]}'
```

The reply is in `choices[0].message.content`. Because the API follows the OpenAI format, most OpenAI client libraries work when you set their base URL to `http://SERVER_ADDRESS/v1` and their API key to your key.

## Common mistakes

- **401 or "Invalid API Key"**: the API always needs the key, also in the chat page's settings.
- **The server runs but the page does not answer**: the model is still downloading. Bigger files take longer; wait and reload.
- **The model does not start or is very slow**: it does not fit in the GPU memory. Choose a smaller quantization (for example `Q4_K_M` instead of `Q8_0`) or a configuration with more **VRAM**.
- **Want another model later**: the simplest way is a new server with the new `LLAMA_ARG_HF_REPO`. Destroy the old one when you no longer need it, so its disk stops costing money.

## Keep it private

> [!WARNING]
> The page and the API use plain `http`. Anyone who has the address and the key can use your model. Do not share the key and do not paste secrets into chats.

## When you are done: stop or destroy

- **Stop** ends the compute charge. The downloaded model stays in `/workspace/models` on the disk, which is still billed, and the key stays the same.
- **Destroy** ends every charge and deletes the disk with the model. Open the server, go to **Settings** and choose **Destroy server**.

## Next

- [Serve an OpenAI-compatible API with vLLM](/docs/tutorial-model-api) for higher throughput with many users.
- [Run a vector database for search with Qdrant](/docs/tutorial-vector-database-qdrant)
- [Control costs](/docs/tutorial-save-money)
