From 911bfe78b1441c2e90e09d1dfa895393e2cd3c55 Mon Sep 17 00:00:00 2001 From: Markov Date: Mon, 23 Feb 2026 10:03:26 +0100 Subject: [PATCH] Support OAuth tokens (sk-ant-oat*) with Bearer auth --- picogent/providers/anthropic.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/picogent/providers/anthropic.py b/picogent/providers/anthropic.py index a94887b..3b75bd8 100644 --- a/picogent/providers/anthropic.py +++ b/picogent/providers/anthropic.py @@ -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,