DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

r48n34 /

r48n34/dsh-hku-llm

Verified

HKU GenAI Developer Portal models in DeepSeek Harness

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHubProject homepage
READMESource: main@ac863b9c

Language: English · 简体中文 · 繁體中文

dsh-hku-llm

dsh-hku-llm — HKU GenAI model routes for DeepSeek Harness
dsh-hku-llm on npm 25 models in 3 routes DeepSeek Harness 0.2.0 or newer MIT license

Use HKU GenAI Developer Portal models in DeepSeek Harness, with the header HKU actually accepts.
OpenAI Responses, Chat Completions and Gemini · rotating key pool · editable model catalogue · one settings page

https://developer.hku.hk/

Install · Verify · Configure


This is not an official HKU plugin. dsh-hku-llm is an independent, unofficial project. It is not affiliated with, endorsed by, sponsored by, or supported by The University of Hong Kong — including its faculties, departments, institutes, research centres, staff and students — or by any other university or institution in Hong Kong. The names "HKU" and "HKU GenAI" appear only to identify the third-party gateway this software connects to — here and in the package name dsh-hku-llm; all related marks belong to their respective owners.

Why this plugin exists

The HKU gateway authenticates with an api-key header, not Authorization: Bearer. Every generic provider route in DSH sends bearer auth, so a hand-declared route under Settings → Models answers:

401 Access denied due to missing subscription key.

This plugin registers its own adapter for the three protocols the gateway serves, so the header is right and the models behave like any other DSH model.

Route Protocol Endpoint
hku-chat Chat Completions https://api.hku.hk/deepseek/models
hku-responses Responses https://api.hku.hk/openai/v1
hku-gemini Gemini Chat Completions https://api.hku.hk/vertexai-gemini

The OpenAI prefix serves Responses only, and Gemini refuses every tool but its own url_context — see Known limits. A model outside your subscription answers 500 rather than 404, so switch off what you do not use.

Install

dsh-hku-llm is published on npm. Install it through your DSH profile:

dsh plugin --profile web add dsh-hku-llm

The same plugin can also be installed straight from this repository — use the GitHub form when you need a commit that is not on npm yet, or when npm is unreachable (it needs Git on your PATH and a public repository):

dsh plugin --profile web add github:r48n34/dsh-hku-llm

If your DSH runs the Desktop profile, use the profile name shown in Settings → Plugins (for the Desktop app this is usually desktop):

dsh plugin --profile desktop add dsh-hku-llm

After installing, restart DSH once, then open Settings → HKU GenAI, paste your Developer Portal key and choose Save key. Uncheck the models your subscription does not include; the composer offers the rest. This needs DeepSeek Harness 0.2.0 or newer, and every shipped model is text-only.

To update or remove it, use Settings → Plugins in DSH and install again, or dsh plugin --profile <name> remove dsh-hku-llm.

Verify the install

Ask the agent to run the plugin's own health check.

{ "action": "status" }

A healthy profile answers with the routes, their endpoints, which models are enabled or disabled, and the state of each credential reference:

{
  "plugin": "dsh-hku-llm",
  "adapterRegistered": true,
  "routeCount": 3,
  "settingsRows": ["hku-responses", "hku-chat", "hku-gemini"],
  "routes": [
    {
      "provider": "hku-chat",
      "displayName": "HKU Chat (Chat Completions)",
      "api": "openai-completions",
      "baseURL": "https://api.hku.hk/deepseek/models",
      "apiKeyEnv": "HKU_OPENAI_API_KEY",
      "apiKeyEnvs": [],
      "models": {
        "enabled": ["DeepSeek-V4-Flash", "DeepSeek-V4.1-Flash-1017", "DeepSeek-V4-Pro", "DeepSeek-V3.2", "kimi-k3.1-pro"],
        "disabled": []
      },
      "credentials": [{ "ref": "HKU_OPENAI_API_KEY", "state": "configured", "detail": "stored" }]
    }
  ]
}

To prove the key actually works, make one small live call:

{ "action": "test", "provider": "hku-chat", "model": "DeepSeek-V4-Flash" }
{
  "ok": true,
  "provider": "hku-chat",
  "model": "DeepSeek-V4-Flash",
  "latencyMs": 812,
  "text": "ok",
  "usage": { "inputTokens": 9, "outputTokens": 1, "totalTokens": 10 }
}

