omp packages

pi-auto-models0.1.14

Auto-switch pi between a primary and fallback model based on quota, with /usage and /auto-model commands.

GitHub Actions Published 28 days ago MIT ~563 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-auto-models

A pi extension that automatically switches between a primary and a fallback model based on quota. When your primary provider (Claude by default) is rate-limited, it transparently falls back (Codex by default) and switches back once quota recovers.

Features

  • Auto-switch on quota — on each session start it uses the primary model if quota is available, otherwise the fallback. Passing --model keeps the explicitly selected model and disables automatic switching for that run.
  • 429/529 recovery — detects rate-limit responses, caches the cooldown, and switches to the fallback mid-session.
  • Passive quota tracking — reads rate-limit headers from provider responses (no extra requests for Claude); Codex quota is fetched live.
  • Subscription usage in the status bar — footer follows the active model's provider and shows its 5h usage when available (5h 42%), otherwise its weekly usage (Weekly 42%). API-key accounts show ∞ (API key).
  • /usage — shows each provider's quota windows (Codex windows are labelled by their actual duration, so it adapts if OpenAI drops the 5h window).
  • /auto-model — interactive TUI to configure the primary/fallback model and thinking level.

Install

pi install npm:pi-auto-models

Or install from git:

pi install git:github.com/Fatpandac/pi-auto-models

Try it for one run without installing:

pi -e npm:pi-auto-models

Commands

Command Description
/usage Show Claude / Codex quota usage
/auto-model Configure primary and fallback models (model + thinking level)

Configuration

/auto-model writes your choices to ~/.pi/agent/auto-model.json:

{
  "primary":  { "provider": "anthropic",   "model": "claude-opus-4-6", "thinking": "high" },
  "fallback": { "provider": "openai-codex", "model": "gpt-5.5",        "thinking": "high" }
}

Defaults (used when the file is absent):

Slot Provider Model Thinking
Primary anthropic claude-opus-4-6 high
Fallback openai-codex gpt-5.5 high

Thinking levels: off, minimal, low, medium, high, xhigh.

How it works

State is persisted under ~/.pi/agent/:

  • auto-model.json — your primary/fallback configuration
  • claude-quota-cache.json — per-provider rate-limit cooldown expiry
  • auto-model-rate-limits.json — last captured rate-limit snapshot per provider

Auth is read from pi's existing auth.json; the extension does not store credentials.