Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/anthropics/anthropic-sdk-python
/ functions
Functions
6,399 in github.com/anthropics/anthropic-sdk-python
⨍
Functions
6,399
◇
Types & classes
2,012
↳
Endpoints
17
↓ 4 callers
Function
_apply_hop
`entry` applied as a patch against `body`: a field set to a value overrides it, a field explicitly `None` unsets it (absent from the retried r
src/anthropic/lib/middleware/_fallbacks.py:1465
↓ 4 callers
Function
_assert_credential_chain_off
(client: AnthropicGoogleCloud | AsyncAnthropicGoogleCloud)
tests/lib/test_google_cloud.py:942
↓ 4 callers
Function
_assert_exchanged_and_called_own_deployment
The traffic seen by ``base_url`` is exactly one exchange followed by one request bearing the token that exchange minted.
tests/lib/test_credentials.py:1996
↓ 4 callers
Function
_async_secure_mkdir
(path: AsyncPath, mode: int = _DIR_CREATE_MODE)
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:656
↓ 4 callers
Method
_calculate_retry_timeout
( self, remaining_retries: int, options: FinalRequestOptions, response_headers
src/anthropic/_base_client.py:797
↓ 4 callers
Function
_count
(respx_mock: MockRouter)
tests/lib/test_output_format_helpers.py:19
↓ 4 callers
Function
_format_file_size
(bytes_size: int)
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:372
↓ 4 callers
Function
_get_open_connections
(client: Anthropic | AsyncAnthropic)
tests/test_client.py:107
↓ 4 callers
Function
_get_weather
(location: str, units: Literal["c", "f"])
tests/lib/tools/test_runners.py:1441
↓ 4 callers
Method
_item
(self, path: str, *, view: str = "full")
tests/lib/tools/memory_sync/_fake_anthropic.py:96
↓ 4 callers
Function
_json_dumps
(value: Any)
src/anthropic/lib/middleware/_fallbacks.py:1515
↓ 4 callers
Function
_last_body
(respx_mock: MockRouter)
tests/lib/test_output_format_helpers.py:23
↓ 4 callers
Function
_merge_output_configs
( output_config: BetaOutputConfigParam | Omit, output_format: Optional[BetaJSONOutputFormatParam] | Om
src/anthropic/resources/beta/messages/messages.py:3885
↓ 4 callers
Function
_mock_token_exchange
(respx_mock: MockRouter, base_url: str, token: str)
tests/lib/test_credentials.py:1976
↓ 4 callers
Method
_prepare_options
(self, options: FinalRequestOptions)
src/anthropic/lib/foundry.py:275
↓ 4 callers
Method
_prepare_options
(self, options: FinalRequestOptions)
src/anthropic/lib/foundry.py:495
↓ 4 callers
Function
_read_env
Return the first non-None value from the given env vars, or None.
src/anthropic/lib/aws/_credentials.py:22
↓ 4 callers
Function
_require_https
Reject non-``https://`` token-endpoint URLs. Localhost is allowed for testing so ``base_url="http://localhost:8080"`` works against a local `
src/anthropic/lib/credentials/_constants.py:116
↓ 4 callers
Function
_secure_mkdir
Create ``path`` and any missing parents with ``mode``, regardless of umask. ``Path.mkdir(parents=True, mode=...)`` and ``os.makedirs(mode=...)``
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:307
↓ 4 callers
Function
_tar_file
( name: str, data: bytes, *, mode: int = 0o644, type: bytes = tarfile.REGTYPE )
tests/lib/tools/test_skills.py:69
↓ 4 callers
Function
_zip_entry
(name: str, *, mode: int, create_system: int = 3)
tests/lib/tools/test_skills.py:94
↓ 4 callers
Method
aiter_bytes
Given an iterator that yields raw binary data, iterate over it & yield every event encountered
src/anthropic/_streaming.py:405
↓ 4 callers
Function
assert_message_matches
(message: BetaMessage, expected: Dict[str, Any])
tests/lib/streaming/test_beta_messages.py:197
↓ 4 callers
Function
assert_signatures_in_sync
Ensure that the signature of the second function matches the first.
src/anthropic/_utils/_reflection.py:14
↓ 4 callers
Function
beta_headers
(respx_mock: MockRouter)
tests/lib/test_refusal_fallback_streaming.py:166
↓ 4 callers
Function
build_headers
Fold header layers into one `httpx2.Headers`, later layers taking precedence whatever a name's casing. An `Omit` value removes the header set by
src/anthropic/_base_client.py:2460
↓ 4 callers
Method
close
Close the response and release the connection. Automatically called if the response body is read to completion.
src/anthropic/lib/streaming/_beta_messages.py:88
↓ 4 callers
Method
close
Close the response and release the connection. Automatically called if the response body is read to completion.
src/anthropic/lib/streaming/_messages.py:85
↓ 4 callers
Method
copy
Create a new client instance re-using the same options given to the current client with optional overriding.
src/anthropic/lib/bedrock/_mantle.py:283
↓ 4 callers
Function
create_message_async
(client: AsyncAnthropic)
tests/lib/test_refusal_fallback.py:91
↓ 4 callers
Method
hash_file
One file's sha256; ``None`` when absent. Shares :meth:`hashtree`'s cache.
src/anthropic/lib/tools/_file_store.py:203
↓ 4 callers
Function
helper_headers
(respx_mock: MockRouter)
tests/lib/test_refusal_fallback.py:577
↓ 4 callers
Method
is_closed
Whether or not the response body has been closed. If this is False then there is response data that has not been read yet. You must e
src/anthropic/_response.py:114
↓ 4 callers
Function
iter_next
(iter: Iterator[_T] | AsyncIterator[_T])
tests/decoders/test_jsonl.py:68
↓ 4 callers
Method
ls
The relative path of every file under the directory ``under``.
src/anthropic/lib/tools/_file_store.py:169
↓ 4 callers
Function
make_async_client
(**kwargs: Any)
tests/lib/test_refusal_fallback.py:36
↓ 4 callers
Function
mcp_message
Convert an MCP prompt message to an Anthropic ``BetaMessageParam``.
src/anthropic/lib/tools/mcp.py:254
↓ 4 callers
Method
move
Rename ``src`` to ``dst``; an existing ``dst`` is refused. The banned store root as either end does nothing.
src/anthropic/lib/tools/_file_store.py:220
↓ 4 callers
Function
parse_obj
(model: type[_ModelT], value: object)
src/anthropic/_compat.py:80
↓ 4 callers
Function
parse_text
(text: str, output_format: ResponseFormatT | NotGiven)
src/anthropic/lib/_parse/_response.py:16
↓ 4 callers
Function
quote
Add single quotation marks around the given string. Does *not* do any escaping.
src/anthropic/_utils/_utils.py:221
↓ 4 callers
Function
read_text_exact
Read a UTF-8 file without newline translation.
src/anthropic/lib/tools/_files.py:13
↓ 4 callers
Method
retrieve
Get a specific model. The Models API response can be used to determine information about a specific model or resolve a model
src/anthropic/resources/models.py:48
↓ 3 callers
Method
__init__
(self, *, cache_control: BetaCacheControlEphemeralParam | None = None)
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:88
↓ 3 callers
Method
_apply_verdict
Dispatch or resolve a gated call according to the user's verdict. The idle-clock hold accounting lives here: a denial drops the held
src/anthropic/lib/tools/_beta_session_runner.py:757
↓ 3 callers
Function
_async_read_file_content
(full_path: AsyncPath, memory_path: str)
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:660
↓ 3 callers
Function
_backoff
(attempt: int)
src/anthropic/lib/environments/_poller.py:32
↓ 3 callers
Function
_beat_ok
(ttl_seconds: int = 0)
tests/lib/environments/test_worker.py:1032
↓ 3 callers
Function
_config_dir
Resolve the config directory. ``ANTHROPIC_CONFIG_DIR`` env var → platform default. Platform defaults: * Linux & macOS: ``~/.config/ant
src/anthropic/lib/credentials/_constants.py:67
↓ 3 callers
Function
_determine_next_step_from_stop_reason
Decide how the runner loop treats a finished assistant turn. - ``run_tools``: run the turn's client tool calls, append their results and continue
src/anthropic/lib/tools/_beta_runner.py:76
↓ 3 callers
Method
_enforce_trailing_slash
(self, url: URL)
src/anthropic/_base_client.py:419
↓ 3 callers
Function
_fs_error
(op: str, file_path: str, e: OSError)
src/anthropic/lib/tools/agent_toolset.py:184
↓ 3 callers
Function
_get_annotated_type
If the given type is an `Annotated` type then it is returned, if not `None` is returned. This also unwraps the type when applicable, e.g. `Requir
src/anthropic/_utils/_transform.py:116
↓ 3 callers
Method
_get_last_message
(self)
src/anthropic/lib/tools/_beta_runner.py:318
↓ 3 callers
Method
_get_last_message
(self)
src/anthropic/lib/tools/_beta_runner.py:453
↓ 3 callers
Method
_get_page_items
(self)
src/anthropic/_base_client.py:209
↓ 3 callers
Function
_install_session_ended_by_heartbeat
A session that never completes on its own, with the fake heartbeat held back until the runner is serving it: the heartbeat's outcome — not skill
tests/lib/environments/test_worker.py:463
↓ 3 callers
Function
_is_fatal_4xx
(err: Exception)
src/anthropic/lib/environments/_poller.py:40
↓ 3 callers
Function
_is_supported_image_type
(mime_type: str)
src/anthropic/lib/tools/mcp.py:108
↓ 3 callers
Function
_iter
()
tests/lib/environments/test_worker.py:214
↓ 3 callers
Function
_jitter
(low: float, high: float)
src/anthropic/lib/environments/_poller.py:36
↓ 3 callers
Function
_json_dumps_secrets
``json.dumps`` with ``SecretStr`` values unwrapped at dump time. Returns bytes so call sites can pass the result inline (request content, ``o
src/anthropic/lib/credentials/_secrets.py:95
↓ 3 callers
Method
_list_memories
The store's memories — ``basic`` view (shas, no content) at :data:`_LIST_PAGE_SIZE` per page unless the caller needs ``full`` pages. `
src/anthropic/lib/tools/_memories.py:748
↓ 3 callers
Method
_make_status_error
( self, err_msg: str, *, body: object, response: httpx2.Response,
src/anthropic/_client.py:507
↓ 3 callers
Function
_make_tar
(path: Path, members: list[tuple[tarfile.TarInfo, bytes]])
tests/lib/tools/test_skills.py:88
↓ 3 callers
Function
_make_zip_infos
(path: Path, entries: list[tuple[zipfile.ZipInfo, bytes]])
tests/lib/tools/test_skills.py:101
↓ 3 callers
Function
_message_response
()
tests/lib/test_credentials.py:1956
↓ 3 callers
Function
_messages
(caplog: pytest.LogCaptureFixture)
tests/lib/environments/test_worker.py:1050
↓ 3 callers
Function
_not_found_result
(tool_use_id: str)
tests/lib/tools/test_runners.py:1214
↓ 3 callers
Function
_paused_server_tool_use
()
tests/lib/tools/test_runners.py:672
↓ 3 callers
Function
_prepare_options
(input_options: FinalRequestOptions, *, project_id: str | None, region: str)
src/anthropic/lib/vertex/_client.py:420
↓ 3 callers
Function
_read_file_content
(full_path: Path, memory_path: str)
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:355
↓ 3 callers
Function
_redact_body
Truncate a token-endpoint error body for safe inclusion in an exception.
src/anthropic/lib/credentials/_workload.py:58
↓ 3 callers
Function
_reject_read_only
Raise :class:`ToolError` when ``target`` falls under a read-only root. Roots resolve at check time, exactly like ``allowed_roots`` in :func:`
src/anthropic/lib/tools/agent_toolset.py:417
↓ 3 callers
Method
_request_api_list
( self, model: Type[object], page: Type[SyncPageT], options: FinalRequestOptio
src/anthropic/_base_client.py:1366
↓ 3 callers
Function
_request_id
(resp: httpx2.Response)
src/anthropic/lib/credentials/_workload.py:53
↓ 3 callers
Method
_resolve_base_url
base_url precedence: top-level config field → bound (the owning client's base_url, via :meth:`bind_base_url`) → default. Validated aga
src/anthropic/lib/credentials/_providers.py:275
↓ 3 callers
Function
_resolve_max_bytes
Resolve a configured cap to an effective size limit. ``not_given`` selects ``default``; ``None`` disables the size check (uncapped); a positi
src/anthropic/lib/tools/agent_toolset.py:132
↓ 3 callers
Function
_run_heartbeat_loop
( monkeypatch: pytest.MonkeyPatch, script: list[tuple[float, Any]] )
tests/lib/environments/test_worker.py:1036
↓ 3 callers
Function
_run_timed
Run the worker to completion and return the wall-clock seconds it took.
tests/lib/tools/memory_sync/test_e2e_memory.py:127
↓ 3 callers
Function
_safe_json
(text: str)
src/anthropic/lib/middleware/_fallbacks.py:1508
↓ 3 callers
Method
_scan_marker
(self, store: _AttachedStore)
src/anthropic/lib/tools/_memories.py:353
↓ 3 callers
Function
_seam_block
The synthetic `fallback` content block marking one model boundary.
src/anthropic/lib/middleware/_fallbacks.py:1403
↓ 3 callers
Method
_should_retry
(self, response: httpx2.Response)
src/anthropic/_base_client.py:821
↓ 3 callers
Method
_signal
(self)
src/anthropic/lib/tools/_beta_session_runner.py:173
↓ 3 callers
Function
_strip_traceback
Detach the frames chained onto ``err`` before raising from it. Foreign frames (json decoder, httpx transport) hold raw payloads — request bod
src/anthropic/lib/credentials/_secrets.py:104
↓ 3 callers
Method
_sync_all
(self, *, final: bool)
src/anthropic/lib/tools/_memories.py:347
↓ 3 callers
Function
_tar_special
(name: str, type: bytes, linkname: str = "")
tests/lib/tools/test_skills.py:79
↓ 3 callers
Function
_transform_recursive
Transform the given data against the expected type. Args: annotation: The direct type annotation given to the particular piece of data.
src/anthropic/_utils/_transform.py:154
↓ 3 callers
Function
_unwrap_secret
Inverse of :func:`_wrap_secret_fields` for a single value; pass-through for values that were never wrapped (absent or non-string fields).
src/anthropic/lib/credentials/_secrets.py:83
↓ 3 callers
Function
_validate_profile_name
Reject profile names that could escape the config directory. Profile names come from user-controlled sources (``ANTHROPIC_PROFILE``, the ``ac
src/anthropic/lib/credentials/_constants.py:135
↓ 3 callers
Function
_wrap_secret_fields
Wrap the secret fields of a parsed JSON object in ``SecretStr``. Called at every boundary where credential material enters SDK code. Tracebac
src/anthropic/lib/credentials/_secrets.py:51
↓ 3 callers
Method
arm
(Re)start the idle countdown from now and wake the watchdog. Deferred while any gated call is held or in flight — stopping then would
src/anthropic/lib/tools/_beta_session_runner.py:194
↓ 3 callers
Function
async_mcp_tool
Convert an MCP tool to an async runnable tool for ``tool_runner()``. Example:: from anthropic.lib.tools.mcp import async_mcp_tool
src/anthropic/lib/tools/mcp.py:416
↓ 3 callers
Function
async_to_custom_raw_response_wrapper
Higher order function that takes one of our bound API methods and an `APIResponse` class and wraps the method to support returning the given respo
src/anthropic/_response.py:841
↓ 3 callers
Function
async_to_custom_streamed_response_wrapper
Higher order function that takes one of our bound API methods and an `APIResponse` class and wraps the method to support streaming and returning t
src/anthropic/_response.py:759
↓ 3 callers
Method
bind_base_url
Adopt the owning client's ``base_url`` as a fallback for the token exchange. Slots between the config file's own ``base_url`` field and
src/anthropic/lib/credentials/_providers.py:229
↓ 3 callers
Function
body
()
tests/decoders/test_jsonl.py:17
↓ 3 callers
Method
call
(self, input: object)
src/anthropic/lib/tools/_tool_dispatch.py:43
↓ 3 callers
Method
close
Close the underlying HTTPX client. The client will *not* be usable after this.
src/anthropic/_base_client.py:1022
← previous
next →
301–400 of 6,399, ranked by callers