@@ -56,6 +56,7 @@ class ContextualAI(SyncAPIClient):
5656
5757 # client options
5858 api_key : str
59+ is_snowflake : bool
5960
6061 def __init__ (
6162 self ,
@@ -97,6 +98,11 @@ def __init__(
9798 if base_url is None :
9899 base_url = f"https://api.contextual.ai/v1"
99100
101+ if 'snowflakecomputing.app' in str (base_url ):
102+ self .is_snowflake = True
103+ else :
104+ self .is_snowflake = False
105+
100106 super ().__init__ (
101107 version = __version__ ,
102108 base_url = base_url ,
@@ -123,7 +129,10 @@ def qs(self) -> Querystring:
123129 @override
124130 def auth_headers (self ) -> dict [str , str ]:
125131 api_key = self .api_key
126- return {"Authorization" : f"Bearer { api_key } " }
132+ if self .is_snowflake :
133+ return {"Authorization" : f"Snowflake Token={ api_key } " }
134+ else :
135+ return {"Authorization" : f"Bearer { api_key } " }
127136
128137 @property
129138 @override
@@ -228,6 +237,7 @@ class AsyncContextualAI(AsyncAPIClient):
228237
229238 # client options
230239 api_key : str
240+ is_snowflake : bool
231241
232242 def __init__ (
233243 self ,
@@ -269,6 +279,11 @@ def __init__(
269279 if base_url is None :
270280 base_url = f"https://api.contextual.ai/v1"
271281
282+ if 'snowflakecomputing.app' in str (base_url ):
283+ self .is_snowflake = True
284+ else :
285+ self .is_snowflake = False
286+
272287 super ().__init__ (
273288 version = __version__ ,
274289 base_url = base_url ,
@@ -295,7 +310,10 @@ def qs(self) -> Querystring:
295310 @override
296311 def auth_headers (self ) -> dict [str , str ]:
297312 api_key = self .api_key
298- return {"Authorization" : f"Bearer { api_key } " }
313+ if self .is_snowflake :
314+ return {"Authorization" : f"Snowflake Token={ api_key } " }
315+ else :
316+ return {"Authorization" : f"Bearer { api_key } " }
299317
300318 @property
301319 @override
0 commit comments