@howaboua/pi-glm-via-anthropic 0.1.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/LICENSE +21 -0
- package/README.md +88 -0
- package/index.ts +59 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Igor Warzocha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# @howaboua/pi-glm-via-anthropic
|
|
2
|
+
|
|
3
|
+
Use Z.ai GLM models in [pi](https://pi.dev/) through Z.ai's Anthropic-compatible endpoint.
|
|
4
|
+
|
|
5
|
+
It overrides pi's built-in `zai` provider to send requests to `https://api.z.ai/api/anthropic`.
|
|
6
|
+
|
|
7
|
+
## Why
|
|
8
|
+
|
|
9
|
+
This package exists because many GLM Coding Plan users prefer Z.ai's Anthropic-compatible route over the default coding endpoint.
|
|
10
|
+
|
|
11
|
+
Why:
|
|
12
|
+
|
|
13
|
+
- Z.ai officially exposes an Anthropic-compatible endpoint for coding tools.
|
|
14
|
+
- Z.ai's Claude Code docs describe that setup around "Code faster" and "rock-solid reliability".
|
|
15
|
+
- Community reports and benchmarks commonly describe the Anthropic route as faster, lower-latency, or less flaky than the default coding endpoint.
|
|
16
|
+
|
|
17
|
+
## What it does
|
|
18
|
+
|
|
19
|
+
- keeps the provider name as `zai`
|
|
20
|
+
- reuses your existing Z.ai credentials in pi
|
|
21
|
+
- switches pi to the Anthropic-compatible transport for these models:
|
|
22
|
+
- `zai/glm-5.1`
|
|
23
|
+
- `zai/glm-5-turbo`
|
|
24
|
+
- `zai/glm-4.7`
|
|
25
|
+
- `zai/glm-4.5-air`
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pi install npm:@howaboua/pi-glm-via-anthropic
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Project-local install:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pi install npm:@howaboua/pi-glm-via-anthropic -l
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
One-off usage without installing:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pi -e npm:@howaboua/pi-glm-via-anthropic
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Credentials
|
|
46
|
+
|
|
47
|
+
If you already use Z.ai in pi, you probably do not need to do anything.
|
|
48
|
+
|
|
49
|
+
This package keeps the provider name as `zai`, so pi continues using the normal Z.ai credential sources:
|
|
50
|
+
|
|
51
|
+
1. `~/.pi/agent/auth.json`
|
|
52
|
+
2. `ZAI_API_KEY`
|
|
53
|
+
|
|
54
|
+
Example `auth.json` entry:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"zai": { "type": "api_key", "key": "your-zai-key" }
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Or use an environment variable:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
export ZAI_API_KEY=your-zai-key
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Remove
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pi remove npm:@howaboua/pi-glm-via-anthropic
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Optional override
|
|
75
|
+
|
|
76
|
+
If you want to point the adapter at a different Anthropic-compatible base URL, set:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
export ZAI_ANTHROPIC_BASE_URL=https://your-proxy.example.com
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## References
|
|
83
|
+
|
|
84
|
+
- Z.ai Claude Code guide: https://docs.z.ai/devpack/tool/claude
|
|
85
|
+
- Z.ai third-party tool guide: https://docs.z.ai/guides/development/using-glm-api-with-third-party-tools
|
|
86
|
+
- Roo Code issue discussing faster results via `https://api.z.ai/api/anthropic`: https://github.com/RooCodeInc/Roo-Code/issues/8488
|
|
87
|
+
- Community discussion: https://www.reddit.com/r/ZaiGLM/comments/1rti3cy/psa_for_legacy_users_with_no_active_sub/
|
|
88
|
+
- pi package docs: https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/docs/packages.md
|
package/index.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_BASE_URL = "https://api.z.ai/api/anthropic";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Z.ai GLM Coding Plan models over the Anthropic-compatible endpoint.
|
|
7
|
+
*
|
|
8
|
+
* Notes:
|
|
9
|
+
* - Provider name is intentionally "zai" so pi will reuse the existing
|
|
10
|
+
* ~/.pi/agent/auth.json credential at key "zai".
|
|
11
|
+
* - Model set follows Z.ai's current Coding Plan docs for the Anthropic flow.
|
|
12
|
+
*/
|
|
13
|
+
export const MODELS = [
|
|
14
|
+
{
|
|
15
|
+
id: "glm-5.1",
|
|
16
|
+
name: "GLM-5.1",
|
|
17
|
+
reasoning: true,
|
|
18
|
+
input: ["text"] as const,
|
|
19
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
20
|
+
contextWindow: 204800,
|
|
21
|
+
maxTokens: 131072,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "glm-5-turbo",
|
|
25
|
+
name: "GLM-5-Turbo",
|
|
26
|
+
reasoning: true,
|
|
27
|
+
input: ["text"] as const,
|
|
28
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
29
|
+
contextWindow: 200000,
|
|
30
|
+
maxTokens: 131072,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "glm-4.7",
|
|
34
|
+
name: "GLM-4.7",
|
|
35
|
+
reasoning: true,
|
|
36
|
+
input: ["text"] as const,
|
|
37
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
38
|
+
contextWindow: 204800,
|
|
39
|
+
maxTokens: 131072,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "glm-4.5-air",
|
|
43
|
+
name: "GLM-4.5-Air",
|
|
44
|
+
reasoning: true,
|
|
45
|
+
input: ["text"] as const,
|
|
46
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
47
|
+
contextWindow: 131072,
|
|
48
|
+
maxTokens: 98304,
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
export default function (pi: ExtensionAPI) {
|
|
53
|
+
pi.registerProvider("zai", {
|
|
54
|
+
baseUrl: process.env.ZAI_ANTHROPIC_BASE_URL || DEFAULT_BASE_URL,
|
|
55
|
+
apiKey: "ZAI_API_KEY",
|
|
56
|
+
api: "anthropic-messages",
|
|
57
|
+
models: MODELS.map((model) => ({ ...model })),
|
|
58
|
+
});
|
|
59
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@howaboua/pi-glm-via-anthropic",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Use Z.ai GLM models in pi through Z.ai's Anthropic-compatible endpoint.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/IgorWarzocha/pi-glm-via-anthropic.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/IgorWarzocha/pi-glm-via-anthropic#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/IgorWarzocha/pi-glm-via-anthropic/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"pi-package",
|
|
17
|
+
"pi-extension",
|
|
18
|
+
"pi",
|
|
19
|
+
"zai",
|
|
20
|
+
"z.ai",
|
|
21
|
+
"glm",
|
|
22
|
+
"anthropic"
|
|
23
|
+
],
|
|
24
|
+
"files": [
|
|
25
|
+
"index.ts",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@mariozechner/pi-coding-agent": "*"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"pack:check": "npm pack --dry-run"
|
|
37
|
+
},
|
|
38
|
+
"pi": {
|
|
39
|
+
"extensions": [
|
|
40
|
+
"./index.ts"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|