Preface¶
The built-in openrouter router in DeepSeek Harness (dsh) uses a static model list included at release. New models launched on OpenRouter (such as deepseek/deepseek-v4.1-flash) will not appear in the model selector until the next DSH release. The dsh-openrouter-live plugin provides a new router for dsh that reads OpenRouter’s /models endpoint directly, ensuring the model list is updated in real-time.
Core Features¶
This plugin extends DSH’s capabilities by reading real-time data from OpenRouter:
- Real-time Model List: The list refreshes every 10 minutes. Models are sorted by name, and input/output prices are calculated per million tokens and appended to the model name. If a refresh fails, the last valid list is retained.
- Model Metadata: Context windows and output limits are taken directly from OpenRouter’s API. Reasoning levels are read from the model’s
reasoning.supported_efforts, and only supported options are displayed in the selector. - Image Input: Supports image input. The plugin inlines images and adheres to DSH’s image budget: images are scaled, and older images are evicted when the request size is too large.
- Reasoning Continuity: The plugin sends
reasoning_details(including signatures and encrypted entries) in subsequent requests, enabling models like Claude or DeepSeek to maintain reasoning state across tool calls. - Prompt Caching: For Anthropic models, cache breakpoints are set at the system prompt and the latest message. For other providers, the plugin uses the
x-session-idheader to keep the session consistent with the upstream provider, thus maintaining cache hits. - Failure Classification: Errors are mapped to DSH failure codes so that the retry plugin only retries on cases worth retrying (such as rate limits, 5xx errors, or empty responses), while skipping errors like invalid keys or context overflow.
- Actual Cost Tracking: The plugin records the
usage.costreported by OpenRouter for each response, which is the actual charge rather than an estimate. Costs are attached to the current session and all delegated sub-sessions. Data is persisted in~/.dsh/openrouter-live/costs.jsonl, with each line corresponding to a JSON record containing OpenRouter’s generation ID. - Shared Credentials: By default, this router reads the same
OPENROUTER_API_KEYcredentials as the built-inopenrouterrouter, requiring no additional configuration.
Installation and Activation¶
Please ensure the environment meets the following requirements before installation:
* DeepSeek Harness Version: 0.1.6-alpha.2 to 0.1.7
* Node.js Version: ^22.19 or >=24
* An active OpenRouter API Key
Execute the following command to install the plugin:
dsh plugin --profile web add dsh-openrouter-live
After installation, the configuration file must be restarted. If the API Key has not been stored yet, please select the OpenRouter card in the settings to store it, or export the OPENROUTER_API_KEY environment variable.
Configuration¶
All configuration items for the plugin are located in ~/.dsh/profiles/<profile>/cordis.patch.yml, under the openrouter-live node.
Basic Configuration Example¶
- id: openrouter-live
config:
models: ['deepseek/*', 'anthropic/claude-*']
priceInName: true
Key Configuration Options¶
| Field | Default Value | Description |
|---|---|---|
models |
[] |
A wildcard filter list for model IDs. An empty list indicates displaying all models. |
priceInName |
true |
Whether to append prices to the model name. |
apiKeyEnv |
OPENROUTER_API_KEY |
The name of the environment variable to read credentials from. |
maxTokens |
32768 |
Output limit. If not set, this value is used, but the model’s own limit takes precedence. |
costLedgerPath |
$DSH_HOME/openrouter-live/costs.jsonl |
The path to the cost log file. Set to an empty string to keep it in memory only. |
Typical Usage¶
Set the default model:
agent-default-model:
provider: openrouter-live
model: deepseek/deepseek-v4.1-flash
Select a model in the Composer, or use the command to view costs:
/cost
Notes¶
- License: This project is licensed under the MIT License.
- Source Code Review: As a plugin, it runs with the current process permissions. It is recommended to inspect the source code before installation.
- Installation Method: Please install the packaged
.tgzfile, not the directory, otherwise it will cause dependency resolution errors.