The LM Studio CLI (lms) is a command-line tool for managing models, controlling the API server, and chatting with models directly from your terminal.
lms is LM Studio’s official command-line interface built with TypeScript and Node.js. It allows you to:
License: MIT (Open Source)
Repository: lmstudio-ai/lms
Stars: 4.3k+
LM Studio includes the CLI tool. Install it with:
macOS/Linux:
npx lmstudio install-cli
Windows:
npx lmstudio install-cli
This adds the lms command to your PATH.
# Clone the repository
git clone https://github.com/lmstudio-ai/lmstudio-js.git --recursive
cd lmstudio-js
# Install dependencies
npm install
# Build
npm run build
# Run CLI
node publish/cli/dist/index.js --help
Open a new terminal window and run:
lms --help
Expected output shows version info and available commands.
# Show all commands
lms --help
# Show help for specific command
lms chat --help
# Start interactive chat with default model
lms chat
# Chat with specific model
lms chat --model "llama-3-8b-instruct"
# Chat with system prompt
lms chat --system-prompt "You are a helpful coding assistant"
Chat Slash Commands:
| Command | Description |
|---|---|
/help |
Show help message |
/model |
Change model |
/download |
Download a model |
/system-prompt |
Set system prompt |
/exit or /quit |
Exit chat |
# List downloaded models
lms ls
# List loaded models in memory
lms ps
# Search and download models
lms get llama-3
# Load model into memory
lms load llama-3-8b-instruct
# Load with GPU offload
lms load llama-3-8b-instruct --gpu=max
# Load with custom identifier
lms load openai/gpt-oss-20b --identifier="my-model"
# Unload specific model
lms unload llama-3-8b-instruct
# Unload all models
lms unload --all
# Import model file
lms import /path/to/model.gguf
# Start local API server
lms server start
# Stop local API server
lms server stop
# Check server status
lms server status
# Manage inference runtime
lms runtime
# Survey available GPUs
lms runtime survey
# Stream incoming/outgoing messages
lms log stream
# Maximum GPU offload
lms load model-name --gpu=max
# Automatic GPU offload
lms load model-name --gpu=auto
# Specific GPU offload percentage (0.0-1.0)
lms load model-name --gpu=0.8
# No GPU offload (CPU only)
lms load model-name --gpu=0
# Set custom context length
lms load model-name --context-length=8192
# List models with JSON output
lms ls --json
# List loaded models with JSON
lms ps --json
# Load with custom identifier for API use
lms load model-name --identifier="custom-name"
# Use in API calls as "custom-name"
# Start chat
lms chat
# In chat:
# - Type your message
# - Use /model to switch models
# - Use /exit to quit
# Download model
lms get mistral-7b-instruct
# Load model
lms load mistral-7b-instruct
# Check it's loaded
lms ps
# Start server
lms server start
# Test with curl
curl http://localhost:1234/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "mistral-7b-instruct",
"messages": [{"role": "user", "content": "Hello!"}]
}'
# List all models
lms ls
# Load and test each
for model in $(lms ls --json | jq -r '.[].id'); do
echo "Testing $model"
lms load "$model"
lms chat --prompt "Test message"
lms unload "$model"
done
The CLI uses LM Studio’s configuration located at:
%APPDATA%/LM Studio~/Library/Application Support/LM Studio~/.config/LM Studio# Set custom LM Studio API endpoint
export LMSTUDIO_API_BASE=http://localhost:1234
# Set authentication token (if configured)
export LMSTUDIO_API_KEY=your-token
# Ensure LM Studio is installed and run at least once
# Reinstall CLI
npx lmstudio install-cli
# Check PATH includes npm global binaries
echo $PATH
# Ensure LM Studio is running
# Start the server
lms server start
# Check server status
lms server status
# List available models
lms ls
# Download the model first
lms get model-name
# Survey available GPUs
lms runtime survey
# Ensure GPU drivers are installed
# Restart LM Studio
import subprocess
import json
# List models
result = subprocess.run(['lms', 'ls', '--json'], capture_output=True, text=True)
models = json.loads(result.stdout)
for model in models:
print(f"Model: {model['id']}")
#!/bin/bash
# Load model
lms load llama-3-8b-instruct
# Start server
lms server start
# Wait for server
sleep 2
# Test with curl
curl http://localhost:1234/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "llama-3-8b-instruct", "messages": [{"role": "user", "content": "Hello!"}]}'
lmstudio package@lmstudio/sdkAny questions?
Feel free to contact us. Find all contact information on our contact page.