Skip to content

dsh-llm-key-rotation

Verified

@m1khal3v/dsh-llm-key-rotation Β· v1.1.0 Β· MIT Β· Web UI

Seamless API-key rotation for DeepSeek Harness LLM providers when subscription limits are hit

Install

dsh plugin add @m1khal3v/dsh-llm-key-rotation

Confirm the layer applied with dsh --profile default --dump-config β€” see the install guide.

Source

Tags

Creators

Readme

npm DeepSeek Harness MIT License Status GitHub

dsh-llm-key-rotation

ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

Seamless API-key rotation for DeepSeek Harness.
Hit a quota limit or 429 Rate Limit? The plugin swaps in the next key you configured and retries instantly β€” no restarts, no context loss, and zero interruptions.


⚑️ Highlights

  • πŸ”„ Invisible to Agent & User: Request fails with quota/rate limit β†’ plugin hot-swaps the key β†’ request retries and succeeds seamlessly.
  • πŸŽ› Native Web UI: List every key a provider can use and toggle rotation right inside Settings.
  • 🧠 Smart Anti-Spin: Cooldown discipline prevents infinite loops if all your keys are exhausted.
  • 🧼 Zero Core Patches: Plugs cleanly into the Harness recovery waterfall β€” safe to install, safe to remove.

πŸ›  How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          429 / QUOTA / AUTH          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Model Request  β”‚ ───────────────────────────────────► β”‚  llm-key-rotation    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β–²                                                          β”‚
         β”‚                  { kind: 'retry' }                       β”‚ 1. Pick next key
         β”‚             (Adapter re-resolves key)                    β”‚ 2. Hot-swap env ref
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. You keep working with your currently-active key as usual.
  2. If a request fails (QUOTA, RATE_LIMIT, or AUTH), the plugin loads the next key from your configured chain.
  3. The turn retries with the new key, and future requests continue with the working key.

πŸš€ Quick Start

1. Install the plugin

dsh plugin --profile web add @m1khal3v/dsh-llm-key-rotation

2. Configure via Web UI

Navigate to Settings β†’ Plugins β†’ Key Rotation:

  1. Toggle on rotation for your target provider.
  2. Select your trigger codes (default: QUOTA, AUTH).
  3. Click Add key, paste all the keys you want that provider to rotate through, and hit Save.

(Keys are safely saved to the Harness credential store).


βš™οΈ Behavior & Good to Know

  • Smart Rotation Window (300s): During consecutive failures, the plugin walks forward through your configured keys. If no failures occur for >5 minutes, the chain resets to start from the top again.
  • Interplay with dsh-llm-retry:
    • QUOTA and AUTH rotate immediately.
    • RATE_LIMIT is handled by dsh-llm-retry first (with backoff). To rotate instantly on 429 errors instead, simply remove RATE_LIMIT from your provider's retryableCodes.
  • Live Terminal Logs: Watch rotation events in real time right in your dsh terminal:
    [llm-key-rotation] rotated provider="opencode-go" chain[0]β†’"OPENCODE_GO_API_KEY" (QUOTA)
    
    (Secret values are never logged β€” only provider names, indices, and error codes).

πŸ§‘β€πŸ’» Development

pnpm install
pnpm run verify    # typecheck + test
pnpm run build

πŸ“„ License

MIT