Skip to content

Commit 610353e

Browse files
committed
revert: remove unrelated api_token changes from PR
This PR should only contain the legacy exception compatibility aliases. The api_token parameter support is unrelated and should be in a separate PR.
1 parent 018ccb3 commit 610353e

File tree

2 files changed

+0
-130
lines changed

2 files changed

+0
-130
lines changed

src/replicate/_client.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ def __init__(
102102
self,
103103
*,
104104
bearer_token: str | None = None,
105-
api_token: str | None = None, # Legacy compatibility parameter
106105
base_url: str | httpx.URL | None = None,
107106
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
108107
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -125,17 +124,7 @@ def __init__(
125124
"""Construct a new synchronous Replicate client instance.
126125
127126
This automatically infers the `bearer_token` argument from the `REPLICATE_API_TOKEN` environment variable if it is not provided.
128-
129-
For legacy compatibility, you can also pass `api_token` instead of `bearer_token`.
130127
"""
131-
# Handle legacy api_token parameter
132-
if api_token is not None and bearer_token is not None:
133-
raise ReplicateError(
134-
"Cannot specify both 'bearer_token' and 'api_token'. Please use 'bearer_token' (recommended) or 'api_token' for legacy compatibility."
135-
)
136-
if api_token is not None:
137-
bearer_token = api_token
138-
139128
if bearer_token is None:
140129
bearer_token = _get_api_token_from_environment()
141130
if bearer_token is None:
@@ -334,7 +323,6 @@ def use(
334323
def copy(
335324
self,
336325
*,
337-
api_token: str | None = None,
338326
bearer_token: str | None = None,
339327
base_url: str | httpx.URL | None = None,
340328
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
@@ -349,15 +337,6 @@ def copy(
349337
"""
350338
Create a new client instance re-using the same options given to the current client with optional overriding.
351339
"""
352-
# Handle api_token as legacy alias for bearer_token
353-
if api_token is not None and bearer_token is not None:
354-
raise ValueError(
355-
"Cannot provide both api_token and bearer_token parameters. "
356-
"Use bearer_token (api_token is deprecated)."
357-
)
358-
if api_token is not None:
359-
bearer_token = api_token
360-
361340
if default_headers is not None and set_default_headers is not None:
362341
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
363342

@@ -498,7 +477,6 @@ def __init__(
498477
self,
499478
*,
500479
bearer_token: str | None = None,
501-
api_token: str | None = None, # Legacy compatibility parameter
502480
base_url: str | httpx.URL | None = None,
503481
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
504482
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -521,17 +499,7 @@ def __init__(
521499
"""Construct a new async AsyncReplicate client instance.
522500
523501
This automatically infers the `bearer_token` argument from the `REPLICATE_API_TOKEN` environment variable if it is not provided.
524-
525-
For legacy compatibility, you can also pass `api_token` instead of `bearer_token`.
526502
"""
527-
# Handle legacy api_token parameter
528-
if api_token is not None and bearer_token is not None:
529-
raise ReplicateError(
530-
"Cannot specify both 'bearer_token' and 'api_token'. Please use 'bearer_token' (recommended) or 'api_token' for legacy compatibility."
531-
)
532-
if api_token is not None:
533-
bearer_token = api_token
534-
535503
if bearer_token is None:
536504
bearer_token = _get_api_token_from_environment()
537505
if bearer_token is None:
@@ -730,7 +698,6 @@ def use(
730698
def copy(
731699
self,
732700
*,
733-
api_token: str | None = None,
734701
bearer_token: str | None = None,
735702
base_url: str | httpx.URL | None = None,
736703
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
@@ -745,15 +712,6 @@ def copy(
745712
"""
746713
Create a new client instance re-using the same options given to the current client with optional overriding.
747714
"""
748-
# Handle api_token as legacy alias for bearer_token
749-
if api_token is not None and bearer_token is not None:
750-
raise ValueError(
751-
"Cannot provide both api_token and bearer_token parameters. "
752-
"Use bearer_token (api_token is deprecated)."
753-
)
754-
if api_token is not None:
755-
bearer_token = api_token
756-
757715
if default_headers is not None and set_default_headers is not None:
758716
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
759717

tests/test_api_token_compatibility.py

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)