Introduction¶
In local agent development, directly invoking remote APIs to handle high token-consumption tasks (such as text compression and session title generation) can be costly. DSH’s plugin-based architecture allows users to customize behavior. This article introduces a router plugin that intercepts such “non-critical but token-intensive” tasks and forwards them to a locally running LM Studio.
Plugin Introduction¶
dsh-lmstudio-router is a local model router for the DSH Web GUI, maintained by xiaoyizhuang03-droid. It routes non-critical but token-intensive requests (bulk text work, compression, session titles) to local LM Studio models, executes them through the OpenAI-compatible /v1 endpoint, and automatically starts LM Studio when it is not running.
Core Features¶
- Intelligent Routing: Routes token-expensive tasks (text work, compression, session titles) to local LM Studio models.
- Auto Launch: Automatically starts LM Studio when it is not running.
- Context Adaptation: Adapts each local request to the model’s context window (default 8192).
- Zero Dependencies: This is a dependency-free host plugin.
Installation and Activation¶
Add the plugin via the command line:
dsh plugin --profile web add link:<path-to-this-package>
After installation, you need to add an override in the configuration file. Edit ~/.dsh/profiles/web/cordis.patch.yml:
- id: lmstudio-router
name: 'dsh-lmstudio-router'
config:
baseUrl: http://127.0.0.1:1234/v1
model: qwen3.5-9b
contextWindow: 8192
autoLaunch: true
After saving the file, restart the dsh web service.
Typical Usage¶
Once the configuration is active, you can control where requests are directed by using forced routing markers at the beginning of user messages. Supported markers include:
- [local] or local:
- [remote] or remote:
For example, sending a message containing [local] routes the task to local LM Studio; otherwise, the default routing policy is used.
Use Cases and Considerations¶
Use Cases:
- You need to handle large volumes of high token-consumption tasks such as text summarization and compression.
- You want to leverage local compute resources and reduce remote API costs.
Considerations:
- The runtime environment must meet the Node.js version requirement (^22.19.0 or >=24.0.0).
- Local LM Studio must be running at http://127.0.0.1:1234/v1 and configured with an OpenAI-compatible /v1 endpoint.
- The plugin runs with the permissions of the current dsh process. It is recommended to review the source code and license before installation.
Conclusion¶
This is a lightweight routing solution for developers who want to reduce remote API costs and leverage local compute resources. For more details, see the GitHub repository.