# cloudflaremore **Repository Path**: opencode-plugin/cloudflaremore ## Basic Information - **Project Name**: cloudflaremore - **Description**: cloudflaremore-支持多key轮询 - **Primary Language**: TypeScript - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-10-13 - **Last Updated**: 2026-10-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Cloudflare More OpenCode 提供商插件:接入 Cloudflare Workers AI(OpenAI 兼容网关),支持**多组 `account_id + apikey` 组合轮询**。 ## 项目简介 - 提供商 id:`cloudflaremore`,适配器:`@ai-sdk/openai-compatible` - baseUrl 模板:`https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1`,运行时由当前轮询到的组合的 `account_id` 动态替换 - 每组组合 = `{ account_id, apiKey }`,按组合 round-robin 轮询;连续 3 次非瞬态错误跳过该组合,全部失败复位 - 错误处理:401/403 原始 Response 原样返回 OpenCode(不重试);短暂性错误转固定 429 错误流(OpenCode 重试);网络异常 502 错误流;fetch 中不 throw ## 模型列表 | id | name | context | output | reasoning | vision | |---|---|---|---|---|---| | @cf/zai-org/glm-5.3 | @cf/zai-org/glm-5.3 | 1048576 | 966656 | true | - | | @cf/zai-org/glm-5.3-flash | @cf/zai-org/glm-5.3-flash | 1048576 | 966656 | true | ✓ | | @cf/deepseek-ai/deepseek-v4-pro-0813 | @cf/deepseek-ai/deepseek-v4-pro-0813 | 1048576 | 393216 | true | - | | @cf/deepseek-ai/deepseek-v4-flash-0731 | @cf/deepseek-ai/deepseek-v4-flash-0731 | 1048576 | 966656 | true | - | | moonshotai/kimi-k3 | moonshotai/kimi-k3 | 1048576 | 966656 | true | ✓ | | @cf/zai-org/glm-5.2 | @cf/zai-org/glm-5.2 | 1048576 | 966656 | true | - | | @cf/moonshotai/kimi-k2.7-code | @cf/moonshotai/kimi-k2.7-code | 262144 | 241664 | true | ✓ | | minimax/m3 | minimax/m3 | 1048576 | 524288 | true | ✓ | | minimax/m2.7 | minimax/m2.7 | 209920 | 181248 | true | - | cost 全部为 `{ "input": 0, "output": 0 }`(按积分计费,倍率以上游为准)。 ## 安装与接入 1. 安装插件(opencode plugin 安装方式): ```bash opencode plugin add opencode-cloudflaremore ``` 或在 `opencode.json` 的 `plugin` 中加入 `opencode-cloudflaremore`。 2. `/connect` 授权流程(**先 account_id 后 apikey**): - 第一步:输入 **Account ID**(多组用逗号分隔,Cloudflare 仪表盘右侧栏 / Workers 概览页可查) - 第二步:输入 **API Keys**(多 key 用逗号分隔,**顺序与 Account ID 一一对应**) - 两者数量必须一致,组成多组 `{ account_id, apiKey }` 组合 - 多组时按组合轮询,每次请求以当前组合的 `account_id` 构造 baseUrl: `https://api.cloudflare.com/client/v4/accounts//ai/v1` 3. API Key 获取地址:https://dash.cloudflare.com/profile/api-tokens(10000 神经元 / 天) ## 配置文件说明(%USERPROFILE%/.cloudflaremore/) | 文件 | 说明 | |---|---| | `provider.jsonc` | `{ "id": "cloudflaremore", "name": "Cloudflare More", "type": "key" }`(模块加载时 fail-fast 读取) | | `models.jsonc` | 模型列表(key = id 全小写,limit/reasoning/vision/cost 等) | | `auth.json` | 授权后自动生成,保存多组 `{ accountId, apiKey }` | | `blacklist.json` | Key 黑名单快照(自动持久化;可选复制项目内 `jsonc/blacklist.jsonc` 作为初始模板) | | `debug.log` | 调试日志 | ## 调试 设置环境变量后日志写入 `%USERPROFILE%/.cloudflaremore/debug.log`: - `DEBUG=1` - 或 `OPENCODE_CLOUDFLAREMORE_DEBUG=1` ## Key 黑名单机制 - 每组组合维护 `errorCount`,仅**非瞬态错误**(401/403 凭据无效、400/404/422 等持久错误)计数 - 连续 3 次非瞬态错误 → 该组合被跳过(blacklist);成功请求自动清零(自愈) - 全部组合失败 → 复位 errorCount 重新轮询 - 快照持久化到 `%USERPROFILE%/.cloudflaremore/blacklist.json`(存 accountId + apiKey 掩码 + errorCount + blocked),IO 异常仅告警绝不中断 - 可选:复制项目内 `jsonc/blacklist.jsonc` 到 `%USERPROFILE%/.cloudflaremore/blacklist.json` 作为初始模板