proxitor 0.14.0 → 0.16.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 +72 -8
- package/dist/cli.mjs +373 -174
- package/dist/cli.mjs.map +1 -1
- package/dist/prompt.mjs +3 -3
- package/dist/prompt.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.
|
|
@@ -89,12 +131,16 @@ proxitor config wizard # (re)run guided setup
|
|
|
89
131
|
proxitor config browse # explore models + pricing
|
|
90
132
|
```
|
|
91
133
|
|
|
92
|
-
From the menu you can set your API key and connection, pick routing per model (with live provider pricing), tune caching, and add or edit model overrides. It pulls live data from OpenRouter, so you browse real models and providers with up-to-date prices.
|
|
134
|
+
From the menu you can set your API key and connection, pick routing per model (with live provider pricing), tune caching, and add or edit model overrides. It pulls live data from OpenRouter, so you browse real models and providers with up-to-date prices. The model picker is **fuzzy** — type `claudops` to land on `anthropic/claude-opus`, `gpt4o` for `openai/gpt-4o`; matches rank by relevance so the best fit surfaces first.
|
|
93
135
|
|
|
94
136
|
<p align="center"><img src="./docs/assets/proxitor-add.gif" alt="proxitor: add a model override" width="640"></p>
|
|
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
|
|
@@ -105,7 +151,7 @@ It prints a clear report and exits non-zero if anything fails — handy from CI
|
|
|
105
151
|
|
|
106
152
|
While proxitor runs, it logs cache usage from upstream so you can see whether caching is actually helping:
|
|
107
153
|
|
|
108
|
-
```
|
|
154
|
+
```text
|
|
109
155
|
[abc123] Cache read: 50000, write: 25000 tokens (99.6% hit)
|
|
110
156
|
```
|
|
111
157
|
|
|
@@ -113,7 +159,7 @@ Quick health poke: `curl http://localhost:8828/health`.
|
|
|
113
159
|
|
|
114
160
|
### Tuning the cache
|
|
115
161
|
|
|
116
|
-
If the cache hit looks low,
|
|
162
|
+
If the cache hit looks low, four levers fix it — tune them from `proxitor config` → **💾 Caching** (or `proxitor config cache`):
|
|
117
163
|
|
|
118
164
|
- **`cacheControl`** — inject `cache_control` to activate caching (Anthropic-native).
|
|
119
165
|
- **`sessionId`** — inject `session_id` so the provider pins from the first request.
|
|
@@ -125,15 +171,33 @@ See the [configuration reference](./docs/configuration.md#prompt-caching) for th
|
|
|
125
171
|
## Commands
|
|
126
172
|
|
|
127
173
|
| Command | Description |
|
|
128
|
-
|
|
174
|
+
| --- | --- |
|
|
129
175
|
| `proxitor` | Start the proxy (default command) |
|
|
130
176
|
| `proxitor config` | Interactive config menu |
|
|
131
177
|
| `proxitor config wizard` | Guided setup |
|
|
132
178
|
| `proxitor config browse` | Explore models + pricing |
|
|
179
|
+
| `proxitor config add` | Add a model override |
|
|
180
|
+
| `proxitor config edit` | Edit an existing model override |
|
|
181
|
+
| `proxitor config remove` | Remove a model override |
|
|
182
|
+
| `proxitor config list` | List all model overrides (also `--json`) |
|
|
183
|
+
| `proxitor config cache` | Tune prompt-caching settings |
|
|
184
|
+
| `proxitor config show` | Print the resolved config |
|
|
185
|
+
| `proxitor config validate` | Check the config (exit 0 ok, 1 invalid — CI-friendly) |
|
|
133
186
|
| `proxitor doctor` | Diagnose everything |
|
|
187
|
+
| `proxitor --version` | Print version |
|
|
134
188
|
| `proxitor --help` | Full list of flags |
|
|
135
189
|
|
|
136
|
-
Common flags: `--port`, `--host`, `--config <path>`, `--openrouter-key <key
|
|
190
|
+
Common flags: `--port`, `--host`, `--config <path>`, `--openrouter-key <key>` / `-k <key>`, `--verbose`, `--no-config`.
|
|
191
|
+
|
|
192
|
+
## Common pitfalls
|
|
193
|
+
|
|
194
|
+
**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.
|
|
195
|
+
|
|
196
|
+
**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).
|
|
197
|
+
|
|
198
|
+
**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.
|
|
199
|
+
|
|
200
|
+
**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
201
|
|
|
138
202
|
## Contributing
|
|
139
203
|
|