A failure comes back with the mapped code and message instead of ok, so this is also the fastest way to tell a bad key from a bad endpoint.

What you get

Three protocols, one picker Every HKU prefix becomes an ordinary DSH provider: one composer, one picker, one settings page. Tool calls and token streaming still depend on the route.
A key pool that fails over Requests rotate across every configured key; a key the gateway rejects is skipped before the first chunk, so a failover never duplicates an answer.
Per-model switches Any catalogue model can be hidden from the picker and refused, without editing files. The catalogue itself is never destroyed.
A catalogue you own Rename a model, change the gateway id, retune its context window or output cap, declare reasoning levels, add a model the shipped catalogue lacks, or delete one you never use — all on the settings page.
One settings page Enable the routes, rename them, edit endpoints, manage the model catalogue, toggle models, add or remove key slots — all in Settings → HKU GenAI.
A health check tool hku_llm_status reports routes, credentials and models, and can make one small live call.
Errors that say what to do 401, 404, 429, 5xx, the 2 MiB edge limit and an empty account each map to a named code with an actionable message.

The settings page

The HKU GenAI settings page: enable switch, key slots, and a route card with its name, endpoint and editable model rows

Illustration of Settings → HKU GenAI. The real page follows your DSH theme and shows your own key slots.

That page is the one place to:

  • switch every route on or off;
  • rename a route and edit its endpoint;
  • manage the model catalogue — open a model's parameters to change its gateway id, label, context window, output cap, input types or reasoning levels; Add model appends an entry the shipped catalogue lacks, Remove deletes one you never use;
  • toggle individual models — an unchecked model leaves the picker and refuses requests until it is checked again, while the entry itself stays in the catalogue;
  • keep a pool of Developer Portal keys — Add key appends a slot, Remove deletes one, and requests rotate across every configured key;
  • store or clear a key value (write-only, through the credential store).

Model catalogue

Capacities are transcribed from the Model Information panel of the GenAI app (Model Information → Text Models), so they differ per model family instead of following one gateway-wide default:

Panel context Declared contextWindow Models
128k 128000 DeepSeek V3.2, o4-mini
400k 400000 GPT-5 nano, GPT-5 mini, GPT-5.1, GPT-5.3 codex
1M 1048576 GPT-4.1 family, GPT-5.4, GPT-5.5, GPT-6 family, DeepSeek V4 family, Kimi K3.1 Pro, every Gemini deployment

The panel publishes no output ceiling, so maxTokens keeps the per-protocol value: 16k on hku-chat and hku-responses, 64k on hku-gemini. Declaring the real window is what lets a long session run before the harness compacts; retune a single model on the settings page if the gateway turns out to cap lower.

hku-chat — Chat Completions

Model id Label Context Reasoning levels
DeepSeek-V4-Flash DeepSeek V4 Flash 1M high, max
DeepSeek-V4.1-Flash-1017 DeepSeek V4.1 Flash (1017) 1M high, max
DeepSeek-V4-Pro DeepSeek V4 Pro 1M high, max
DeepSeek-V3.2 DeepSeek V3.2 128k high, max
kimi-k3.1-pro Kimi K3.1 Pro 1M —

hku-responses — Responses

Model id Label Context Reasoning levels
gpt-4.1-nano GPT-4.1 nano 1M —
gpt-4.1-mini GPT-4.1 mini 1M —
gpt-4.1 GPT-4.1 1M —
o4-mini o4-mini 128k low · medium · high
gpt-5-nano GPT-5 nano 400k low · medium · high
gpt-5-mini GPT-5 mini 400k low · medium · high
gpt-5.1 GPT-5.1 400k low · medium · high
gpt-5.3-codex GPT-5.3 codex 400k low · medium · high
gpt-5.4 GPT-5.4 1M low · medium · high
gpt-5.5 GPT-5.5 1M low · medium · high
gpt-6-luna GPT-6 luna 1M low · medium · high
gpt-6.1-terra GPT-6.1 terra 1M low · medium · high
gpt-6.2-sol GPT-6.2 sol 1M low · medium · high
gpt-6.2-astra GPT-6.2 astra 1M low · medium · high

