Skip to main content

Syntax

Description

Run a downloaded GGUF model using llama-cli (interactive chat) or llama-server (OpenAI-compatible API server). The command searches for the model in your local llama.cpp cache and launches it with appropriate hardware acceleration settings. Requires llama-cli (for interactive mode) or llama-server (for server mode) to be installed and available in your PATH.

Arguments

string
required
Model file or name to run. Can be:
  • Full path to a GGUF file
  • Model filename (searches local cache)
  • Partial model name (e.g., llama-8b, mistral)

Options

boolean
default:"false"
Run as an OpenAI-compatible API server instead of interactive chat. Uses llama-server instead of llama-cli.
integer
default:"8080"
Port for the API server (only applies when --server is used).
integer
default:"-1"
Number of GPU layers to offload. Use -1 to offload all layers to GPU (full GPU inference). Use 0 for CPU-only inference. Values between 0 and the model’s layer count enable partial GPU offloading.
integer
default:"4096"
Context size in tokens. Maximum number of tokens the model can process in a single prompt/conversation. Larger values require more VRAM/RAM.

Usage Examples

Run interactive chat (default)

Launches an interactive chat session with the model using llama-cli.

Run as API server

Starts an OpenAI-compatible API server on port 8080. You can then make requests:

Run with custom GPU offload

Offloads 20 layers to GPU, keeping the rest on CPU. Useful for models that don’t fully fit in VRAM.

Run with larger context

Increases context window to 8192 tokens (from default 4096). Requires more memory.

CPU-only inference

Forces CPU-only inference by disabling GPU offload.

Combined options

Runs as API server on port 8888 with 30 GPU layers and 16K context.

Example Output

Interactive Mode

Server Mode

GPU Layer Offloading

The --ngl (number of GPU layers) flag controls how much of the model runs on GPU vs CPU:
Use --ngl -1 for maximum speed when your GPU has enough VRAM. If you get out-of-memory errors, try reducing to a specific number like --ngl 20.

Context Size Guidelines

Larger context sizes require significantly more VRAM/RAM. A 7B model at 4K context might use 6GB VRAM, but at 16K context could use 10GB+.

Requirements

  • llama.cpp must be installed with llama-cli (for interactive) or llama-server (for API mode) in your PATH
  • Install from: https://github.com/ggml-org/llama.cpp
  • Models must be downloaded first using llmfit download or manually placed in the llama.cpp cache

Notes

  • The command automatically detects your GPU and enables Metal (Apple Silicon), CUDA (NVIDIA), or ROCm (AMD) acceleration if available
  • Model search checks:
    1. Exact filename in current directory
    2. Exact filename in ~/.cache/llama.cpp/
    3. Partial name match in cache (e.g., llama-8b matches Llama-3.1-8B-Instruct.Q4_K_M.gguf)
  • Server mode is fully compatible with OpenAI API clients (LangChain, LiteLLM, etc.)
  • Interactive mode supports multi-turn conversations with automatic context management