proxitor 0.15.0 → 0.17.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 +75 -9
- package/dist/cli.mjs +632 -149
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://www.npmjs.com/package/proxitor"><img src="https://img.shields.io/npm/v/proxitor?color=6366f1&labelColor=1e2327&label=npm" alt="npm version"></a>
|
|
11
|
+
<a href="https://github.com/neiromaster/proxitor/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/neiromaster/proxitor/ci.yml?branch=main&color=22c55e&labelColor=1e2327&label=CI" alt="CI status"></a>
|
|
11
12
|
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-22c55e?labelColor=1e2327" alt="MIT License"></a>
|
|
12
13
|
<img src="https://img.shields.io/badge/node-%3E%3D22-3b82f6?labelColor=1e2327" alt="Node.js ≥ 22">
|
|
13
14
|
<a href="https://github.com/neiromaster/proxitor/issues"><img src="https://img.shields.io/github/issues/neiromaster/proxitor?color=f59e0b&labelColor=1e2327&label=issues" alt="GitHub issues"></a>
|
|
@@ -19,9 +20,34 @@
|
|
|
19
20
|
|
|
20
21
|
---
|
|
21
22
|
|
|
23
|
+
## Contents
|
|
24
|
+
|
|
25
|
+
- [Why proxitor](#why-proxitor)
|
|
26
|
+
- [How it works](#how-it-works)
|
|
27
|
+
- [The caching problem](#the-caching-problem)
|
|
28
|
+
- [Features](#features)
|
|
29
|
+
- [Install](#install)
|
|
30
|
+
- [Quick start](#quick-start)
|
|
31
|
+
- [Minimal config](#minimal-config)
|
|
32
|
+
- [Configuration](#configuration)
|
|
33
|
+
- [Diagnostics](#diagnostics)
|
|
34
|
+
- [Commands](#commands)
|
|
35
|
+
- [Common pitfalls](#common-pitfalls)
|
|
36
|
+
- [Contributing](#contributing)
|
|
37
|
+
- [License](#license)
|
|
38
|
+
|
|
39
|
+
## Why proxitor
|
|
40
|
+
|
|
41
|
+
AI CLIs already speak Anthropic or OpenAI APIs. proxitor keeps that interface intact and fixes the expensive parts in the middle:
|
|
42
|
+
|
|
43
|
+
- **Provider pinning** keeps OpenRouter from bouncing the same conversation between upstreams.
|
|
44
|
+
- **Prompt-cache shaping** adds sticky sessions, cache breakpoints, TTL fixes, and volatile-prefix normalization where needed.
|
|
45
|
+
- **Per-model routing** lets Claude, GPT, Qwen, GLM, and other model families use different providers and policies.
|
|
46
|
+
- **Operational checks** (`doctor`, `/health`, config validation, hot reload) make the proxy safe to leave running during long coding sessions.
|
|
47
|
+
|
|
22
48
|
## How it works
|
|
23
49
|
|
|
24
|
-
```
|
|
50
|
+
```text
|
|
25
51
|
your AI CLI → proxitor → OpenRouter → the provider you picked
|
|
26
52
|
```
|
|
27
53
|
|
|
@@ -33,6 +59,8 @@ OpenRouter load-balances across providers, and **prompt caching is provider-scop
|
|
|
33
59
|
|
|
34
60
|
Pin `claude-*` to `anthropic`, and that system prompt gets cached after the first hit. Subsequent requests cost a fraction.
|
|
35
61
|
|
|
62
|
+
A typical 50k-token Claude Code system prompt at $3/M input costs **$0.15 per turn** with no cache. After a warm Anthropic cache, the same prefix costs ~10% of input price — about **$0.015 per turn**. The cache amortizes in 1-2 turns and pays for itself the rest of the session.
|
|
63
|
+
|
|
36
64
|
## Features
|
|
37
65
|
|
|
38
66
|
- 🔒 **Stable caching** — pin models to a single provider so prompt caches survive across requests
|
|
@@ -48,6 +76,7 @@ Requires **Node.js 22+**.
|
|
|
48
76
|
|
|
49
77
|
```sh
|
|
50
78
|
npm install -g proxitor
|
|
79
|
+
# or: pnpm install -g proxitor
|
|
51
80
|
# or: bun install -g proxitor
|
|
52
81
|
# or run it once, no install: npx proxitor
|
|
53
82
|
```
|
|
@@ -63,8 +92,9 @@ proxitor config wizard
|
|
|
63
92
|
**2. Run it**
|
|
64
93
|
|
|
65
94
|
```sh
|
|
66
|
-
proxitor
|
|
67
|
-
#
|
|
95
|
+
proxitor # default: http://0.0.0.0:8828
|
|
96
|
+
proxitor --port 9000 # or pick a custom port
|
|
97
|
+
proxitor up # aliases: up, run
|
|
68
98
|
```
|
|
69
99
|
|
|
70
100
|
**3. Point your tool at it**
|
|
@@ -79,6 +109,18 @@ OPENAI_BASE_URL=http://localhost:8828/v1 codex
|
|
|
79
109
|
|
|
80
110
|
That's the whole setup. Requests flow through proxitor; streaming responses pass through untouched.
|
|
81
111
|
|
|
112
|
+
## Minimal config
|
|
113
|
+
|
|
114
|
+
The wizard writes a full config; the minimum is just an API key and a routing rule. Drop this into `proxitor.config.yaml` (or `.yaml`/`.yml`/`.json`, also accepted as `.proxitor.yaml`/`.proxitor.json` in the project root):
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
openrouterKey: sk-or-v1-... # or set OPENROUTER_API_KEY in your shell
|
|
118
|
+
provider:
|
|
119
|
+
order: "anthropic" # pin everything to Anthropic for stable caching
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Run `proxitor config validate` to check it, then `proxitor` to start.
|
|
123
|
+
|
|
82
124
|
## Configuration
|
|
83
125
|
|
|
84
126
|
The friendly way: an interactive menu — no YAML required.
|
|
@@ -95,6 +137,10 @@ From the menu you can set your API key and connection, pick routing per model (w
|
|
|
95
137
|
|
|
96
138
|
Prefer to edit a file? The full **[configuration reference](./docs/configuration.md)** covers provider routing, per-model overrides, headers, caching modes, and every option. [`proxitor.config.example.yaml`](./proxitor.config.example.yaml) is a commented template.
|
|
97
139
|
|
|
140
|
+
**Hot-reload** — proxitor watches the config file and reloads on save; no restart needed. Bad edits fall back to the last valid config and the proxy keeps running. `proxitor config validate` shows the current state.
|
|
141
|
+
|
|
142
|
+
**Environment variables** — `OPENROUTER_API_KEY` is used when the config key is empty; `XDG_CONFIG_HOME` overrides the user-config directory on Linux/macOS. CLI flags take precedence over both.
|
|
143
|
+
|
|
98
144
|
## Diagnostics
|
|
99
145
|
|
|
100
146
|
```sh
|
|
@@ -103,17 +149,19 @@ proxitor doctor # checks environment, config, key, network, port, version
|
|
|
103
149
|
|
|
104
150
|
It prints a clear report and exits non-zero if anything fails — handy from CI too (`--json`, `--offline`, `--timeout`).
|
|
105
151
|
|
|
106
|
-
While proxitor runs, it
|
|
152
|
+
While proxitor runs, it prints a classified per-request cache line — `HIT` / `PARTIAL` / `MISS` / `COLD` / `NOUSAGE`, the hit percentage, the provider that served the request, and the request type (`[main]`/`[side]`) — so you can see at a glance whether caching is actually helping:
|
|
107
153
|
|
|
154
|
+
```text
|
|
155
|
+
[a1b2] HIT 99% read 48640 in 48874 glm-4.5-air [main]
|
|
108
156
|
```
|
|
109
|
-
|
|
110
|
-
|
|
157
|
+
|
|
158
|
+
See **Configuration → [Cache observability](./docs/configuration.md#cache-observability)** for the full label reference, the `observability:` config block, and enriched dumps.
|
|
111
159
|
|
|
112
160
|
Quick health poke: `curl http://localhost:8828/health`.
|
|
113
161
|
|
|
114
162
|
### Tuning the cache
|
|
115
163
|
|
|
116
|
-
If the cache hit looks low,
|
|
164
|
+
If the cache hit looks low, four levers fix it — tune them from `proxitor config` → **💾 Caching** (or `proxitor config cache`):
|
|
117
165
|
|
|
118
166
|
- **`cacheControl`** — inject `cache_control` to activate caching (Anthropic-native).
|
|
119
167
|
- **`sessionId`** — inject `session_id` so the provider pins from the first request.
|
|
@@ -125,15 +173,33 @@ See the [configuration reference](./docs/configuration.md#prompt-caching) for th
|
|
|
125
173
|
## Commands
|
|
126
174
|
|
|
127
175
|
| Command | Description |
|
|
128
|
-
|
|
176
|
+
| --- | --- |
|
|
129
177
|
| `proxitor` | Start the proxy (default command) |
|
|
130
178
|
| `proxitor config` | Interactive config menu |
|
|
131
179
|
| `proxitor config wizard` | Guided setup |
|
|
132
180
|
| `proxitor config browse` | Explore models + pricing |
|
|
181
|
+
| `proxitor config add` | Add a model override |
|
|
182
|
+
| `proxitor config edit` | Edit an existing model override |
|
|
183
|
+
| `proxitor config remove` | Remove a model override |
|
|
184
|
+
| `proxitor config list` | List all model overrides (also `--json`) |
|
|
185
|
+
| `proxitor config cache` | Tune prompt-caching settings |
|
|
186
|
+
| `proxitor config show` | Print the resolved config |
|
|
187
|
+
| `proxitor config validate` | Check the config (exit 0 ok, 1 invalid — CI-friendly) |
|
|
133
188
|
| `proxitor doctor` | Diagnose everything |
|
|
189
|
+
| `proxitor --version` | Print version |
|
|
134
190
|
| `proxitor --help` | Full list of flags |
|
|
135
191
|
|
|
136
|
-
Common flags: `--port`, `--host`, `--config <path>`, `--openrouter-key <key
|
|
192
|
+
Common flags: `--port`, `--host`, `--config <path>`, `--openrouter-key <key>` / `-k <key>`, `--verbose`, `--no-config`.
|
|
193
|
+
|
|
194
|
+
## Common pitfalls
|
|
195
|
+
|
|
196
|
+
**Cache reads stay at 0 even after several requests.** The prefix usually churns every turn (Claude Code's `cch`/`cc_version` hashes) — enable `normalizeVolatileSystem: true` and confirm the request actually lands on the same provider. `proxitor doctor` reports the loaded config; the cache-read log in the proxy console reports hits.
|
|
197
|
+
|
|
198
|
+
**Anthropic returns `400` about mixed TTLs when `cacheControlTtl: 1h`.** Set `rewriteBlockTtl: auto` (or `always`) to normalize the client's block-level `cache_control` breakpoints to the same TTL — see the [configuration reference](./docs/configuration.md#prompt-caching).
|
|
199
|
+
|
|
200
|
+
**The provider keeps switching between requests.** Make sure `sessionId` is not `skip` — both `auto` (default) and `always` inject a sticky session ID; without it OpenRouter only pins after the first cache hit.
|
|
201
|
+
|
|
202
|
+
**Config edits don't take effect.** They should — proxitor hot-reloads on save. If the file is invalid the proxy keeps the last valid config; `proxitor config validate` shows what was rejected.
|
|
137
203
|
|
|
138
204
|
## Contributing
|
|
139
205
|
|