@jacobbd/relay-ai 0.2.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/.cursor/rules/post-change-build-link.mdc +19 -0
- package/AGENTS.md +168 -0
- package/CHANGELOG.md +85 -0
- package/LICENSE +21 -0
- package/README.md +439 -0
- package/assets/banner.png +0 -0
- package/dist/cli.js +12599 -0
- package/package.json +79 -0
- package/scripts/refresh-models-dev-cache.mjs +34 -0
- package/vertex-models.example.json +14 -0
package/README.md
ADDED
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/banner.png" alt="relay-ai banner" width="100%">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# relay-ai
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
> Relay any model into any coding agent — launch tools, switch providers, and run local API gateways.
|
|
9
|
+
|
|
10
|
+
[](https://www.npmjs.com/package/relay-ai)
|
|
11
|
+
[](https://github.com/jacob-bd/relay-ai/blob/main/LICENSE)
|
|
12
|
+
[](https://buymeacoffee.com/jacobbd)
|
|
13
|
+
|
|
14
|
+
**relay-ai** is an interactive CLI that launches AI coding tools and runs Anthropic-compatible API gateways on your machine. Today that means **Claude Code** and **Claude Desktop (Cowork + Code)**. Tomorrow we'll add more agents.
|
|
15
|
+
|
|
16
|
+
Pick your backend:
|
|
17
|
+
|
|
18
|
+
- **Your providers** — configure once with `relay-ai providers` (Groq, Mistral, Nvidia, DeepSeek, custom OpenAI/Anthropic endpoints, and more)
|
|
19
|
+
- **OpenCode Zen / Go** — cloud models with your OpenCode API key (optional; add via `relay-ai providers`)
|
|
20
|
+
- **One-time OpenCode import** — bring existing OpenCode provider settings into the registry (`relay-ai providers import`)
|
|
21
|
+
- **Google Vertex AI** — Claude on Vertex via `relay-ai server --vertex` and local gcloud credentials (no OpenCode key required)
|
|
22
|
+
|
|
23
|
+
## Commands
|
|
24
|
+
|
|
25
|
+
| Command | Description |
|
|
26
|
+
|---------|-------------|
|
|
27
|
+
| `relay-ai` | Print help (does not launch Claude Code) |
|
|
28
|
+
| `relay-ai claude` | Pick a provider → launch Claude Code |
|
|
29
|
+
| `relay-ai providers` | Add, import, list, remove, and refresh your AI providers |
|
|
30
|
+
| `relay-ai models` | Manage favorite models for mid-session `/model` switching |
|
|
31
|
+
| `relay-ai server` | Foreground API gateway (registry providers + optional Zen/Go) |
|
|
32
|
+
| `relay-ai server --vertex` | Foreground Anthropic-compatible gateway to Claude on Vertex AI |
|
|
33
|
+
| `relay-ai codex` | Launch OpenAI Codex CLI with registry providers ([guide](docs/CODEX.md)) |
|
|
34
|
+
| `relay-ai --ai` | Full agent reference for scripts and alef-agent ([guide](docs/AI-AGENTS.md)) |
|
|
35
|
+
|
|
36
|
+
Bare `relay-ai` prints help and migration guidance. Use `relay-ai claude` for the wizard.
|
|
37
|
+
|
|
38
|
+
## Features
|
|
39
|
+
|
|
40
|
+
- **Native provider registry:** `relay-ai providers` stores config in `~/.relay-ai/providers.json` and secrets in the OS keychain — no OpenCode binary required at launch
|
|
41
|
+
- **Provider templates:** Add Groq, Mistral, Together, OpenRouter, and 15+ SDK-backed providers, plus custom OpenAI/Anthropic-compatible endpoints
|
|
42
|
+
- **OpenCode import:** One-time migration from OpenCode (`providers import`); validates API keys and skips placeholders like `anything`
|
|
43
|
+
- **OpenCode Zen / Go:** Optional cloud backends when you have an OpenCode API key
|
|
44
|
+
- **SDK adapter proxy:** Non-Anthropic providers route through the Vercel AI SDK (same packages OpenCode uses), so Claude Code still speaks Anthropic format. Labeled `(via proxy)` in the picker
|
|
45
|
+
- **Favorite models:** Save up to 20 and switch mid-session with Claude Code's `/model` command
|
|
46
|
+
- **Smart model pickers:** Recent models per provider, search for large lists (>25), paginated browse (15 per page)
|
|
47
|
+
- **Refresh model lists:** `relay-ai providers refresh-models` updates cached catalogs per provider
|
|
48
|
+
- **API server:** Run a local gateway on port **17645** for Claude Code, Claude Desktop, or any Anthropic-compatible client
|
|
49
|
+
- **Server wizard:** Filter exposed providers, mask discovery ids for Claude Desktop, optional favorites-only catalog, local vs network listen mode
|
|
50
|
+
- **Vertex gateway:** Anthropic-compatible Claude on Google Vertex AI using gcloud Application Default Credentials
|
|
51
|
+
- **Clean environment isolation:** We strip 17 conflicting env vars (Vertex AI, Bedrock, AWS, Foundry, stale Anthropic config) from the child process only. We never touch `~/.claude/settings.json` (see caveat below)
|
|
52
|
+
- **Secure key storage:** Per-provider keys and the OpenCode API key go in the OS credential store (macOS Keychain, Windows Credential Manager, Linux Secret Service) or your shell profile
|
|
53
|
+
- **Cross-platform:** macOS, Windows, Linux (Ubuntu, Fedora, distros with GNOME Keyring or KWallet)
|
|
54
|
+
- **Dry run mode:** Walk through the full wizard and preview the launch command without starting anything
|
|
55
|
+
- **Preference memory:** Last provider and model are pre-selected next time
|
|
56
|
+
- **Agent / headless launch:** Boot flags (`--provider`, `--model`), clean NDJSON/JSONL stdout for alef-agent, and `relay-ai --ai` reference — see **[docs/AI-AGENTS.md](docs/AI-AGENTS.md)**
|
|
57
|
+
|
|
58
|
+
## Supported tools
|
|
59
|
+
|
|
60
|
+
| Tool | Command | Status |
|
|
61
|
+
|------|---------|--------|
|
|
62
|
+
| Provider registry | `relay-ai providers` | ✅ Supported |
|
|
63
|
+
| Claude Code | `relay-ai claude` | ✅ Supported |
|
|
64
|
+
| Favorite models | `relay-ai models` | ✅ Supported |
|
|
65
|
+
| OpenCode API server | `relay-ai server` | ✅ Supported |
|
|
66
|
+
| Vertex API gateway | `relay-ai server --vertex` | ✅ Supported |
|
|
67
|
+
| Claude Desktop (Cowork + Code) | `relay-ai claude-app` | ✅ Supported macOS + Windows ([guide](docs/CLAUDE_DESKTOP_SETUP.md)) |
|
|
68
|
+
| Codex CLI | `relay-ai codex` | ✅ Supported ([guide](docs/CODEX.md)) |
|
|
69
|
+
| Codex desktop app | `relay-ai codex-app` | ✅ Supported macOS + Windows ([guide](docs/CODEX.md)) |
|
|
70
|
+
|
|
71
|
+
## Prerequisites
|
|
72
|
+
|
|
73
|
+
- Node.js 18+
|
|
74
|
+
- A supported AI coding tool installed (e.g. [Claude Code](https://www.npmjs.com/package/@anthropic-ai/claude-code))
|
|
75
|
+
- At least one provider configured via `relay-ai providers add` or `import` — **or** an [OpenCode API key](https://opencode.ai/auth) for Zen/Go cloud backends
|
|
76
|
+
- [OpenCode CLI](https://opencode.ai) only if you want **one-time import** from an existing OpenCode setup (optional)
|
|
77
|
+
- For **Vertex gateway:** [Google Cloud SDK](https://cloud.google.com/sdk) with `gcloud auth application-default login`, a GCP project with Vertex AI enabled, and Claude partner models enabled in that project
|
|
78
|
+
|
|
79
|
+
**A note on providers:** relay-ai keeps your provider list in `~/.relay-ai/providers.json`. You can add providers directly (API key + template), import from OpenCode once, or use Zen/Go cloud backends. OpenCode is not required after setup.
|
|
80
|
+
|
|
81
|
+
## Installation
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Install globally
|
|
85
|
+
npm install -g relay-ai
|
|
86
|
+
|
|
87
|
+
# Upgrade to the latest version
|
|
88
|
+
npm update -g relay-ai
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Setup
|
|
92
|
+
|
|
93
|
+
### Configure providers
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
relay-ai providers # hub: add, import, list, refresh models
|
|
97
|
+
relay-ai providers add # pick a template or custom endpoint
|
|
98
|
+
relay-ai providers import # one-time migration from OpenCode (optional)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
On first `relay-ai claude` run with an empty registry, an inline wizard walks you through Quick start (Zen), import, or opening `relay-ai providers`.
|
|
102
|
+
|
|
103
|
+
### OpenCode API key (Zen/Go only)
|
|
104
|
+
|
|
105
|
+
Grab your key at [opencode.ai/auth](https://opencode.ai/auth) if you use OpenCode Zen or Go (skip for registry-only or Vertex setups).
|
|
106
|
+
|
|
107
|
+
| Platform | Secure storage | Plaintext fallback |
|
|
108
|
+
|----------|---------------|-------------------|
|
|
109
|
+
| macOS | Keychain (optional: + `~/.zshrc` auto-load) | Shell profile |
|
|
110
|
+
| Windows | Credential Manager | `setx` user env var |
|
|
111
|
+
| Linux (desktop) | Secret Service (GNOME Keyring / KWallet) | Shell profile |
|
|
112
|
+
| Linux (headless) | n/a | Shell profile |
|
|
113
|
+
|
|
114
|
+
The key is active in your current session right away, no matter which option you pick. No terminal restart needed.
|
|
115
|
+
|
|
116
|
+
## Usage
|
|
117
|
+
|
|
118
|
+
### Launch Claude Code
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
relay-ai claude
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
First run: pick a provider from your registry (or complete the inline setup wizard). If you've added OpenCode Zen/Go, those appear alongside registry providers like Groq, Nvidia, or DeepSeek.
|
|
125
|
+
|
|
126
|
+
#### Favorite models and mid-session switching
|
|
127
|
+
|
|
128
|
+
Save the models you bounce between:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
relay-ai models
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Add up to 20 favorites from Zen, Go, or any OpenCode-configured provider. When you have favorites, `relay-ai claude` starts a multi-route proxy automatically. Claude Code's `/model` command lists your starting model plus favorites. Switch live, no restart.
|
|
135
|
+
|
|
136
|
+
No favorites? Launch works like before: single model, no switch menu. `--dry-run` ignores saved favorites so you can preview a single-model launch.
|
|
137
|
+
|
|
138
|
+
#### `relay-ai claude` options
|
|
139
|
+
|
|
140
|
+
| Flag | Description |
|
|
141
|
+
|------|-------------|
|
|
142
|
+
| `--dry-run` | Run the full wizard but preview the launch command instead of executing |
|
|
143
|
+
| `--setup` | Reminder to use `relay-ai providers` for provider setup |
|
|
144
|
+
| `--trace` | Write debug logs to `~/.relay-ai/logs/` and show errors on exit |
|
|
145
|
+
| `--help` | Show command help |
|
|
146
|
+
| `--version` | Show version |
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
relay-ai claude --dry-run
|
|
150
|
+
relay-ai claude --setup
|
|
151
|
+
relay-ai claude --trace
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Claude Code flags and session IDs pass through unchanged:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
relay-ai claude -c
|
|
158
|
+
relay-ai claude --resume abc-123
|
|
159
|
+
relay-ai claude abc-123
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Non-interactive / agent launch** — skip the wizard with boot flags:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
relay-ai claude --provider groq --model llama-3.3-70b-versatile -p "Summarize README.md"
|
|
166
|
+
relay-ai claude --model zen__deepseek-v4-flash-free -p "task" --output-format stream-json
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
| Flag | Description |
|
|
170
|
+
|------|-------------|
|
|
171
|
+
| `--provider` | Boot provider id (skip wizard with `--model` or in print mode) |
|
|
172
|
+
| `--model` | Boot model id, or slug `provider__model-id` |
|
|
173
|
+
|
|
174
|
+
For alef-agent, NDJSON streaming, Codex `exec --json`, and sandbox defaults, see **[docs/AI-AGENTS.md](docs/AI-AGENTS.md)** and run `relay-ai --ai`.
|
|
175
|
+
|
|
176
|
+
Use `--` when you want every following token passed directly to Claude Code:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
relay-ai claude -- --print "hello"
|
|
180
|
+
relay-ai claude -- --dangerously-skip-permissions
|
|
181
|
+
relay-ai claude --dry-run -- --print "test"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Server mode
|
|
185
|
+
|
|
186
|
+
Run relay-ai as a foreground API gateway on port **17645**:
|
|
187
|
+
|
|
188
|
+
| Mode | Command | Auth | Models |
|
|
189
|
+
|------|---------|------|--------|
|
|
190
|
+
| **Registry gateway** | `relay-ai server` | Per-provider keys in registry (+ OpenCode key for Zen/Go if exposed) | Providers you configured |
|
|
191
|
+
| **Vertex gateway** | `relay-ai server --vertex` | gcloud Application Default Credentials | Claude on Vertex AI |
|
|
192
|
+
|
|
193
|
+
> **Claude Desktop (Cowork + Code):** For the automated macOS/Windows setup, use `relay-ai claude-app`. For manual or network setups, see [docs/CLAUDE_DESKTOP_SETUP.md](docs/CLAUDE_DESKTOP_SETUP.md).
|
|
194
|
+
|
|
195
|
+
### Registry gateway (`relay-ai server`)
|
|
196
|
+
|
|
197
|
+
Works with any providers in your registry. Zen/Go models appear when you have an OpenCode API key and those providers are exposed.
|
|
198
|
+
|
|
199
|
+
The wizard asks:
|
|
200
|
+
|
|
201
|
+
| Prompt | What it does |
|
|
202
|
+
|--------|--------------|
|
|
203
|
+
| **Configure & start** vs **Start with saved settings** | Full wizard or reuse saved server preferences |
|
|
204
|
+
| **Exposed providers** | Limit which providers appear in the catalog (Zen, Go, Groq, OpenAI, etc.) |
|
|
205
|
+
| **Mask gateway model ids for discovery?** | Recommended **Yes** for Claude Desktop — hides competitor vendor strings in model ids so discovery works |
|
|
206
|
+
| **Expose only favorite models?** | Optional cap at your favorites (manage with `relay-ai models`) |
|
|
207
|
+
| **Listen mode** | **Local only** (`127.0.0.1`) or **Network** (`0.0.0.0` + server password) |
|
|
208
|
+
|
|
209
|
+
**Local mode** — point any Anthropic-compatible client at your machine:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
export ANTHROPIC_BASE_URL="http://127.0.0.1:17645/anthropic"
|
|
213
|
+
export ANTHROPIC_API_KEY="anything"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Network mode** — other devices on your LAN:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
export ANTHROPIC_BASE_URL="http://<server-ip>:17645/anthropic"
|
|
220
|
+
export ANTHROPIC_API_KEY="<server-password>"
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
By default the server password stays in memory only. If you choose to save it, relay-ai stores it in `~/.relay-ai/config.json`.
|
|
224
|
+
|
|
225
|
+
OpenAI-format models also get an OpenAI-compatible endpoint:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
export OPENAI_BASE_URL="http://127.0.0.1:17645/openai/v1"
|
|
229
|
+
export OPENAI_API_KEY="anything"
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Health check:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
curl -s http://127.0.0.1:17645/health
|
|
236
|
+
curl -s http://127.0.0.1:17645/anthropic/v1/models | head
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
The spinner reports how many models loaded and how many came from registry providers.
|
|
240
|
+
|
|
241
|
+
### Vertex gateway (`relay-ai server --vertex`)
|
|
242
|
+
|
|
243
|
+
Anthropic-compatible gateway to Claude on Google Vertex AI. No OpenCode API key required.
|
|
244
|
+
|
|
245
|
+
**Setup:**
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
gcloud auth application-default login
|
|
249
|
+
export ANTHROPIC_VERTEX_PROJECT_ID="your-gcp-project" # or GOOGLE_CLOUD_PROJECT
|
|
250
|
+
export GOOGLE_CLOUD_LOCATION="global" # optional; default: global
|
|
251
|
+
relay-ai server --vertex
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Default models:** `claude-sonnet-4-6`, `claude-opus-4-6`, `claude-haiku-4-5`
|
|
255
|
+
|
|
256
|
+
**Shorthand aliases** (for Claude Code `/model` and `settings.json`): `sonnet`, `opus`, `haiku`. Append `[1m]` for 1M context on Sonnet and Opus only (Haiku stays 200k).
|
|
257
|
+
|
|
258
|
+
**Custom catalog:** copy `vertex-models.example.json` to `~/.relay-ai/vertex-models.json` and edit. Override the config directory with `RELAY_AI_HOME`.
|
|
259
|
+
|
|
260
|
+
When the gateway is running:
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
export ANTHROPIC_BASE_URL="http://127.0.0.1:17645/anthropic"
|
|
264
|
+
export ANTHROPIC_API_KEY="anything"
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Claude Code tip:** When routing through the gateway, unset native Vertex env vars so Claude Code doesn't bypass the proxy:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
unset CLAUDE_CODE_USE_VERTEX ANTHROPIC_VERTEX_PROJECT_ID CLOUD_ML_REGION
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Codex CLI (`relay-ai codex`)
|
|
274
|
+
|
|
275
|
+
Launch [OpenAI Codex CLI](https://developers.openai.com/codex/cli) with registry providers. Requires `npm install -g @openai/codex`.
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
relay-ai providers add # Anthropic, xAI, OpenAI, etc.
|
|
279
|
+
relay-ai codex # pick provider + model → Codex TUI
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Claude Desktop app (`relay-ai claude-app`)
|
|
283
|
+
|
|
284
|
+
Launch **Claude Desktop** (macOS or Windows) with registry providers:
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
relay-ai claude-app
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
This command automates the "Third-Party Inference" (Developer Mode) setup. It temporarily configures Claude Desktop to point at a local gateway, launches the app, and routes traffic to your chosen provider.
|
|
291
|
+
|
|
292
|
+
- **Keep the terminal open:** The proxy runs in the foreground.
|
|
293
|
+
- **Ctrl+C to restore:** When you're done, press `Ctrl+C` in the terminal to automatically restore Claude Desktop to its normal Anthropic cloud mode.
|
|
294
|
+
- **Cleanup:** If the terminal crashes, run `relay-ai claude-app --restore`.
|
|
295
|
+
|
|
296
|
+
For manual network setups (e.g., remote cloud desktop), you can still use `relay-ai server`. See the full [Claude Desktop Setup Guide](docs/CLAUDE_DESKTOP_SETUP.md).
|
|
297
|
+
|
|
298
|
+
relay-ai writes a **temporary** profile (`~/.codex/relay-ai-launch.config.toml`) and removes it when Codex exits. After a crash: `relay-ai codex --restore`.
|
|
299
|
+
|
|
300
|
+
**Sandbox / network:** `relay-ai codex` defaults to **`danger-full-access`** (profile + `-s` flag) so shell tools like `curl`, `nlm`, and npm can reach the network. Override for one session:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
relay-ai codex -s workspace-write
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Pass Codex flags directly after `relay-ai codex` — you do **not** need `--` before `-s`. Codex’s `--dangerously-bypass-approvals-and-sandbox` also passes through if you need it.
|
|
307
|
+
|
|
308
|
+
Full details: **[docs/CODEX.md](docs/CODEX.md)** — CLI + desktop app, configs, restore, sandbox, routing.
|
|
309
|
+
|
|
310
|
+
For agent / alef-agent integration (boot flags, NDJSON, JSONL): **[docs/AI-AGENTS.md](docs/AI-AGENTS.md)** and `relay-ai --ai`.
|
|
311
|
+
|
|
312
|
+
### Codex desktop app (`relay-ai codex-app`)
|
|
313
|
+
|
|
314
|
+
Launch the **Codex app** (macOS or Windows) with registry providers:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
relay-ai codex-app
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Patches `~/.codex/config.toml` with backup; **Ctrl+C** in the relay-ai terminal restores your config. Tier 2 (Anthropic, etc.) requires keeping that terminal open. Preview config without writing: `relay-ai codex-app --config`. Recovery: `relay-ai codex-app --restore`.
|
|
321
|
+
|
|
322
|
+
See **[docs/CODEX.md](docs/CODEX.md)** for CLI vs app differences, file ownership, and troubleshooting.
|
|
323
|
+
|
|
324
|
+
**Reasoning effort:** Capable models show Codex's native reasoning picker (low/medium/high, etc.). relay-ai maps your choice to each provider's SDK options and preserves existing `model_reasoning_effort` in Codex config. Claude Code `/effort` and the `relay-ai server` gateway use the same mapping — see the [reasoning section in docs/CODEX.md](docs/CODEX.md#reasoning-effort).
|
|
325
|
+
|
|
326
|
+
## How it works
|
|
327
|
+
|
|
328
|
+
### OpenCode Zen / Go filtering
|
|
329
|
+
|
|
330
|
+
When OpenCode Zen is in your registry, `subscriptionFilter` controls which Zen models appear (`free` = free tier only; default = all Zen models). Add or change Zen via `relay-ai providers`.
|
|
331
|
+
|
|
332
|
+
### Environment isolation
|
|
333
|
+
|
|
334
|
+
When you launch, relay-ai builds a clean child environment:
|
|
335
|
+
|
|
336
|
+
1. Removes 17 conflicting env vars from the child process (Vertex AI, Bedrock, AWS, Foundry, stale Anthropic config)
|
|
337
|
+
2. Sets `ANTHROPIC_BASE_URL`, `ANTHROPIC_API_KEY`, and `ANTHROPIC_MODEL` for the session
|
|
338
|
+
3. Passes `--model <selected>` to Claude Code as a backup override
|
|
339
|
+
|
|
340
|
+
When Claude Code exits (normal exit, Ctrl+C, terminal close), your shell is unchanged. No cleanup step. No restore needed.
|
|
341
|
+
|
|
342
|
+
**Caveat: Claude Code persists the model.** relay-ai doesn't edit `~/.claude/settings.json`, but Claude Code saves the model you launched with (via `--model` and `ANTHROPIC_MODEL`). A later bare `claude` launch may still show that model, e.g. `anthropic-opencode-go__deepseek-v4-flash` from a prior relay-ai session. To get back to a first-party default, run `claude --model sonnet` (or your preferred Claude model), or remove the `"model"` key from `~/.claude/settings.json`. If you used the favorites switch menu, Claude Code may also cache the gateway catalog at `~/.claude/cache/gateway-models.json`. Delete that file if `/model` shows stale entries from a dead proxy.
|
|
343
|
+
|
|
344
|
+
### Model compatibility
|
|
345
|
+
|
|
346
|
+
OpenCode exposes models through different API formats. relay-ai handles them when it can:
|
|
347
|
+
|
|
348
|
+
| Model format | Examples | How it works | Label |
|
|
349
|
+
|---|---|---|---|
|
|
350
|
+
| Anthropic native | Claude, Qwen, MiniMax (Go) | Direct connection | *(none)* |
|
|
351
|
+
| OpenAI chat completions | DeepSeek, Kimi, MiMo, GLM, Grok, GPT-4o (OpenCode OpenAI provider) | SDK adapter proxy (Vercel AI SDK) | `via proxy` |
|
|
352
|
+
| OpenAI Responses API | GPT-5.4+, GPT-5.5, Codex, o-series (OpenCode OpenAI provider only) | Same proxy; SDK picks Responses API | `via proxy` |
|
|
353
|
+
| Gemini native | Gemini (OpenCode Google provider) | SDK adapter, Gemini native API | `via proxy` |
|
|
354
|
+
| Other SDK providers | Cerebras, Perplexity, Bedrock, Vertex, Together AI, etc. | Whatever `api.npm` OpenCode assigns | `via proxy` |
|
|
355
|
+
| Not in cloud wizard | GPT, Gemini on OpenCode Zen/Go | Use an OpenCode-configured provider instead (OpenAI/Google in OpenCode config) | `not yet supported` |
|
|
356
|
+
|
|
357
|
+
The SDK adapter proxy starts on a random local port for proxy-routed models and stops when Claude Code exits. Each `relay-ai claude` session gets its own port, so multiple terminals are fine. (`relay-ai server` uses fixed port `17645`. One server instance per machine.)
|
|
358
|
+
|
|
359
|
+
### Provider notes
|
|
360
|
+
|
|
361
|
+
**Mistral (free tier):** Rate limits are tight. Expect HTTP 429 during tool-heavy sessions. Claude Code retries with backoff. That's Mistral throttling, not a proxy bug.
|
|
362
|
+
|
|
363
|
+
**OpenAI (OpenCode-configured provider):** Configure OpenAI in [OpenCode](https://opencode.ai) with your API key, then pick the OpenAI provider at launch. Newer GPT models use OpenAI's Responses API. The SDK picks `responses` vs `chat` from the model ID. OpenCode catalog IDs can differ from API IDs (e.g. `gpt-5.5-fast` maps to upstream `gpt-5.5`). If you see "model not available", run `relay-ai claude --trace` and check `~/.relay-ai/logs/claude-debug.log`.
|
|
364
|
+
|
|
365
|
+
`CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1` is set for direct (non-proxy) routes only. Proxy sessions keep tool-search betas.
|
|
366
|
+
|
|
367
|
+
### API key storage
|
|
368
|
+
|
|
369
|
+
relay-ai uses [`@napi-rs/keyring`](https://www.npmjs.com/package/@napi-rs/keyring) for the OS credential store. On later runs it checks silently. Key found? Wizard skips the prompt.
|
|
370
|
+
|
|
371
|
+
| Platform | Credential store | Notes |
|
|
372
|
+
|----------|-----------------|-------|
|
|
373
|
+
| macOS | macOS Keychain | Optional `~/.zshrc` auto-load line for system-wide availability |
|
|
374
|
+
| Windows | Windows Credential Manager | `setx` available as plaintext alternative |
|
|
375
|
+
| Linux (desktop) | Secret Service API (GNOME Keyring, KWallet) | Needs a running keyring daemon |
|
|
376
|
+
| Linux (headless) | Not available | Falls back to shell profile or session-only |
|
|
377
|
+
|
|
378
|
+
If the native module fails to load, credential store options are skipped and you get shell profile / session-only storage.
|
|
379
|
+
|
|
380
|
+
## Configuration
|
|
381
|
+
|
|
382
|
+
**Provider registry** (no secrets in this file):
|
|
383
|
+
|
|
384
|
+
```text
|
|
385
|
+
~/.relay-ai/providers.json
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Manage with `relay-ai providers`. API keys are stored in the OS keychain (`keyring:provider:<id>`).
|
|
389
|
+
|
|
390
|
+
**App preferences** — favorites, last provider/model, server settings, optional server password:
|
|
391
|
+
|
|
392
|
+
```text
|
|
393
|
+
~/.relay-ai/config.json
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
Override the config directory:
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
export RELAY_AI_HOME="/path/to/your/relay-ai-home"
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
The OpenCode API key (for Zen/Go) and per-provider keys are stored separately, based on what you chose during setup (Keychain, credential store, or shell profile).
|
|
403
|
+
|
|
404
|
+
## Troubleshooting
|
|
405
|
+
|
|
406
|
+
See **[docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md)** for common issues — especially **“Not logged in”** after accidentally choosing **No** on Claude Code’s custom API key prompt.
|
|
407
|
+
|
|
408
|
+
## Upgrading from opencode-starter
|
|
409
|
+
|
|
410
|
+
If you used the old **opencode-starter** CLI, relay-ai migrates automatically on first run:
|
|
411
|
+
|
|
412
|
+
- Config moves from `~/.opencode-starter/` → `~/.relay-ai/`
|
|
413
|
+
- Legacy Keychain / credential-store entries are read and re-saved under `relay-ai`
|
|
414
|
+
- The CLI command is now `relay-ai` (not `opencode-starter`)
|
|
415
|
+
- Launch Claude Code with `relay-ai claude` (bare `relay-ai` prints help)
|
|
416
|
+
|
|
417
|
+
The deprecated `OPENCODE_STARTER_HOME` env var still works as a fallback for `RELAY_AI_HOME`.
|
|
418
|
+
|
|
419
|
+
## Contributing
|
|
420
|
+
|
|
421
|
+
Private beta right now. Issues and PRs welcome on GitHub.
|
|
422
|
+
|
|
423
|
+
## Disclaimer
|
|
424
|
+
|
|
425
|
+
This project and its creator have **no affiliation** with OpenCode, Anthropic, Claude, Google, or any other vendor named or integrated here. Trademarks belong to their respective owners.
|
|
426
|
+
|
|
427
|
+
relay-ai was built for **education and research**, and mostly for fun. It routes inference through services you configure yourself (OpenCode Zen/Go, OpenCode-configured providers, Vertex AI, and gateways you run locally). Use at your own risk.
|
|
428
|
+
|
|
429
|
+
## Vibe Coding Alert
|
|
430
|
+
|
|
431
|
+
Full transparency: this project was vibe coded with AI coding assistants. If you're an experienced developer, you might look at parts of this codebase and wince. That's okay.
|
|
432
|
+
|
|
433
|
+
The goal was to scratch an itch: launch Claude Code and Claude Desktop (Cowork + Code) against OpenCode backends and Vertex without fighting env vars, proxies, and model discovery. The code works. It's not corporate polish.
|
|
434
|
+
|
|
435
|
+
If something makes you cringe, open an issue or PR. Human expertise is irreplaceable. For the tone and spirit of this section, see [notebooklm-mcp-cli](https://github.com/jacob-bd/notebooklm-mcp-cli) on the same GitHub org.
|
|
436
|
+
|
|
437
|
+
## License
|
|
438
|
+
|
|
439
|
+
MIT
|
|
Binary file
|