llama-cli tool provides a powerful command-line interface for running LLM inference. It supports interactive conversations, structured outputs, and various sampling configurations.
Quick Start
1
Load a model
Start llama-cli with your GGUF model:
2
Add a prompt
Generate text from a prompt:
3
Enable conversation mode
Use
-cnv for interactive chat:Loading Models
From Local Files
From Hugging Face
When using
-hf, llama-cli automatically downloads the model and any associated multimodal projectors (like for vision models). Use --no-mmproj to disable automatic projector loading.From Docker Hub
Conversation Mode
Conversation mode provides an interactive chat interface that automatically formats messages using the model’s chat template.Basic Conversation
Single-Turn Conversation
Conversation Options
boolean
default:"auto"
Enable conversation mode. Automatically enabled if the model has a chat template.
string
System prompt to use with the model (if applicable based on chat template).
boolean
default:"false"
Run conversation for a single turn only, then exit when done.
string
Halt generation at this prompt and return control in interactive mode.
Prompting
Direct Prompts
From Files
Multiline Input
Grammar Constraints
Constrain model outputs to follow specific formats using BNF-like grammars or JSON schemas.Using Grammar Files
Inline Grammar
JSON Schema
For JSON schemas with external
$refs, use --grammar combined with the json_schema_to_grammar.py conversion script instead.Sampling Parameters
Control how tokens are generated with various sampling strategies.Temperature and Top-K/Top-P
Repetition Control
Advanced Sampling
Sampler Order
Context and Generation Control
Context Window
Generation Length
Batch Processing
GPU Acceleration
Advanced Features
LoRA Adapters
Control Vectors
Reasoning Models
Performance Options
Threading
Memory Optimization
KV Cache Configuration
Common Use Cases
Code Completion
Creative Writing
Structured Data Extraction
Output Control
Display Options
Simple I/O Mode
Environment Variables
Many parameters can be set via environment variables:Command-line arguments take precedence over environment variables when both are set.
Logging
See Also
Server
OpenAI-compatible API server
Embeddings
Generate text embeddings
Multimodal
Vision and audio models
Speculative Decoding
Accelerate generation with draft models

