ClawAPI Manager
🔧 Professional API management and cost optimization for OpenClaw deployments
English | 中文
English
Overview
ClawAPI Manager is an OpenClaw-native tool for managing API keys, monitoring costs, and optimizing API spending through intelligent routing. It saves 30-90% on API costs by automatically routing simple tasks to free models.
Capabilities
- - Multi-Provider Management: Manage keys for OpenAI, Anthropic, Google, and 40+ providers
- Cost Tracking: Real-time monitoring of API usage and spending
- Smart Routing: Automatically route tasks to cost-effective models
- Key Health Monitoring: Detect expired, rate-limited, or invalid keys
- Config Validation: Detect and auto-fix configuration issues
- Budget Alerts: Multi-channel notifications (Telegram, Discord, Slack, Feishu, QQ)
- Automated Failover: Round-robin key rotation with health checks
How to Use
1. Installation
CODEBLOCK0
2. Basic Commands
CODEBLOCK1
3. Configuration
CODEBLOCK2
Example Usage
Scenario 1: Validate Configuration
CODEBLOCK3
Scenario 2: Auto-Fix Issues
CODEBLOCK4
Scenario 3: Add OpenRouter Key
CODEBLOCK5
Scripts
- -
claw_api_manager_central.py: Main management CLI - INLINECODE1 : Configuration management core
- INLINECODE2 : Automated key rotation
- INLINECODE3 : Cost tracking and reporting
- INLINECODE4 : Intelligent task routing
Limitations
- - Requires Python 3.8+
- Only supports OpenClaw deployments
- Config validation covers common issues only
- Smart routing requires OpenRouter integration
Troubleshooting
Issue: "Unknown model" error
- - Run: INLINECODE5
- Run: INLINECODE6
- Restart gateway: INLINECODE7
Issue: Key rotation not working
- - Check:
config/openrouter_keys.json exists - Verify: All keys have INLINECODE9
- Check logs: INLINECODE10
中文
概述
ClawAPI Manager 是 OpenClaw 原生的 API 管理和成本优化工具。通过智能路由自动将简单任务分配给免费模型,节省 30-90% 的 API 成本。
功能
- - 多 Provider 管理:管理 OpenAI、Anthropic、Google 等 40+ 家 API 密钥
- 成本追踪:实时监控 API 使用和花费
- 智能路由:自动将任务路由到性价比最高的模型
- 密钥健康监控:检测过期、限流或无效的密钥
- 配置验证:检测并自动修复配置问题
- 预算告警:多渠道通知(Telegram、Discord、Slack、飞书、QQ)
- 自动故障转移:Round-robin 密钥轮换 + 健康检查
使用方法
1. 安装
CODEBLOCK6
2. 基本命令
CODEBLOCK7
3. 配置
CODEBLOCK8
使用示例
场景 1:验证配置
CODEBLOCK9
场景 2:自动修复
CODEBLOCK10
场景 3:添加 OpenRouter 密钥
CODEBLOCK11
脚本
- -
claw_api_manager_central.py:主管理 CLI - INLINECODE12 :配置管理核心
- INLINECODE13 :自动密钥轮换
- INLINECODE14 :成本追踪和报告
- INLINECODE15 :智能任务路由
限制
- - 需要 Python 3.8+
- 仅支持 OpenClaw 部署
- 配置验证仅覆盖常见问题
- 智能路由需要 OpenRouter 集成
故障排除
问题:"Unknown model" 错误
- - 运行: INLINECODE16
- 运行: INLINECODE17
- 重启 gateway: INLINECODE18
问题:密钥轮换不工作
- - 检查:
config/openrouter_keys.json 是否存在 - 验证:所有密钥都有 INLINECODE20
- 查看日志: INLINECODE21
📖 详细文档:
README.md
🐛 问题反馈:
GitHub Issues
🚀 快速开始: 运行 INLINECODE22
技能名称: clawapi-manager
详细描述:
ClawAPI Manager
🔧 面向 OpenClaw 部署的专业 API 管理与成本优化工具
English | 中文
English
概述
ClawAPI Manager 是一款 OpenClaw 原生工具,用于管理 API 密钥、监控成本,并通过智能路由优化 API 支出。通过自动将简单任务路由至免费模型,可节省 30-90% 的 API 成本。
功能
- - 多提供商管理:管理 OpenAI、Anthropic、Google 等 40 多家提供商的密钥
- 成本追踪:实时监控 API 使用情况与支出
- 智能路由:自动将任务路由至性价比最高的模型
- 密钥健康监控:检测过期、限流或无效的密钥
- 配置验证:检测并自动修复配置问题
- 预算告警:多渠道通知(Telegram、Discord、Slack、飞书、QQ)
- 自动故障转移:基于健康检查的轮询密钥轮换
使用方法
1. 安装
bash
cd ~/.openclaw/workspace/skills
git clone https://github.com/2233admin/clawapi-manager.git
cd clawapi-manager
pip install -r requirements.txt
2. 基本命令
bash
列出所有提供商
python3 claw
apimanager_central.py list
验证配置
python3 claw
apimanager_central.py validate
自动修复配置问题
python3 claw
apimanager_central.py fix
更新 API 密钥
python3 claw
apimanager_central.py update provider-name new-key
添加新提供商
python3 claw
apimanager_central.py add provider-name https://api.example.com sk-key anthropic-messages
3. 配置
bash
创建示例配置
cp config/managed
keyscentral.json.example config/managed
keyscentral.json
cp config/openrouter
keys.json.example config/openrouterkeys.json
编辑你的密钥
nano config/managed
keyscentral.json
使用示例
场景 1:验证配置
用户:检查我的 OpenClaw 配置是否有效
助手:[运行 validate 命令,报告问题]
场景 2:自动修复问题
用户:修复我的配置错误
助手:[运行 fix 命令,修复常见问题]
场景 3:添加 OpenRouter 密钥
用户:添加这个 OpenRouter 密钥:sk-or-v1-xxx
助手:[添加密钥,配置轮换]
脚本
- - clawapimanagercentral.py:主管理 CLI
- lib/configmanager.py:配置管理核心
- lib/keyrotation.py:自动密钥轮换
- lib/costmonitor.py:成本追踪与报告
- lib/smart_router.py:智能任务路由
限制
- - 需要 Python 3.8+
- 仅支持 OpenClaw 部署
- 配置验证仅涵盖常见问题
- 智能路由需要集成 OpenRouter
故障排除
问题:未知模型 错误
- - 运行:python3 clawapimanagercentral.py validate
- 运行:python3 clawapimanagercentral.py fix
- 重启网关:openclaw gateway restart
问题:密钥轮换不工作
- - 检查:config/openrouter_keys.json 是否存在
- 验证:所有密钥均设置 enabled: true
- 查看日志:~/.openclaw/logs/gateway.log
中文
概述
ClawAPI Manager 是 OpenClaw 原生的 API 管理和成本优化工具。通过智能路由自动将简单任务分配给免费模型,节省 30-90% 的 API 成本。
功能
- - 多 Provider 管理:管理 OpenAI、Anthropic、Google 等 40+ 家 API 密钥
- 成本追踪:实时监控 API 使用和花费
- 智能路由:自动将任务路由到性价比最高的模型
- 密钥健康监控:检测过期、限流或无效的密钥
- 配置验证:检测并自动修复配置问题
- 预算告警:多渠道通知(Telegram、Discord、Slack、飞书、QQ)
- 自动故障转移:Round-robin 密钥轮换 + 健康检查
使用方法
1. 安装
bash
cd ~/.openclaw/workspace/skills
git clone https://github.com/2233admin/clawapi-manager.git
cd clawapi-manager
pip install -r requirements.txt
2. 基本命令
bash
列出所有 providers
python3 claw
apimanager_central.py list
验证配置
python3 claw
apimanager_central.py validate
自动修复配置问题
python3 claw
apimanager_central.py fix
更新 API Key
python3 claw
apimanager_central.py update provider-name new-key
添加新 provider
python3 claw
apimanager_central.py add provider-name https://api.example.com sk-key anthropic-messages
3. 配置
bash
创建示例配置
cp config/managed
keyscentral.json.example config/managed
keyscentral.json
cp config/openrouter
keys.json.example config/openrouterkeys.json
编辑你的密钥
nano config/managed
keyscentral.json
使用示例
场景 1:验证配置
用户:检查我的 OpenClaw 配置是否正确
助手:[运行 validate 命令,报告问题]
场景 2:自动修复
用户:修复我的配置错误
助手:[运行 fix 命令,修复常见问题]
场景 3:添加 OpenRouter 密钥
用户:添加这个 OpenRouter 密钥:sk-or-v1-xxx
助手:[添加密钥,配置轮换]
脚本
- - clawapimanagercentral.py:主管理 CLI
- lib/configmanager.py:配置管理核心
- lib/keyrotation.py:自动密钥轮换
- lib/costmonitor.py:成本追踪和报告
- lib/smart_router.py:智能任务路由
限制
- - 需要 Python 3.8+
- 仅支持 OpenClaw 部署
- 配置验证仅覆盖常见问题
- 智能路由需要 OpenRouter 集成
故障排除
问题:Unknown model 错误
- - 运行:python3 clawapimanagercentral.py validate
- 运行:python3 clawapimanagercentral.py fix
- 重启 gateway:openclaw gateway restart
问题:密钥轮换不工作
- - 检查:config/openrouter_keys.json 是否存在
- 验证:所有密钥都有 enabled: true
- 查看日志:~/.openclaw/logs/gateway.log
📖 详细文档:
README.md
🐛 问题反馈:
GitHub Issues
🚀 快速开始: 运行 python3 claw
apimanager_central.py --help