copy() — anthropic-sdk-python Function Reference
Architecture documentation for the copy() function in _client.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD e4092c74_6e15_8d09_ed44_0aa689cf9aff["copy()"] 0fd89929_7b38_b43a_7bae_43e09dda2e19["AsyncAnthropic"] e4092c74_6e15_8d09_ed44_0aa689cf9aff -->|defined in| 0fd89929_7b38_b43a_7bae_43e09dda2e19 78959f31_800c_73ec_a45c_376fadc7e9e8["copy()"] 78959f31_800c_73ec_a45c_376fadc7e9e8 -->|calls| e4092c74_6e15_8d09_ed44_0aa689cf9aff 78959f31_800c_73ec_a45c_376fadc7e9e8["copy()"] e4092c74_6e15_8d09_ed44_0aa689cf9aff -->|calls| 78959f31_800c_73ec_a45c_376fadc7e9e8 style e4092c74_6e15_8d09_ed44_0aa689cf9aff fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/anthropic/_client.py lines 440–487
def copy(
self,
*,
api_key: str | None = None,
auth_token: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = not_given,
http_client: httpx.AsyncClient | None = None,
max_retries: int | NotGiven = not_given,
default_headers: Mapping[str, str] | None = None,
set_default_headers: Mapping[str, str] | None = None,
default_query: Mapping[str, object] | None = None,
set_default_query: Mapping[str, object] | None = None,
_extra_kwargs: Mapping[str, Any] = {},
) -> Self:
"""
Create a new client instance re-using the same options given to the current client with optional overriding.
"""
if default_headers is not None and set_default_headers is not None:
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
if default_query is not None and set_default_query is not None:
raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
headers = self._custom_headers
if default_headers is not None:
headers = {**headers, **default_headers}
elif set_default_headers is not None:
headers = set_default_headers
params = self._custom_query
if default_query is not None:
params = {**params, **default_query}
elif set_default_query is not None:
params = set_default_query
http_client = http_client or self._client
return self.__class__(
api_key=api_key or self.api_key,
auth_token=auth_token or self.auth_token,
base_url=base_url or self.base_url,
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
http_client=http_client,
max_retries=max_retries if is_given(max_retries) else self.max_retries,
default_headers=headers,
default_query=params,
**_extra_kwargs,
)
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does copy() do?
copy() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_client.py.
Where is copy() defined?
copy() is defined in src/anthropic/_client.py at line 440.
What does copy() call?
copy() calls 1 function(s): copy.
What calls copy()?
copy() is called by 1 function(s): copy.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free