OpenRouter Usage Monitor
What this skill does
Retrieves OpenRouter usage and cost data via:
- - Live totals (Today / Week / Month) from INLINECODE0
- Historical per-model breakdown from
/activity (completed UTC days only)
How to run (recommended)
Set environment variables (recommended) or create a
credentials.env file:
CODEBLOCK0
Then execute: INLINECODE3
Alternatively, create credentials.env in the skill directory:
OPENROUTER_API_KEY=your_key_here
OPENROUTER_MGMT_KEY=your_mgmt_key_here
Fallback method (no Python)
If Python is unavailable, query endpoints directly:
Live totals
curl -sS -H "Authorization: Bearer $OPENROUTERAPIKEY"
https://openrouter.ai/api/v1/auth/key
Per-model activity (7d)
curl -sS -H "Authorization: Bearer $OPENROUTERMGMTKEY"
https://openrouter.ai/api/v1/activity
Configuration
Required:
- -
OPENROUTER_API_KEY - Required for real-time usage totals and balance
Optional:
- -
OPENROUTER_MGMT_KEY - Enables per-model spend breakdown from activity endpoint
Credentials can be provided via:
- 1. Environment variables (recommended for security)
- INLINECODE7 file in skill directory (fallback)
Output format
💰 OpenRouter Usage
Today: $X.XX* | Week: $X.XX | Month: $X.XX
Balance: $X.XX / $X.XX
Recent Models (7d):
• model-name: $X.XX (N)
...
* indicates live totals that may not yet appear in model breakdowns.
Edge cases
- -
/activity only returns completed UTC days. - Today’s spend may appear in totals but not per-model data until next UTC rollover.
- Invalid keys → 401/403.
- Rate limiting → 429.
- Network failures should be retried or surfaced.
OpenRouter 使用监控器
功能说明
通过以下方式获取 OpenRouter 使用量和费用数据:
- - 实时总计(今日/本周/本月) 来自 /auth/key
- 历史按模型细分 来自 /activity(仅限已完成的 UTC 日期)
运行方式(推荐)
设置环境变量(推荐)或创建 credentials.env 文件:
bash
export OPENROUTERAPIKEY=yourkeyhere
export OPENROUTERMGMTKEY=yourmgmtkey_here # 可选,启用模型细分
然后执行:python3 scripts/stats.py
或者,在技能目录中创建 credentials.env:
OPENROUTERAPIKEY=yourkeyhere
OPENROUTERMGMTKEY=yourmgmtkey_here
备用方法(无需 Python)
如果 Python 不可用,可直接查询端点:
实时总计
curl -sS -H Authorization: Bearer $OPENROUTERAPIKEY
https://openrouter.ai/api/v1/auth/key
按模型活动(7天)
curl -sS -H Authorization: Bearer $OPENROUTERMGMTKEY
https://openrouter.ai/api/v1/activity
配置
必需:
- - OPENROUTERAPIKEY - 用于实时使用量总计和余额
可选:
- - OPENROUTERMGMTKEY - 启用来自活动端点的按模型费用细分
凭据可通过以下方式提供:
- 1. 环境变量(推荐,更安全)
- 技能目录中的 credentials.env 文件(备用)
输出格式
💰 OpenRouter 使用量
今日:$X.XX* | 本周:$X.XX | 本月:$X.XX
余额:$X.XX / $X.XX
近期模型(7天):
• 模型名称:$X.XX(N)
...
边界情况
- - /activity 仅返回已完成的 UTC 日期。
- 今日支出可能出现在总计中,但直到下一个 UTC 日期切换才会出现在按模型数据中。
- 无效密钥 → 401/403。
- 速率限制 → 429。
- 网络故障应重试或上报。