Support OAuth tokens (sk-ant-oat*) with Bearer auth
This commit is contained in:
parent
3ccce3eae6
commit
911bfe78b1
@ -28,11 +28,19 @@ class AnthropicProvider(BaseProvider):
|
||||
) -> Dict[str, Any]:
|
||||
"""Generate response using Anthropic Messages API"""
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"x-api-key": self.api_key,
|
||||
"anthropic-version": self.anthropic_version
|
||||
}
|
||||
# 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,
|
||||
"anthropic-version": self.anthropic_version
|
||||
}
|
||||
|
||||
payload = {
|
||||
"model": self.model,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user