hku-gemini — Gemini Chat Completions

Model id Label Context Reasoning levels
gemini-2.5-flash Gemini 2.5 Flash 1M —
gemini-3-flash-preview Gemini 3 Flash (preview) 1M —
gemini-3.1-pro-preview Gemini 3.1 Pro (preview) 1M —
gemini-3.5-flash Gemini 3.5 Flash 1M —
gemini-4-carbon Gemini 4 Carbon 1M —
gemini-4-hydrogen Gemini 4 Hydrogen 1M —

The OpenAI reasoning models default to medium. The DeepSeek entries declare high and max but ship no default, so the gateway's own default applies until you pick a level, and a model with no levels never sends the reasoning field at all. Gemini exposes no reasoning knob on this operation, so it declares none — a thinking trace still arrives as reasoning when the deployment returns one.

The Gemini service also lists four image deployments (gemini-2.5-flash-image, gemini-3-pro-image, gemini-3.1-flash-image, gemini-nano-banana-2.1) under its separate Generate Content operation. This plugin does not speak that operation yet, so they are not shipped in the catalogue.

How it works

Architecture: the Host seams, the plugin's two halves, and the HKU gateway
  • The Host owns the seams. The agent loop, the LLM registry, the credential store and the settings Remote are all DeepSeek Harness services; the plugin registers into them and keeps none of their state.
  • One adapter, three protocols. lib/wire/ builds the request body and parses the stream for each protocol; the adapter and the chunk assembler never branch on protocol.
  • Credentials are resolved per request. apiKeyEnv is read through the credential seam on every turn, so adding or rotating a key needs no restart.
  • Failover happens before output. Keys are tried in rotation order; a rejected one is skipped and remembered, so a dead key costs one failed attempt rather than one per turn.

Configuration

The row accepts the same profile shape as llm-pi-ai, so the existing Models editor can edit it:

- id: hku-llm
  name: dsh-hku-llm
  config:
    enabled: true
    providers:
      hku-chat:
        displayName: HKU Chat (Chat Completions)
        api: openai-completions          # or openai-responses, gemini-completions
        baseURL: https://api.hku.hk/deepseek/models
        apiKeyEnv: HKU_OPENAI_API_KEY
        headers: {}                      # extra deployment headers; api-key always wins
        models:
          - id: DeepSeek-V4-Flash
            name: DeepSeek V4 Flash
            contextWindow: 1048576
            maxTokens: 16000
            input: [text]                # text-only in this version
            reasoningEfforts: { high: high, max: max }
            defaultReasoningEffort: high
      hku-gemini:
        displayName: HKU Gemini (Chat Completions)
        api: gemini-completions
        baseURL: https://api.hku.hk/vertexai-gemini
        urlContext: false                # true adds the service's only tool
        models:
          - id: gemini-2.5-flash
            contextWindow: 1048576
            maxTokens: 65536

reasoningEfforts maps a selectable level to the exact string the gateway receives; off (or an absent level) sends nothing. enabled: false withdraws every route while leaving the plugin mounted.

urlContext is the one knob the Gemini route adds. Setting it to true sends tools: [{ url_context: {} }], which lets Gemini fetch the URLs a prompt mentions. Leave it off unless you want that: the gateway refuses any other tools value, including an empty array, and this route never sends the harness tool set.

Adding a vendor route is a config edit: point baseURL at any OpenAI-compatible prefix and list its models. The adapter appends /responses or /chat/completions according to api.

Models and toggles

Each catalogue entry carries enabled. A disabled model is omitted from llm.listModels, so the composer picker no longer offers it, and a request that names it fails with UNKNOWN_MODEL before any network I/O. The catalogue itself is untouched, so re-enabling a model restores it exactly.

models:
  - id: gpt-6.2-sol
    enabled: false        # hidden from the picker, refused if requested

Beyond the toggle, the settings page edits the catalogue itself: Edit opens a model's id, label (name), contextWindow, maxTokens, input types, reasoningEfforts and defaultReasoningEffort; Add model appends an entry; Remove deletes one. A save rewrites only the route whose catalogue changed, as a partial settings.update patch, and fields the page does not show are preserved. The page refuses an invalid draft before writing: model ids must be unique within a route, capacities must be positive whole numbers, and a default reasoning level must be one of the declared levels.

