@adeildo/pi-providers 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -40
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,50 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">@adeildo/pi-providers</h1>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://www.npmjs.com/package/@adeildo/pi-providers"><img src="https://img.shields.io/npm/v/@adeildo/pi-providers" alt="npm"></a>
|
|
5
|
+
<a href="https://pi.dev"><img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Ffelipeadeildo%2Fpi-harness%2Fmain%2Fpackage.json&query=%24.devDependencies%5B%22%40earendil-works%2Fpi-coding-agent%22%5D&label=pi%20SDK&color=6E56CF" alt="pi SDK"></a>
|
|
6
|
+
</p>
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
<p align="center">
|
|
9
|
+
<strong>The plan you already pay for, and more than one login per provider.</strong><br>
|
|
10
|
+
Bill Anthropic requests to your Claude plan, and keep several accounts with a switch to the next one when a limit hits.
|
|
11
|
+
</p>
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
pi install npm:@adeildo/pi-providers
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
It also comes in [`@adeildo/pi-harness`](../harness), with the rest of the pieces.
|
|
13
|
+
<p align="center"><code>pi install npm:@adeildo/pi-providers</code></p>
|
|
12
14
|
|
|
13
|
-
##
|
|
15
|
+
## Claude plan
|
|
14
16
|
|
|
15
|
-
With a Claude Pro or Max plan connected through `/login anthropic`, Pi's requests count as
|
|
17
|
+
With a Claude Pro or Max plan connected through `/login anthropic`, Pi's requests count as extra usage, billed by the token. This makes them come out of the plan, the way Claude Code's own requests do.
|
|
16
18
|
|
|
17
19
|
> [!WARNING]
|
|
18
|
-
>
|
|
20
|
+
> It does that by introducing Pi to Anthropic as Claude Code, and using a subscription from anything other than Claude Code may break Anthropic's terms. It is on as soon as you install the package. To say no to that: switch the extension off in `pi config`, or set `"features": { "subscription": { "enabled": false } }` in the settings file below.
|
|
19
21
|
|
|
20
|
-
Pi already sends Claude Code's identity
|
|
22
|
+
Pi already sends Claude Code's identity when the token is an OAuth one. Anthropic checks two more things before it bills the request to the plan:
|
|
21
23
|
|
|
22
24
|
1. The user agent has to read `claude-cli/<version> (external, cli)`.
|
|
23
|
-
2. The first `system` block has to be
|
|
25
|
+
2. The first `system` block has to be the billing attribution, with nothing Claude Code would not send. Pi's own prompt moves to the start of the first user message, wrapped in `<system-instructions>`, where the model still reads it.
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
Any provider that speaks the Anthropic Messages API with an OAuth token gets this, not only the one named `anthropic`, so a second account under another name is billed to its own plan. A request with an API key goes out untouched.
|
|
26
28
|
|
|
27
|
-
Pi warns about extra usage
|
|
29
|
+
Pi warns about extra usage in every Anthropic OAuth session. Once the plan pays, that warning is wrong, and `warnings.anthropicExtraUsage` in `~/.pi/agent/settings.json` turns it off.
|
|
28
30
|
|
|
29
31
|
```json
|
|
30
32
|
{ "warnings": { "anthropicExtraUsage": false } }
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
```json
|
|
36
|
-
{ "subscription": { "claudeCodeVersion": "2.1.280" } }
|
|
37
|
-
```
|
|
35
|
+
Anthropic answers `400 claude_code_version_too_old` when it considers the version too old for a newer model, and `subscription.claudeCodeVersion` raises the version Pi reports.
|
|
38
36
|
|
|
39
|
-
##
|
|
37
|
+
## Accounts
|
|
40
38
|
|
|
41
|
-
Pi keeps one credential per provider, the one `/login` wrote.
|
|
39
|
+
Pi keeps one credential per provider, the one `/login` wrote. This keeps more. The credential of `/login` stays as the first account, and every other one is an extra credential with a name.
|
|
42
40
|
|
|
43
41
|
```text
|
|
44
42
|
/accounts anthropic
|
|
45
43
|
```
|
|
46
44
|
|
|
47
|
-
It
|
|
45
|
+
It asks for the provider, its login method and a name, and runs the login Pi already has, so there is no OAuth of its own here. Each account shows its kind:
|
|
48
46
|
|
|
49
47
|
| Kind | Is |
|
|
50
48
|
| ------- | --------------------------------------------------------------------- |
|
|
@@ -52,31 +50,29 @@ It picks the provider and its login method, asks for a name, and runs the login
|
|
|
52
50
|
| `oauth` | A subscription token, billed to its own plan |
|
|
53
51
|
| `key` | An API key |
|
|
54
52
|
|
|
55
|
-
`alt+a` switches the account of the current model's provider, and the Providers tab of `Alt+S` lists
|
|
53
|
+
`alt+a` switches the account of the current model's provider, and the Providers tab of `Alt+S` lists them to choose, rename or remove. The account in use sits next to the model. The session remembers the choice, so a resume or a fork comes back to the same one.
|
|
56
54
|
|
|
57
|
-
When a
|
|
55
|
+
When a provider refuses a request for a quota or a rate limit and that provider has another account, `accounts.onLimit` decides what happens:
|
|
58
56
|
|
|
59
|
-
| Value | Does
|
|
60
|
-
| -------- |
|
|
61
|
-
| `ask` | Opens a dialog, with
|
|
62
|
-
| `switch` | Moves to the next account on its own
|
|
63
|
-
| `stop` | Leaves the error in front of you
|
|
57
|
+
| Value | Does |
|
|
58
|
+
| -------- | ------------------------------------------------------------------------- |
|
|
59
|
+
| `ask` | Opens a dialog, with an option to always switch from then on. The default |
|
|
60
|
+
| `switch` | Moves to the next account on its own |
|
|
61
|
+
| `stop` | Leaves the error in front of you |
|
|
64
62
|
|
|
65
|
-
Only a limit that arrives before anything was shown switches, so
|
|
63
|
+
Only a limit that arrives before anything was shown switches, so a retry never repeats output you already saw. Only chat streams move: image generation, classifier calls and deferred responses keep pi's own credential.
|
|
66
64
|
|
|
67
65
|
## Settings
|
|
68
66
|
|
|
69
67
|
In `~/.pi/agent/extensions/pi-harness/settings.json`:
|
|
70
68
|
|
|
71
|
-
| Key | Default | Does
|
|
72
|
-
| -------------------------------- | ----------- |
|
|
73
|
-
| `subscription.claudeCodeVersion` | `"2.1.280"` | The
|
|
74
|
-
| `accounts.onLimit` | `"ask"` | What a quota or rate limit does when another account exists: `"ask"`, `"switch"` or `"stop"`
|
|
75
|
-
|
|
76
|
-
## Credit
|
|
69
|
+
| Key | Default | Does |
|
|
70
|
+
| -------------------------------- | ----------- | ---------------------------------------------------------------------------------------------- |
|
|
71
|
+
| `subscription.claudeCodeVersion` | `"2.1.280"` | The version Pi reports. Anthropic will not serve newer models to a version it considers old |
|
|
72
|
+
| `accounts.onLimit` | `"ask"` | What a quota or a rate limit does when another account exists: `"ask"`, `"switch"` or `"stop"` |
|
|
77
73
|
|
|
78
|
-
The
|
|
74
|
+
The Claude plan billing comes from [pi-claude-max](https://github.com/bradennss/pi-claude-max) by Braden Lamb, MIT. This is a rewrite: it reads the version from settings, carries pi's cache breakpoints over instead of dropping the one-hour TTL, moves every system block after the identity instead of only the second, and checks for an OAuth token instead of the provider name.
|
|
79
75
|
|
|
80
|
-
|
|
76
|
+
Several accounts per provider, with a switch to the next one when a limit hits, follow [pi-multiprovider](https://github.com/monotykamary/pi-multiprovider) by monotykamary, also MIT. This one keeps them inside pi's own login, with no OAuth of its own.
|
|
81
77
|
|
|
82
|
-
[
|
|
78
|
+
Part of [pi-harness](https://github.com/felipeadeildo/pi-harness), which brings every piece in one install.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adeildo/pi-providers",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Provider features for Pi. Bills Anthropic OAuth requests to the Claude Pro or Max plan instead of extra usage.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anthropic",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@adeildo/pi-kit": "5.
|
|
40
|
+
"@adeildo/pi-kit": "5.2.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@earendil-works/pi-ai": "*",
|