pi-cliproxyapi-provider 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Richard Hao
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,153 @@
1
+ # pi-cliproxyapi-provider
2
+
3
+ `pi-cliproxyapi-provider` registers one [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) instance as a pi model provider. It discovers models from CLIProxyAPI's OpenAI-compatible `/v1/models` endpoint and enriches them with metadata from [models.dev](https://models.dev/).
4
+
5
+ ## Install
6
+
7
+ Install from npm:
8
+
9
+ ```bash
10
+ pi install npm:pi-cliproxyapi-provider
11
+ ```
12
+
13
+ Or install from GitHub:
14
+
15
+ ```bash
16
+ pi install git:github.com/0xRichardH/pi-cliproxyapi-provider@master
17
+ ```
18
+
19
+ You can omit `@master`, but pinning a branch, tag, or commit makes Git installs reproducible:
20
+
21
+ ```bash
22
+ pi install git:github.com/0xRichardH/pi-cliproxyapi-provider@a28f326
23
+ ```
24
+
25
+ Restart pi after installing, then run:
26
+
27
+ ```text
28
+ /cliproxyapi config
29
+ /login cpa
30
+ /model
31
+ ```
32
+
33
+ ## Install for local testing
34
+
35
+ From this repository:
36
+
37
+ ```bash
38
+ pi -e .
39
+ ```
40
+
41
+ List models without installing:
42
+
43
+ ```bash
44
+ CLIPROXYAPI_BASE_URL=http://localhost:8317/v1 \
45
+ CLIPROXYAPI_API_KEY=your-key \
46
+ pi -e . --list-models cpa
47
+ ```
48
+
49
+ ## Configure
50
+
51
+ Run the interactive command:
52
+
53
+ ```text
54
+ /cliproxyapi config
55
+ ```
56
+
57
+ It writes global connection/auth config to:
58
+
59
+ ```text
60
+ ~/.pi/agent/pi-cliproxyapi-provider/config.json
61
+ ```
62
+
63
+ Environment variables override config:
64
+
65
+ ```text
66
+ CLIPROXYAPI_BASE_URL
67
+ CLIPROXYAPI_PROVIDER_NAME
68
+ CLIPROXYAPI_AUTH_REQUIRED
69
+ CLIPROXYAPI_AUTH_HEADER
70
+ CLIPROXYAPI_MODELS_DEV_ENABLED
71
+ ```
72
+
73
+ Project config only supports metadata aliases. Connection and auth settings such as `baseUrl`, `providerName`, `authRequired`, `authHeader`, and `headers` must be set in global config or environment variables.
74
+
75
+ ## Authenticate
76
+
77
+ Use pi's normal API-key login flow:
78
+
79
+ ```text
80
+ /login cpa
81
+ ```
82
+
83
+ If you changed the provider name, use that name instead:
84
+
85
+ ```text
86
+ /login 0xdev
87
+ ```
88
+
89
+ For non-interactive runs, set:
90
+
91
+ ```bash
92
+ export CLIPROXYAPI_API_KEY=your-key
93
+ ```
94
+
95
+ ## Commands
96
+
97
+ ```text
98
+ /cliproxyapi config # interactive setup
99
+ /cliproxyapi status # show config, cache ages, and enrichment counts
100
+ /cliproxyapi refresh # refresh caches, then run /reload
101
+ /cliproxyapi aliases # show unmatched model IDs for metadata aliases
102
+ ```
103
+
104
+ ## Metadata aliases
105
+
106
+ Aliases affect metadata only. The package still sends the original CLIProxyAPI model ID to the proxy.
107
+
108
+ Add global aliases to:
109
+
110
+ ```text
111
+ ~/.pi/agent/pi-cliproxyapi-provider/config.json
112
+ ```
113
+
114
+ Add project aliases manually to:
115
+
116
+ ```text
117
+ .pi/pi-cliproxyapi-provider/config.json
118
+ ```
119
+
120
+ Project config only reads `modelAliases`; other fields are ignored.
121
+
122
+ ```json
123
+ {
124
+ "modelAliases": {
125
+ "claude-opus-4-6-thinking": "anthropic/claude-opus-4-6"
126
+ }
127
+ }
128
+ ```
129
+
130
+ ## Caches
131
+
132
+ ```text
133
+ CPA /v1/models cache: 1 hour
134
+ models.dev cache: 1 day
135
+ ```
136
+
137
+ Caches live under:
138
+
139
+ ```text
140
+ ~/.cache/pi-cliproxyapi-provider/
141
+ ```
142
+
143
+ Startup does not fetch `models.dev`. It uses a fresh local `models.dev` cache when present, otherwise it uses `data/models-dev-fallback.json`. Run `/cliproxyapi refresh` to update both the CPA model cache and the `models.dev` metadata cache.
144
+
145
+ ## Test
146
+
147
+ ```bash
148
+ npm test
149
+ ```
150
+
151
+ ## Release
152
+
153
+ Releases are published to npm when a matching `v*` tag is pushed. See [RELEASING.md](RELEASING.md) for npm authentication, first-release steps, versioning, verification, and troubleshooting.