8
72
近 7 天 10
37.0
生态多维模型
1 个月前
2026-07-04
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@pandada8/opencode-axonhub@0.2.6"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@pandada8/opencode-axonhub@0.2.6"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D @pandada8/opencode-axonhubopencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
OpenCode plugin that discovers AxonHub models from /v1/models and /v1/models?include=all, merges both responses, and exposes them as the axonhub provider.
Models are cached at ~/.cache/opencode/axonhub-models.json for one day. If no API key is configured, discovery returns no models.
By default, discovered AxonHub models are enriched from OpenCode's default model cache at ~/.cache/opencode/models.json. The plugin matches entries by model id and uses the cached metadata to fill OpenCode-specific fields such as family, capabilities, modalities, cost, limits, provider package, headers, options, and variants. AxonHub still provides the actual api.id and AxonHub endpoint URL used for requests.
If the matched OpenCode metadata defines experimental.modes, the plugin also exposes those modes as separate models with the mode suffix. For example, when OpenCode's cache defines a fast mode for gpt-5.4, gpt-5.5, or gpt-5.4-mini, AxonHub will expose both the base model and the corresponding gpt-5.4-fast, gpt-5.5-fast, or gpt-5.4-mini-fast model.
API keys can be stored with OpenCode auth as provider axonhub; on Linux this is written to ~/.local/share/opencode/auth.json.
Usage
Add the axonhub provider to opencode.jsonc before logging in or fetching models. Without this provider entry, OpenCode cannot discover the AxonHub model list.
{
"plugin": ["@pandada8/opencode-axonhub"],
"provider": {
"axonhub": {
"options": {
"baseURL": "https://your-axonhub.example.com"
},
"models": {}
}
}
}
To disable enrichment from ~/.cache/opencode/models.json, pass plugin options with enrichModels set to false:
{
"plugin": [["@pandada8/opencode-axonhub", { "enrichModels": false }]],
"provider": {
"axonhub": {
"options": {
"baseURL": "https://your-axonhub.example.com"
},
"models": {}
}
}
}
When enrichModels is disabled, the plugin only uses AxonHub's model responses and does not create experimental.modes derived models such as *-fast.
Then store the API key with OpenCode:
opencode auth login --provider axonhub
You can also set provider.axonhub.options.apiKey directly, for example with {env:AXONHUB_API_KEY}.
Or manually edit ~/.local/share/opencode/auth.json:
{
"axonhub": {
"type": "api",
"key": "ah-your-api-key"
}
}
If the file already contains other providers, add axonhub as another top-level key. Keep the file private:
chmod 600 ~/.local/share/opencode/auth.json
OpenAI-owned models use @ai-sdk/openai against the AxonHub /v1 endpoint. All other models use @ai-sdk/anthropic against the AxonHub /anthropic/v1 endpoint.