dsh-llm-key-loop 0.0.0-stage → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +105 -2
- package/client.js +676 -0
- package/cordis.patch.yml +18 -0
- package/docs/DETAIL.md +56 -0
- package/icon.svg +7 -0
- package/index.js +673 -0
- package/locale/en.json +7 -0
- package/package.json +69 -4
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# dsh-llm-key-loop — bundle patch layer.
|
|
2
|
+
#
|
|
3
|
+
# One plugin row on the agent loop's `agent/request-error` waterfall.
|
|
4
|
+
# Any provider with backup keys joins the loop automatically: no provider
|
|
5
|
+
# needs to be listed here. Per provider it tries Main key -> Key 1 -> Key 2 …
|
|
6
|
+
# within a turn, stops when every key failed, and never switches provider.
|
|
7
|
+
#
|
|
8
|
+
# Key refs per provider (values live only in the credential store):
|
|
9
|
+
# <PROVIDER>_API_KEY key in use (the plugin writes here)
|
|
10
|
+
# <PROVIDER>_API_KEY_DEFAULT main key (saved from the key in use on first switch)
|
|
11
|
+
# <PROVIDER>_API_KEY_CHAIN_1..9 backup keys
|
|
12
|
+
#
|
|
13
|
+
# To exclude a provider: providers: { some-provider: { enabled: false } }
|
|
14
|
+
- insert:
|
|
15
|
+
- id: llm-key-loop
|
|
16
|
+
name: 'dsh-llm-key-loop'
|
|
17
|
+
config:
|
|
18
|
+
providers: {}
|
package/docs/DETAIL.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Key Loop for DeepSeek Harness
|
|
2
|
+
|
|
3
|
+
Use several API keys for one model provider, and switch between them when one runs out.
|
|
4
|
+
|
|
5
|
+
- **Automatic switching:** when the key in use hits its limit, is rejected, or is rate-limited, the next key takes over and the request is retried. Order: Main key → Key 1 → Key 2 → … If every key fails in one message, it stops and shows the error. It never switches to a different provider.
|
|
6
|
+
- **Manual choice:** model menu → **Key** → pick a key. Automatic switching pauses until you pick **Default** again.
|
|
7
|
+
- **Usage in the status line** under the message box, for example `Key 1 · 74%`. Click it to see every key's usage and when it resets.
|
|
8
|
+
- **Key Loop page (key icon in the left menu):** providers are listed on the left with their key count and usage. Click one to see each key's usage bars, add or remove keys, see which key is in use (**Active**), which failed (**Limit**, **Rejected**, **Throttled**), and test a key with the 🔌 button. The icon turns green when the key works.
|
|
9
|
+
|
|
10
|
+
Keys stay in DeepSeek Harness's own credential store (`~/.dsh/.credentials.yaml`). The browser panel only sees masked previews, and the plugin never logs key values.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
Requires DeepSeek Harness `>=0.2.1-rc.5 <0.3.0`.
|
|
15
|
+
|
|
16
|
+
**Desktop app:** Plugins → **Add** → enter the path to the file, for example
|
|
17
|
+
`/Users/you/Downloads/dsh-llm-key-loop-2.4.0.tgz`, then quit and reopen the app.
|
|
18
|
+
|
|
19
|
+
**Terminal:**
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
dsh plugin --profile desktop add /path/to/dsh-llm-key-loop-2.4.0.tgz
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
If you already use `@m1khal3v/dsh-llm-key-rotation`, disable or uninstall it first, so only one plugin switches keys.
|
|
26
|
+
|
|
27
|
+
## Set up
|
|
28
|
+
|
|
29
|
+
1. Add your provider in **Settings → Models** as usual, with its normal API key.
|
|
30
|
+
2. Click the **key icon** in the left menu (Key Loop) → pick the provider.
|
|
31
|
+
3. Paste each extra key and click **Add key**. Click 🔌 on a key to test it.
|
|
32
|
+
|
|
33
|
+
That's all. The key you entered in Models becomes the **Main key**.
|
|
34
|
+
|
|
35
|
+
## Providers
|
|
36
|
+
|
|
37
|
+
Key Loop rotates keys for providers you have set up in **Settings → Models**, and it never falls back to a different provider. A provider is picked up when its key is stored under `<PROVIDER_ID>_API_KEY` (the provider id in capitals, dashes turned into underscores, for example `token-harbor` → `TOKEN_HARBOR_API_KEY`), which is what Models uses for providers you add there. DeepSeek, whose id differs from its key name, is mapped explicitly.
|
|
38
|
+
|
|
39
|
+
**Tested with:** Token Harbor, ClinePass, Xiaomi MiMo, River AI, DeepSeek and Anthropic.
|
|
40
|
+
|
|
41
|
+
Other providers that follow the same naming (OpenAI, OpenRouter, Mistral, Groq, Together AI, Fireworks, Moonshot, MiniMax, any OpenAI-compatible endpoint, …) should work but have not been tested. If one is not picked up, please [open an issue](https://github.com/thisisalamin/dsh-llm-key-loop/issues/new/choose) with the provider id and the name of its key reference.
|
|
42
|
+
|
|
43
|
+
## What usage shows
|
|
44
|
+
|
|
45
|
+
What you see next to each key depends on whether the plugin has a usage reader for that provider:
|
|
46
|
+
|
|
47
|
+
| Provider has a built-in usage reader | No reader yet |
|
|
48
|
+
|---|---|
|
|
49
|
+
| Usage bars for each limit window (5-hour, weekly, monthly, plan credits) with the reset time, read from the provider's own read-only API about once a minute. | Requests and tokens counted by this app today, per key (resets at local midnight). Enter a daily request limit to see a percentage. |
|
|
50
|
+
| Today: Token Harbor, Xiaomi MiMo Token Plan, ClinePass. More can be added (see [CONTRIBUTING.md](CONTRIBUTING.md)). | Every other provider. Some APIs, such as Anthropic's pay-as-you-go keys, do not report usage to an API key at all. |
|
|
51
|
+
|
|
52
|
+
The local count only covers requests made from this app. It is stored as numbers only in `~/.dsh/llm-key-loop-counts.json`.
|
|
53
|
+
|
|
54
|
+
## Logs
|
|
55
|
+
|
|
56
|
+
The plugin prints lines tagged `[llm-key-loop]` when the app is started from a terminal, and writes a status summary without key values to `~/.dsh/llm-key-loop-status.json`.
|
package/icon.svg
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Key loop">
|
|
2
|
+
<title>Key loop</title>
|
|
3
|
+
<circle cx="32" cy="32" r="27" fill="none" stroke="currentColor" stroke-width="4" stroke-dasharray="10 7" stroke-linecap="round"/>
|
|
4
|
+
<circle cx="32" cy="32" r="13" fill="none" stroke="currentColor" stroke-width="4"/>
|
|
5
|
+
<circle cx="32" cy="32" r="4.5" fill="currentColor"/>
|
|
6
|
+
<path d="M47 17l8-8M55 9v6M55 9h-6" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
7
|
+
</svg>
|