lion231226/dsh-freellmapi ↗★ 0

dsh-freellmapi

Self-contained free-tier LLM routing for DeepSeek Harness: one `auto` model that scores each request's complexity and picks the best of 12 free providers, failing over automatically. Unconfigured providers collapse to a single 'add your key' entry instead of dead models, and pinning a specific model is strict -- never silently swapped. Works with zero credentials out of the box. 适合需要自动评估请求复杂度并分流至免费API的用户。

パッケージ
dsh-freellmapi
互換性
未検証
Cordis ピア範囲
*
バージョン
0.4.0
ライセンス
MIT
最終更新
2026/10/13

インストール

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:lion231226/dsh-freellmapi

ドキュメント

README 全文を読む ↗

Configuration

Every field is live (a settings edit applies to the next request, no restart) and validated totally — a malformed value falls back to its default instead of preventing the plugin from loading.

FieldTypeDefaultMeaning
modedirect | gatewaydirectSelf-contained routing, or forward to an external gateway
baseURLstringhttp://localhost:3001/v1Gateway mode only: OpenAI-compatible root of the freellmapi gateway
apiKeyEnvstringFREELLMAPI_API_KEYGateway mode only: credential reference name (not the key)
apiKeystring (secret)''Gateway mode only: optional inline credential; prefer apiKeyEnv
providersdict or array{}Per-provider overrides for the built-in pool (see below)
routingdict{maxAttempts: 6, budgetMs: 45000}Routing-engine knobs (see below)
logRoutingbooleantrueLog the direct-mode routing decision (tier, winner, candidates tried)
logRoutedViabooleantrueLog X-Routed-Via / fallback trail (gateway mode)
visionbooleantrueAdvertise image input when the chosen model supports it; set false to force text-only
contextWindownumber131072Context window assumed for ids the pool does not describe
maxTokensnumber0Output cap declared to DSH; 0 = declare none and let the provider decide
timeoutMsnumber600000Per-attempt timeout in milliseconds; 0 disables it
includeFusionbooleantrueGateway mode: advertise the gateway's fusion route
exposeDiscoveredModelsbooleantrueGateway mode: merge GET /v1/models into the picker
discoveryTimeoutMsnumber5000Gateway mode: timeout for that discovery request
discoveryCacheMsnumber60000Gateway mode: how long a discovery result stays fresh
maxTokensFieldmax_tokens | max_completion_tokensmax_tokensWhich wire field carries the cap. max_tokens is the canonical field; the gateway also accepts the other
headersmap{}Extra request headers. user-agent, authorization, content-type, accept are reserved
taskType'' | auto | code | chat''Gateway mode: optional X-FreeLLM-Task-Type hint (empty sends no header)
cacheMode'' | on | off''Gateway mode: optional X-FreeLLM-Cache switch (empty sends no header)

The settings form is generated when the host resolves @deepseek-ai/schemastery (it normally does in a DSH profile). If it does not, the plugin still loads and runs with exactly these defaults — you just configure it through the profile patch instead. No configuration value, however malformed, can stop the plugin from loading.

One environment escape hatch worth knowing: FREELLMAPI_BASE_URL overrides the gateway endpoint from the environment, and it is honoured only while baseURL still holds its built-in default, so an explicit setting always wins over the environment.

providers. — override one pool entry

KeyMeaning
enabledTurn a provider on/off. This is how you enable the seven providers that ship disabled
displayNameLabel used in the picker and logs
baseURLEndpoint root — fix a hostname without waiting for a release (see zhipu)
apiKeyEnvYour own credential reference name for this provider
apiKeyInline credential for this provider (stored in the profile patch — prefer apiKeyEnv)
keylessMark a custom endpoint as usable without a credential
modelsReplaces the built-in model list for that provider. Each entry: id, name, and capability / speed (1–5), contextWindow, maxTokens, vision, toolCalling — either inline or under caps

A provider that is not in the built-in pool at all is added the same way: give it id/baseURL and a models list (see Adding keys).

routing — engine knobs

KeyDefaultMeaning
maxAttempts6Maximum candidates tried for one request
budgetMs45000Total failover time budget; 0 = unlimited
contextSafetyFactor1.15Safety margin on the context gate: a candidate must satisfy contextWindow >= estimated tokens × this factor. The token estimate is a heuristic and undercounts, so one model of headroom is cheaper than a 400 from upstream. A value below 1 is rejected and the default applies
thresholds.medium0.34Score at which simple becomes medium
thresholds.complex0.67Score at which medium becomes complex
weightsper-tier defaults{capability, speed} or {simple: {…}, medium: {…}, complex: {…}}
preferredOrder[]Provider ids you want preferred; a bounded bonus of at most 0.05

Three ways to set them

  1. Settings page — Settings → Plugins → dsh-freellmapi (every top-level field, with the generated form described above).

  2. Profile patch — $DSH_HOME/profiles/ /cordis.patch.yml; the recommended place for providers and routing:

    - id: freellmapi
      config:
        mode: direct
        logRouting: true
        providers:
          cerebras:
            enabled: true
          kilo:
            enabled: false        # if you do not accept its training-recording terms
        routing:
          maxAttempts: 4
          preferredOrder: [cerebras, groq]
    
  3. Environment — the per-provider apiKeyEnv names in Adding keys.