← 返回 Skills 市场
bjmfjoy

Bailian Usage Proxy

作者 bjmfjoy · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
103
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install bailian-usage-proxy
功能描述
阿里百炼大模型平台的多人共享账号用量统计代理服务。用于解决公司共用阿里百炼账号时无法区分个人用量的问题。当用户需要:1) 部署阿里百炼用量统计代理,2) 统计多人Token用量和调用次数,3) 管理大模型API调用配额时激活此技能。
使用说明 (SKILL.md)

阿里百炼用量统计代理

为阿里百炼(阿里云大模型服务平台)提供多人共享账号场景下的精细化用量统计方案。

核心能力

  • API代理转发:兼容 OpenAI 格式,透明转发到阿里百炼
  • 用量实时统计:按用户、模型、时间维度记录 Token 消耗
  • 配额管理:支持日限额、限流控制
  • 管理后台:用量查询、报表导出

使用场景

  1. 公司统一申请阿里百炼账号,需要统计每个员工的用量
  2. 需要按项目/部门分摊大模型调用成本
  3. 需要限制单个用户的日调用配额

快速部署

1. 环境准备

# 克隆或复制本项目
cd bailian-proxy

# 安装依赖
pip install -r requirements.txt

# 配置环境变量
cp .env.example .env
# 编辑 .env 填入阿里百炼主账号 Key 和数据库配置

2. 数据库初始化

python scripts/init_db.py

3. 启动服务

# 开发模式
python -m app.main

# 生产模式(Docker)
docker-compose up -d

4. 创建用户

python scripts/create_user.py --name "张三" --department "算法部" --daily-limit 1000000

客户端使用

同事只需修改两处配置:

# 原配置
base_url = "https://dashscope.aliyuncs.com/compatible-mode/v1"
api_key = "sk-xxx"  # 阿里百炼的key

# 新配置
base_url = "http://your-proxy-server:8080/v1"
api_key = "internal-key-xxx"  # 代理系统分配的key

查看用量

命令行

# 今日用量
python scripts/usage_report.py --today

# 指定用户
python scripts/usage_report.py --user-key xxx --start 2026-03-01 --end 2026-03-08

# 导出CSV
python scripts/usage_report.py --export usage.csv

管理后台

访问 http://proxy-server:8081 查看:

  • 实时用量仪表盘
  • 用户用量排行
  • 模型调用分布
  • 历史趋势图表

技术架构

详见 references/architecture.md

API 文档

详见 references/api.md

数据库结构

详见 references/database.md

安全使用建议
Before installing, consider the following: (1) The code expects a Bailian/Alibaba master API key (BAILIAN_API_KEY or similar) and database credentials even though the registry metadata doesn't list required env vars — supply these carefully and only to an isolated instance. (2) Change SECRET_KEY from the default and secure the DB and log directories; logs and the start scripts can print or store API keys. (3) The start scripts may create a default admin user and print its API key — rotate/delete that key or set your own admin key after install. (4) There are inconsistent env var names in provided docker-compose assets (BAILIAN_MASTER_KEY vs BAILIAN_API_KEY); confirm which you use to avoid accidental disclosure. (5) Run the service in a network-isolated environment (or behind a firewall) and review the code yourself or with a trusted engineer before handing production credentials to it. If you need higher assurance, ask the author for provenance (source repo/homepage) or run it in a sandboxed environment first.
能力评估
Purpose & Capability
The name/description (a proxy that forwards OpenAI-format requests to the Bailian/Alibaba large-model endpoint and tracks per-user token usage) matches the included code (proxy, DB, admin UI, scripts). However the registry metadata says 'required env vars: none' while the code expects secrets like BAILIAN_API_KEY, DATABASE_URL, SECRET_KEY, etc. This mismatch is unexpected and worth flagging.
Instruction Scope
SKILL.md and start scripts instruct the agent/administrator to place a master Bailian API key in .env and run startup scripts. The runtime instructions remain within the proxy's purpose (init DB, start service, create users, generate usage reports). But startup scripts create a default admin user (and print its API key to stdout) and write data/log files under ./data and ./logs — these behaviors can expose credentials if not handled carefully.
Install Mechanism
No remote binary downloads or obscure installers are used — installation is standard Python package installation (pip) and optional Docker compose. This is a lower-risk install mechanism. There are no download-from-arbitrary-URL steps in the files provided.
Credentials
The skill actually requires sensitive environment variables (BAILIAN_API_KEY or BAILIAN_MASTER_KEY in assets, DATABASE_URL, SECRET_KEY, optional REDIS_URL) even though the registry lists none. The presence of a default weak SECRET_KEY ('change-me-in-production') and scripts that will create and print an admin API key increase exposure risk. Also there is an inconsistency in env var names across assets (assets/docker-compose.yml references BAILIAN_MASTER_KEY while docker-compose.yml and config.py use BAILIAN_API_KEY), which could cause secrets to be misconfigured or accidentally leaked.
Persistence & Privilege
The skill is not set to always:true and does not attempt to modify other skills. It does persist data (SQLite/MySQL files, logs) and may auto-create an admin user when started. Those are normal for a service, but creating and printing an admin API key by default is a privilege that requires operational caution.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install bailian-usage-proxy
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /bailian-usage-proxy 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of bailian-usage-proxy. - Provides a proxy service for precise usage tracking when sharing an Alibaba Bailian (DashScope) account among multiple users. - Tracks token usage and call counts per user, model, and time period. - Supports daily quota management and rate limiting for individual users. - Includes a management dashboard for usage queries and report export. - Compatible with OpenAI-style API, requiring minimal client changes.
元数据
Slug bailian-usage-proxy
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Bailian Usage Proxy 是什么?

阿里百炼大模型平台的多人共享账号用量统计代理服务。用于解决公司共用阿里百炼账号时无法区分个人用量的问题。当用户需要:1) 部署阿里百炼用量统计代理,2) 统计多人Token用量和调用次数,3) 管理大模型API调用配额时激活此技能。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 103 次。

如何安装 Bailian Usage Proxy?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install bailian-usage-proxy」即可一键安装,无需额外配置。

Bailian Usage Proxy 是免费的吗?

是的,Bailian Usage Proxy 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Bailian Usage Proxy 支持哪些平台?

Bailian Usage Proxy 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Bailian Usage Proxy?

由 bjmfjoy(@bjmfjoy)开发并维护,当前版本 v1.0.0。

💬 留言讨论