mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
fix: Claude API 模型列表查询兼容 Bearer Token 认证
第三方代理可能使用 Bearer Token 而非 x-api-key 认证, 在请求头中同时发送两种认证方式以提高兼容性。
This commit is contained in:
@@ -160,8 +160,12 @@ class ClaudeChatAdapter(ChatAdapterBase):
|
||||
api_key: str,
|
||||
extra_headers: dict[str, str] | None = None,
|
||||
) -> tuple[list, str | None]:
|
||||
"""查询 Claude API 支持的模型列表(使用 x-api-key 认证)"""
|
||||
"""查询 Claude API 支持的模型列表(兼容 x-api-key 和 Bearer 认证)"""
|
||||
headers = cls.build_headers_with_extra(api_key, extra_headers)
|
||||
# 兼容第三方提供商:同时发送 Authorization: Bearer 认证头
|
||||
# 官方 Claude API 使用 x-api-key,第三方代理可能使用 Bearer Token
|
||||
if "authorization" not in {k.lower() for k in headers}:
|
||||
headers["Authorization"] = f"Bearer {api_key}"
|
||||
return await cls._fetch_models_paginated(client, base_url, headers, cls.FORMAT_ID)
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user