You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-8Lines changed: 26 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
<p><strong>Stop rewiring your AI tools every time an account hits quota.</strong></p>
5
5
<p>
6
6
A macOS menu-bar router that puts your connected accounts, models,
7
-
API keys, and fallback routes behind one local chat-completions endpoint.
7
+
API keys, and fallback routes behind one local endpoint.
8
8
</p>
9
9
<p>
10
10
<a href="https://rerouted.dev">Website</a> |
@@ -31,7 +31,7 @@
31
31
32
32
Your editor should not need to know which account still has quota, which provider is having a bad morning, or which model you want to try next.
33
33
34
-
ReRouted gives compatible chat-completions clients the same local contract:
34
+
ReRouted gives compatible OpenAI and Anthropic clients the same local contract:
35
35
36
36
```text
37
37
Base URL http://127.0.0.1:4949/v1
@@ -41,7 +41,7 @@ Model coding
41
41
42
42
`coding` is a route you own. Put your preferred model first, another account second, and a backup provider third. When an upstream rate-limits, times out, or returns a retryable failure before output begins, ReRouted advances through the route without changing the URL or model name your client uses.
43
43
44
-
The promise is deliberately focused: ReRouted exposes model discovery and OpenAI-style chat completions. It is a routing layer, not a clone of every OpenAI API.
44
+
The promise is deliberately focused: ReRouted exposes model discovery, OpenAI-style chat completions and Responses requests, plus Anthropic Messages compatibility for Claude Code and similar clients. It is a routing layer, not a clone of either platform API.
45
45
46
46
## Why ReRouted exists
47
47
@@ -60,7 +60,7 @@ No hosted control plane. No account with ReRouted. No Dock icon. The gateway and
60
60
```text
61
61
editor / agent / script
62
62
|
63
-
| POST /v1/chat/completions
63
+
| POST /v1/chat/completions or /v1/messages
64
64
| model: "coding"
65
65
v
66
66
127.0.0.1:4949/v1
@@ -72,7 +72,7 @@ No hosted control plane. No account with ReRouted. No Dock icon. The gateway and
-d '{"model":"coding","messages":[{"role":"user","content":"Say hello in three words."}]}'
135
135
```
136
136
137
-
Then enter the same base URL, gateway key, and route name in a configurable client that supports OpenAI-style chat completions. Setting names vary by client. Switch providers, accounts, models, and route order inside ReRouted; leave the client configuration alone.
137
+
Then enter the same base URL, gateway key, and route name in a configurable OpenAI-style client. Setting names vary by client. Switch providers, accounts, models, and route order inside ReRouted; leave the client configuration alone.
138
+
139
+
Claude Code uses the Anthropic Messages route. Point it at the gateway with its generated key and map each alias to a ReRouted model or named route:
140
+
141
+
```json
142
+
{
143
+
"env": {
144
+
"ANTHROPIC_BASE_URL": "http://127.0.0.1:4949/v1",
145
+
"ANTHROPIC_AUTH_TOKEN": "rr-your-generated-key",
146
+
"ANTHROPIC_DEFAULT_OPUS_MODEL": "coding",
147
+
"ANTHROPIC_DEFAULT_SONNET_MODEL": "coding",
148
+
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "fast"
149
+
}
150
+
}
151
+
```
152
+
153
+
ReRouted accepts both `/v1/messages` and `/v1/v1/messages`, so current Claude Code versions work whether they append `/messages` or `/v1/messages` to that base URL.
138
154
139
155
## The menu-bar control plane
140
156
@@ -161,8 +177,10 @@ The gateway continues running when the panel is hidden. Quitting ReRouted stops
161
177
|`GET /v1/models`| Enabled direct models and named routes |
162
178
|`POST /v1/chat/completions`| Streaming or non-streaming routed chat completions |
163
179
|`POST /v1/responses`| Streaming or non-streaming routed Responses API requests |
180
+
|`POST /v1/messages`| Streaming or non-streaming Anthropic Messages requests |
181
+
|`POST /v1/messages/count_tokens`| Local best-effort Anthropic input-token estimate |
164
182
165
-
Requests require a generated bearer key except for `/` and `/health`. OpenAI-style image inputs inside chat-completion messages are supported when the selected upstream model accepts them. The separate `/v1/images` generation API, embeddings, audio, and the rest of the OpenAI platform API are outside ReRouted's scope.
183
+
Requests require a generated gateway key except for `/` and `/health`. OpenAI routes accept `Authorization: Bearer`; Anthropic routes accept that header or `x-api-key`. OpenAI-style image inputs inside chat-completion messages and Anthropic image blocks are supported when the selected upstream model accepts them. The separate `/v1/images` generation API, embeddings, audio, Anthropic Batches, and the rest of both platform APIs are outside ReRouted's scope.
166
184
167
185
## Local-first, with the boundaries stated plainly
168
186
@@ -207,7 +225,7 @@ The implementation is intentionally small: Electron, Node's built-in HTTP server
207
225
208
226
## Current release
209
227
210
-
ReRouted `0.4.7` accepts the standalone authorization code shown by xAI while preserving callback-state validation and PKCE binding. The xAI connection panel now presents the code field directly instead of hiding it under troubleshooting. Public builds are Developer ID signed, notarized, stapled, and distributed through stable GitHub Releases with in-app updates. The public API is intentionally limited to health, model discovery, and chat completions; a published third-party client compatibility matrix is still forthcoming.
228
+
Public builds are Developer ID signed, notarized, stapled, and distributed through stable GitHub Releases with in-app updates. The public API is intentionally limited to health, model discovery, chat completions, Responses, and Anthropic Messages compatibility; a published third-party client compatibility matrix is still forthcoming.
|`POST /v1/responses`| Bearer key | Responses requests adapted through the chat-completions router |
54
+
|`POST /v1/messages`| Bearer key or `x-api-key`| Anthropic Messages requests adapted through the chat-completions router |
55
+
|`POST /v1/messages/count_tokens`| Bearer key or `x-api-key`| Local best-effort input-token estimate without an upstream request |
54
56
55
57
The default bind is `127.0.0.1:4949`. Settings can switch the host to `0.0.0.0` for LAN or Tailscale access. CORS is currently `*`, so the bearer key is the gateway's access boundary when network binding is enabled.
56
58
57
59
JSON request bodies are limited to 32 MiB. Oversized requests receive a JSON `413` response before routing begins.
58
60
61
+
Anthropic Messages requests are normalized into the same internal OpenAI chat-completions shape used by the router, so account pools, named routes, retries, fallback, round robin, activity, and usage all follow the existing path. Responses are converted back to Anthropic JSON or SSE, including text, tool use, tool results, stop reasons, and token usage. Native Claude thinking, signatures, cache-control blocks, and stop sequences are preserved in memory when a Messages request routes back to Claude, while the private metadata is not serialized to non-Claude providers. Both `/v1/messages` and the duplicate-prefix `/v1/v1/messages` form are accepted for compatibility with Claude Code versions and base-URL conventions that each add `/v1`.
62
+
59
63
## Model IDs and routes
60
64
61
65
Provider model IDs are generated by `src/lib/providers/index.js`. Custom OpenAI-compatible connections use the readable form `<connection name>/custom/<upstream model>` while legacy hash-qualified IDs remain resolvable. A direct model resolves to one enabled provider/model pair.
0 commit comments