← Catalog

pi-openai-usage

Focused Pi extension package for showing OpenAI Codex subscription usage in the status line.

Extension

Install

Install with PiG

pig install npm:pi-openai-usage

Install with Pi

pi install npm:pi-openai-usage
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.4 (README.md). PiG does not review it.

pi-openai-usage

Shows your remaining OpenAI Codex subscription usage in Pi.

Usage: 5h ████████░░ 88% | 7d ███████░░░ 73% | 5h ↺ 42m | 7d ↺ 2d4h

Prerequisites

  • Pi CLI.
  • An OpenAI subscription.

Install

pi install npm:pi-openai-usage

Login

This extension uses Pi's existing OpenAI Codex login. If you have not logged in yet, run:

/login openai-codex

Command

/openai-usage-settings is the command for OpenAI usage and settings.

Run it with no arguments in Pi's interactive UI to open the settings menu. In non-UI runs, it shows a read-only fallback with the available utility subcommands.

/openai-usage-settings
/openai-usage-settings usage
/openai-usage-settings refresh
/openai-usage-settings diagnostics
/openai-usage-settings help

Utility subcommands

Use utility subcommands when you want a direct status check, refresh, diagnostics, or help:

SubcommandWhat it does
usageShow cached usage, refreshing first if the cache is missing or stale.
refreshForce a usage refresh and show the updated usage status.
diagnosticsShow setup, auth, config-path, timestamp, and last-error diagnostics without printing tokens.
helpShow command help for the one-command workflow.

Example form: /openai-usage-settings usage.

Interactive settings menu

Running /openai-usage-settings with no arguments opens a ten-row menu for common settings:

RowVisible values
DisplayOn, Off, Always
Color schemetraffic, cyan, green, mono, none
Bar styleblocks, thin, ascii, dots, squares, braille
Bar width4, 6, 8, 10, 12, 16, 20
5h displayhidden, percent, bar, bar + percent
7d displayhidden, percent, bar, bar + percent
5h reset displayhidden, countdown, clock, both
7d reset displayhidden, countdown, clock, both
Refresh interval15s, 30s, 1m, 2m, 5m, 10m
Hide labelNo, Yes

Display controls whether the status line is shown normally, hidden, or always shown. Normal display appears for OAuth-backed openai and openai-codex models; Always shows usage regardless of the selected model. Hide label controls the Usage: prefix. If a JSON config uses a custom color scheme or custom bar style, the menu may show custom (JSON) as the current value; selecting a preset replaces it with that preset.

Configuration files

Configuration is read from:

  1. Project config: .pi/extensions/pi-openai-usage.json
  2. Global config: ~/.pi/agent/extensions/pi-openai-usage.json

Project config overrides global config.

The interactive menu writes to the project config only when .pi/extensions/pi-openai-usage.json already exists. Otherwise, menu changes are written to the global config. Create the project config file first if you want menu changes to stay project-local.

Use the interactive menu for common display settings. Advanced visual customization is JSON-file-only: edit the project or global config file for custom label text, widget labels, separators, partial bars, custom bar glyphs, custom color stops or targets, and bar-gradient controls. Slash-command setting writes are not supported.

JSON configuration reference

Top-level settings

KeyTypeDefaultAccepted values / notes
enabledbooleantrueEnables or hides the status-line entry.
refreshIntervalMsnumber6000015000, 30000, 60000, 120000, 300000, 600000.
displayobjectsee belowStatus-line label and visibility presentation.
widgetsobjectsee belowUsage and reset widgets.
barobjectsee belowProgress-bar style and width.
colorsobjectsee belowColor scheme, target, gradients, and custom stops.

display

KeyTypeDefaultAccepted values / notes
display.showAlwaysbooleanfalsetrue shows usage even when the selected model is not an OAuth-backed OpenAI/Codex model.
display.showLabelbooleantrueControls the label prefix.
display.labelstring"Usage"Non-empty string.
display.separatorstring`""`

widgets

KeyTypeDefaultAccepted values / notes
widgets.fiveHour.enabledbooleantrueShows or hides the 5h usage widget.
widgets.fiveHour.labelstring"5h"Non-empty string.
widgets.fiveHour.modestring"bar-percent"percent, bar, bar-percent, hidden.
widgets.sevenDay.enabledbooleantrueShows or hides the 7d usage widget.
widgets.sevenDay.labelstring"7d"Non-empty string.
widgets.sevenDay.modestring"bar-percent"percent, bar, bar-percent, hidden.
widgets.fiveHourReset.enabledbooleantrueShows or hides the 5h reset widget.
widgets.fiveHourReset.labelstring"5h ↺"Non-empty string.
widgets.fiveHourReset.modestring"countdown"countdown, clock, both, hidden.
widgets.sevenDayReset.enabledbooleantrueShows or hides the 7d reset widget.
widgets.sevenDayReset.labelstring"7d ↺"Non-empty string.
widgets.sevenDayReset.modestring"countdown"countdown, clock, both, hidden.

bar

KeyTypeDefaultAccepted values / notes
bar.stylestring"blocks"blocks, thin, ascii, dots, squares, braille, custom.
bar.widthnumber104, 6, 8, 10, 12, 16, 20.
bar.partialsbooleantrueUses partial glyphs when the selected style supports them.
bar.custom.filledstring"▰"Filled glyph used when bar.style is custom.
bar.custom.emptystring"▱"Empty glyph used when bar.style is custom.
bar.custom.partialsstring[][]Optional partial glyphs used when bar.style is custom and bar.partials is true.

colors

KeyTypeDefaultAccepted values / notes
colors.schemestring"traffic"traffic, cyan, green, mono, none, custom.
colors.targetstring"value"value, widget, bar, percent, none.
colors.barGradient.enabledbooleanfalseColors filled bar cells across the selected color scale.
colors.barGradient.directionstring"low-to-high"low-to-high, high-to-low.
colors.custom.modestring"step"step, gradient.
colors.custom.stopsarraysee belowArray of color stops sorted by percent.

Default colors.custom.stops (matching the built-in traffic scheme):

percentcolorlabel
80#22c55egreen
60#84cc16lime
40#eab308yellow
20#f97316orange
0#ef4444red

Each custom color stop has this shape:

KeyTypeAccepted values / notes
percentnumberClamped to 0 through 100.
colorstring or numberPi theme token (success, warning, error, muted, dim, text, accent) for step mode, #RRGGBB, or xterm color number 0 through 255. Gradient mode supports interpolating #RRGGBB and xterm colors.
labelstringOptional label for your own reference.

Display customization

The default display uses progress bars and percentages:

Usage: 5h ████████░░ 88% | 7d ███████░░░ 73% | 5h ↺ 42m | 7d ↺ 2d4h

To simplify it in the interactive menu, set:

  • Hide label: Yes
  • 5h display: percent
  • 7d display: percent
  • 5h reset display: hidden
  • 7d reset display: hidden

Result:

5h: 88% | 7d: 73%

To use the neutral footer text colour instead of usage-coloured values, set Color scheme to none.

Privacy and auth

The extension uses Pi's existing openai-codex OAuth credentials to request Codex usage from ChatGPT's usage endpoint. Diagnostics are designed for troubleshooting and do not print access tokens.

Reference attribution

Inspired by pi-better-openai.