Skip to main content

lmsp - LM Studio Prompt CLI

A simple command-line interface for sending prompts to LM Studio loaded models.

Features

  • Send prompts to locally loaded LM Studio models
  • Uses the first loaded model by default (or specify with -m)
  • Requires pre-loaded models: Models must be loaded using lms load <model> or LM Studio desktop app
  • Support for piping input from other commands
  • Verbose logging with -v flag for debugging
  • Simple and fast command-line interface

Installation

# Install globally with pip
pip install lmsp

# Or install globally with uv (recommended)
uv tool install lmsp

Alternative Installation Methods

Install from source

# Using uv tool (recommended - installs globally)
uv tool install git+https://github.com/kmlawson/lmsp.git

# Or clone and install locally
git clone https://github.com/kmlawson/lmsp.git
cd lmsp
uv tool install .

Install in virtual environment

# Using uv
uv venv
source .venv/bin/activate
uv pip install lmsp

# Or using pip
python -m venv venv
source venv/bin/activate
pip install lmsp

Development installation

# Clone and install in development mode
git clone https://github.com/kmlawson/lmsp.git
cd lmsp
uv pip install -e .  # or pip install -e .

Configuration

lmsp supports a configuration file to set default values for command-line options. The configuration file is located at ~/.lmsp-config and is automatically created with default values when you first run lmsp.

Configuration File Format

The configuration file uses JSON format:

{
  "model": null,
  "port": 1234,
  "pipe_mode": "append",
  "wait": false,
  "stats": false,
  "plain": false,
  "verbose": false
}

Configuration Options

  • model: Default model to use (null means use first loaded model)
  • port: Default LM Studio server port (1234)
  • pipe_mode: How to handle piped input ("replace", "append", or "prepend")
  • wait: Disable streaming by default (false)
  • stats: Show response statistics by default (false)
  • plain: Disable markdown formatting by default (false)
  • verbose: Enable verbose logging by default (false)

Example Custom Configuration

{
  "model": "google/gemma-3n-e4b",
  "port": 1234,
  "pipe_mode": "append",
  "wait": true,
  "stats": true,
  "plain": false,
  "verbose": false
}

This configuration would:

  • Use "google/gemma-3n-e4b" as the default model
  • Wait for complete responses (no streaming) and beautify markdown output
  • Show response statistics by default
  • Append piped content to prompts

Command-line arguments always override configuration file settings.

Usage

Prerequisites

Before using lmsp, you need to load a model:

# Load a model using lms command
lms load google/gemma-3n-e4b

# Or use LM Studio desktop app to load a model

Basic usage

lmsp "What is the capital of France?"

Specify a model

# Use a specific model (must be already loaded)
lmsp -m llama-3.2-1b-instruct "Explain quantum computing"

# Enable verbose logging for debugging
lmsp -v -m google/gemma-3n-e4b "What is AI?"

Pipe input

# Simple piping - replaces the prompt
cat document.txt | lmsp

# Combine prompt with piped content (default appends)
cat document.txt | lmsp "Summarize this document:"

# Control how piped input is combined
cat context.txt | lmsp "Answer based on context:" --pipe-mode prepend
cat document.txt | lmsp "Summarize:" --pipe-mode append

# Real example: Translate a text to English
cat tests/testdata/test-text.md | lmsp "Please translate the following text to English:"

Check loaded models

# List currently loaded models
lmsp --list-models

# List all available models (not loaded)
lms ls

Check server status

lmsp --check-server

Get help

lmsp --help
# or lmsp -h

Security Considerations

When using lmsp, please be aware of the following security considerations:

Piped Content

  • Be cautious about what content you pipe to lmsp. The piped content is directly appended or prepended to your prompt without sanitization.
  • Avoid piping untrusted content or files from unknown sources
  • Be especially careful when piping content that might contain prompt injection attempts or malicious instructions
  • Example of what to avoid:
    # Don't pipe untrusted user input or files
    cat untrusted_user_file.txt | lmsp "Summarize this:"
    

Model Selection

  • Only use trusted models that you have intentionally loaded into LM Studio
  • Be aware that models will execute the prompts you send, including any piped content

Local Usage

  • lmsp is designed for local use with your own LM Studio instance
  • It connects to localhost only and does not expose any network services

Prerequisites

  1. LM Studio must be installed
  2. The LM Studio server must be running (lms server start)
  3. At least one model must be loaded (lms load <model>)

Running Tests

python -m unittest tests.test_lmsp -v

Planned Features

  • Ability to attach images with -a flag for multi-modal models
  • Ability to continue from last prompt
  • Enhanced piping support for documents

Metadata

Release files for lmsp 0.5.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lmsp 0.5.7
File Size Uploaded Provenance Actions
lmsp-0.5.7.tar.gz 25.8 kB Without provenance Details for lmsp-0.5.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lmsp 0.5.7
File Interpreter ABI Platform Actions
lmsp-0.5.7-py3-none-any.whl Python 3 none any Details for lmsp-0.5.7-py3-none-any.whl

Total release size: 39.6 kB

Release files / lmsp-0.5.7.tar.gz

Download URL lmsp-0.5.7.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
32d0d03b1d4fda4a63bfbc0112076cfc805de35f0d8afc1fd57544844267bd65
BLAKE2b-256 checksum
How to use checksums
576e92577ddfa14110176efd56932f0f1270f4f3a342f47c9e0427e3b0d3a09c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / lmsp-0.5.7-py3-none-any.whl

Download URL lmsp-0.5.7-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1cee2a325eb9291ba4f4f7b8478c5b190e16a6970bd1b6a33d2a8e51f9cb7767
BLAKE2b-256 checksum
How to use checksums
737b63dc14aee7287acca1fa6f80dfda55221a561347867291efd955c0ce2764
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Security for lmsp 0.5.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page