
Product
Socket for Asana Is Now Available
Create and manage Asana tasks directly from Socket alerts, with manual task creation, automated ticketing rules, and two-way sync.
codex-usage-analyzer
Advanced tools
Read the account usage shown by Codex through the official app-server protocol, from one small CLI.
codex-usage-analyzer starts a compatible Codex process from your installed CLI or macOS app, calls account/usage/read, and emits a stable, identity-free contract. It does not scan local sessions or directly read authentication files, tokens, keychains, prompts, or responses.
Documented upstream: This CLI uses OpenAI Codex's documented
account/usage/readapp-server method.
Maintained with support from OpenAI’s Codex for Open Source program.
Support is provided to the maintainer and does not imply endorsement.
npx codex-usage-analyzer@latest
Human-readable output:
Codex account usage
Lifetime tokens 1.23B
Peak daily tokens 45.6M
Longest turn 12m 34s
Current streak 3 days
Longest streak 21 days
Daily buckets 30 days
Captured at 2026-07-11T00:00:00.000Z
The values above are synthetic. Your command reads the usage available to the currently signed-in Codex account.
For machine-readable output:
npx codex-usage-analyzer@latest --json
{
"contractVersion": 1,
"capturedAt": "2026-07-11T00:00:00.000Z",
"summary": {
"lifetimeTokens": 1234567890,
"peakDailyTokens": 45600000,
"longestRunningTurnSec": 754,
"currentStreakDays": 3,
"longestStreakDays": 21
},
"dailyUsageBuckets": [
{
"startDate": "2026-07-10",
"tokens": 123456
}
]
}
null semantics.Lower is faster. This snapshot measured one warm environment on 2026-07-13 with one warm-up and five timed runs.
| Tool | Median | Relative time |
|---|---|---|
codex-usage-analyzer@0.2.0 | 1.145s | 1.0x |
ccusage@20.0.17 | 3.306s | 2.9x |
tokscale@4.4.1 | 19.723s | 17.2x |
This compares Codex usage lookup only, not whole products or every workflow they support. The data sources also differ: codex-usage-analyzer reads account-level usage through app-server, while the comparison commands scan retained local Codex session history. See the benchmark methodology, environment, command arrays, and limitations.
| Field | Meaning |
|---|---|
summary.lifetimeTokens | Lifetime token usage |
summary.peakDailyTokens | Highest token usage reported for one day |
summary.longestRunningTurnSec | Longest-running turn, in seconds |
summary.currentStreakDays | Current activity streak, in days |
summary.longestStreakDays | Longest activity streak, in days |
dailyUsageBuckets | Source-dated daily token buckets, when available |
Every summary field is present. A value of null means the upstream method did not provide that metric; it does not mean zero. Daily buckets can likewise be null, an empty array, or an array of dated values.
codex on PATH, or a compatible macOS ChatGPT app or Codex app installed in a standard Applications locationaccount/usage/readAPI-key-only and Bedrock authentication do not provide this account usage method. Sign in through Codex before running the analyzer. The package delegates authentication to the selected Codex CLI or app and never asks you to paste a token.
codex-usage-analyzer - Read your Codex account usage
Usage:
codex-usage-analyzer [usage] [--json]
codex-usage-analyzer [usage] --help
codex-usage-analyzer --version
| Command | Output |
|---|---|
codex-usage-analyzer | Human-readable account usage |
codex-usage-analyzer usage | Same human-readable output |
codex-usage-analyzer --json | Account Usage Contract JSON |
codex-usage-analyzer usage --json | Same JSON output |
codex-usage-analyzer --help | Help without starting app-server |
codex-usage-analyzer --version | Package version without starting app-server |
Successful output is written to stdout. Failures are written to stderr as a stable error code and a safe message, without raw RPC data or app-server stderr.
import {
ACCOUNT_USAGE_CONTRACT_VERSION,
CodexUsageError,
readAccountUsage
} from "codex-usage-analyzer";
try {
const usage = await readAccountUsage({ timeoutMs: 15_000 });
console.log(usage.contractVersion === ACCOUNT_USAGE_CONTRACT_VERSION);
} catch (error) {
if (error instanceof CodexUsageError) {
console.error(error.code);
}
}
The SDK returns the same document as CLI --json. See the Account Usage Contract and JSON Schema for field and compatibility rules.
codex executable available on PATH.app-server, without a shell.account/usage/read.The package has no direct credential reader and no private profile endpoint fallback. Authentication and service communication remain inside the selected Codex process.
Profile sites, README cards, and other services can accept the identity-free JSON contract and combine it with identity they manage separately. The Downstream Integration Guide defines recommended field names, ownership, submit-token, validation, rendering, caching, and deletion boundaries.
Do not add identity fields to the account usage document. A downstream service should resolve GitHub identity from its own authenticated account binding, not trust a display name or avatar submitted by this CLI.
The default CLI does not directly read or emit:
Treat account usage as private data even though the contract excludes identity. Review a downstream service's retention and visibility policy before submitting output anywhere.
For vulnerability reporting and supported versions, see SECURITY.md.
| Error code | What to check |
|---|---|
CODEX_NOT_FOUND | Install or update a Codex CLI on PATH, or install a compatible macOS ChatGPT or Codex app in a standard Applications location. |
APP_SERVER_START_FAILED or APP_SERVER_EXITED | Confirm the selected Codex CLI or app can start and that your environment permits child processes. |
APP_SERVER_TIMEOUT | Retry after checking connectivity; SDK callers can set timeoutMs up to 120000. |
APP_SERVER_RPC_ERROR | Update Codex and confirm a compatible ChatGPT-backed sign-in. |
APP_SERVER_PROTOCOL_ERROR or INVALID_ACCOUNT_USAGE_RESPONSE | Update both Codex and this package; the upstream response was not safe to normalize. |
The CLI intentionally suppresses raw upstream details. When reporting a bug, include the package version, Codex version, Node.js version, platform, command shape, and error code only.
npm test
npm pack --dry-run
Maintainers should use the repository's npm release guide for release operations; those steps are intentionally kept out of the user guide.
Read CONTRIBUTING.md before opening a pull request. Changes to the public contract need an issue and explicit consumer-impact review.
Use GitHub Issues for reproducible bugs and focused feature requests. Use GitHub's private vulnerability reporting path for security-sensitive reports.
Copyright (c) postmelee. Released under the MIT License.
This license covers only this repository's code and documentation. It does not grant rights to OpenAI services, Codex assets, user data, model outputs, trademarks, or third-party content.
This independent project is not affiliated with, endorsed by, or sponsored by OpenAI. OpenAI and Codex names and trademarks belong to their respective owners.
FAQs
Read Codex account usage through the official app-server protocol.
The npm package codex-usage-analyzer receives a total of 58 weekly downloads. As such, codex-usage-analyzer popularity was classified as not popular.
We found that codex-usage-analyzer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Product
Create and manage Asana tasks directly from Socket alerts, with manual task creation, automated ticketing rules, and two-way sync.

Security News
Open VSX has removed three extension IDs from its malicious-extension list as the legitimate publishers they impersonated move to claim the names for themselves.

Product
Socket’s PHP and Composer support is now in Beta for all customers, with PHP reachability analysis generally available.