mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-09-02 01:20:23 +08:00
fix(anthropic): support ANTHROPIC_AUTH_TOKEN as alternative to ANTHROPIC_API_KEY (#853)
* fix(anthropic): support ANTHROPIC_AUTH_TOKEN as alternative to ANTHROPIC_API_KEY Anthropic SDK supports two mutually exclusive auth methods: apiKey (sent as x-api-key header) and authToken (sent as Authorization: Bearer header). Detect either env var during provider detection and credential validation, and pass authToken to createAnthropic when only ANTHROPIC_AUTH_TOKEN is set. * docs(anthropic): document ANTHROPIC_AUTH_TOKEN and refine error message - Add ANTHROPIC_AUTH_TOKEN to env.example and the en/cn/ja provider docs - Reword the missing-credential error to "Either ... or ..." for readability --------- Co-authored-by: duyunjie <duyunjie@zhuanzhuan.com> Co-authored-by: dayuan.jiang <jdy.toh@gmail.com>
This commit is contained in:
@@ -68,6 +68,13 @@ ANTHROPIC_API_KEY=your_api_key
|
||||
AI_MODEL=claude-sonnet-4-5-20250514
|
||||
```
|
||||
|
||||
Or use a Bearer auth token instead of an API key (e.g. when going through a gateway that issues OAuth-style tokens). `ANTHROPIC_AUTH_TOKEN` is sent as `Authorization: Bearer <token>`, while `ANTHROPIC_API_KEY` is sent as `x-api-key`. The two are mutually exclusive — set only one:
|
||||
|
||||
```bash
|
||||
ANTHROPIC_AUTH_TOKEN=your_auth_token
|
||||
AI_MODEL=claude-sonnet-4-5-20250514
|
||||
```
|
||||
|
||||
Optional custom endpoint:
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user