pi-claude-oauth-adapter
Anthropic OAuth / Claude Code compatibility adapter for Pi.
Package details
Install pi-claude-oauth-adapter from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-claude-oauth-adapter- Package
pi-claude-oauth-adapter- Version
0.2.2- Published
- Sep 14, 2026
- Downloads
- 2,083/mo · 151/wk
- Author
- minzicat
- License
- MIT
- Types
- extension
- Size
- 68.5 KB
- Dependencies
- 0 dependencies · 3 peers
Pi manifest JSON
{
"extensions": [
"./extensions/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-claude-oauth-adapter
Use a Claude Pro or Max subscription with Pi.
pi install npm:pi-claude-oauth-adapter
This extension adapts Pi's built-in Anthropic OAuth flow to the request format expected by Claude's subscription backend. It does not implement OAuth or bypass usage limits.
Setup
- Install the package.
- Start Pi and run
/login. - Choose Claude Pro/Max.
- Select an Anthropic model with
/model.
The footer should show ✓ Claude OAuth ready, then ✓ Claude OAuth active after the first request.
The adapter runs only when both conditions are true:
- the provider is
anthropic - Pi is using OAuth
Requests using ANTHROPIC_API_KEY are unchanged.
What it changes
flowchart LR
A[Pi request] --> B{Anthropic OAuth?}
B -- No --> C[Send unchanged]
B -- Yes --> D[Normalize prompt and billing header]
D --> E[Anthropic]
E -- 429 --> F[Resolve quota and reset time]
E -- Success --> G[Claude response]
For Anthropic OAuth requests, the adapter:
- removes Pi's docs block and any conflicting Claude Code identity block from the system prompt
- reinjects Pi docs as hidden context when the user asks about Pi
- adds or updates the Claude billing header
- turns generic
429responses into Claude-style limit and reset messages
On an ambiguous 429, it checks Anthropic's OAuth usage endpoint and falls back to a minimal Haiku request. Results are cached for 30 seconds.
Status
| Footer text | Meaning |
|---|---|
✓ Claude OAuth ready |
OAuth was detected and setup is valid. |
✓ Claude OAuth active |
A request was normalized. |
⚠ Claude OAuth setup |
Required Pi docs context could not be found. |
You've hit your ... limit |
Anthropic reported a subscription limit. |
No status appears for API-key sessions or other providers.
Configuration
No configuration is required for normal use.
| Variable | Default | Purpose |
|---|---|---|
PI_CLAUDE_OAUTH_REINJECT_SCOPE |
pi-only |
pi-only, always, or never |
PI_CLAUDE_OAUTH_REINJECT_MODE |
prepend-custom-message |
prepend-custom-message, append-custom-message, user-reminder, or none |
PI_CLAUDE_OAUTH_DOCS_FILE |
unset | Fallback file containing Pi docs context |
PI_CLAUDE_OAUTH_LOG_FILE |
unset | JSONL debug log path |
PI_CLAUDE_CODE_VERSION |
bundled version | Pin the Claude Code version in request metadata (disables version learning) |
PI_CLAUDE_OAUTH_VERSION_CHECK |
1 |
Set to 0 to stop refreshing the advertised Claude Code version from the npm registry |
PI_CLAUDE_OAUTH_CLIENT_HEADERS |
1 |
Set to 0 to stop sending user-agent / x-app / x-claude-code-session-id |
PI_CLAUDE_CODE_ENTRYPOINT |
pi |
Billing-header entrypoint |
PI_CLAUDE_CODE_WORKLOAD |
unset | Optional workload metadata |
PI_CLAUDE_CODE_SUBSCRIPTION_TYPE |
unset | Plan type used for limit labels |
Example:
PI_CLAUDE_OAUTH_REINJECT_SCOPE=always pi
Debug logs may contain prompt excerpts and request metadata. Review and redact them before sharing.
Install from source
git clone https://github.com/minzique/pi-claude-oauth-adapter.git
pi install ./pi-claude-oauth-adapter
To test a checkout without installing it:
pi -e ./pi-claude-oauth-adapter
Troubleshooting
If no status appears, check pi list, select an Anthropic model, and log in through Claude Pro/Max instead of an API key.
If ⚠ Claude OAuth setup appears, provide the docs context explicitly:
PI_CLAUDE_OAUTH_DOCS_FILE=/absolute/path/to/pi-docs-only.txt pi
To collect a debug log:
PI_CLAUDE_OAUTH_LOG_FILE="$PWD/claude-oauth-debug.jsonl" pi
Report bugs on GitHub. See the changelog for release notes.
Development
npm install
npm run check
npm pack --dry-run
The extension entry point is extensions/index.ts.
Security
Pi extensions run with your user account's permissions. Review third-party extension code before installing it.
This adapter sends no telemetry and writes no logs unless PI_CLAUDE_OAUTH_LOG_FILE is set. Quota checks go to the configured Anthropic endpoint. The first-party OAuth usage endpoint is used only for api.anthropic.com sessions.
This project is unofficial and is not affiliated with Anthropic.