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,11 +28,19 @@ class AnthropicProvider(BaseProvider):
) -> Dict[str, Any]: ) -> Dict[str, Any]:
"""Generate response using Anthropic Messages API""" """Generate response using Anthropic Messages API"""
headers = { # OAuth tokens (sk-ant-oat*) use Bearer auth, regular keys use x-api-key
"Content-Type": "application/json", if self.api_key.startswith("sk-ant-oat"):
"x-api-key": self.api_key, headers = {
"anthropic-version": self.anthropic_version "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,
"anthropic-version": self.anthropic_version
}
payload = { payload = {
"model": self.model, "model": self.model,