rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:taxah92/dsh-nanogpt
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
Subscription and paid NanoGPT models in DSH: two pickers (subscription and all text models), a "charged to subscription / charged to balance" switch on every model, two API keys with their billing mode, upstream provider selection for a model, and the remaining weekly quota in the card and in the usage-stats block.
NanoGPT serves 298 subscription and 618 text models (318 of them are paid, outside the subscription), and the built-in DSH selector would show everything at once. The plugin provides:
llm-pi-ai.providers.nanogpt.models, and the selector shows exactly them;$/1M in/out and are forcibly charged to the balance;NANOGPT_API_KEY, weekly limit)
or "Balance" (key NANOGPT_PAYGO_API_KEY, money on the account);subscription only / subscription first / paygo only);GET /api/models/:id/providers: name, $/1M price, unavailable ones in grey; "Auto" is
the default. An explicit provider is always paid from the balance at the provider's price,
so the list is shown only for balance models;×2 suffix in the subscription
model name;reasoning_efforts to reasoningEfforts of
llm-pi-ai (none → off, the rest keep their names);$X.XX of balance and the
counter "N models · subscription X · balance Y" in the card; the line
"NanoGPT · Text N% · Images N%" inside the usage-stats block and a bar in the card;If a model was added with the built-in Models editor (its "Fetch available models" reads
{baseURL}/models without ?detailed=true, so it gets only the id), the NanoGPT card
shows the warning "N model(s) are missing settings from the catalog" and the "Fill from
catalog" button: it fills in contextWindow, maxTokens, input and reasoningEfforts,
without touching values the user has already set.
NanoGPT lets you create several API keys and set a policy for each in the dashboard
(API keys → key → Billing): subscription first, subscription only or
pay-as-you-go only. The plugin expects two keys:
| Field in the card | Credential reference | Charged to |
|---|---|---|
| Subscription key | NANOGPT_API_KEY |
weekly input-token limit |
| Balance key | NANOGPT_PAYGO_API_KEY |
money on the NanoGPT balance |
The keys are written through ctx.remote.credentials.set (write-only; the value is never
returned to the browser — the host returns only a masked preview). Next to the field the card
shows the key's actual billing mode from its /subscription/v1/usage and warns
if the balance key is in fact subscription only — balance models would then fail.
How the key is switched. In llm-pi-ai the key is set for the whole route, while the mode
is set per model, so the plugin's host half intercepts outgoing requests to
api.nano-gpt.com in globalThis.fetch (the same technique as in dsh-llm-request-routing).
For a model marked "Balance", the request gets Authorization: Bearer <balance key>;
for "Subscription" the header is left untouched. If a balance model is present but the balance
key is not saved, the request fails with an explicit error instead of spending the subscription.
Provider. For a balance model, X-Provider: <provider-id> is added to the request.
An explicit provider at NanoGPT is always pay-as-you-go and costs more than the model's base
price (provider-selection markup), so provider selection is available only in "Balance" mode.
Switching a model back to "Subscription" resets the pinned provider.
Paid models. In the "All models" picker, entries with subscription.included: false
are forcibly balance models (the switch is locked). They need Enable paid models on API
turned on in the NanoGPT dashboard; the card warns if the balance key
reports that paid charges are disabled.
Important about the balance. On pay-as-you-go, NanoGPT reserves balance for the whole
max_completion_tokens of the request. The plugin keeps maxTokens = max_output_tokens of the
model (as decided for the subscription), so a small balance can produce 402 insufficient_balance — top up the balance or lower maxTokens in the built-in editor.
~/.dsh/.credentials.yaml → refs.NANOGPT_API_KEY and
refs.NANOGPT_PAYGO_API_KEY (or in the two card fields on the Models page).
The subscription key is always required: it is the credential of the llm-pi-ai route
itself; the balance key is needed only when there are models in "Balance" mode — the
interceptor substitutes it in place of the route key.nanogpt route in llm-pi-ai (in the profile patch layer): nanogpt:
displayName: NanoGPT
apiKeyEnv: NANOGPT_API_KEY
api: openai-completions
baseURL: https://api.nano-gpt.com/api/v1legacy
models: [ ... ]
baseURL is v1legacy: reasoning arrives in reasoning_content, as NanoGPT's official
guide for DSH recommends. The balance key does not need to be set in apiKeyEnv:
the host interceptor substitutes it per model.
Published: github.com/taxah92/dsh-nanogpt,
npm dsh-nanogpt@0.2.0.
dsh plugin --profile web add dsh-nanogpt
Local development from a checkout:
dsh plugin --profile web add link:/path/to/dsh-nanogpt
Since 0.2.0 the host half intercepts fetch and adds routes, so after an update a
DSH restart is required (a client-side change is picked up without a restart).
schemasteryThe plugin declares @deepseek-ai/schemastery in dependencies, but pnpm does not expand the
dependencies of a link: package. Node resolves imports from the real path, so a
symlink is needed (the node_modules/ directory is not tracked in git):
cd /path/to/dsh-nanogpt
mkdir -p node_modules/@deepseek-ai
ln -sfn ~/.dsh/profiles/web/node_modules/@deepseek-ai/schemastery \
node_modules/@deepseek-ai/schemastery
Check that the schema is "native" (otherwise DSH shows the plugin as "Problem" and does not render the settings form):
# from the same package directory
node -e "import('./index.js')
.then(m => console.log(Reflect.get(m.Config, Symbol.for('schemastery')) === true))"
It must be true.
Plugins page → the nanogpt row:
| Field | Default | Meaning |
|---|---|---|
apiKeyEnv |
NANOGPT_API_KEY |
credential reference for the subscription key |
paygoKeyEnv |
NANOGPT_PAYGO_API_KEY |
credential reference for the balance key |
baseURL |
https://api.nano-gpt.com/api |
API base |
modelsCacheTtlMs |
600000 |
cache of catalogs and provider lists |
usageCacheTtlMs |
60000 |
cache of the quota, the balance and the keys' billing mode |
extraRate2 |
'' |
extra ×2 ids, comma-separated |
balanceModels |
[] |
ids of models charged to the balance (written by the card) |
modelProviders |
{} |
{ "<model-id>": "<provider-id>" } (written by the card) |
| Route | What it returns |
|---|---|
GET /dsh-nanogpt/models |
subscription catalog (Latin: models[] with rate/efforts) |
GET /dsh-nanogpt/all-models |
canonical catalog of 618 models (anonymous, without account filters) |
GET /dsh-nanogpt/providers?model=<id> |
supportsProviderSelection, providers, $/1M prices |
GET /dsh-nanogpt/usage |
weekly quota, images, routing.billingMode |
GET /dsh-nanogpt/keys |
state of both keys: configured/masked/billing mode |
GET /dsh-nanogpt/balance |
balance in USD (POST /check-balance, without generation or charges) |
node plugins/dsh-nanogpt/tools/probe.mjs # summary
node plugins/dsh-nanogpt/tools/probe.mjs --json # machine-readable output
The script reads the catalogs, usage, the provider list for the first suitable model and the
balance. No inference is called; the balance is read through POST /check-balance, which does
not spend tokens.
index.js host: Config, six GET routes, fetch interception
(balance key + X-Provider for balance models)
client.js client: settings.models.provider-card (quota, balance, two keys,
two pickers, per-model switch, provider dropdown),
quota row inside the usage-stats block
lib/normalize.js pure normalization functions (tested without DSH)
tools/probe.mjs API check without spending
tools/smoke-*.mjs offline tests for the host and the client bundle
The host resolves keys through ctx.credentials on every request, caches responses and, on an
upstream error, serves the stale cache. The client writes the selected models through
ctx.configForms.get('llm-pi-ai').mutate(...) — the same path as the built-in editor;
the balance and provider flags go to the plugin's own nanogpt section (volatile fields), so
the selector and the interceptor see the edit without a DSH restart.
subscription.inputTokenMultiplier in the canonical
catalog); if NanoGPT changes it, extraRate2 is edited.maxTokens is taken from the model's max_output_tokens (null → 65536) and for balance
models too — see the warning about the balance reserve.llm-pi-ai rejects the request before the interceptor
(MISSING_CREDENTIAL), so balance models will not work either until the route gets
its own key.supportsProviderSelection: true; for other
models the card has an explanation, and NanoGPT ignores X-Provider.data-usage-stats-footer + unifiedMain; if usage-stats
changes it, the row will fall back to a separate row (revisit the question: fork or ask the author).CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。