説明
以下はプラグイン作者による原文です。
📦 @goodandready/dsh-ollama-cloud-provider
Ollama Cloud provider plugin for DeepSeek Harness (dsh).
It registers one native LLM route, ollama-cloud, served by https://ollama.com, with two wire protocols:
| Transport | Endpoint | When |
|---|---|---|
native (default) | POST /api/chat | thinking, tool calls, usage counters |
openai-chat | POST /v1/chat/completions | OpenAI-compatible deployments and fallback |
Requests resolve the key per call, so a changed credential reaches the next request without a restart.
Web search and fetch
When the web service is present, the plugin registers Ollama Cloud as both a
search and a fetch provider (id: ollama-cloud). It calls
POST <apiBase>/api/web_search and POST <apiBase>/api/web_fetch with the same
credential reference as chat. Requests fail closed on redirects, retry one
transport/timeout failure, cap search results at 10 and fetched text at 256 KiB.
Select it in the profile:
- id: web
config:
searchProvider: ollama-cloud
fetchProvider: ollama-cloud
Architecture
graph LR
subgraph DSH["DeepSeek Harness Core"]
Agent["DSH Agent / Chat"]
Creds["Credentials / launch env"]
end
subgraph Plugin["dsh-ollama-cloud-provider"]
Router{"Route: ollama-cloud"}
Pool["Account pool<br/>rotation, cooldowns, sticky"]
Catalog["Live catalog<br/>/v1/models + /api/tags"]
Usage["Balance & usage<br/>/api/balance + /api/usage"]
subgraph Transports["Wire protocols"]
T1["Native /api/chat (NDJSON)"]
T2["OpenAI /v1/chat/completions (SSE)"]
end
end
subgraph Ollama["Ollama Cloud"]
Chat["ollama.com/api/chat"]
OpenAI["ollama.com/v1/chat/completions"]
Billing["/api/balance, /api/usage"]
end
Agent --> Router
Creds -.-> Pool
Router --> Pool
Pool --> Transports
T1 --> Chat
T2 --> OpenAI
Catalog --> Router
Usage --> Billing
Features
- Two wire transports chosen per model: the native Ollama API (NDJSON) and the OpenAI-compatible gateway (SSE).
- Text, thinking, tool calls, images, usage and finish reasons on both transports.
- Unique tool-call IDs minted across steps and turns, preventing session log collisions when upstream omits an id.
- Live catalog from
GET /v1/models, enriched with capability flags fromGET /api/tags. - Accurate limits for the dsh picker: context window, input modalities, reasoning levels and their default, tool support, and API visibility.
- Balance and usage from the official
/api/balanceand/api/usageendpoints: included credits, purchased credits, 24-hour / 7-day / 30-day spend, and spend by model. - Multi-account rotation before any content is streamed: 401/403/429 and quota rejections mark a key and retry with the next one. Cooldowns persist across restarts.
- Model-scoped marks: an unsupported model or a per-model quota rejection marks only that key+model for five minutes; other and free models keep using the account.
- Sticky accounts per conversation, plus model → account glob rules.
- Price estimates from the published Ollama pricing table, including off-peak rates, with per-model overrides.
- Browser UI:
- Settings → Ollama Cloud: key, balance, accounts, rules, model allowlist, per-model transport, connection settings.
- Sidebar quota card (off by default, and it does not poll
/statewhile disabled): a ring with the highest used window and rows with remaining credits or legacy windows; an optionalplanLabelis shown next to the provider name. - Center quota panel: spend windows, spend by model, accounts, routing trace, usage analytics and a request heatmap.
/ollamacommand for status, usage, balance, accounts, models, rules andtest [model].- TUI settings section for terminal profiles.
- One-click plugin update in Settings → Ollama Cloud.
Requirements
- DeepSeek Harness:
0.2.0-rc.2 || >=0.2.1-rc.2 <0.2.3-0 || >=0.2.2-0 <0.2.3-0 || >=0.2.3-0 <0.2.4-0(desktop and web profiles). - Node.js:
>=22.0.0. - Ollama Cloud Account: one or more active API keys from Ollama Cloud or a compatible proxy endpoint.
Install
Install the published package from the registry:
sole plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.41
# DSH Desktop:
sole plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.41
Restart dsh (or DSH Desktop), then pick Ollama Cloud in the model picker.
The exact registry version is the supported installation source. Build and pack from source only when developing the plugin itself; see Development.
Configure
- id: llm-ollama-cloud
name: "@goodandready/dsh-ollama-cloud-provider"
config:
apiKeyEnv: OLLAMA_API_KEY # default
# apiKey: ... # composition only, never commit
transport: native # native | openai-chat
requestTimeoutMs: 300000
streamIdleTimeoutMs: 300000
visibleModels: []
modelTransports: {}
# contextWindowOverrides: { "model-id": 131072 }
# maxOutputTokens: 32768
accounts:
- label: Work
apiKeyEnv: OLLAMA_API_KEY_2
activeAccount: '' # label or credential name to pin
stickySession: true
showSidebarQuota: false
planLabel: '' # optional, e.g. PRO
Every field except apiKey is volatile and appears in dsh settings.
Settings reference
| Field | Default | Meaning |
|---|---|---|
apiKeyEnv | OLLAMA_API_KEY | Credential-reference name of the primary key. |
apiKey | — | Literal key, composition only; never commit. |
apiBase | https://ollama.com | Native API root. |
openAiBase | https://ollama.com/v1 | OpenAI-compatible root. |
usageUrl | https://ollama.com/api/usage | Spend endpoint. |
balanceUrl | https://ollama.com/api/balance | Balance endpoint. |
transport | native | Default wire protocol. |
modelTransports | {} | Per-model protocol override. |
requestTimeoutMs | 300000 | Response-header timeout per attempt. |
streamIdleTimeoutMs | 300000 | Max gap between stream chunks. |
attemptTimeoutMs | 0 | Whole-attempt budget; 0 disables it. |
retryMaxRetries | 0 | In-adapter retries before rotation. |
retryBaseDelayMs | 250 | Backoff base. |
retryMaxDelayMs | 2000 | Backoff cap. |
retryJitter | 0.2 | Backoff jitter (0–1). |
visibleModels | [] | Explicit allowlist when not showing all. |
showAllModels | false | Ignore the allowlist and show everything. |
modelVisibility | {} | Per-model explicit show/hide. |
manualModels | [] | Hand-defined models absent from the catalog. |
modelOverrides | {} | Per-model capabilities, context and reasoning. |
modelOrder | [] | Picker order. |
filterModelsByPlan | true | Hide models the plan cannot use. |
contextWindow | model meta | Global context override. |
contextWindowOverrides | {} | Per-model context override. |
maxOutputTokens | model meta | Global output cap. |
temperature…topP/minP | provider default | Sampling. |
seed, repeatPenalty, repeatLastN | provider default | Sampling. |
numCtx, keepAlive, stop | provider default | Native generation controls. |
autoRefresh | true | Refresh the catalog in the background. |
refreshMinutes | 1440 | Refresh interval; 0 = mount only. |
accounts | [] | Extra keys with label and apiKeyEnv. |
modelAccountRules | [] | Glob pattern → account routing. |
stickySession | true | Keep one account per conversation. |
activeAccount | "" | Pin one account by label. |
showSidebarQuota | false | Show the sidebar quota card. |
planLabel | "" | Optional label next to the provider name. |
priceOverrides | {} | Per-model price overrides. |
userAgent | dsh-ollama-cloud-provider/<version> | Outbound User-Agent. |
Keys
config.apiKey(composition only,role('secret')).- The dsh credential seam under
apiKeyEnv(defaultOLLAMA_API_KEY). - The launch environment (process, project
.env,$DSH_HOME/.env).
Create a key at https://ollama.com/settings/keys. Keys do not expire; x-api-key is not accepted, only Authorization: Bearer.
Accounts and rotation
Add a second account in Settings → Ollama Cloud → Accounts: give it a name and a credential reference (for example OLLAMA_API_KEY_2), paste its key, then Save. The default account always serves first unless activeAccount pins another one.
Rotation happens before any content is streamed. When the serving key is rejected with an invalid credential, a rate limit or an exhausted quota, the adapter marks that key and retries the same request with the next usable account. A request that already started streaming is not replayed. Cooldowns are stored in ~/.dsh/storages/dsh-ollama/cooldowns.json keyed by a SHA-256 fingerprint — raw keys are never written. Authentication rejections (401/403) cool keys for 5 minutes instead of locking them for a day, and quota rejections follow provider Retry-After headers. Cooldowns can be cleared at any time via the Reset cooldowns button in the Accounts card or by sending POST /dsh-ollama/cooldowns/reset.
Model → account rules
Pin a model to a preferred account with a glob. The first matching rule wins; * and ? are supported and matching is case-insensitive. Other accounts remain fallbacks.
modelAccountRules:
- pattern: "*flash*"
account: "Work"
Balance and usage
The plugin uses the documented cloud endpoints:
GET /api/balance→included.balance_usd/included.allowance_usd/included.periodandpurchased.balance_usd. Legacy accounts returnincluded.session.remaining_percentandincluded.weekly.remaining_percent; both formats are displayed.GET /api/usage?range=24h|7d|30d&group_by=model→ totals and per-model groups with request count, USD, input, cached input and output tokens.
/api/usage is limited to 10 requests per minute per user, so the reader caches each range (balance 60 s, usage 120 s, failures 30 s) and never polls in the background. Quota failures are fail-open: chat never depends on them.
Settings page
Open Settings → Ollama Cloud:
- Key — status, paste a key, clear it, run Test connection against a chosen model. The probe disables thinking so the reply is visible.
- Balance and usage — credit bar or legacy windows, spend windows, warning at 80 % and exhausted at 95 %.
- Accounts — extra keys, per-account spend, pin, remove, set a key, reset cooldowns.
- Service status — reachability probe with latency and the last check time.
- Model → account rules — glob rules.
- Routing — sticky session per conversation.
- Models — search, refresh the live catalog, hide models, override the wire transport per model, see price, context and capabilities.
- Manual catalog entries — add models the catalog does not list.
- Generation defaults — sampling and output limits.
- Connection — native and OpenAI bases, usage and balance endpoints, transport, timeouts, output cap and context override.
- Discover — probe an unsaved endpoint with a one-shot key before saving it.
- Sidebar — show or hide the quota card, and an optional plan label (for example
PRO) shown next to the provider name. - Plugin update — current/latest version and Update now.
The Host serves /dsh-ollama/state, /health, /status, /analytics, /usage, /balance, /config, /key, /key/clear, /refresh, /models/refresh, /discover, /test and /update. /status probes the public tag endpoint without a key or quota. Writes require JSON, an Origin or Referer matching Host (the Desktop renderer is identified by its dsh-auth-* cookie and desktop user agent when both headers are absent), and are restricted to loopback (127.0.0.1 / ::1); a write without any source identity is rejected with 403.
Command
/ollama status # provider, accounts, quota and model count
/ollama usage # 7-day spend windows and spend by model
/ollama balance # included and purchased credits
/ollama accounts # labels, source, active/cooling, 7-day spend
/ollama models # ids, price, context, capabilities
/ollama rules # model → account rules
/ollama test [model] # minimal real request
Verified API facts
Checked live on 2026-10-21:
GET https://ollama.com/v1/modelsis public and returnsdata[]plus a non-standardmodels[]array carryingcontext_window,max_context_window,input_modalities,supported_reasoning_levels,default_reasoning_level,visibilityandsupported_in_api.GET https://ollama.com/api/tagsis public and is the only per-model source ofcapabilities(completion,tools,thinking,vision).- The live catalog returned 23 cloud models.
- Native
/api/chatstreams NDJSON and reportsprompt_eval_count,prompt_eval_cached_count,eval_countanddone_reasonin the final line. - OpenAI
/v1/chat/completionssupports streaming, tools, vision,reasoning_effortandstream_options.include_usage. - Anthropic compatibility (
/v1/messages) exists but is partial; this plugin does not use it.
Development
npm run typecheck
npm test
npm run build
npm run check # typecheck + tests + build + smoke-load + pack:check
npm run release # check + packed tarball
node scripts/probe.mjs
scripts/probe.mjs is read-only against the public catalog; with OLLAMA_API_KEY set it also probes chat, balance and usage and prints the raw shapes.
Visual verification
The Ollama Cloud settings page in DSH Desktop (dark theme): configured credential, balance and usage, and the connection probe.

