Introduction¶
When connecting DeepSeek official APIs, compatible relays, and third-party search services to DSH simultaneously, Search and Fetch often require separate sets of addresses and keys; different model Providers may also prefer using different channels. Switching channels after failures and rotating multiple keys are manual tasks, while usage and costs are scattered across various consoles. It is difficult to answer “which route was actually taken, how many attempts were made, and how much was spent” after a single tool call.
dsh-search-ledger (Maintainer: gordan-code) is a plugin for channel management and cost statistics for DSH’s native web_search / web_fetch. It consolidates Provider binding, key pools, ordered failover, and a local ledger into a single settings page. It tracks search and fetch requests passing through the plugin’s backend—not model tokens. Costs displayed in the interface are local estimates and do not replace service provider invoices. The current version is 0.5.1, compatible with DSH 0.2.1-rc.2. The plugin falls under the “Model Inference” category in the community directory; please review the repository source code and the MIT license before installing. The plugin runs with the permissions of the current DSH process, and keys and ledger data are stored locally; you must protect DSH_HOME according to your own security policies.
What is this¶
In short: It selects channels for Search / Fetch based on the model Provider, manages multiple keys and failure failover, and records the usage and estimated costs of every API attempt locally.
Compared to plugins that “only connect a specific search API,” the extra layer here is linking request routing with cost recording. For example, Search for the official DeepSeek Provider uses the official API, Search for a relay Provider uses the relay, and Fetch uniformly uses local HTTP—each can use its own pricing and credentials. Failed attempts during failover are also recorded; if prices are not filled in, they are shown as unknown rather than treated as free.
Core Features¶
Routing and Overrides¶
- Search and Fetch can use different channels; they can also be overridden individually by Provider, globally, or per session. The override order is: Session override → Global override → Provider binding.
- Ordered failover can be enabled: Engines missing keys are skipped; after failures, rate limits, or timeouts, the next channel is tried according to the configured order; success or legitimate empty results stop the process.
- Installing the patch selects the
web-search-metered/web-fetch-meteredbackends. Higher priority configurations may override this; the plugin does not bind to model Providers by default and will not autonomously select paid channels when unbound.
Key Pools and Rotation¶
- Each channel can store multiple keys (one per line, up to 32). Normal requests use them sequentially starting from the rotation point; if a single key fails, other keys in the same channel are tried first.
- Keys are stored in the host credential store, isolated by
DSH_HOME, Profile, and channel. They are not written in plaintext to plugin configuration or the ledger.
Local Ledger¶
- Every actual attempt is recorded separately; the same failover round is linked via
operationId. Historical records use the price at the time of the request and are not recalculated based on current configuration. - Usage can be filtered by date, channel, source Provider, session, and currency. The ledger does not store keys, Authorization headers, query terms, or webpage content. The data directory is
$DSH_HOME/web-search-billing/(the project was renamed fromdsh-web-search-billing, but the internal directory name retains the old name).
Supported Channels¶
| Channel | Search | Fetch | Notes |
|---|---|---|---|
| DeepSeek Official API | ✓ | ✓ | Search and Fetch are priced separately |
| DeepSeek Compatible Relay | ✓ | ✓ | Requires compatible tool API |
| TinyFish | ✓ | ✓ | Uses official API addresses for corresponding operations |
| Baidu Qianfan | ✓ | — | Search only |
| Tavily | ✓ | ✓ | basic Search / Extract; credits are conservatively reserved locally |
| SearXNG | ✓ | — | JSON output must be enabled |
| Local HTTP | — | ✓ | Reuses DSH fetch backend |
Whether services are free or their quotas depend on individual service provider accounts; SearXNG and local fetching still incur deployment and network costs.
Installation and Activation¶
Requires Node.js ≥ 22.19 and DSH 0.2.1-rc.2; other DSH versions are unverified, and forcible installation bypassing compatibility checks is not recommended.
Before installation, stop DSH processes sharing that DSH_HOME and back up the target Profile and plugin data. Below, replace web with your actual Profile (commonly desktop in the desktop version):
dsh plugin --profile web add "dsh-search-ledger@0.5.1" --ignore-scripts
dsh-search-ledger@0.5.1 is published on npm. A standard npm install dsh-search-ledger@0.5.1 only adds the package to the current Node project and does not register it as a plugin for DSH. Before updating, exit DSH first, and do not mix old and new packages within the same Profile.
If the old package dsh-web-search-billing is already installed, exit DSH first, back up the Profile and $DSH_HOME/web-search-billing/, then remove the old package before installing the new one. Do not keep both packages in the same Profile:
dsh plugin --profile web remove dsh-web-search-billing
dsh plugin --profile web add "dsh-search-ledger@0.5.1" --ignore-scripts
Uninstallation (does not automatically delete ledger data):
dsh plugin --profile web remove dsh-search-ledger
Typical Usage: Configuration Order¶
After restarting DSH, open DSH Search Ledger in the settings sidebar. It is recommended to proceed in the following order.
- In Channel Management, add a channel by filling in the name, address, and rates, then save. New channels are disabled by default and will not send requests automatically.
- Expand the channel and enter keys one per line in the API Key area to save the key pool. Saving again replaces the entire pool rather than appending; saved keys are not displayed back in the interface.
- In Channel Address, Rates & Advanced Config, check “Enable” and then save the channel configuration. Saving keys and enabling the channel are two separate steps.
- Go to Providers & Overrides, select Search and Fetch channels respectively for the actual model Provider IDs, and save.
- Confirm that the host Web tools use the
web-search-metered/web-fetch-meteredbackends. Trigger a nativeweb_searchorweb_fetch, then check Usage & Costs for recent records.
For automatic failover, enable “Ordered Failover” under the corresponding operation and adjust channel order and timeout budgets. See the repository example provider-routing.patch.yml; Provider IDs, addresses, and prices there must be modified to match your actual situation.
Test Keys¶
Click “Test Key” after selecting Search or Fetch. If the input box has content, it tests the current input; if empty, it tests the saved pool. Testing may incur charges and write to the ledger; a single key has a maximum timeout of 10 seconds, and the whole batch is capped at 60 seconds. The target for Fetch testing is fixed to https://example.com/.
Understanding Costs¶
The statistical unit is actual API attempts, not chat turns; a single tool call containing multiple queries may correspond to multiple underlying requests.
The DeepSeek official channel defaults to 5 CNY / 1000 requests for both Search and Fetch, billed based on HTTP 200 and non-empty results—this is the plugin’s default configuration and does not sync with official website prices in real-time. Relays can independently fill in unit prices and billing criteria (non-empty success vs. all HTTP 200, etc.), which should be verified with your service provider.
The ledger distinguishes between billed success, empty results, explicit failures, unconfirmed status, and unknown prices. Timeouts or unparseable responses are not treated as free by default; if a previous attempt fails and a subsequent failover succeeds, both records are retained.
The plugin only records requests passing through its own backend; other plugins, devices, or internal server-side model searches are out of scope. Tavily credits are for local protection only and cannot guarantee the entire account will not exceed its limit.
Use Cases and Notes¶
Suitable for scenarios requiring the distribution of Search / Fetch across multiple Providers and search services, or where you need to trace which channels a call traversed and why costs increased. It does not perform full account billing sync, nor does it automatically pick the cheapest service or silently enable paid relays.
Channels with historical ledger entries cannot be deleted or have their address ownership changed; to switch services, create a new channel and disable the old one. Modifying names or prices will not recalculate history. Before backing up the ledger, stop processes sharing $DSH_HOME/web-search-billing/, and retain database-related files and installation-salt; do not just copy the main database while it is being written to.
The DSH ecosystem emphasizes “Everything is a plugin”; the SkillHub directory page is a community site and has no official affiliation with DeepSeek or 幻方 (Huanfang).
Conclusion¶
dsh-search-ledger centralizes channel selection, key rotation, failure failover, and local cost ledgers for web_search / web_fetch, facilitating controlled use of search and fetching in multi-Provider environments. For further information, please refer to the GitHub Repository and the SkillHub Plugin Page.