自定义 Anthropic 端点改用 x-api-key 出示凭据
Project CI / AI game creator shell Rust crates (push) Successful in 1m56s
Project CI / AI game creator shell Rust lane 2/2 (push) Failing after 2m12s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m26s
Project CI / AI game creator shell Rust lane 1/2 (push) Failing after 4m5s
Project CI / Frontend tests (push) Successful in 3m26s
Project CI / Backend tests (push) Successful in 5m20s
Project CI / Repository checks (push) Successful in 3m26s
Project CI / AI game creator shell web tests (push) Successful in 2m8s
Project CI / Native shell tests (push) Successful in 7m43s
Project CI / AI game creator shell Rust crates (push) Successful in 1m56s
Project CI / AI game creator shell Rust lane 2/2 (push) Failing after 2m12s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m26s
Project CI / AI game creator shell Rust lane 1/2 (push) Failing after 4m5s
Project CI / Frontend tests (push) Successful in 3m26s
Project CI / Backend tests (push) Successful in 5m20s
Project CI / Repository checks (push) Successful in 3m26s
Project CI / AI game creator shell web tests (push) Successful in 2m8s
Project CI / Native shell tests (push) Successful in 7m43s
- claude_code_cli:custom 模型(用户自带 key 的 Claude 兼容端点)下把 key 放到 ANTHROPIC_API_KEY,让 Claude Code 走 Anthropic 规范的 x-api-key 头;官方模型仍走平台会话的 ANTHROPIC_AUTH_TOKEN - 依据:同一次 /v1/messages 请求,Router 只认 x-api-key 时返回 200,走 Authorization: Bearer 时会长时间不响应
This commit is contained in:
@@ -458,7 +458,14 @@ fn configure_claude_code_environment(
|
||||
&& std::env::var_os("ANTHROPIC_API_KEY").is_none()
|
||||
&& std::env::var_os("ANTHROPIC_AUTH_TOKEN").is_none()
|
||||
{
|
||||
command.env("ANTHROPIC_AUTH_TOKEN", llm.api_key.trim());
|
||||
if llm.custom_enabled {
|
||||
// 自定义 Claude 兼容端点用 Anthropic 规范的 `x-api-key`:Claude Code 只在
|
||||
// `ANTHROPIC_API_KEY` 下发这个头(`ANTHROPIC_AUTH_TOKEN` 会发 Bearer,实测
|
||||
// Router 的 `/v1/messages` 对 Bearer 会挂住不返回)。
|
||||
command.env("ANTHROPIC_API_KEY", llm.api_key.trim());
|
||||
} else {
|
||||
command.env("ANTHROPIC_AUTH_TOKEN", llm.api_key.trim());
|
||||
}
|
||||
}
|
||||
// Official AGC model entries use the account session rather than a
|
||||
// user-supplied API key. The Claude SDK only reads Anthropic auth
|
||||
|
||||
Reference in New Issue
Block a user