Support OAuth tokens (sk-ant-oat*) with Bearer auth

This commit is contained in:
Markov 2026-02-23 10:03:26 +01:00
parent 3ccce3eae6
commit 911bfe78b1

View File

@ -28,6 +28,14 @@ class AnthropicProvider(BaseProvider):
) -> Dict[str, Any]:
"""Generate response using Anthropic Messages API"""
# OAuth tokens (sk-ant-oat*) use Bearer auth, regular keys use x-api-key
if self.api_key.startswith("sk-ant-oat"):
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {self.api_key}",
"anthropic-version": self.anthropic_version
}
else:
headers = {
"Content-Type": "application/json",
"x-api-key": self.api_key,