@@ -65,7 +65,6 @@ class Codex(SyncAPIClient):
6565 with_streaming_response : CodexWithStreamedResponse
6666
6767 # client options
68- bearer_token : str | None
6968 api_key : str | None
7069 access_key : str | None
7170
@@ -74,7 +73,6 @@ class Codex(SyncAPIClient):
7473 def __init__ (
7574 self ,
7675 * ,
77- bearer_token : str | None = None ,
7876 api_key : str | None = None ,
7977 access_key : str | None = None ,
8078 environment : Literal ["production" , "staging" , "local" ] | NotGiven = NOT_GIVEN ,
@@ -100,14 +98,9 @@ def __init__(
10098 """Construct a new synchronous Codex client instance.
10199
102100 This automatically infers the following arguments from their corresponding environment variables if they are not provided:
103- - `bearer_token` from `CODEX_BEARER_TOKEN`
104101 - `api_key` from `CODEX_API_KEY`
105102 - `access_key` from `CODEX_ACCESS_KEY`
106103 """
107- if bearer_token is None :
108- bearer_token = os .environ .get ("CODEX_BEARER_TOKEN" )
109- self .bearer_token = bearer_token
110-
111104 if api_key is None :
112105 api_key = os .environ .get ("CODEX_API_KEY" )
113106 self .api_key = api_key
@@ -168,21 +161,12 @@ def qs(self) -> Querystring:
168161 @property
169162 @override
170163 def auth_headers (self ) -> dict [str , str ]:
171- if self ._http_bearer :
172- return self ._http_bearer
173164 if self ._authenticated_api_key :
174165 return self ._authenticated_api_key
175166 if self ._public_access_key :
176167 return self ._public_access_key
177168 return {}
178169
179- @property
180- def _http_bearer (self ) -> dict [str , str ]:
181- bearer_token = self .bearer_token
182- if bearer_token is None :
183- return {}
184- return {"Authorization" : f"Bearer { bearer_token } " }
185-
186170 @property
187171 def _authenticated_api_key (self ) -> dict [str , str ]:
188172 api_key = self .api_key
@@ -208,11 +192,6 @@ def default_headers(self) -> dict[str, str | Omit]:
208192
209193 @override
210194 def _validate_headers (self , headers : Headers , custom_headers : Headers ) -> None :
211- if self .bearer_token and headers .get ("Authorization" ):
212- return
213- if isinstance (custom_headers .get ("Authorization" ), Omit ):
214- return
215-
216195 if self .api_key and headers .get ("X-API-Key" ):
217196 return
218197 if isinstance (custom_headers .get ("X-API-Key" ), Omit ):
@@ -224,13 +203,12 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
224203 return
225204
226205 raise TypeError (
227- '"Could not resolve authentication method. Expected one of bearer_token, api_key or access_key to be set. Or for one of the `Authorization`, `X-API-Key` or `X-Access-Key` headers to be explicitly omitted"'
206+ '"Could not resolve authentication method. Expected either api_key or access_key to be set. Or for one of the `X-API-Key` or `X-Access-Key` headers to be explicitly omitted"'
228207 )
229208
230209 def copy (
231210 self ,
232211 * ,
233- bearer_token : str | None = None ,
234212 api_key : str | None = None ,
235213 access_key : str | None = None ,
236214 environment : Literal ["production" , "staging" , "local" ] | None = None ,
@@ -267,7 +245,6 @@ def copy(
267245
268246 http_client = http_client or self ._client
269247 return self .__class__ (
270- bearer_token = bearer_token or self .bearer_token ,
271248 api_key = api_key or self .api_key ,
272249 access_key = access_key or self .access_key ,
273250 base_url = base_url or self .base_url ,
@@ -327,7 +304,6 @@ class AsyncCodex(AsyncAPIClient):
327304 with_streaming_response : AsyncCodexWithStreamedResponse
328305
329306 # client options
330- bearer_token : str | None
331307 api_key : str | None
332308 access_key : str | None
333309
@@ -336,7 +312,6 @@ class AsyncCodex(AsyncAPIClient):
336312 def __init__ (
337313 self ,
338314 * ,
339- bearer_token : str | None = None ,
340315 api_key : str | None = None ,
341316 access_key : str | None = None ,
342317 environment : Literal ["production" , "staging" , "local" ] | NotGiven = NOT_GIVEN ,
@@ -362,14 +337,9 @@ def __init__(
362337 """Construct a new async Codex client instance.
363338
364339 This automatically infers the following arguments from their corresponding environment variables if they are not provided:
365- - `bearer_token` from `CODEX_BEARER_TOKEN`
366340 - `api_key` from `CODEX_API_KEY`
367341 - `access_key` from `CODEX_ACCESS_KEY`
368342 """
369- if bearer_token is None :
370- bearer_token = os .environ .get ("CODEX_BEARER_TOKEN" )
371- self .bearer_token = bearer_token
372-
373343 if api_key is None :
374344 api_key = os .environ .get ("CODEX_API_KEY" )
375345 self .api_key = api_key
@@ -430,21 +400,12 @@ def qs(self) -> Querystring:
430400 @property
431401 @override
432402 def auth_headers (self ) -> dict [str , str ]:
433- if self ._http_bearer :
434- return self ._http_bearer
435403 if self ._authenticated_api_key :
436404 return self ._authenticated_api_key
437405 if self ._public_access_key :
438406 return self ._public_access_key
439407 return {}
440408
441- @property
442- def _http_bearer (self ) -> dict [str , str ]:
443- bearer_token = self .bearer_token
444- if bearer_token is None :
445- return {}
446- return {"Authorization" : f"Bearer { bearer_token } " }
447-
448409 @property
449410 def _authenticated_api_key (self ) -> dict [str , str ]:
450411 api_key = self .api_key
@@ -470,11 +431,6 @@ def default_headers(self) -> dict[str, str | Omit]:
470431
471432 @override
472433 def _validate_headers (self , headers : Headers , custom_headers : Headers ) -> None :
473- if self .bearer_token and headers .get ("Authorization" ):
474- return
475- if isinstance (custom_headers .get ("Authorization" ), Omit ):
476- return
477-
478434 if self .api_key and headers .get ("X-API-Key" ):
479435 return
480436 if isinstance (custom_headers .get ("X-API-Key" ), Omit ):
@@ -486,13 +442,12 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
486442 return
487443
488444 raise TypeError (
489- '"Could not resolve authentication method. Expected one of bearer_token, api_key or access_key to be set. Or for one of the `Authorization`, `X-API-Key` or `X-Access-Key` headers to be explicitly omitted"'
445+ '"Could not resolve authentication method. Expected either api_key or access_key to be set. Or for one of the `X-API-Key` or `X-Access-Key` headers to be explicitly omitted"'
490446 )
491447
492448 def copy (
493449 self ,
494450 * ,
495- bearer_token : str | None = None ,
496451 api_key : str | None = None ,
497452 access_key : str | None = None ,
498453 environment : Literal ["production" , "staging" , "local" ] | None = None ,
@@ -529,7 +484,6 @@ def copy(
529484
530485 http_client = http_client or self ._client
531486 return self .__class__ (
532- bearer_token = bearer_token or self .bearer_token ,
533487 api_key = api_key or self .api_key ,
534488 access_key = access_key or self .access_key ,
535489 base_url = base_url or self .base_url ,
0 commit comments