https://github.com/leohenon/pi-anthropic-oauth
Pi extension for Anthropic OAuth with Claude Pro/Max.
https://github.com/leohenon/pi-anthropic-oauth
anthropic claude pi pi-agent pi-extensions
Last synced: about 17 hours ago
JSON representation
Pi extension for Anthropic OAuth with Claude Pro/Max.
- Host: GitHub
- URL: https://github.com/leohenon/pi-anthropic-oauth
- Owner: leohenon
- License: mit
- Created: 2026-04-09T10:49:09.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2026-08-04T10:21:25.000Z (6 days ago)
- Last Synced: 2026-08-07T08:20:02.742Z (3 days ago)
- Topics: anthropic, claude, pi, pi-agent, pi-extensions
- Language: TypeScript
- Homepage:
- Size: 196 KB
- Stars: 75
- Watchers: 3
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-pi-coding-agent - leohenon-pi-anthropic-oauth
README
# pi-anthropic-oauth
[](https://www.npmjs.com/package/pi-anthropic-oauth)
Use Claude Pro/Max in Pi with browser OAuth.
> [!IMPORTANT]
> This extension supports Pi 0.80.8 or later.
## Features
- Claude Pro/Max login from `/login`
- Automatic token refresh
- Claude Code-compatible OAuth headers and prompt shaping
- No Anthropic API key needed
- Uses the Anthropic models available in Pi's built-in model registry
- Auto-creates `~/.Claude Code` → `~/.pi` symlink when missing
## Quick start
```bash
pi install npm:pi-anthropic-oauth
```
Start Pi, then run Pi's login command:
```text
/login
```
Choose:
```text
Claude Pro/Max
```
Complete the browser login. After login, select an Anthropic model in Pi.
When the extension is active, `/login` includes `Claude Pro/Max` and Anthropic models show `(sub)` after OAuth login.
Update with:
```bash
pi update npm:pi-anthropic-oauth
```
> [!NOTE]
> Anthropic auth changes are closely monitored for quick compatibility updates.
## System prompt rewriting
When using Claude Pro/Max OAuth, the extension prepends Claude Code identity text and rewrites standalone `Pi` / `pi` references in Pi's system prompt to `Claude Code`. The rewrite mode defaults to `aggressive`:
```bash
PI_ANTHROPIC_OAUTH_REWRITE_MODE=aggressive
```
Other modes are opt-in and avoid rewriting some technical strings such as paths, package names, or repository names. If OAuth starts failing, switch back to `aggressive`.
Available modes:
| Mode | Behavior |
| ---------------- | ----------------------------------------------------------------------------------------------------------- |
| `aggressive` | Default. Replaces standalone `Pi` / `pi` wherever the word-boundary pattern matches. |
| `path-safe` | Avoids replacing `Pi` / `pi` immediately after `/` or `\`, preserving path segments like `/srv/dev/pi-foo`. |
| `technical-safe` | Avoids replacing `Pi` / `pi` next to common technical-token separators: `/`, `\`, `.`, `@`, `:`, `_`, `-`. |
| `custom` | Uses `PI_ANTHROPIC_OAUTH_REWRITE_PATTERN` as the replacement regex. |
Custom patterns can be a regex source or a JavaScript-style regex literal. The `g` flag is added automatically when omitted:
```bash
PI_ANTHROPIC_OAUTH_REWRITE_MODE=custom
PI_ANTHROPIC_OAUTH_REWRITE_PATTERN='(? [!NOTE]
> Opus 5 and Fable 5 are included in Pi's built-in Anthropic model catalog as `claude-opus-5` and `claude-fable-5`.
>
> Pi requires `baseUrl`, `apiKey`, and `api` when defining custom models in `models.json`. With this extension, requests normally authenticate through Claude Pro/Max OAuth after `/login`, so `apiKey` is only a placeholder to satisfy Pi's config requirements and does not need to be a valid Anthropic API key.
>
> Do not use a fake `sk-ant-oat...` value as the placeholder. If OAuth login has not completed, Pi may try to use that fake token and Anthropic will return `401 Invalid bearer token`. Use a harmless placeholder such as `"unused"`, then run `/login` and choose `Claude Pro/Max`.
## Troubleshooting
- Run `/login` with no arguments, then choose `Claude Pro/Max`.
- If local callback login does not complete, paste the final callback URL or `code#state` when prompted
- If you see `401 Invalid bearer token`, remove any fake `sk-ant-oat...` placeholder from `~/.pi/agent/models.json` and log in again
- If something breaks, please open an issue with your Pi version, extension version, and error output
## License
MIT