dsh-ollama-cloud-usage: View Ollama Cloud Quota and Keys in DSH

Preface

DeepSeek Harness (DSH) adopts a plugin-based architecture designed to decouple feature extensions from the core application. When using the Ollama Cloud service, developers need to pay attention to the session window, weekly quota, and specific request costs. The native ollama.com settings page is separated from the DSH interface, making it impossible to directly view remaining quota or manage API keys within the development environment.

The dsh-ollama-cloud-usage plugin registers a settings.section, adding a new configuration block named ollama-quota (order: -9) below “Account and Balance” in the DSH settings page. This block directly displays Cloud quota data and integrates API key editing capabilities, solving the issue of fragmented monitoring and configuration.

Plugin Positioning

  • Name: dsh-ollama-cloud-usage
  • Author: adamaik
  • Purpose: A DeepSeek Harness plugin for viewing remaining Ollama Cloud quota and managing API keys within the local DSH interface.
  • Problem Solved: Addresses the pain points of being unable to view Cloud quota or quickly switch/edit API keys within the DSH environment.

Core Features

The plugin retrieves data by polling the ollama.com/api/usage endpoint and utilizes DSH’s Remote mechanism to handle credentials.

Quota Display

In the ollama-quota block of the settings page, the plugin displays the following information:
* Session window remaining: Value range [0, 1].
* Weekly window remaining: Direct numeric value.
* Per-model request count: Corresponds to limits.<window>.models[].request_count for each window.
* Cost for the last 4 weeks: Shows activity.cost and activity.period.

API Key Management

  • Editor: Provides an input box for editing or replacing API keys.
  • Write Mechanism: Only edits the key referenced by the first keyEnvs entry in the list.
  • Storage Path: Saved to $DSH_HOME/.credentials.yaml.
  • Security: Keys are never rendered in the browser; the input box remains empty, and API responses do not contain plaintext keys.

Installation & Activation

Install the plugin from the npm repository:

dsh plugin --profile <profile> add dsh-ollama-cloud-usage

Notes:
1. If the Host line does not appear after installation, restart the DSH application.
2. Client-side updates usually require a page refresh to take effect (desktop apps do not currently support hot reloading).

Configuration

The plugin supports customizing behavior via configuration files. The default configuration is as follows:

Configuration Item Default Description
keyEnvs ["OLLAMA_CLOUD_API_KEY", "OLLAMA_API_KEY"] Priority order for attempting to read credentials; only the first entry is editable
refreshMs 60000 Snapshot refresh interval, minimum 5000
timeoutMs 15000 Request timeout duration

Example Configuration

In DSH’s configuration file, you can override the defaults using YAML syntax:

- id: ollama-cloud-usage
  config:
    refreshMs: 120000

Credential Configuration

The plugin reads keys via ctx.credentials, supporting environment variables, $DSH_HOME/.env, or refs within $DSH_HOME/.credentials.yaml.

Example of $DSH_HOME/.credentials.yaml:

version: 1
refs:
  OLLAMA_CLOUD_API_KEY: ollama_cloud_api_key_here

Notes

  1. Platform Limitation: Web platform only.
  2. Environment Requirements: Node.js version >= 22.19.0 required.
  3. Edit Limitation: Only the first reference in the keyEnvs list supports editing; subsequent references are read-only.
  4. Update Mechanism: Polling is used for data retrieval rather than push updates. Automatic refresh is triggered upon credential updates.
  5. Missing Data: The ollama.com/api/usage endpoint does not return plan names or reset timestamps, so the plugin interface only displays remaining window amounts.
  6. Verification Script: The project includes scripts/verify.mjs, allowing offline verification of Host routing and Client component rendering logic.

Conclusion

The dsh-ollama-cloud-usage plugin provides DSH users with a native entry point for Cloud quota monitoring while ensuring secure API key management. By interacting with the standard DSH Remote interface and credential system, it is suitable for users who frequently switch or monitor Ollama Cloud resources in a local development environment.

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

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

Xiaoye