LLM plugin for models served by LMStudio (local LLM studio HTTP API)
Project description
llm-lmstudio
This is a plugin for Simon Willison's LLM command-line utility that lets you talk to models running on a local LMStudio server.
Installation
Make sure you have llm installed, then install this plugin from PyPI:
pip install llm-lmstudio
Or, to install the latest development version directly from GitHub:
llm install -U git+https://github.com/agustif/llm-lmstudio.git
Alternatively, llm install llm-lmstudio will also find and install the plugin.
Usage
First, you need LMStudio running with a model loaded. The plugin talks to the LMStudio server API, which usually runs at http://localhost:1234.
Once the server is up, the plugin should automatically find the models you have loaded in LMStudio. You can check this using the llm models command:
llm models list
You should see your LMStudio models listed, prefixed with lmstudio/ (e.g., lmstudio/llava-v1.5-7b).
To run a prompt against a model:
# Replace 'your-model-id' with the actual ID shown in 'llm models list'
# e.g., llm -m lmstudio/llava-v1.5-7b "Describe this image"
llm -m lmstudio/your-model-id -o temperature 0.7 -o max_tokens 100 "Tell me a joke"
To start an interactive chat session:
llm chat -m lmstudio/your-model-id
You can exit the chat by typing exit or quit.
Vision Model Support
The plugin supports vision-language models (VLMs).
- When using a VLM, you can attach images using the standard
llmattachment syntax:llm chat -m lmstudio/your-vlm-id -a path/to/image.png "Describe this image"
Or for a single prompt:llm -m lmstudio/your-vlm-id -a path/to/image.png "What is in this picture?"
- The plugin will encode the image and send it to the model.
- This feature's success depends on the specific VLM, its configuration in LM Studio, and LM Studio's API correctly handling image data.
- Models that support vision may have a
👁️(eye icon) in theirdisplay_suffixwhen inspected viallm inspect -m lmstudio/your-vlm-id, though this may not always render inllm models list.
Tool Support
Some models loaded in LMStudio can call tools. The plugin will surface those tool invocations and their results when interacting with such models.
Example:
$ llm --tool llm_version "What version of LLM is this?" --td
For more information about tool calling support consult the llm documentation on tools.
Embedding Models
If you have embedding models loaded in LMStudio (their names usually contain "embed"), the plugin will register them too. You can list them with:
llm embed-models
You should see models like lmstudio/text-embedding-nomic-embed-text-v1.5@f16.
To generate embeddings for text using one of these models:
llm embed -m lmstudio/your-embedding-model-id -c "This is the text to embed"
Configuration
The plugin connects to the LMStudio server API. By default, it tries http://localhost:1234.
You can configure the server URL(s) using the LMSTUDIO_API_BASE environment variable.
- For a single server:
export LMSTUDIO_API_BASE="http://your-server-address:port"
- For multiple servers (the plugin will try them in order):
export LMSTUDIO_API_BASE="http://server1:1234,http://server2:5678,https://server3:custom_port"
The variable accepts one or more http[s]://host:port values, separated by commas (spaces around commas are optional). The plugin automatically attempts to append /v1 or /api/v0 to the determined base URL(s) as needed when probing the server.
Model Options
You can pass generation options supported by the LMStudio API (like temperature, max_tokens, top_p, stop) using the -o flag:
llm -m lmstudio/your-model-id -o temperature 0.7 -o max_tokens 100 "Tell me a joke"
Automatic Model Loading
If a selected model is not currently loaded in LM Studio, the plugin will attempt to automatically load it by invoking lms load <model_id> (if lms CLI is installed and configured). You may see progress messages from LM Studio in your terminal during this process.
Development
To set up this plugin for development:
- Clone the repository.
- Run tests
uv run pytest
Or do the classic complicated dance:
- Create a virtual environment:
python -m venv .venv - Activate it:
source .venv/bin/activate - Install dependencies, including dev dependencies: `pip install -e . --group dev
- Run tests:
pytest
The asynchronous tests in tests/test_llm_lmstudio_async.py (among others) use pytest-vcr to record and replay HTTP interactions with the LM Studio server. To record new cassettes:
- Ensure LM Studio is running with the target model(s) loaded (e.g.,
llava-v1.5-7b). - Temporarily set
record_mode='all'in the@pytest.mark.vcrdecorator for the relevant tests intests/test_llm_lmstudio_async.py. - Run
pytest -v -s tests/test_llm_lmstudio_async.py. - Cassettes will be saved in
tests/cassettes/. - Important: Change
record_modeback to'once'after recording. - Commit the new/updated cassettes.
Missing features / Known Issues:
- The reliability and capabilities of image support can vary significantly based on the specific VLM and its implementation within LM Studio.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_lmstudio-0.2.1.tar.gz.
File metadata
- Download URL: llm_lmstudio-0.2.1.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8bdfc9b851de4e61d56c8b41c3ada23a2a7959e5a74faa6ff880dbe9d59cbb7
|
|
| MD5 |
2f7a442802ab4743d94a01bb464bcc3c
|
|
| BLAKE2b-256 |
913aa90005faeb16d3d0ec0a1042c5958e4ec540874cb8be5c23ae9cec6574a5
|
Provenance
The following attestation bundles were made for llm_lmstudio-0.2.1.tar.gz:
Publisher:
publish.yml on agustif/llm-lmstudio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_lmstudio-0.2.1.tar.gz -
Subject digest:
c8bdfc9b851de4e61d56c8b41c3ada23a2a7959e5a74faa6ff880dbe9d59cbb7 - Sigstore transparency entry: 747183615
- Sigstore integration time:
-
Permalink:
agustif/llm-lmstudio@a63ff776fa93817c85ad8e86e1656fdfce67a10e -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/agustif
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a63ff776fa93817c85ad8e86e1656fdfce67a10e -
Trigger Event:
release
-
Statement type:
File details
Details for the file llm_lmstudio-0.2.1-py3-none-any.whl.
File metadata
- Download URL: llm_lmstudio-0.2.1-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09748cb047d2ff7a541f4c722dae25d2e9f9da73f34aa46a970872bc7618d45a
|
|
| MD5 |
5b928f2edc44e09800ba5cedb284d369
|
|
| BLAKE2b-256 |
8753a0f9308ab47d5ba960a94c043da67661e520c937ac46d8556a7245c7060c
|
Provenance
The following attestation bundles were made for llm_lmstudio-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on agustif/llm-lmstudio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_lmstudio-0.2.1-py3-none-any.whl -
Subject digest:
09748cb047d2ff7a541f4c722dae25d2e9f9da73f34aa46a970872bc7618d45a - Sigstore transparency entry: 747183616
- Sigstore integration time:
-
Permalink:
agustif/llm-lmstudio@a63ff776fa93817c85ad8e86e1656fdfce67a10e -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/agustif
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a63ff776fa93817c85ad8e86e1656fdfce67a10e -
Trigger Event:
release
-
Statement type: