When using models in a DSH environment, you may encounter cases where a specific model endpoint is restricted by network region and must be accessed through a proxy, while other models from the same provider work fine over direct connections. Configuring a proxy via global environment variables affects all requests; directly modifying baseURL may obscure the true upstream. dsh-plugin-model-proxy solves this problem by allowing proxy routing for specific provider/model pairs at the transport layer, while other requests remain direct and baseURL in the configuration remains unchanged.
This is a community DSH plugin maintained by biyuhao. It provides a rule-based system for routing specific model requests to designated proxy servers, with a built-in settings interface for batch and group management.
Core Features¶
The plugin supports rule-based fine-grained routing. Matching priority is: exact model > prefix match > wildcard.
- Routing rules: Supports configuration in the
{provider, model, proxyUrl, enabled}format, with exact model matching having the highest priority. - Purpose filtering: Supports adding a
purposefield to a rule, such ascompaction, so that specific request types go through the proxy while conversation requests and similar remain direct. - Credential integration: Supports referencing
user:passwordentries in the DSH credential service viacredentialRef, decoupling proxy passwords from configuration. - Connectivity testing: After adding a proxy rule, automatic probing checks whether the CONNECT or SOCKS handshake succeeds; the result is recorded in the host log.
- Protocol support: Supports
http://,https://,socks5://, andsocks5h://. - Real-time effect: After modifying rules, the change takes effect on the next
llm/streamcall without restarting the process. - Settings interface: Accessed via
Settings → Plugins → Model Proxy, it provides a provider selector (dropdown menu or custom text) and batch management functionality.
Installation¶
It is recommended to install using DSH’s profile management method, which automatically handles dependencies and injects the loader entry.
dsh plugin --profile <name> add dsh-plugin-model-proxy
Configuration¶
Configure via UI¶
Go to the Settings → Plugins → Model Proxy page, and use the interface to select the provider, model, and proxy address, then enable the rule.
Configure via file¶
Add a model-proxy configuration section to ~/.dsh/settings.yaml. The setting proxyUrl: "" means direct connection (no proxy).
model-proxy:
enabled: true
debug: false
defaultProxy: ""
rules:
- provider: opencode
model: muse-spark-1.2-contributor
proxyUrl: socks5://127.0.0.1:1080
enabled: true
- provider: opencode
model: "*"
proxyUrl: ""
enabled: true
Notes and Manual Installation¶
The plugin runs with the privileges of the current dsh process. Before installing, review the source code and license.
- Manual installation: If you need to manage the configuration manually, install the dependencies in the profile directory first, then create or modify
~/.dsh/cordis.patch.ymland insert a loader entry.
# ~/.dsh/cordis.patch.yml
- insert:
- id: model-proxy/host
name: dsh-plugin-model-proxy
config: {}
- Field names and nesting: The identifier field for a loader entry is
name:, notmodule:. Newly inserted lines must be nested underinsert:. Note that only the host half is a loader entry; the browser half is automatically discovered bydsh.client. - Avoid conflicts: Do not manually add a
model-proxy/clientline, as this will cause browser code to run in the Node process. Also, do not combine the manual configuration path with the recommended profile-based installation method above, otherwise startup conflicts will occur.
The plugin implements routing by intercepting fetch and listening to the llm/stream event. It does not modify baseURL, preserving the original configuration. See GitHub for the complete source code and repository.