dsh-ollama-quota: View all Ollama / Codex / DeepSeek quotas in a single sidebar line

Preface

When running agents in DeepSeek Harness (DSH), Ollama Cloud, ChatGPT Codex subscriptions, and DeepSeek API often have separate quota or balance interfaces. After Ollama accounts switched to a credit model, reading the old limits.session / limits.weekly from GET https://ollama.com/api/usage returns errors (e.g., Could not parse the response · no limits object); the remaining quota should now be read via GET https://ollama.com/api/balance. Additionally, comparing Codex subscription windows with DeepSeek balances and peak/off-peak pricing requires switching between multiple pages.

The following introduces the community plugin dsh-ollama-quota (Maintainer: okku000, Category: Client). It registers a “Quota Dock” line at the bottom of the sidebar in the DSH Web client and includes an Ollama-related Settings section, summarizing data from the above sources in a unified interface. API Keys can be edited within the page via the DSH Remote credential interface, eliminating the need to modify configuration files separately just to check the balance.

What is this

dsh-ollama-quota is a DeepSeek Harness plugin (package name dsh-ollama-quota, current README corresponds to version 0.3.0, MIT License). In one sentence: it occupies a sidebar.footer.action slot at the bottom of the sidebar, displaying Ollama Cloud credits, Codex subscription usage, and DeepSeek API balance (including peak/off-peak status dots) in a single line when collapsed; when expanded, it shows separate cards for each provider. The Settings section also contains full rule descriptions for Ollama, usage reports, and an API Key editor.

The three cards are independent in terms of data; a failure in one provider will not crash the others. The Codex quota reuses the dsh-codex-subscription channel published by the dsh-codex-subscription plugin and does not touch ChatGPT OAuth; the coupling is limited to the channel name and payload shape (the README notes verification against dsh-codex-subscription 2.5.9).

Core Features

Data Sources

The plugin’s Host side fetches or forwards the following interfaces (keys do not enter the snapshot; only the order of credential references is recorded):

Provider Endpoint Purpose
Ollama Cloud GET https://ollama.com/api/balance Main data: included.balance_usd, included.allowance_usd, included.period, purchased.balance_usd
Ollama Cloud GET https://ollama.com/api/usage?range=24h\|7d\|30d Reference: totals (cost, requests, tokens) and daily buckets
DeepSeek GET https://api.deepseek.com/user/balance is_available and granted_balance / topped_up_balance for each currency
Codex POST /api/codex-subscription/usage Calls the subscription plugin’s own quota channel via Connection

Ollama requests use Authorization: Bearer <Ollama Cloud key>; DeepSeek uses Bearer tokens similar to DEEPSEEK_API_KEY. If the usage report fails, it does not hide the normal balance but displays an inline explanation within the usage card; usage is refreshed separately at the slower usageRefreshMs.

Host exposes:

  • GET /ollama-quota/snapshot — Ollama card snapshot
  • GET /ollama-quota/deepseek — DeepSeek card snapshot

Both support ?force=1 to force a refresh before returning.

Ollama Settings Card Display Items

Row Source
Remaining included quota included.balance_usd / included.allowance_usd
Usage ratio bar (allowance - balance) / allowance
Purchased quota purchased.balance_usd
Quota period included.period.from → included.period.until
Cost, requests, input/cache/output tokens usage.totals, window determined by usageRange
Daily cost bars usage.buckets[].usage_usd (up to 31 buckets)
Peak/off-peak status and countdown Calculated via browser clock: Weekdays UTC 12:00–18:00 is peak, others are off-peak
Key source Actual resolved credential reference
API Key editor remote.credentials.describe(refs) / set(ref, value) / unset(ref)

Request counts per model are no longer displayed (the endpoint no longer returns them). The Settings section also includes full rule text, local peak window, current local time, and bidirectional countdowns.

When collapsed: one line aligning providers — brand color markers, optional peak/off-peak dots (Green dot = off-peak, Red dot = peak), one number each; no phase text. The collapsed rail retains quota and a compact H:MM countdown within a 56px height.

Block When Collapsed Hover Title
Ollama Remaining included quota + phase dot Remaining, phase, countdown to next boundary
Codex Highest usage ratio across subscription windows Provider name
DeepSeek Total balance + phase dot Provider name and phase

