mcpField
O
omni-usage-logs

omni-usage-logs

github.com/cheaper-inference数据与数据库82.3k1.1k 次安装今天更新
代码仓库

关于 omni-usage-logs

omni-usage-logs 提供经过身份验证的 OmniRoute API,用于查询调用日志、使用分析及相关指标。运维人员可据此检查请求、筛选记录、跟踪用量,或分析延迟和缓存健康状况。

主要功能

  1. 01浏览并筛选调用日志
  2. 02查看用量分析与历史
  3. 03跟踪预算和 Token 限额
  4. 04查看延迟与缓存指标
  5. 05检查服务提供方和模型用量

适用场景

  1. 01按服务提供方、模型或状态排查调用
  2. 02跟踪用量和预算消耗
  3. 03比较不同服务提供方和模型的延迟
  4. 04检查提示词缓存健康状况

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/cheaper-inference/omniroute --skill omni-usage-logs

安装后在 Claude Code 中输入/omni-usage-logs确认已加载。

详细介绍

概述

查看详细的调用日志和用量分析。按提供商、模型、时间范围、状态和费用筛选。导出日志,并汇总所有连接的令牌用量。

身份验证

所有请求都需要有效的 Bearer 令牌或会话 Cookie。通过 POST /api/auth/login 获取令牌,或在本地开发时配置 REQUIRE_API_KEY=false。

端点

GET /api/usage/analytics

获取用量分析

curl http://localhost:20128/api/usage/analytics \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/call-logs

获取调用日志

curl http://localhost:20128/api/usage/call-logs \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/call-logs/filters

获取调用日志筛选选项

列出调用日志中出现过的不同提供商、模型、账户和 API 密钥,以及所有已配置的 API 密钥(仅包含 id 和名称)。为日志选项卡中的筛选下拉菜单提供数据。

curl http://localhost:20128/api/usage/call-logs/filters \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/call-logs/{id}

获取指定调用日志

curl http://localhost:20128/api/usage/call-logs/{id} \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/{connectionId}

获取指定连接的用量

curl http://localhost:20128/api/usage/{connectionId} \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/history

获取用量历史记录

curl http://localhost:20128/api/usage/history \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/logs

获取用量日志

curl http://localhost:20128/api/usage/logs \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/proxy-logs

获取代理日志

curl http://localhost:20128/api/usage/proxy-logs \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/request-logs

获取请求日志

curl http://localhost:20128/api/usage/request-logs \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/budget

获取用量预算状态

返回当前预算上限和消耗情况。

curl http://localhost:20128/api/usage/budget \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
POST /api/usage/budget

配置用量预算

设置或更新用量跟踪的预算上限。

curl -X POST http://localhost:20128/api/usage/budget \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
GET /api/usage/cache-health

获取提示词缓存健康状况摘要

汇总指定时间范围内 call_logs 的 write/read 缓存比率: 分布情况(缓存写入令牌数的 p50/p90/p99/最大值)、缓存命中/未命中/重写/未缓存的调用次数、“高写入量”异常值占比(超过时间范围中位数的 10 倍,且不低于 1024 个令牌——这是 Anthropic 创建缓存的最低要求),以及按模型划分的明细。 仅统计成功(status = 200)且缓存列非空的调用。

curl http://localhost:20128/api/usage/cache-health \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/model-latency-stats

获取按模型/提供商划分的延迟统计数据

在滚动时间范围内,将 usage_history 行汇总为按(提供商、模型)划分的延迟统计数据(平均值/p50/p95/p99、标准差、TTFT、令牌数/秒)。当成功样本数低于 minSamples 时,将统计范围从仅成功样本扩展到所有样本。

curl http://localhost:20128/api/usage/model-latency-stats \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/budget/bulk

GET 用量 › 预算 › 批量

curl http://localhost:20128/api/usage/budget/bulk \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/codex-reset-credit

GET 用量 › codex 重置额度

curl http://localhost:20128/api/usage/codex-reset-credit \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
POST /api/usage/codex-reset-credit

POST 用量 › codex 重置额度

curl -X POST http://localhost:20128/api/usage/codex-reset-credit \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
GET /api/usage/combo-forecast

GET 用量 › 组合预测

curl http://localhost:20128/api/usage/combo-forecast \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/combo-health

GET 用量 › 组合健康状况

curl http://localhost:20128/api/usage/combo-health \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/combo-health-autopilot

GET 用量 › 组合健康状况自动驾驶

curl http://localhost:20128/api/usage/combo-health-autopilot \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/combo-health-dashboard

GET 用量 › 组合健康状况仪表板

curl http://localhost:20128/api/usage/combo-health-dashboard \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/combo-scoring-inspector

GET 用量 › 组合评分检查器

curl http://localhost:20128/api/usage/combo-scoring-inspector \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/combo-trace/{id}

GET 用量 › 组合跟踪 ›

curl http://localhost:20128/api/usage/combo-trace/{id} \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/om-usage

GET 用量 › om 用量

curl http://localhost:20128/api/usage/om-usage \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/provider-limits

GET 用量 › 提供商限制

curl http://localhost:20128/api/usage/provider-limits \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
POST /api/usage/provider-limits

POST 用量 › 提供商限制

curl -X POST http://localhost:20128/api/usage/provider-limits \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
GET /api/usage/provider-window-costs

GET 用量 › 提供商时间窗口费用

curl http://localhost:20128/api/usage/provider-window-costs \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/quota

GET 用量 › 配额

curl http://localhost:20128/api/usage/quota \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/requests-by-provider-date

GET 用量 › 按提供商和日期统计请求

curl http://localhost:20128/api/usage/requests-by-provider-date \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/route-explain/{id}

GET 用量 › 路由说明 ›

curl http://localhost:20128/api/usage/route-explain/{id} \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/token-limits

GET 用量 › 令牌限制

curl http://localhost:20128/api/usage/token-limits \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
POST /api/usage/token-limits

POST 用量 › 令牌限制

保存每个密钥的令牌限制。每个密钥在每个范围和重置间隔下可设置一个限制,因此同一范围的每日、每周和每月限制可以共存。不带 id 时,将添加新限制(或更新该密钥在相同范围和间隔下的限制);带 id 时,将更新该限制。

curl -X POST http://localhost:20128/api/usage/token-limits \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
DELETE /api/usage/token-limits

DELETE 用量 › 令牌限制

curl -X DELETE http://localhost:20128/api/usage/token-limits \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"
GET /api/usage/utilization

GET 用量 › 使用率

curl http://localhost:20128/api/usage/utilization \
  -H "Authorization: Bearer $OMNIROUTE_TOKEN"

负载

有关详细的请求/响应架构,请参阅 GET /api/openapi/spec 或 docs/openapi.yaml 中的完整 OpenAPI 规范。

评论

支持 Markdown