omp packages

pi-usage-limits0.1.4

[![npm](https://img.shields.io/npm/v/pi-usage-limits)](https://www.npmjs.com/package/pi-usage-limits)

ailinykh Published 5 days ago MIT ~544 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-usage-limits

npm

A pi extension that shows your Claude and Codex subscription limits in pi's status line and updates them after every prompt.

5h: 12%, 7d: 25%

Why use it

  • Works with Claude through the Claude Agent SDK. It reads limits with your existing Claude Code login, so it works when pi runs Claude models through the SDK, including pi-claude-bridge. You don't need a separate Anthropic login or API key in pi.
  • Codex support, no CLI needed. Reads 5-hour and weekly Codex limits over HTTPS with pi's own openai-codex login. pi refreshes the token; ~/.codex/auth.json is never read or touched.
  • Never slows pi down. Usage is fetched in the background, and pi doesn't wait for it.
  • Updates after each prompt. It refreshes when a session starts, when you switch models, and once each prompt finishes, instead of on every turn or tool call.
  • Fewer calls with several sessions. Results are cached on disk for 60 seconds, and the cache is shared between all running pi sessions. A cached value is marked with 󰃨.
  • Doesn't replace your footer. It adds one status entry, so pi's built-in footer and other extensions keep working.
  • No tokens used. Reading limits sends no prompt and doesn't touch your quota.
  • Clear errors. If a lookup fails, the status line shows the reason in red, such as the Claude CLI's own error.
  • Small and readable. A few hundred lines of plain TypeScript, with no build step.

Supported models

Active model Source Shows
Model id contains claude Claude Agent SDK (Claude Code login) 5-hour and 7-day utilization
openai or openai-codex provider, or model id contains codex ChatGPT usage endpoint (pi's openai-codex login) 5-hour and weekly usage

OpenAI models such as (openai) gpt-6.1-sol show the same ChatGPT subscription limits using your openai-codex login, not OpenAI API limits.

Other models show <model> not supported yet.

Requirements

  • pi
  • For Claude: @anthropic-ai/claude-agent-sdk installed alongside pi (for example as a pi-claude-bridge dependency), signed in to a Claude subscription. API-key logins have no subscription limits to show.
  • For Codex: signed in to pi's openai-codex provider (/login in pi) with a ChatGPT subscription.

Install

pi install npm:pi-usage-limits

Try it for a single session without installing:

pi -e npm:pi-usage-limits

How it works

Event Action
session_start Show current usage
model_select Show usage for the new model
agent_settled Refresh after a prompt completes

The cache lives at ~/.pi/agent/cache/pi-usage-limits.json. Writes are atomic and protected by a lockfile, so parallel sessions don't corrupt it.

Caveats

  • Claude limits come from an experimental Claude Agent SDK API, which may change in a future SDK release.
  • Codex limits come from an undocumented ChatGPT endpoint (chatgpt.com/backend-api/wham/usage, the same one the Codex CLI uses), which may change without notice.
  • Each uncached Claude lookup starts a short-lived claude process, which takes about a second. It runs in the background.

License

MIT