Foreword

When calling external models in DSH, common issues are not just the lack of a single OpenAI-compatible endpoint, but rather the coexistence of multiple endpoints, unstable free tiers, the need to switch after rate limiting, and the requirement to query which provider served each call and how many tokens were consumed.

dsh-polyglot is a DSH plugin maintained by Jesse-njx, licensed under MIT. It consolidates multiple OpenAI-compatible providers into a selectable virtual provider polyglot, automatically falling back to the next provider in the chain when the free tier triggers 429, quota-exceeded, 5xx, or missing keys.

What This Is

dsh-polyglot can be summarized in three points:

  • A generic OpenAI-compatible ctx.llm adapter;
  • A set of provider presets maintained as JSON files;
  • A router that automatically falls back when requests fail.

It suits scenarios where you need to use multiple DeepSeek or other OpenAI-compatible endpoints in DSH and want to avoid interrupting the call chain when free-tier rate limits are hit.

Core Features

A Generic ctx.llm Adapter

dsh-polyglot provides a single generic OpenAI-compatible ctx.llm adapter with parameters including:

baseUrl
apiKey
model
optional headers
quirks

This adapter handles streaming, tool calls, and usage extraction. Deviations across different providers are expressed through declarative configurations like quirks, rather than writing a separate adapter for each provider.

Automatic Fallback Routing

The router triggers fallback under the following conditions:

429
quota-exceeded
5xx
missing key

After triggering, the failed provider enters a cooling-down state, with strategies including exponential backoff and Retry-After support. Requests attempt the next provider in the chain.

If a provider has no key configured, it is automatically skipped. Thus, the entire chain can degrade gracefully rather than hard-failing due to a single missing key.

Two types of failures need to be distinguished:

  • If a fallback-eligible failure occurs before any content has streamed out, switching to the next provider is feasible;
  • If the failure occurs after content has already streamed out, the already-written content cannot be retracted, and the request ultimately ends with a normal error finish.

Provider Presets

Provider presets are JSON data files located under presets. Each preset includes verifiedAt and free-tier notes, making it easy to review the free quota, limits, and caveats for that provider.

The documentation notes that provider figures may change weekly, so verifiedAt in the presets reflects the verification time.

Session Logs and Usage Statistics

Each attempt is recorded in the session log, marked as:

polyglot/served

/polyglot usage aggregates per-provider calls, ok/failed, tokens, and estimated cost based on session logs.

Commands

The plugin provides the following commands:

/model
/model <chain>
/polyglot
/polyglot usage
/polyglot presets

Where:

  • /model displays the chains and the active one;
  • /model <chain> switches the active chain within the session;
  • /polyglot usage shows per-provider call and usage summaries.

Installation and Enablement

Install into a specific DSH profile using the following command:

dsh plugin --profile web add @dsh-polyglot/bundle

After installation, select the virtual provider in the model selector:

polyglot

Once selected, requests are processed by dsh-polyglot’s adapter and router. Providers without configured keys are skipped, and the chain continues attempting subsequent providers.

Typical Usage

Configuring Keys

Different presets use credentials seams or environment variables for keys. Example environment variables from the documentation include:

export NOUS_PORTAL_TOKEN=...      # nous-portal (bearer, manual token for v0.1)
export OPENCODE_API_KEY=...       # opencode-zen
export DEEPSEEK_API_KEY=...       # deepseek-official (new accounts: 5M free tokens, 30 days, no card)
export KILO_API_KEY=...           # kilo (paid fallback rung)

Once configured, polyglot attempts available endpoints in provider order within the chain.

Viewing and Switching Chains

View the current chain:

/model

Switch the active chain:

/model <chain>

The switch action is recorded as polyglot/chain.

Viewing Usage

View per-provider summaries:

/polyglot usage

The summary includes calls, ok/failed, tokens, and estimated cost.

View preset status:

/polyglot presets

Suitable Scenarios and Considerations

Suitable for the following scenarios:

  • Integrating multiple OpenAI-compatible providers in DSH;
  • Wanting automatic switching after free-tier rate limits;
  • Needing to check which provider served each request;
  • Needing per-provider token and estimated cost aggregation.

Considerations for installation and usage:

  • The plugin runs with the current dsh process privileges; review the source code, license, and preset notes before installation;
  • Free tiers are often gated for evaluation use;
  • OpenCode Zen’s commercial terms are marked as undocumented in the documentation;
  • Preset notes expose ToS concerns at configure time;
  • dsh-polyglot does not silently launder usage;
  • Provider data may change over time; review alongside verifiedAt.

Links

GitHub:

https://github.com/Jesse-njx/dsh-polyglot

The directory page URL was not provided in the verified materials.