Both capacities are editable at any time, and the values the catalogue ships are only defaults:

  • The context window starts at the number the Model Information panel publishes for that model, the output cap at the per-protocol default (16k, or 64k on Gemini).
  • Retune either field and the row starts showing Documented default: … next to a Use default action, which writes the shipped numbers back. Saving an untouched row writes nothing at all.
  • A row added with Add model adopts the documented capacity of the model id you type as you type it — until you edit a capacity by hand, after which the row keeps your numbers. An id the catalogue does not ship starts from 128000 context / 16000 output.
  • Blank means default, and the default is per model: clearing the context window of a 1M model falls back to its documented 1048576, not to a fixed 128k floor.

Two controls on that page are one-step, so a stray click cannot leave a half-written route behind:

  • The model checkbox saves on click. Hiding or showing a model persists that route's catalogue immediately — there is no Save changes step for a toggle. The write covers the whole catalogue of the route, so the click is refused with a notice while another row on that route is still invalid.
  • Endpoints are locked. Every route always shows its endpoint, as read-only text plus a padlock button. Clicking the padlock unlocks the field, and Save changes stores the new URL; locking it again without saving restores the stored endpoint. A value that is not a full http(s) URL is refused before any write.

A profile that stores a route object without its endpoint — an earlier build could write one, because a settings patch replaces the route object rather than deep-merging it — still works: the plugin falls back to the shipped endpoint for a route id it knows, and the next save writes the missing fields back.

models:
  - id: my-gateway-model       # the id the gateway expects
    name: My gateway model     # what the picker shows
    contextWindow: 200000
    maxTokens: 32000
    input: [text]
    reasoningEfforts: { low: low, high: max }   # level: wire value
    defaultReasoningEffort: low

A removed model is gone from that route; add it again if you need it. To restore the shipped catalogue, delete the providers key from the plugin's configuration and reopen Settings: the shipped table is the schema default for that whole field, so removing one route's models list alone leaves the route with no models at all rather than restoring them.

Key pool

apiKeyEnv is the primary reference; apiKeyEnvs adds more. Requests rotate across the pool, and a key the gateway rejects (401, 403, 429) is skipped in favour of the next one — before any output exists, so a failover never duplicates a streamed answer. A rejected key is remembered for five minutes (thirty seconds for rate limits) and tried last, so a dead key costs one failed attempt rather than one per request.

hku-chat:
  apiKeyEnv: HKU_OPENAI_API_KEY
  apiKeyEnvs:
    - HKU_OPENAI_API_KEY_2
    - HKU_OPENAI_API_KEY_3

Every reference is a separate credential-store entry, so each key stays independently rotatable and revocable. The settings page creates the slot names for you (HKU_OPENAI_API_KEY_2, _3, …) and stores each value separately.

Credential

Every route resolves apiKeyEnv per request through the DSH credential seam. The default is HKU_OPENAI_API_KEY.

Set it in any of the three places the credential seam reads, highest priority first:

  1. The HKU GenAI settings page (or a provider row in Settings → Models) — paste the Developer Portal key. This is the only place that stores the value in the credential file.
  2. The launch environment — HKU_OPENAI_API_KEY=… dsh (PowerShell: $env:HKU_OPENAI_API_KEY = "…"; dsh).
  3. <harness home>/.env — one HKU_OPENAI_API_KEY=… line, read at startup.

To use a different reference, point apiKeyEnv at another name. Nothing ever writes a key into cordis.patch.yml.

Failures

Situation Reported code
No credential for the reference MISSING_CREDENTIAL
The request never reached the gateway TRANSPORT
Gateway rejects the key (401/403) AUTH
Wrong path or base URL (404) NOT_FOUND, message names the URL
Rate limited (429) RATE_LIMIT with providerRetryAfterMs
Gateway fault (5xx) SERVER, message keeps the gateway's activityId
Any other 400/422 BAD_REQUEST
Gateway timed out or reported a conflict (408/409) TIMEOUT / CONFLICT
Any other status UNKNOWN
Model not in the catalogue UNKNOWN_MODEL, before any network I/O
Model toggled off, or routes disabled UNKNOWN_MODEL / NO_ADAPTER
Image or file block reached the adapter UNSUPPORTED_CONTENT
Stream with no content or tool call EMPTY_RESPONSE
Request body above ~1.5 MB CONTEXT_WINDOW_EXCEEDED, message names the size
Account out of AI credits QUOTA, message points at the balance page
Gemini refused the prompt on safety grounds CONTENT_FILTERED, with the gateway's reason

