Skip to content

jeouly3-bot/openclaw-provider-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openclaw-provider-manager

npm version npm downloads license GitHub stars

OpenClaw Skill: AI model provider manager — auto-discover models, track quota exhaustion across agents, and auto-switch on failure.

English | 中文


Features

  • Auto Model Discovery - Query any OpenAI-compatible /v1/models endpoint to list all available models
  • Quota Tracking - Mark exhausted models, share state across multiple agents (file-lock safe)
  • Auto Failover - When a model's quota runs out, automatically pick the next available one
  • Batch Config Sync - Update all agent configs in one command
  • Multi-Provider - Built-in support for Alibaba Cloud Bailian, DeepSeek, Zhipu, Kimi, OpenAI, SiliconFlow, plus any custom OpenAI-compatible endpoint
  • Health Check - JSON-based health status for proactive monitoring (healthy / warning / critical)
  • OpenClaw Skill - Drop into any OpenClaw agent's skill directory; the agent reads SKILL.md and gains full model management capability

功能

  • 模型自动发现 - 通过 /v1/models API 自动获取供应商所有可用模型
  • 额度追踪 - 标记耗尽的模型,多 Agent 间共享状态(文件锁保证并发安全)
  • 自动切换 - 模型额度用完后,自动选择下一个可用模型
  • 批量同步 - 一条命令更新所有 Agent 的配置文件
  • 多供应商 - 内置阿里云百炼、DeepSeek、智谱、Kimi、OpenAI、SiliconFlow,支持任何 OpenAI 兼容端点
  • 健康检查 - JSON 格式健康状态输出,支持主动监控(healthy / warning / critical)
  • OpenClaw Skill - 放入 Agent 的 skill 目录即可使用,Agent 读取 SKILL.md 自动获得模型管理能力

Supported Providers

Provider Endpoint
Alibaba Cloud Bailian (bailian) https://dashscope.aliyuncs.com/compatible-mode/v1
DeepSeek https://api.deepseek.com/v1
Zhipu (zhipu) https://open.bigmodel.cn/api/paas/v4
Kimi / Moonshot https://api.moonshot.cn/v1
OpenAI https://api.openai.com/v1
SiliconFlow https://api.siliconflow.cn/v1
Custom Any OpenAI-compatible endpoint via --base-url

Installation

npm (recommended)

npm install -g openclaw-provider-manager

Git clone

git clone https://github.com/jeouly3-bot/openclaw-provider-manager.git
cd openclaw-provider-manager
npm install

As OpenClaw Skill

# Clone into your OpenClaw skills directory
git clone https://github.com/jeouly3-bot/openclaw-provider-manager.git \
  ~/.openclaw/skills/openclaw-provider-manager
cd ~/.openclaw/skills/openclaw-provider-manager && npm install

Quick Start

1. Interactive Setup

npm run setup
# or: openclaw-pm setup (if installed globally)

2. Add API Key & Discover Models

node scripts/registry.js add-key \
  --provider bailian \
  --key sk-your-api-key \
  --label "my-account"

3. Check Status

node scripts/registry.js status

4. Health Check (JSON output)

node scripts/health-check.js
# Output: { "status": "healthy", "summary": "0/95 text models exhausted (0%)", ... }

5. Mark Model as Exhausted

node scripts/registry.js mark-exhausted \
  --provider bailian \
  --model qwen3.5-plus \
  --by "Agent-XiaoYi"

6. Get Next Available Model

node scripts/registry.js next-model --provider bailian --type text
# Output: { "model": "deepseek-v3", "type": "text", "fallback": false }

7. Sync Config to Agents

# Single agent
node scripts/sync-config.js \
  --format agent --provider bailian \
  --config ./openclaw.json --key-label "XiaoYi"

# All agents in a directory
node scripts/sync-config.js \
  --format agent --provider bailian \
  --config-dir ./agents/

8. New Account Reset

When a user provides keys from a new account with fresh quota:

node scripts/registry.js reset --provider bailian
node scripts/registry.js add-key --provider bailian --key sk-new-key --label "new-account"

CLI Reference

discover.js

node scripts/discover.js --provider <name> --key <api-key> [--base-url <url>]

registry.js

Subcommand Description
add-key Add API key and auto-discover models
status Show model availability statistics
mark-exhausted Mark a model as quota exhausted
next-model Get next available model of a given type
reset Reset all exhausted models to available
blacklist-add Add a model to the blacklist
blacklist-remove Remove a model from the blacklist

sync-config.js

# Gateway format
node scripts/sync-config.js --format gateway --provider bailian --config ./gateway.json

# Agent format
node scripts/sync-config.js --format agent --provider bailian --config ./openclaw.json

health-check.js

node scripts/health-check.js [--registry <path>]

Returns JSON with status (healthy | warning | critical | no-registry), model counts by type, and recently exhausted models.

Using as an OpenClaw Skill

Clone this repo into your OpenClaw skills directory. The agent reads SKILL.md and automatically gains:

  1. First-run setup - detects missing registry, asks user for API key
  2. 403/quota error handling - marks model exhausted, switches to next, syncs config, retries
  3. Proactive health checks - monitors quota status, alerts user when running low
  4. Key management - adds new keys, resets exhaustion on new accounts

The skill is platform-agnostic: it does not prescribe any notification channel. Each agent decides how to communicate with its user based on available tools.

Architecture

openclaw-provider-manager/
├── SKILL.md                    # OpenClaw Skill definition (agent decision tree)
├── package.json
├── lib/
│   ├── providers.js            # Provider presets + model type classification
│   ├── file-lock.js            # File locking (concurrent-safe writes)
│   └── utils.js                # JSON I/O, atomic writes, backup
├── scripts/
│   ├── discover.js             # Model auto-discovery
│   ├── registry.js             # Shared registry management
│   ├── sync-config.js          # Config file synchronization
│   ├── health-check.js         # Health status (JSON output)
│   ├── setup.js                # Interactive first-time setup
│   └── proxy-server.js         # Local proxy with auto-switch
└── references/
    ├── blacklist.json          # Models with no free quota
    └── providers.md            # Provider endpoint reference

Multi-Agent Setup

All agents share one registry file. Set the path via:

  • Environment variable: PROVIDER_REGISTRY_PATH=/shared/.provider-registry.json
  • CLI flag: --registry /shared/.provider-registry.json

When one agent marks a model exhausted, all other agents see it immediately. File-locking ensures safe concurrent writes.

Contributing

Issues and PRs welcome! This project is in early stage - feedback on real-world usage is especially valuable.

License

MIT

About

OpenClaw Skill: AI模型供应商管理器 - 自动发现模型、追踪额度、多Agent共享状态、额度用完自动切换

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages