0
416
近 7 天 246
36.1
生态多维模型
1 天前
2026-10-03
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-zeldoc@0.2.0"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-zeldoc@0.2.0"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-zeldocOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
An OpenCode plugin that shows exactly the Zeldoc models your API key can use, with the right limits, prices and capabilities.
Without it, OpenCode lists the Zeldoc models from models.dev, a static catalog that says nothing about your key. You may see models your key cannot call, miss models it can, and get no context limits or capabilities for Zeldoc's own models. This plugin asks Zeldoc which models your key has and builds the model picker from that answer. When a model is removed from your key, it disappears from OpenCode on the next start (OpenCode 1) or within minutes (OpenCode 2).
How it works
OpenCode starts
│
▼
opencode-zeldoc (the "zeldoc" provider's model list)
│ • GET https://api.zeldoc.ai/v1/zeldoc/models with your API key
│ • keeps the chat models your key may call
│ • per model: context/output limits, your price per 1M tokens,
│ tool calls, reasoning (+ effort levels), image and PDF input
│ • display names come from models.dev where it knows the model
▼
the model picker shows only what your key can use
The plugin is resilient by design:
- Graceful fallback: if the Zeldoc endpoint is unreachable or slow (3 s timeout), OpenCode keeps the models.dev catalog instead of showing no models at all.
- Nothing extra to configure: it reuses the API key you already gave OpenCode for Zeldoc and the base URL from models.dev.
- Prices are yours: the catalog returns what your organization pays, so OpenCode's cost tracking matches your Zeldoc usage.
Install
Works with OpenCode 1 (1.18.29 and newer) and OpenCode 2.
From npm (recommended)
Add to your opencode.json (global or per-project):
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-zeldoc"]
}
OpenCode installs the plugin automatically on next launch. OpenCode 2 reads
this plugin key too; its native name is plugins.
From source (for development)
Clone this repo. The included opencode.jsonc loads the plugin from local
source:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["./src/index.ts"]
}
That path is for OpenCode 1. OpenCode 2 only loads plugin directories and
looks for a server or index file in them, but 2.0.18 skips a directory that
has no server file. Point it at a directory holding a server.ts with
export { default } from "<repo>/src/index.ts".
Configure
Log in to Zeldoc once, if you have not already:
opencode auth login # choose Zeldoc, paste your API key
The plugin uses that key. Without a stored login it falls back to the
ZELDOC_API_KEY environment variable, which OpenCode also reads for Zeldoc.
| Source | Used when |
|---|---|
opencode auth login |
A Zeldoc API key is stored (preferred) |
ZELDOC_API_KEY |
No stored key |
OpenCode 1 fetches the model list when it starts; restart it after a change to your key's models. OpenCode 2 keeps a background service running between sessions, so there the plugin also refreshes the list every 5 minutes and as soon as you log in with a different key.
Develop
This repo uses Flox for a reproducible dev environment (Bun). Tests use Bun's built-in test runner against a local HTTP server, no mocks.
flox activate # enter the dev env (runs bun install)
bun test # run the unit tests
bun run typecheck # typecheck
License
MIT
同类生态推荐
Failover
opencode-failover
OpenCode plugin for automatic API-key failover and rotation across multiple provider keys
Models Info
@vymalo/opencode-models-info
OpenCode plugin that enriches model entries with full metadata (context length, pricing, modalities, capability flags) fetched from a provider-supplied OpenRouter-shaped endpoint.
Otel
@vymalo/opencode-otel
OpenTelemetry plugin for OpenCode: exports developer interactions as OTLP traces, metrics and logs — real USD cost, all five token types (including cache read/write and reasoning), tool results, permission decisions, API errors and lines of code. Configur