5656
5757class Replicate (SyncAPIClient ):
5858 # client options
59- api_key : str
59+ bearer_token : str
6060
6161 def __init__ (
6262 self ,
6363 * ,
64- api_key : str | None = None ,
64+ bearer_token : str | None = None ,
6565 base_url : str | httpx .URL | None = None ,
6666 timeout : Union [float , Timeout , None , NotGiven ] = NOT_GIVEN ,
6767 max_retries : int = DEFAULT_MAX_RETRIES ,
@@ -83,15 +83,15 @@ def __init__(
8383 ) -> None :
8484 """Construct a new synchronous Replicate client instance.
8585
86- This automatically infers the `api_key ` argument from the `REPLICATE_API_TOKEN` environment variable if it is not provided.
86+ This automatically infers the `bearer_token ` argument from the `REPLICATE_API_TOKEN` environment variable if it is not provided.
8787 """
88- if api_key is None :
89- api_key = os .environ .get ("REPLICATE_API_TOKEN" )
90- if api_key is None :
88+ if bearer_token is None :
89+ bearer_token = os .environ .get ("REPLICATE_API_TOKEN" )
90+ if bearer_token is None :
9191 raise ReplicateError (
92- "The api_key client option must be set either by passing api_key to the client or by setting the REPLICATE_API_TOKEN environment variable"
92+ "The bearer_token client option must be set either by passing bearer_token to the client or by setting the REPLICATE_API_TOKEN environment variable"
9393 )
94- self .api_key = api_key
94+ self .bearer_token = bearer_token
9595
9696 if base_url is None :
9797 base_url = os .environ .get ("REPLICATE_BASE_URL" )
@@ -179,8 +179,8 @@ def qs(self) -> Querystring:
179179 @property
180180 @override
181181 def auth_headers (self ) -> dict [str , str ]:
182- api_key = self .api_key
183- return {"Authorization" : f"Bearer { api_key } " }
182+ bearer_token = self .bearer_token
183+ return {"Authorization" : f"Bearer { bearer_token } " }
184184
185185 @property
186186 @override
@@ -194,7 +194,7 @@ def default_headers(self) -> dict[str, str | Omit]:
194194 def copy (
195195 self ,
196196 * ,
197- api_key : str | None = None ,
197+ bearer_token : str | None = None ,
198198 base_url : str | httpx .URL | None = None ,
199199 timeout : float | Timeout | None | NotGiven = NOT_GIVEN ,
200200 http_client : httpx .Client | None = None ,
@@ -228,7 +228,7 @@ def copy(
228228
229229 http_client = http_client or self ._client
230230 return self .__class__ (
231- api_key = api_key or self .api_key ,
231+ bearer_token = bearer_token or self .bearer_token ,
232232 base_url = base_url or self .base_url ,
233233 timeout = self .timeout if isinstance (timeout , NotGiven ) else timeout ,
234234 http_client = http_client ,
@@ -278,12 +278,12 @@ def _make_status_error(
278278
279279class AsyncReplicate (AsyncAPIClient ):
280280 # client options
281- api_key : str
281+ bearer_token : str
282282
283283 def __init__ (
284284 self ,
285285 * ,
286- api_key : str | None = None ,
286+ bearer_token : str | None = None ,
287287 base_url : str | httpx .URL | None = None ,
288288 timeout : Union [float , Timeout , None , NotGiven ] = NOT_GIVEN ,
289289 max_retries : int = DEFAULT_MAX_RETRIES ,
@@ -305,15 +305,15 @@ def __init__(
305305 ) -> None :
306306 """Construct a new async AsyncReplicate client instance.
307307
308- This automatically infers the `api_key ` argument from the `REPLICATE_API_TOKEN` environment variable if it is not provided.
308+ This automatically infers the `bearer_token ` argument from the `REPLICATE_API_TOKEN` environment variable if it is not provided.
309309 """
310- if api_key is None :
311- api_key = os .environ .get ("REPLICATE_API_TOKEN" )
312- if api_key is None :
310+ if bearer_token is None :
311+ bearer_token = os .environ .get ("REPLICATE_API_TOKEN" )
312+ if bearer_token is None :
313313 raise ReplicateError (
314- "The api_key client option must be set either by passing api_key to the client or by setting the REPLICATE_API_TOKEN environment variable"
314+ "The bearer_token client option must be set either by passing bearer_token to the client or by setting the REPLICATE_API_TOKEN environment variable"
315315 )
316- self .api_key = api_key
316+ self .bearer_token = bearer_token
317317
318318 if base_url is None :
319319 base_url = os .environ .get ("REPLICATE_BASE_URL" )
@@ -401,8 +401,8 @@ def qs(self) -> Querystring:
401401 @property
402402 @override
403403 def auth_headers (self ) -> dict [str , str ]:
404- api_key = self .api_key
405- return {"Authorization" : f"Bearer { api_key } " }
404+ bearer_token = self .bearer_token
405+ return {"Authorization" : f"Bearer { bearer_token } " }
406406
407407 @property
408408 @override
@@ -416,7 +416,7 @@ def default_headers(self) -> dict[str, str | Omit]:
416416 def copy (
417417 self ,
418418 * ,
419- api_key : str | None = None ,
419+ bearer_token : str | None = None ,
420420 base_url : str | httpx .URL | None = None ,
421421 timeout : float | Timeout | None | NotGiven = NOT_GIVEN ,
422422 http_client : httpx .AsyncClient | None = None ,
@@ -450,7 +450,7 @@ def copy(
450450
451451 http_client = http_client or self ._client
452452 return self .__class__ (
453- api_key = api_key or self .api_key ,
453+ bearer_token = bearer_token or self .bearer_token ,
454454 base_url = base_url or self .base_url ,
455455 timeout = self .timeout if isinstance (timeout , NotGiven ) else timeout ,
456456 http_client = http_client ,
0 commit comments