pi-cliproxyapi 0.1.0 → 0.1.2
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 +70 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# pi-cliproxyapi
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/pi-cliproxyapi)
|
|
4
|
+
[](https://github.com/abix5/pi-cliproxyapi)
|
|
5
|
+
|
|
6
|
+
Pi extension for corporate management of model providers via a single [CliProxyAPI](https://github.com/router-for-me/CLIProxyAPI) endpoint.
|
|
4
7
|
|
|
5
8
|
One `(endpoint, apiKey)` pair — every provider and model inherits it automatically.
|
|
6
9
|
|
|
@@ -23,10 +26,16 @@ One `(endpoint, apiKey)` pair — every provider and model inherits it automatic
|
|
|
23
26
|
| `/cliproxy-usage` | Per-account quota windows with progress bars (`d` = show disabled, `v` = verbose) |
|
|
24
27
|
| `/cliproxy-doctor` | Connectivity, key resolution, discovery diagnostics |
|
|
25
28
|
|
|
29
|
+
## Prerequisites
|
|
30
|
+
|
|
31
|
+
You need a running [CliProxyAPI](https://github.com/router-for-me/CLIProxyAPI) instance — this is the corporate LLM proxy that aggregates multiple providers behind a single OpenAI-compatible endpoint.
|
|
32
|
+
|
|
33
|
+
For full functionality (`/cliproxy-usage`, enriched model metadata from [models.dev](https://models.dev)), also deploy the companion sidecar: **[pi-cliproxyapi-wellknown](https://github.com/abix5/pi-cliproxyapi-wellknown)**. See [Deploying the sidecar](#deploying-the-sidecar-service) below.
|
|
34
|
+
|
|
26
35
|
## Install
|
|
27
36
|
|
|
28
37
|
```bash
|
|
29
|
-
pi install pi-cliproxyapi
|
|
38
|
+
pi install npm:pi-cliproxyapi
|
|
30
39
|
```
|
|
31
40
|
|
|
32
41
|
Then run `/cliproxy-setup` to configure your proxy endpoint.
|
|
@@ -60,11 +69,14 @@ Values support `!command` (shell exec), `$ENV_VAR`, `~/path` (auto-wrapped to `!
|
|
|
60
69
|
|
|
61
70
|
## Discovery
|
|
62
71
|
|
|
63
|
-
The plugin tries `GET <endpoint-origin>/.well-known/pi` first (requires the
|
|
72
|
+
The plugin tries `GET <endpoint-origin>/.well-known/pi` first (requires the sidecar). If unavailable, falls back to `GET <endpoint>/models` with local heuristics.
|
|
64
73
|
|
|
65
|
-
|
|
74
|
+
## Deploying the sidecar service
|
|
66
75
|
|
|
67
|
-
|
|
76
|
+
The **[pi-cliproxyapi-wellknown](https://github.com/abix5/pi-cliproxyapi-wellknown)** sidecar runs alongside CliProxyAPI and provides:
|
|
77
|
+
|
|
78
|
+
- `/.well-known/pi` — model discovery with metadata from [models.dev](https://models.dev) (context windows, costs, reasoning flags)
|
|
79
|
+
- `/api/usage` — per-account quota windows used by `/cliproxy-usage`
|
|
68
80
|
|
|
69
81
|
```
|
|
70
82
|
┌──────────────┐ ┌───────────────────────────┐
|
|
@@ -79,7 +91,59 @@ For richer model metadata (context windows, costs, reasoning flags from models.d
|
|
|
79
91
|
└──────────────┘
|
|
80
92
|
```
|
|
81
93
|
|
|
82
|
-
|
|
94
|
+
### Quick start with Docker Compose
|
|
95
|
+
|
|
96
|
+
Clone the sidecar repo next to your CliProxyAPI deployment:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
git clone https://github.com/abix5/pi-cliproxyapi-wellknown.git
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Add to your `docker-compose.yml`:
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
services:
|
|
106
|
+
cliproxyapi:
|
|
107
|
+
# ... your existing CliProxyAPI service ...
|
|
108
|
+
|
|
109
|
+
pi-cliproxyapi-wellknown:
|
|
110
|
+
build:
|
|
111
|
+
context: ./pi-cliproxyapi-wellknown
|
|
112
|
+
restart: unless-stopped
|
|
113
|
+
ports:
|
|
114
|
+
- "127.0.0.1:3458:3458"
|
|
115
|
+
environment:
|
|
116
|
+
UPSTREAM_MODELS_URL: http://cliproxyapi:8317/v1/models
|
|
117
|
+
UPSTREAM_TOKEN: ${UPSTREAM_TOKEN} # CliProxyAPI bearer key
|
|
118
|
+
PI_PUBLIC_BASE_URL: ${PI_PUBLIC_BASE_URL} # e.g. https://proxy.example.com/v1
|
|
119
|
+
MANAGEMENT_API_URL: http://cliproxyapi:8317/v0/management
|
|
120
|
+
MANAGEMENT_API_KEY: ${MANAGEMENT_API_KEY}
|
|
121
|
+
PI_PLUGIN_USAGE_KEY: ${PI_PLUGIN_USAGE_KEY} # shared with Pi plugin
|
|
122
|
+
depends_on:
|
|
123
|
+
cliproxyapi:
|
|
124
|
+
condition: service_healthy
|
|
125
|
+
networks:
|
|
126
|
+
- your-network
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Then route `/.well-known/pi` and `/api/usage` on your public domain to port 3458 via your reverse proxy (Nginx, Caddy, Cloudflare Tunnel, etc.).
|
|
130
|
+
|
|
131
|
+
### Connecting the plugin
|
|
132
|
+
|
|
133
|
+
Run `/cliproxy-setup` in Pi and enter:
|
|
134
|
+
- **endpoint** — your public proxy URL ending with `/v1`
|
|
135
|
+
- **apiKey** — CliProxyAPI bearer key
|
|
136
|
+
- **providerPrefix** — short slug for custom provider names (e.g. `corp`, `myproxy`)
|
|
137
|
+
- **usageKey** — same value as `PI_PLUGIN_USAGE_KEY` above (enables `/cliproxy-usage`)
|
|
138
|
+
|
|
139
|
+
The sidecar is **optional for basic usage** — without it the plugin falls back to raw `/v1/models` with local heuristics. What changes:
|
|
140
|
+
|
|
141
|
+
| | With sidecar | Without sidecar |
|
|
142
|
+
| --- | --- | --- |
|
|
143
|
+
| Model discovery | Enriched from [models.dev](https://models.dev) (real context windows, costs, reasoning) | Defaults: `contextWindow=128k`, `maxTokens=16k`, `cost=0`, `reasoning=false` |
|
|
144
|
+
| `/cliproxy-usage` | Works — per-account quota bars | **Does not work** (no `/api/usage` endpoint) |
|
|
145
|
+
| Classification | Server-side, accurate | Local heuristics by `owned_by` |
|
|
146
|
+
| `/cliproxy`, `/cliproxy-list`, `/cliproxy-doctor` | Work | Work |
|
|
83
147
|
|
|
84
148
|
## Layout
|
|
85
149
|
|