Security
- Write routes require a loopback socket, a same-origin
Origin/Refererand the host authentication check; a DNS name is never treated as loopback. - API keys are resolved through the DSH credential service; the browser only learns whether a key is configured, never its value.
- Custom endpoint URLs must be absolute
http(s)without embedded credentials or fragments; link-local and metadata addresses are refused. /statusis cached for 10 seconds, while refresh, test and endpoint-discovery routes are single-flight and rate-limited.
Troubleshooting
- No models in the picker — open
GET /dsh-ollama/health;providerErrornames the catalog failure. CheckapiBase, network access and the key. - 401/403 — the key is rejected and cooled for 5 minutes; fix the credential, then reset cooldowns in Settings or call
POST /dsh-ollama/cooldowns/reset. - All accounts cooling — the error carries the remaining wait and the reason (
INVALID_CREDENTIAL,QUOTA,RATE_LIMIT). - The agent has no shell — Ollama Cloud rejects a request with more than 128 tool declarations, so the plugin caps the list. Core harness tools come first, then other built-in tools, then
mcp__*declarations, so a large MCP set is truncated beforepwsh(Windows) orbash(POSIX) can be dropped. When the cap does drop something, one warning names the omitted tools. - Usage is unavailable after several refreshes —
/api/usageallows 10 requests per minute; the plugin reportsusage rate limit reached; retry shortlyinstead of an outage. Wait a minute. - Update button is disabled — the DSH CLI entry was not found at runtime; install the exact version with
sole plugin --profile web add ...@<version>. - Settings are read-only — the host's settings service is read-only; Save is disabled and the badge says why.
- 502/504 from the gateway — the key rotates to the next account; the routing table shows
rotation.
Limitations
- Cloud only. Local
http://localhost:11434is not registered as a route. - Embeddings are not exposed: no cloud model in the live catalog advertises the
embeddingcapability. - File attachments are forwarded as deterministic handle text, not inline bytes.
- The usage endpoint is limited to 10 requests per minute; caches and the UI account for that.
- Cost values are estimates from the published table (including off-peak rates); the gateway is the authority.
- Automatic update requires the DSH CLI entry in the runtime.
- The UI requires a web profile; the TUI keeps the
/ollamacommand and the model route.
License
MIT © GooDAnDReaDY. See LICENSE and NOTICE.
バージョン履歴
- 0.1.422026/11/29 · 257 KB