# zhipumore **Repository Path**: opencode-plugin/zhipumore ## Basic Information - **Project Name**: zhipumore - **Description**: 智谱-支持多key轮询 - **Primary Language**: TypeScript - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-16 - **Last Updated**: 2026-06-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # opencode-zhipumore OpenCode 智谱 AI 多 API Key 轮询提供商插件。 支持智谱 AI 免费模型,提供多 Key 自动轮询、错误转移、故障恢复能力。 ## 支持的模型 | 模型 | 类型 | 上下文 | 最大输出 | |------|------|--------|----------| | `glm-4.7-flash` | 文本 | 131,072 | 16,384 | | `glm-4.6v-flash` | 视觉多模态 | 131,072 | 4,096 | | `glm-4-flash` | 文本 | 131,072 | 16,384 | | `cogview-3-flash` | 文生图 | — | — | | `cogvideox-flash` | 视频生成 | — | — | ## 安装 ### 1. 构建项目 ```bash cd zhipumore npm install npm run build ``` ### 2. 配置 OpenCode 在 OpenCode 的 `opencode.json` 或 `opencode.jsonc` 中添加插件配置: ```json { "plugins": [ { "type": "module", "module": "./path/to/zhipumore/dist/index.js", "name": "zhipumore" } ] } ``` ### 3. 连接授权 ```bash opencode connect zhipumore ``` 按提示输入 API Key(支持多个 Key,用逗号分隔)。 ## 获取 API Key 前往 [智谱 AI API Key 平台](https://bigmodel.cn/apikey/platform) 创建你的 API Key。 ## 多 Key 轮询机制 - 输入多个 Key(逗号分隔)时自动启用轮询 - 按顺序依次使用每个 Key - 单个 Key 连续失败 3 次后自动跳过 - 所有 Key 均失败后自动重置错误计数,重新从头开始轮询 - 单 Key 模式直接使用,不启动轮询 ## 调试日志 通过环境变量开启调试日志: ```bash # 方式一:全局 DEBUG 开关 DEBUG=1 opencode # 方式二:仅本插件 OPENCODE_ZHIPUMORE_DEBUG=1 opencode ``` 日志文件位置:`%USERPROFILE%\.zhipumore\debug.log` 日志自动保留最近 1000 条记录。 ## 开发 ```bash # 构建 npm run build # 类型检查 npm run typecheck ``` ## 项目结构 ``` zhipumore/ ├── package.json # 项目配置 ├── tsconfig.json # TypeScript 配置 ├── README.md ├── src/ │ ├── index.ts # 主入口:auth hooks、config、key 轮询 │ ├── constants.ts # 模型定义与常量 │ ├── plugin/ │ │ ├── auth.ts # API Key 持久化存储 │ │ └── key-manager.ts # 多 Key 轮询调度器 │ └── utils/ │ └── debug-logger.ts # 调试日志工具 └── dist/ # 编译产物 ``` ## 注意事项 - 插件不实现节流/重试机制,由 OpenCode 框架统一处理 - 错误通过 throw 传播给 OpenCode 框架进行 fallback 处理 - 不使用 `console.error` / `console.log`,日志全部走 `debug-logger.ts`