@@ -335,6 +335,7 @@ def copy(
335335 self ,
336336 * ,
337337 bearer_token : str | None = None ,
338+ api_token : str | None = None , # Legacy compatibility parameter
338339 base_url : str | httpx .URL | None = None ,
339340 timeout : float | Timeout | None | NotGiven = NOT_GIVEN ,
340341 http_client : httpx .Client | None = None ,
@@ -347,7 +348,17 @@ def copy(
347348 ) -> Self :
348349 """
349350 Create a new client instance re-using the same options given to the current client with optional overriding.
351+
352+ For legacy compatibility, you can also pass `api_token` instead of `bearer_token`.
350353 """
354+ # Handle legacy api_token parameter
355+ if api_token is not None and bearer_token is not None :
356+ raise ValueError (
357+ "Cannot specify both 'bearer_token' and 'api_token'. Please use 'bearer_token' (recommended) or 'api_token' for legacy compatibility."
358+ )
359+ if api_token is not None :
360+ bearer_token = api_token
361+
351362 if default_headers is not None and set_default_headers is not None :
352363 raise ValueError ("The `default_headers` and `set_default_headers` arguments are mutually exclusive" )
353364
@@ -721,6 +732,7 @@ def copy(
721732 self ,
722733 * ,
723734 bearer_token : str | None = None ,
735+ api_token : str | None = None , # Legacy compatibility parameter
724736 base_url : str | httpx .URL | None = None ,
725737 timeout : float | Timeout | None | NotGiven = NOT_GIVEN ,
726738 http_client : httpx .AsyncClient | None = None ,
@@ -733,7 +745,17 @@ def copy(
733745 ) -> Self :
734746 """
735747 Create a new client instance re-using the same options given to the current client with optional overriding.
748+
749+ For legacy compatibility, you can also pass `api_token` instead of `bearer_token`.
736750 """
751+ # Handle legacy api_token parameter
752+ if api_token is not None and bearer_token is not None :
753+ raise ValueError (
754+ "Cannot specify both 'bearer_token' and 'api_token'. Please use 'bearer_token' (recommended) or 'api_token' for legacy compatibility."
755+ )
756+ if api_token is not None :
757+ bearer_token = api_token
758+
737759 if default_headers is not None and set_default_headers is not None :
738760 raise ValueError ("The `default_headers` and `set_default_headers` arguments are mutually exclusive" )
739761
0 commit comments