DSH 的模型切换器:指向任意 OpenAI 兼容端点,内置精选免费/低价 DeepSeek 服务商预设,免费额度限流时自动回退。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:Jesse-njx/dsh-polyglot
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
该插件的 README 只有英文版本。
The model switch for DSH. Point DeepSeek Harness at any OpenAI-compatible endpoint — with curated presets for free and cheap DeepSeek providers and automatic fallback when a free tier rate-limits you.
What claude-code-router is to Claude Code, dsh-polyglot is to DSH — except
DSH's ctx.llm is a sanctioned extension seam, so there is no request
interception: the generic adapter and the router are both real LlmAdapter
registrations.
- One generic adapter. A single OpenAI-compatible
ctx.llmadapter parameterized by{baseUrl, apiKey, model, headers?, quirks?}. Streaming, tool calls, and usage extraction are all handled; per-provider deviations (reasoning field names, strict tool schemas, cache-folded usage) are small declarativequirksflags, never per-provider code. - A router with fallback. On 429 / quota-exceeded / 5xx (or a missing
key), the failing provider is marked cooling-down (exponential backoff,
honoring
Retry-After) and the request is retried on the next provider in the chain. Free tiers rate-limit constantly — automatic failover is the whole product. - Provider presets as data.
presets/*.json— community PRs add providers without touching the adapter. Each preset carriesverifiedAtand free-tier notes so rot is visible. - Usage you can see. Every attempt lands in the append-only session log as
polyglot/served;/polyglot usagetallies per provider with token counts and estimated cost from preset pricing.
Quick start
Install the bundle into a profile (a DSH profile is an ordered stack of plugin-bundle patch layers):
dsh plugin --profile web add @dsh-polyglot/bundle
The bundle's patch registers the polyglot plugin with the recommended
default chain — "code all day for free until something rate-limits, then
degrade gracefully to cheapest-paid":
nous-portal → opencode-zen → deepseek-official (5M grant) → kilo
Configure keys through the credentials seam (the web Models page writes them), or export the env names each preset declares:
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)
Pick the virtual provider polyglot in the model selector. A provider without
a configured key is skipped automatically — the chain degrades, it never
fails hard.
Day-to-day commands
| Command | What it does |
|---|---|
/model |
show chains and the active one |
/model <chain> |
switch the active chain mid-session (logged as polyglot/chain) |
/polyglot |
status: active chain, entries, provider cooldowns |
/polyglot usage |
per-provider tally from the session log: calls, ok/failed, tokens, est. cost |
/polyglot presets |
free-tier posture of the active chain's presets |
Configuration
Override chains and cooldown from your profile patch:
# your profile's cordis.patch.yml (or --patch overlay)
- patch:
- id: polyglot
config:
chains:
default:
- preset: nous-portal
- preset: opencode-zen
- preset: deepseek-official
model: deepseek-v4-flash
- preset: kilo
paid:
- preset: deepseek-official
model: deepseek-v4-pro
cooldown:
baseMs: 30000 # initial per-provider cooldown after a failure
maxMs: 900000 # ceiling (also honors provider Retry-After)
factor: 2 # exponential growth per consecutive failure
jitterRatio: 0.1 # symmetric jitter around each delay
Per-entry overrides: provider (route name), model, baseUrl, apiKeyEnv,
headers, quirks — the custom preset is the escape hatch for
vLLM/Ollama/SGLang localhost and any other OpenAI-compatible endpoint
(Qwen/GLM/Kimi official APIs included).
Quirks reference
| Flag | Default | Meaning |
|---|---|---|
reasoningField |
'reasoning_content' |
wire delta field carrying reasoning text; null disables reasoning entirely |
maxTokensField |
'max_tokens' |
output-cap wire field (max_completion_tokens for newer hosts) |
usage |
'standard' |
'deepseek' subtracts cache hits folded into prompt_tokens; 'none' when the host reports none |
streamOptions |
true |
send stream_options: {include_usage: true} |
strictToolSchemas |
false |
add strict: true to tool schemas |
thinkingField |
false |
send thinking: {type} (DeepSeek spelling) |
reasoningEffortField |
true |
send reasoning_effort for high/max efforts |
Preset registry
All figures were re-verified 2026-08-14 against provider docs; these move
weekly — every preset carries verifiedAt, and a CI job pinging each
baseUrl with a 1-token request is the planned trust loop.
| Preset | What you get | Cost / limits | Notes |
|---|---|---|---|
deepseek-official |
V4-Flash, V4-Pro | $0.14/$0.28 per M (Flash); 5M free tokens new accounts, 30 days, no card | Baseline; prices trending up |
opencode-zen |
deepseek-v4-flash-free (+ Qwen 3.6 Plus, MiniMax M3, MiMo…) |
Free, no card, 200k context; rate limits undocumented | Commercial terms unclear — flagged in the preset notes |
nous-portal |
deepseek/deepseek-v4-flash:free |
Free, OAuth-gated, hard rate ceiling that returns errors | The poster child for fallback; put it first in a chain |
kilo |
V4-Pro, V4-Flash, V3.1 Terminus | Pay-as-you-go at no markup over provider rates | Good paid-fallback rung |
openrouter |
:free DeepSeek variants + everything else |
Free variants throttled; paid at listed rates | Widest catalog, one key |
custom |
anything OpenAI-compatible | — | vLLM/Ollama/SGLang localhost; Qwen/GLM/Kimi official endpoints |
groq / together / fireworks |
DeepSeek hosting | fast but pricier | Latency upgrades, not savings |
How it works
profile ──> provider route "polyglot" (the router meta-adapter)
│ chain: nous-portal → opencode-zen → deepseek-official → kilo
▼
ctx.llm.stream({provider: "nous-portal", ...})
│ adapter per real route (OpenAiCompatAdapter, one per preset)
▼
POST {baseUrl}/chat/completions (SSE, usage, tools)
The router forwards the first attempt that completes. A fallback-eligible
failure that arrives before any content flowed — the free-tier ceiling
case — swaps to the next provider seamlessly; a failure after content flowed
cannot be unwritten and surfaces as a normal error finish. Which provider
actually served each turn is durable in the session log (polyglot/served),
so /polyglot usage is a pure fold over the log, not plugin-side accounting.
ToS note
Free tiers are often gated for evaluation use (OpenCode Zen's commercial
terms are undocumented). Preset notes surface this at configure time —
dsh-polyglot does not silently launder usage.
Development
pnpm install
pnpm typecheck # strict TS
pnpm build # tsc → lib/
pnpm test # 56 tests: mock OpenAI-compat server with scripted 429/500/
# stream scenarios, golden wire assertions per quirk, and
# end-to-end cordis mounts proving fallback + session events
Roadmap
- v0.2 — per-role chains (planner → paid V4-Pro, executor/summarizer → free Flash); OAuth device flow for Nous Portal; preset auto-update check; provider benchmark/arena integration.
- Non-goals — proxying non-chat modalities; silent key laundering.
链接
同类插件
V1ki/dsh-plugin-subscriptions★ 394
把 ChatGPT(Codex)、Claude、Grok 订阅当作 DeepSeek Harness 的 LLM 提供方:设置页登录、模型目录、用量展示,以及 image_generate、video_generate 与 x_search 工具。
Mars-Sea/dsh-commandcode-provider★ 337
非官方 Command Code 模型接入插件:注册 `commandcode` 路由,带实时模型目录与推理强度支持。
corrinehu/dsh-workbuddy-connect★ 216
将 WorkBuddy 桌面 App 包含的模型自动接入 DeepSeek Harness,在 DSH 对话窗口里零配置使用。
cv-superding/dsh-deepseek-web-login★ 170
新增 deepseek-web provider,把 chat.deepseek.com 网页端模型接入 DSH:浏览器登录抓取、PoW 请求签名、SSE 流式传输与基于提示词的工具调用。
volcengine/ark-cli#ark-plan-api★ 139
在 DSH 原生模型选择器中注册方舟 Agent Plan、Coding Plan 与后付费模型路由。
franksong2702/dsh-codex-connect★ 120
通过 ChatGPT OAuth 将 OpenAI Codex 模型接入 DeepSeek Harness,并提供可选的搜索与图片工具。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。