The gateway sometimes answers 500 Internal server error for a model that worked minutes earlier; that is upstream, and the activityId in the message is what HKU IT needs to trace it.

The 2 MiB request ceiling

The HKU edge refuses request bodies above roughly 2 MiB, and it reports that as a plain 400 whose body reads Error in update token balance api. — not a context-length error, and not model-specific. A long session with large tool outputs reaches it first, because the whole conversation is resent on every turn.

The plugin recognises that combination (400 + that text + a body above roughly 1.5 MB) and reports CONTEXT_WINDOW_EXCEEDED with the actual size, so the turn fails with something actionable instead of a bare HTTP 400. Compact the session or start a new one, then retry: the next request carries the compacted history and fits.

Running out of AI credits

On a normal-sized body, a 400 reading either Error in update token balance api. or Insufficient token. is the account, not the request: the gateway could not charge the call. The plugin reports QUOTA and points at the balance page. Staff accounts are replenished monthly; check the remaining balance at genai.hku.hk.

This is also why a cheap prompt can succeed while a real turn fails — the charge is assessed per request, and a full agent turn with a large history and a large output cap costs far more than a two-word test.

Security

  • The key never enters configuration. It is stored in the DSH credential store and read per request; cordis.patch.yml holds only the reference name.
  • It goes only where you point it. The resolved key is sent as the api-key header to the route's baseURL. Editing that field sends your key to whatever host you type, so keep the HKU defaults or a host you control.
  • Values are never read back. The page writes through credentials.set; the reads it performs (describe) return configured state and source, not the secret. The settings page's input is a write-only password field.
  • Error text is redacted. A gateway or proxy that echoes request headers cannot leak a key through a failure message: resolved keys are replaced with [redacted] before the body becomes an LlmError, which is recorded with the turn.
  • Logs name references, not values. Failover warnings and credential-resolution failures mention HKU_OPENAI_API_KEY, never the secret.
  • The status tool reports names and states, with model ids and endpoints — no secrets.
  • No other network traffic. The plugin talks only to the configured endpoints, and the settings page talks only to the DSH Remote.
  • The published tarball carries no secrets. npm pack ships the two halves, the locale files, the icon and the docs — no .env, no .credentials.yaml, no captured session log. Keys live in the DSH credential store, never in the repository or the package.

Known limits

  • Text only. Every shipped model declares input: [text], so the harness replaces images with deterministic placeholders instead of failing. Image projection is not implemented, and that includes Gemini's image deployments; a model edited to accept image input bypasses that substitution and fails with UNSUPPORTED_CONTENT.
  • No function calling on the Gemini route. Its Chat Completions operation refuses every tools entry but url_context, so an agent turn on hku-gemini cannot call tools. Use hku-chat or hku-responses for work that needs them; urlContext: true is the one exception, letting Gemini fetch URLs itself.
  • Gemini answers in one piece. That operation is documented as a single response, so text arrives when the completion finishes rather than token by token.
  • Context windows are the portal's numbers; output caps are not. The Model Information panel states a context window per family, so the catalogue follows it — but it states no output ceiling, so maxTokens keeps the per-protocol guess. Retune either on the settings page if a deployment caps lower.
  • No model discovery. The gateway exposes no /models listing; the catalogue is configuration. Models it adds later can be entered by hand with Add model.
  • No replay state. Assistant reasoning is not resent to the provider, so a reasoning model re-thinks instead of reusing provider-side state.
  • The OpenAI Responses upstream is intermittent; hku-chat is the stable path.
  • Unofficial and unaffiliated. This is not an HKU plugin; neither HKU nor any other university or institution in Hong Kong is associated with it. The gateway, model availability and the credit balance are the university's, and they can change without notice.

FAQ

