@nicknisi/pi-fast

Toggle faster premium inference for supported Claude and Codex models

Packages

Package details

extension

Install @nicknisi/pi-fast from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@nicknisi/pi-fast
Package
@nicknisi/pi-fast
Version
0.3.2
Published
Oct 22, 2026
Downloads
223/mo · 196/wk
Author
nicknisi
License
MIT
Types
extension
Size
52.9 KB
Dependencies
1 dependency · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@nicknisi/pi-fast

Toggle the premium low-latency inference modes exposed by Anthropic and OpenAI without leaving Pi or maintaining provider-specific request patches. The extension adds /fast, injects the supported provider setting into outgoing requests, and shows a compact fast footer status only when the current model can actually use it.

Fast mode trades higher usage cost for faster output. It does not change the selected model, its intelligence, or its capabilities.

What it adds

  • Command: /fast — toggle Fast mode for the current Pi session.
  • Footer status: fast while Fast mode is enabled and the selected model is eligible, fast (cooldown) while a rate limit has dropped it to standard speed. Disable it with showStatus.
  • Provider request hooks:
    • Anthropic: adds speed: "fast" to Messages API payloads. For the research-preview models (Opus 5 and Opus 4.8) it also appends the fast-mode-2026-02-01 beta to the payload's betas, keeping every beta pi computed.
  • Rate-limit fallback: a Fast-mode 429/529 switches the session to standard speed for 60 seconds, so pi's automatic retry resends at standard speed.
    • OpenAI Codex: adds service_tier: "fast" to OAuth-backed Codex Responses payloads.
  • Subagents and workflows: children spawned by dispatch, workflow, and other @nicknisi/pi-shared runtime users follow this session's Fast mode live and share its rate-limit cooldown.
  • Config: a global default plus an optional trusted project override.

No tools, keybindings, widgets, overlays, or custom message/entry types.

Install

From npm after the package is published:

pi install npm:@nicknisi/pi-fast

From a local checkout:

pi install ~/Developer/pi-extensions/packages/fast

Usage

Run the command with no arguments:

/fast

Each invocation toggles a session override:

  • If Fast mode is currently off, /fast turns it on for the session.
  • If Fast mode is currently on, /fast turns it off for the session.
  • The notification reports whether the current model is active or why it is ineligible.
  • Starting, resuming, forking, or reloading a session resets the override to the configured default.

Arguments are intentionally not accepted. Use /fast, not /fast on or /fast status.

Supported providers and models

Support is intentionally explicit so the extension does not send premium-tier fields to models whose APIs reject or ignore them.

Provider Required Pi API Supported model IDs Injected request setting
anthropic anthropic-messages claude-opus-5-5, claude-opus-5, claude-opus-4-8 speed: "fast"
openai-codex openai-codex-responses gpt-5.4, gpt-5.5, gpt-5.6-luna, gpt-5.6-sol, gpt-5.6-terra, gpt-6-astra, gpt-6-luna, gpt-6-sol, gpt-6.1-sol service_tier: "fast"

OpenAI Codex eligibility also requires ChatGPT OAuth (/login in Pi). API-key-backed openai models use a different provider and are not modified by this extension.

Anthropic Fast mode on Claude Opus 5.5 is generally available on the first-party Claude API: no beta header or access request, with a default Fast-mode rate limit in the Start, Build, and Scale usage tiers. On Opus 5 and Opus 4.8 it is a research preview that must be enabled for the account; without access, the API answers Fast requests with 429. It is not available on Amazon Bedrock, Google Cloud, or Claude Platform on AWS.

Claude Opus 4.6 and 4.7 are deliberately excluded. Anthropic no longer offers Fast mode on those models: 4.6 silently runs at standard speed, while 4.7 rejects speed: "fast".

Configuration

Copy the example for a global default:

mkdir -p ~/.pi/agent/configs
cp fast.example.json ~/.pi/agent/configs/fast.json

Default config:

