Commit f9d17ae
authored
🤖 feat: allow Anthropic models to work with env vars (#768)
## Summary
Enables Anthropic models to work when credentials are configured via
environment variables instead of requiring explicit `providers.jsonc`
configuration.
### Changes
- Remove mandatory `apiKey` check in `providers.jsonc` for Anthropic
provider
- Support both `ANTHROPIC_API_KEY` and `ANTHROPIC_AUTH_TOKEN` env vars
- Auto-normalize base URLs to include `/v1` suffix (SDK expects it)
- Return structured `api_key_not_found` error when no credentials exist
anywhere
### Credential Resolution Order
1. `providers.jsonc` → `anthropic.apiKey`
2. `ANTHROPIC_API_KEY` env var (SDK reads automatically)
3. `ANTHROPIC_AUTH_TOKEN` env var (passed explicitly)
### Base URL Normalization
The Anthropic SDK expects base URLs to end with `/v1`. Users often
configure URLs without this suffix, so we now auto-append it:
- `https://api.anthropic.com` → `https://api.anthropic.com/v1`
- `https://api.anthropic.com/v1` → unchanged
_Generated with `mux`_1 parent 55f896b commit f9d17ae
File tree
5 files changed
+144
-9
lines changed- docs
- src
- common/utils/providers
- node/services
- tests/ipcMain
5 files changed
+144
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
18 | 39 | | |
19 | 40 | | |
20 | 41 | | |
| |||
258 | 279 | | |
259 | 280 | | |
260 | 281 | | |
261 | | - | |
| 282 | + | |
262 | 283 | | |
263 | 284 | | |
264 | 285 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
129 | | - | |
| 130 | + | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
106 | 124 | | |
107 | 125 | | |
108 | 126 | | |
| |||
290 | 308 | | |
291 | 309 | | |
292 | 310 | | |
293 | | - | |
294 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
295 | 323 | | |
296 | 324 | | |
297 | 325 | | |
298 | 326 | | |
299 | 327 | | |
300 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
301 | 345 | | |
302 | 346 | | |
303 | | - | |
| 347 | + | |
304 | 348 | | |
305 | 349 | | |
306 | 350 | | |
| |||
310 | 354 | | |
311 | 355 | | |
312 | 356 | | |
313 | | - | |
| 357 | + | |
314 | 358 | | |
315 | 359 | | |
316 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
| 229 | + | |
| 230 | + | |
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
| |||
241 | 242 | | |
242 | 243 | | |
243 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
244 | 256 | | |
245 | 257 | | |
246 | 258 | | |
| |||
256 | 268 | | |
257 | 269 | | |
258 | 270 | | |
| 271 | + | |
| 272 | + | |
259 | 273 | | |
260 | 274 | | |
261 | 275 | | |
262 | 276 | | |
263 | 277 | | |
| 278 | + | |
264 | 279 | | |
265 | 280 | | |
266 | 281 | | |
267 | 282 | | |
268 | 283 | | |
| 284 | + | |
269 | 285 | | |
270 | 286 | | |
271 | 287 | | |
272 | 288 | | |
273 | 289 | | |
274 | 290 | | |
275 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
276 | 298 | | |
277 | 299 | | |
278 | 300 | | |
| |||
0 commit comments