Why not just add a custom provider in Settings → Models? Because every generic provider sends Authorization: Bearer. The HKU edge wants api-key, and no profile field changes that header. This plugin registers an adapter instead.

Where is my key stored? In the DSH credential store, under the reference name (HKU_OPENAI_API_KEY). The settings page can write and clear it but never displays it again, and the configuration file only ever contains the name.

Can I use several keys or several accounts? Yes — add slots on the settings page. Each slot is a separate credential entry, and requests rotate across all of them with failover.

Do I need to restart after changing settings? No. Endpoint edits, route names, catalogue edits, model toggles and key changes apply to the next request. You only restart once, after the initial install, so the Settings page itself loads.

Can I add a model the plugin does not ship? Yes. Use Add model on the route, enter the gateway's model id, and save. Fill in the label and capacities so the picker and the context meter show something meaningful.

Which route should I choose? hku-chat for DeepSeek and Kimi models, and as the stable default. hku-responses for the GPT and o-series catalogue, when that upstream is healthy. hku-gemini for the Gemini deployments: long context, but no tool calls. Tool calls work on hku-chat and hku-responses; only hku-gemini refuses them.

Can I send images? Not yet. Models are declared text-only, so attachments are replaced with placeholders rather than failing the turn.

Uninstall

  1. Open Settings → HKU GenAI and clear the stored keys (optional, but it removes the credential entries).
  2. Select Plugins in the sidebar, open the HKU GenAI Models bundle under Installed plugins, and choose Remove. That deselects the bundle and removes the package entry from the profile; restart DSH afterwards.
  3. There is no local checkout to delete: an npm or Git install lives inside the profile and is removed with the bundle. If you cloned the repository separately for development, delete that copy now.

Development

pnpm install                                    # once per clone: the runtime dependency and Vitest
node scripts/link-stubs.mjs                     # mount dev copies of the Host packages
npm test                                        # every offline suite (Vitest, no network)
HKU_TEST_KEY=... node scripts/smoke.mjs --all   # optional live check (CI never runs it)
node scripts/link-stubs.mjs --unlink            # before installing the bundle

In PowerShell, set the key first: $env:HKU_TEST_KEY = '...'.

link-stubs is what lets a bare checkout resolve the peer packages the Host provides. While the stubs are mounted, an installed copy of this directory resolves them too, so unlink before install_bundle and relink when you want the suites again. The script never overwrites a package it did not create.

The same suites run on every push to main through .github/workflows/ci.yml, so a green local run and a green CI run mean the same thing.

The full developer guide — architecture, seam contracts, request lifecycle, testing strategy, recipes, packaging and the release checklist — is in DEVELOPMENT.md.

Disclaimer

dsh-hku-llm is an independent, unofficial project maintained by its contributors.

  • Not an official plugin. It is not an official plugin of The University of Hong Kong, and it is not affiliated with, endorsed by, sponsored by, or supported by HKU or by any other university or institution in Hong Kong — including their faculties, departments, institutes, research centres, staff and students.
  • No institutional support. HKU IT, the HKU GenAI team and the gateway's operators do not maintain this plugin and are not responsible for it. Please do not report problems with it to them.
  • Access and billing are yours. Using the HKU GenAI gateway remains subject to HKU's own terms, policies, quotas and charges. This software only sends requests to the endpoint you configure.
  • Not a licence to spend tokens. This plugin is not meant to encourage unintended, excessive or automated token consumption, and nothing here is an invitation to do so. Every request you send is charged to your own account, so please follow the applicable fair-use policy and usage rules — including the quotas, rate limits and acceptable-use terms set by HKU, your faculty or department, or any other organisation whose gateway or key you use — and use only the tokens your work actually needs.
  • Names are descriptive. "HKU", "HKU GenAI", "DeepSeek", "OpenAI" and other names and marks are the property of their respective owners, used only to identify the services and models involved.
  • No warranty. The software is provided "as is", without warranty of any kind. You use it at your own risk, and the authors accept no liability for lost credits, failed requests, or any other damage arising from its use.

The LICENSE carries the same notice.

License

MIT © 2026 dsh-hku-llm contributors.

—/ 5

No ratings yet

Verified DSH bundle

Commit ac863b9c04d0

Community comments

No comments yet. Be the first to write one.

DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout