Fix auth headers for z.ai - remove Bearer prefix

This commit is contained in:
Thomas
2025-12-28 22:59:32 -05:00
parent 21b71d86a7
commit 55248216b6

View File

@@ -171,7 +171,7 @@ class AnthropicAPIClient(LocalLLMClient):
# For compatible APIs, use dummy key and set auth via headers # For compatible APIs, use dummy key and set auth via headers
kwargs["api_key"] = "dummy-key-for-sdk" kwargs["api_key"] = "dummy-key-for-sdk"
kwargs["default_headers"] = { kwargs["default_headers"] = {
"Authorization": f"Bearer {self.api_key}", "Authorization": self.api_key, # No "Bearer" prefix for z.ai compatibility
"x-api-key": self.api_key, "x-api-key": self.api_key,
} }
else: else:
@@ -212,8 +212,8 @@ class AnthropicAPIClient(LocalLLMClient):
# For compatible APIs, use dummy key and set auth via headers # For compatible APIs, use dummy key and set auth via headers
kwargs["api_key"] = "dummy-key-for-sdk" kwargs["api_key"] = "dummy-key-for-sdk"
kwargs["default_headers"] = { kwargs["default_headers"] = {
"Authorization": f"Bearer {api_key}", "Authorization": api_key, # No "Bearer" prefix for z.ai compatibility
"x-api-key": api_key, # Also try Anthropic's native header "x-api-key": api_key,
} }
else: else:
kwargs["api_key"] = api_key kwargs["api_key"] = api_key