Clicking the same line expands it in place into full cards (Ollama: remaining quota, 30-day spend, phase countdown, 24h strip based on browser local time; Codex: metering and reset for each window; DeepSeek: top-up vs. granted, peak/off-peak, and bars), clicking again collapses. Markers use inline letter coloring with no image assets.

Ollama peak/off-peak rules: Weekdays outside UTC 12:00–18:00 and all day on weekends are off-peak; DeepSeek peak/off-peak can be configured in deepseek.offPeak (Host reload required for changes to take effect).

Installation and Activation

Execute the installation command provided in the README under the DSH Web profile:

dsh plugin --profile web add git+https://github.com/okku000/dsh-ollama-quota.git

For local development, you can link a directory for hot updates:

dsh plugin --profile web add link:/path/to/dsh-ollama-quota

You need to restart the DSH application after modifying the Host; for the Client part, refresh the page. The plugin requires Node >= 22.19.0.

Configuration

Optional fields are written in cordis.patch.yml:

Field Default Meaning
keyEnvs [OLLAMA_CLOUD_API_KEY, OLLAMA_API_KEY] Credential references to try in order; editor writes to the first one
apiBase https://ollama.com Ollama API root address
usageRange 30d Usage window: 24h, 7d, 30d
refreshMs 60000 Balance refresh interval, minimum 5000
usageRefreshMs 300000 Usage report interval, minimum 60000; ?force=1 or switching to a new key triggers immediate reread
timeoutMs 15000 Single request timeout
deepseek.keyEnvs [DEEPSEEK_API_KEY] DeepSeek credential reference order
deepseek.apiBase https://api.deepseek.com DeepSeek API root address
deepseek.refreshMs 60000 DeepSeek balance cache duration (15000–3600000)
deepseek.timeoutMs 15000 DeepSeek request timeout
deepseek.offPeak Built-in schedule enabled, discountPercent, holidayTimeZone, peakWindows, holidays; when enabled: false, the phase row is hidden but balance is still displayed

Ollama Cloud keys are usually provided to DSH Remote for resolution via environment variables or $DSH_HOME/.credentials.yaml; specifics depend on your current DSH credential conventions.

Typical Usage and Verification

  1. Install the plugin and refresh the Web client, then check if the numbers for each provider and peak/off-peak dots appear in the collapsed row at the bottom of the sidebar.
  2. Click to expand, and verify that the Ollama remaining included quota, purchased quota, and usage strips match the Ollama console.
  3. If dsh-codex-subscription is installed, the Codex card should show subscription window usage consistent with that plugin.
  4. In Settings, use the API Key editor in the Ollama section: describe to view references, set / unset to update keys (via DSH Remote, plaintext is not returned in the snapshot).
  5. Verification scripts are available in the repository (offline simulation or hitting real APIs):
node scripts/verify.mjs          # Offline: simulate Host and browser runtime
node scripts/verify.mjs --live   # Use OLLAMA_CLOUD_API_KEY, DEEPSEEK_API_KEY from $DSH_HOME/.credentials.yaml to request real endpoints

npm test / npm run verify point to the same offline script; npm run verify:live corresponds to --live.

Use Cases and Notes

Suitable for: Developers who use Ollama Cloud credit models in the DSH Web client long-term and want to glance at Codex subscriptions and DeepSeek API balances and peak/off-peak pricing in the same interface.

Notes:

  • The plugin runs with the current dsh process permissions. Please review the GitHub Source Code and MIT License before installing; the community directory skillhub.cn has no official affiliation with DeepSeek / High-Flyer and is not an official app store.
  • Codex quota depends on the channel of dsh-codex-subscription; if that plugin is not installed, the Codex card behavior depends on actual runtime results.
  • Changes to DeepSeek’s deepseek.offPeak belong to the Host code path; the browser will only use the new schedule after the Host reloads.
  • If only the Ollama usage interface fails, the balance should still display normally; do not rely on the limits object in the old usage response anymore.

Links

Through the steps above, you can grasp multi-provider quotas in one line on the DSH sidebar, and handle Ollama usage viewing and API Key maintenance within Settings, avoiding misleading information caused by old Ollama usage parsing errors.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye