Command line interface for conversing with language models.
lm [-c context... --] [-i] [-n] [-t] [-f file | instruction | -]
lm command [options] [arguments]
Install with Cargo:
cargo install --path .
To install the man page:
gzip -c man/lm.1.troff > /usr/local/share/man/man1/lm.1.gz
# Enter interactive mode
lm
# Quick question in terminal
lm "What is a language model?"
# Read from stdin
echo "Write a hello world program" | lm
# Read instructions from file
lm -f instructions.txt
# Use files as context
lm -c README.md
lm -c src/*.rs -- "Explain this code"
# Start new conversation
lm -n
# Don't save conversation
lm -t "Quick question"
# List conversations
lm ls
# Remove conversation
lm rm 2
# Switch conversation
lm sw 1
# Print conversation messages
lm ll # last message
lm ll -a # all messages
lm ll -n 3 # last 3 messages
lm ll -t -n 2 # first 2 messages
lm ll 2 # last message from conversation index 2
# Store API key
lm auth # prompts interactively
echo "$MY_API_KEY" | lm auth - # read from stdin
Config file ($XDG_CONFIG_HOME/lm/config.toml
):
model = "claude-3-7-sonnet-latest" # default model
max_tokens = 4096 # maximum tokens in response
[thinking]
type = "enabled" # "disabled" (default) or "enabled"
budget_tokens = 1024 # token limit for thinking (when enabled)
Environment variables (overrides configuration):
LM_ACTIVE
: Active conversation file locationLM_API_KEY
: API keyLM_CONFIG
: Configuration file locationLM_CONVERSATIONS
: Conversation directory locationLM_CREDENTIALS
: Credentials file locationLM_HISTORY
: Readline history file location
See man lm
for complete documentation.