{
  "enabled": false,
  "showStatus": true
}
Field Type Default Description
enabled boolean false Fast-mode state at session start, before a /fast session override.
showStatus boolean true Show fast in Pi's footer while Fast mode is enabled and the selected model is eligible.

Config precedence, from lowest to highest:

  1. Built-in defaults.
  2. Global config: <agentDir>/configs/fast.json (normally ~/.pi/agent/configs/fast.json; honors PI_CODING_AGENT_DIR).
  3. Trusted project config: the nearest .pi/configs/fast.json found while walking from ctx.cwd toward the filesystem root.
  4. The in-memory /fast override for the current session.

Project config is ignored unless ctx.isProjectTrusted() is true. Config is reloaded on session_start; run /reload or start another session after editing it. Malformed JSON or non-boolean known fields produce a warning and fall back to the lower-precedence value. Unknown fields are ignored.

A project override can contain only the value it needs to change:

{
  "enabled": true
}

Request behavior

The extension is conservative about request mutation:

  1. It checks the active provider, API, model ID, and—on Codex—OAuth auth.
  2. It verifies that the provider payload's model exactly matches Pi's selected model.
  3. It returns a complete cloned payload with the added fields; Pi's before_provider_request hook treats returned values as full replacements.
  4. If a payload already contains speed or service_tier, that explicit value wins and the extension leaves the payload unchanged.

For Anthropic, pi puts its betas in the payload's betas array, and the SDK turns that array into the anthropic-beta header. The extension appends the Fast beta to that array rather than setting the header: any anthropic-beta header an extension sets replaces pi's computed list, which would drop betas pi needs (such as the mid-conversation effort betas on Opus 5).

Cost and performance caveats

  • Higher cost or credit use. Fast mode is a premium service tier. Review the linked provider pricing before enabling it by default.
  • Anthropic prompt caches are speed-specific. Switching between standard and Fast mode causes a prompt-cache miss because the two speeds do not share cached prefixes.
  • Anthropic capacity is separate. Fast mode has dedicated rate limits and may return 429 or 529. The extension then uses standard speed for 60 seconds (failed requests don't expose retry-after) and relies on pi's automatic retry (retry.enabled, on by default) to resend the failed request.
  • Codex credit multipliers vary by model. OpenAI currently documents 2.5× ChatGPT credit use for GPT-5.5/5.6 and 2× for GPT-5.4. API Priority/Fast processing has separate token pricing.
  • Faster output is not lower time-to-first-token. Anthropic describes the gain as output tokens per second; OpenAI's Codex documentation describes a supported-model speed increase.
  • Model support changes. The allowlists match the provider documentation and Pi catalog at release time. A newly released model remains ineligible until this package is updated deliberately.

Provider documentation:

Dependencies

  • @earendil-works/pi-coding-agent (peer, *) — extension hooks, model/auth context, config directory helpers, slash commands, notifications, and footer status.

  • Node built-ins: node:fs and node:path for config loading.

  • @nicknisi/pi-shared (workspace:*) — childExtensions(), the registry that loads Fast mode's request hook into subagent children.

Caveats

  • Provider payload fields and beta headers are provider-specific wire contracts. Pi exposes the interception hooks, but a provider can change its accepted values independently of Pi.
  • The extension relies on before_provider_request replacing the entire payload when it returns a value, on pi sending Anthropic betas through the payload's betas array, and on message_end carrying the provider error for failed requests.
  • /fast is session-local and is not persisted. Set enabled in config for a persistent default.
  • Children follow the most recently started session in the process. With one pi session per process (the normal CLI case) that's always the right one; an SDK host running several sessions in one process shares a single child hook.
  • The footer confirms that the extension considers Fast mode active; it does not inspect the provider response's reported tier/speed. Provider-side downgrade, missing preview entitlement, capacity errors, and billing remain authoritative.

Development

From the repository root:

pnpm vitest run packages/fast
pnpm typecheck
pnpm lint
pnpm format:check
pnpm build

Smoke-test extension loading with a scratch agent directory:

tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
PI_CODING_AGENT_DIR="$tmp" pi --no-extensions -e packages/fast/index.ts --list-models