Skip to main content

Artificial Intelligence Usage

artificial-intelligence-usage analyzes local Codex session rollouts and prints a summary of the latest session followed by daily and per-session prompt, token, and rate-limit usage.

Behavior

  • Reads rollout files below ~/.codex/sessions.
  • Shows the installed Codex and Claude CLI versions when those commands are available, followed by the latest versions published under their official npm packages. Latest-version checks require network access and display UNKNOWN when a lookup fails.
  • Shows status details from the most recently modified session.
  • Reports sessions from the last 14 calendar days by default, including today.
  • Counts user turns and cumulative tokens for each session.
  • Breaks applied prompts down into Normal, Plan, and Goal counts. Goal counts include automatic goal continuations, while background tasks such as guardian reviews are excluded.
  • Shows a second table with one row per session, including its start time, finish time, session name (up to 10 characters), first-prompt preview (up to 20 characters), model, GitHub repository, usage, and language. When a session records multiple models, the table shows the first one. A session is finished when its final rollout event is task_complete; otherwise its finish value is In progress.
  • Reads session names from ~/.codex/session_index.jsonl. Missing names and prompts display as Unknown.
  • For goal-only sessions, reads the goal objective from ~/.codex/goals_1.sqlite for the prompt preview and reports its language as Unknown.
  • Uses langid, restricted to English and Spanish, for prompt language detection. Sessions without a detectable user prompt show Unknown.
  • Shows the remaining five-hour and weekly allowance recorded in each day's last session.
  • Ignores malformed JSON lines and incomplete status events.

The tool only reads local session files and does not modify them.

Requirements

  • Python 3.10 or newer
  • langid 1.1.6 (installed automatically with the package)

Building

Testing

Run the unit tests from the project root:

python3 -m unittest discover -s tests -v

Package artifact

Build and validate the package artifacts:

./build-package.sh

This creates the wheel and source distribution under dist/ and checks the package metadata with Twine.

Publish artifact

Publish the generated artifacts to PyPI:

./publish-pypi.sh

The publish script checks that Twine is available, creates a local .venv for Twine when needed, verifies that dist/ contains generated artifacts, and then uploads them. If PyPI rejects a version that was already published, increment the version in pyproject.toml, rebuild, and publish again.

Install artifact

Install the package in a virtual environment:

python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install artificial-intelligence-usage

Usage

After installation, run:

artificial-intelligence-usage

Choose a different reporting window with --days:

artificial-intelligence-usage --days 30

From a source checkout, ./artificial-intelligence-usage.py is the canonical launcher and ./script-sessions.py remains available for compatibility.

Help

usage: artificial-intelligence-usage [-h] [--days DAYS]

Analyze recent Codex sessions.

options:
  -h, --help   show this help message and exit
  --days DAYS  number of calendar days to analyze, including today (default: 14)

Metadata

Release files for artificial-intelligence-usage 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for artificial-intelligence-usage 0.0.9
File Size Uploaded Provenance Actions
artificial_intelligence_usage-0.0.9.tar.gz 15.3 kB Without provenance Details for artificial_intelligence_usage-0.0.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for artificial-intelligence-usage 0.0.9
File Interpreter ABI Platform Actions
artificial_intelligence_usage-0.0.9-py3-none-any.whl Python 3 none any Details for artificial_intelligence_usage-0.0.9-py3-none-any.whl

Total release size: 25.8 kB

Release files / artificial_intelligence_usage-0.0.9.tar.gz

Download URL artificial_intelligence_usage-0.0.9.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2960e6b43489a083350234f2b4db3e283c8a88af25b13a681376f5f909920347
BLAKE2b-256 checksum
How to use checksums
c2d5823054ad7b652ac3c41b8a1986da2e865ab80abe65fffb22643b52c2d029
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / artificial_intelligence_usage-0.0.9-py3-none-any.whl

Download URL artificial_intelligence_usage-0.0.9-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a0066714eb3aac0f510ad4294f757e453af80a8ad269e269be1c95f646963f4
BLAKE2b-256 checksum
How to use checksums
113fc49943de1ad0860be158b1d7c27f6acb045a8b8d612d62e62ddfa599b792
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for artificial-intelligence-usage 0.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page