Skip to main content

Query claude-relay-service usage and limits using your local Codex config

Project description

crs-usage

PyPI version Python License: MIT

通过本地 Codex 配置查询 claude-relay-service 用量、限制和剩余额度的 CLI。零依赖,单文件实现。

~/.codex/config.toml[model_providers.*],按 provider 的 env_key~/.codex/auth.json 解析 API key,调用 {base_origin}/apiStats/api/user-stats 拉取使用量。

快速开始

最简单的方式(无需安装):

uvx crs-usage

或直接从 GitHub 跑:

uvx --from git+https://github.com/kadaliao/crs-usage crs-usage

也可以装到本地工具集:

uv tool install crs-usage
crs-usage

用法

crs-usage [--provider NAME] [--key KEY] [--base-url URL]
          [--config PATH] [--auth PATH] [--json] [--timeout SEC]

常用参数:

  • --provider <name> 只查指定 provider
  • --key <key> --base-url <url> 跳过 codex 解析,直接查任意 CRS 实例
  • --json 输出原始 JSON(适合 jq
  • --timeout <sec> HTTP 超时,默认 15

Key 解析优先级

  1. --key 命令行参数
  2. [model_providers.<name>].env_key 指定的环境变量(如 CRS_OAI_KEY
  3. ~/.codex/auth.json 中的 OPENAI_API_KEY

输出示例

■ aihezu  (https://cc.aihezu.dev)  key from env:CRS_OAI_KEY
  Key: my-key  id=07825a09-...  active=true  expires=never
  Usage (total):
    Requests : 72,642
    Tokens   : 5,548,253,083  (in 436,025,255 / out 29,521,295 / cache_create 64,869,062 / cache_read 5,017,837,471)
    Cost     : $2961.17
  Limits:
    Daily Cost : $19.7727 / $100.0000  (19.8%)
    Total Cost : unlimited
    Rate Window: 13/100 req, 234,567/1,000,000 tok, $0.4500/$10.0000  window=60m  剩余 12m34s

要求

  • Python ≥ 3.11(依赖 stdlib tomllib,零第三方依赖)
  • 一个本地 ~/.codex/config.toml 配置(或通过 --key --base-url 直接指定)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crs_usage-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crs_usage-0.1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file crs_usage-0.1.0.tar.gz.

File metadata

  • Download URL: crs_usage-0.1.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for crs_usage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fd0a9fe182ef477c05c5cb4c3116b93e4f9982f8a2306584d92816b3492db3f9
MD5 c93a2939169bebd96122e45a32942423
BLAKE2b-256 e233fd3be516935eaf6ab05d1d30830663e5d2f8fbab78925971dad8625d6900

See more details on using hashes here.

Provenance

The following attestation bundles were made for crs_usage-0.1.0.tar.gz:

Publisher: release.yml on kadaliao/crs-usage

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crs_usage-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: crs_usage-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for crs_usage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a81cbbd3c81e5be163f81a46bd5851284a29c4f526d75964c40cdb287ed40597
MD5 40f704ddd3a135b746a7a0038fb68e5c
BLAKE2b-256 811cc4dbbc580942b4f3a54dc9017c98a73ab424cd03c5b0b6aa6ffa7a5b6af0

See more details on using hashes here.

Provenance

The following attestation bundles were made for crs_usage-0.1.0-py3-none-any.whl:

Publisher: release.yml on kadaliao/crs-usage

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page