Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/anthropics/anthropic-sdk-python
/ functions
Functions
9,455 in github.com/anthropics/anthropic-sdk-python
⨍
Functions
9,455
◇
Types & classes
3,151
↳
Endpoints
25
↓ 7 callers
Function
extract_type_var_from_base
Given a type like `Foo[T]`, returns the generic type variable `T`. This also handles the case where a concrete subclass is given, e.g. ```py
src/anthropic/_utils/_typing.py:91
↓ 7 callers
Function
is_list
(obj: object)
src/anthropic/_utils/_utils.py:198
↓ 7 callers
Function
marker_stamp
(local: Path)
tests/lib/tools/memory_sync/test_folder_trust.py:28
↓ 7 callers
Function
quoted_name
A model-chosen name as it is echoed inside single quotes in a text the model reads: one line, cut short, and without the quotes and runs of spaces
src/anthropic/lib/tools/_toolsets/_sanitize.py:69
↓ 7 callers
Method
read
Read and return the binary response content.
src/anthropic/_response.py:361
↓ 7 callers
Function
update_env
(**new_env: str | Omit)
tests/utils.py:151
↓ 7 callers
Function
validate_credentials
Raise if only one of aws_access_key/aws_secret_key is provided.
src/anthropic/lib/aws/_credentials.py:7
↓ 6 callers
Method
_build_workload_delegate
(self, auth: Dict[str, Any])
src/anthropic/lib/credentials/_providers.py:693
↓ 6 callers
Function
_custom_tool_use
A CUSTOM (user-defined) tool call — the agent emits `agent.custom_tool_use` rather than `agent.tool_use` for these.
tests/lib/tools/test_session_runner.py:96
↓ 6 callers
Function
_disabled
(entry: Any)
tests/lib/tools/toolsets/test_interface.py:72
↓ 6 callers
Function
_encode_secret
Build a work-item `secret` the way the control plane does: URL-safe base64 of a JSON payload, without padding.
tests/lib/environments/test_worker.py:52
↓ 6 callers
Function
_get_weather
(location: str, units: Literal["c", "f"])
tests/lib/tools/test_runners.py:2421
↓ 6 callers
Function
_is_status
(err: Exception, code: int)
src/anthropic/lib/environments/_poller.py:44
↓ 6 callers
Function
_message_response
()
tests/lib/test_credentials.py:2262
↓ 6 callers
Function
_mock_deployment
Mock one deployment: its token endpoint mints `token` and its messages endpoint accepts anything. Pair with `_requests_to` to check that a cli
tests/lib/test_credentials.py:2288
↓ 6 callers
Function
_mock_token_endpoint
(respx_mock: MockRouter)
tests/lib/test_credentials.py:2253
↓ 6 callers
Function
_mode
(p: Path)
tests/lib/tools/test_skills.py:172
↓ 6 callers
Function
_on
(world: World, tab_id: str, url: str, *, active: bool = False)
tests/lib/tools/toolsets/test_enforcement.py:34
↓ 6 callers
Function
_paused_server_tool_use
()
tests/lib/tools/test_runners.py:691
↓ 6 callers
Function
_reject_httpx_object
`httpx` objects don't work with `httpx2`, and would otherwise fail deep inside a request.
src/anthropic/_base_client.py:145
↓ 6 callers
Function
_requests_to
(respx_mock: MockRouter, base_url: str)
tests/lib/test_credentials.py:2297
↓ 6 callers
Function
_set_ambient_first_party_credentials
(monkeypatch: pytest.MonkeyPatch)
tests/lib/test_aws.py:138
↓ 6 callers
Function
_sha
(content: str | bytes)
tests/lib/tools/test_file_store.py:27
↓ 6 callers
Function
_sha
(content: str)
tests/lib/tools/memory_sync/_fake_anthropic.py:23
↓ 6 callers
Function
_status_error
(code: int)
tests/lib/tools/memory_sync/_fake_anthropic.py:27
↓ 6 callers
Function
_symlink_fixture
Workdir with two symlink cycles, a link that escapes, and a link whose target spells its way through a cycle to the escaping link.
tests/lib/tools/test_agent_toolset.py:85
↓ 6 callers
Method
_toolset_refuse_if_closed
(self)
src/anthropic/lib/tools/_toolsets/_runnable.py:91
↓ 6 callers
Function
_validate_output_config_conflict
( output_config: BetaOutputConfigParam | Omit, output_format: object, )
src/anthropic/resources/beta/messages/messages.py:4083
↓ 6 callers
Method
_validate_path
Validate and resolve memory paths
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:682
↓ 6 callers
Method
_walk_sync_auth
(client: Anthropic)
tests/lib/test_credentials.py:4099
↓ 6 callers
Method
_workload_provider
(self, handler: Callable[[httpx2.Request], httpx2.Response])
tests/lib/test_credentials.py:4442
↓ 6 callers
Function
classify
The rule for an exception out of a member call, at the `execute` boundary and in the runner alike: a `ToolsetUsageError` propagates, a `ToolError`
src/anthropic/lib/tools/_toolsets/_runnable.py:216
↓ 6 callers
Method
close
(self)
tests/lib/test_credentials.py:3815
↓ 6 callers
Method
copy
Create a new client instance re-using the same options given to the current client with optional overriding.
src/anthropic/_client.py:886
↓ 6 callers
Function
defer_calls
Defers the calls with these ids, when the caller sees their blocks finish. Pass each event to what it returns.
tests/lib/tools/test_runner_eager_toolsets.py:445
↓ 6 callers
Function
extract_response_type
Given a type like `APIResponse[T]`, returns the generic type variable `T`. This also handles the case where a concrete subclass is given, e.g.
src/anthropic/_response.py:865
↓ 6 callers
Function
foo
(a: str | None = None)
tests/test_required_args.py:10
↓ 6 callers
Function
ids
(tool_uses: list[Any])
tests/lib/tools/test_runner_eager_tools.py:864
↓ 6 callers
Function
mcp_resource_to_content
Convert MCP resource contents to an Anthropic content block. Finds the first resource with a supported MIME type from the result's `contents`
src/anthropic/lib/tools/mcp.py:246
↓ 6 callers
Function
one_line
A page- or model-supplied text on one line the model or an operator reads: a tab's title, a download's error, a field of a member's confirmation l
src/anthropic/lib/tools/_toolsets/_sanitize.py:58
↓ 6 callers
Method
parse
( self, *, max_tokens: int, messages: Iterable[MessageParam], model: M
src/anthropic/resources/messages/messages.py:1178
↓ 6 callers
Function
prepare_request_data
Copy request params into plain data that can be serialized and re-sent. Drops `NotGiven` / `Omit` entries (`keep_top_level_omit` keeps `Omit` dir
src/anthropic/_utils/_prepare.py:47
↓ 6 callers
Function
redeemed_token
The request-body form of a redeemed credit token — the object shape, best-effort mode.
tests/lib/test_refusal_fallback_streaming.py:148
↓ 6 callers
Function
see
(event: Any)
tests/lib/tools/test_runner_eager_toolsets.py:448
↓ 6 callers
Method
stop
Track a content_block_stop, shifting `event["index"]`.
src/anthropic/lib/middleware/_fallbacks.py:1295
↓ 6 callers
Method
to_dict
(self)
tests/lib/streaming/test_beta_messages.py:40
↓ 6 callers
Function
well_formed
`text` with each unpaired surrogate replaced by U+FFFD, so it can be sent.
src/anthropic/lib/tools/_toolsets/_sanitize.py:41
↓ 6 callers
Method
with_middleware
A new client with the given middleware appended after this client's middleware. Convenience for applying extra middleware to a single request
src/anthropic/_client.py:539
↓ 5 callers
Method
__get_proxied__
(self)
src/anthropic/_utils/_proxy.py:57
↓ 5 callers
Method
__init__
(self, message: str, request: httpx2.Request, *, body: object | None)
src/anthropic/_exceptions.py:50
↓ 5 callers
Method
__init__
( self, *, url: URL, )
src/anthropic/_base_client.py:166
↓ 5 callers
Method
__init__
( self, *, family: ToolsetFamily, helper_tag: StainlessHelperHeaderValue,
src/anthropic/lib/tools/_toolsets/_base.py:117
↓ 5 callers
Function
_api_status_error
(code: int)
tests/lib/environments/test_poller_method.py:38
↓ 5 callers
Function
_api_status_error
(code: int, body: object = None)
tests/lib/environments/test_worker.py:58
↓ 5 callers
Method
_available_tool_names
The tool names currently available, after applying any mid-conversation `tool_removal` / `tool_addition` blocks. Removal is only a hi
src/anthropic/lib/tools/_beta_runner.py:386
↓ 5 callers
Function
_bearer_tokens
The token on each HTTP request so far, in order.
tests/lib/test_credentials.py:3425
↓ 5 callers
Function
_chunk_bytes_to_sse
(raw: bytes)
src/anthropic/lib/bedrock/_stream_decoder.py:71
↓ 5 callers
Function
_created_store
(root: Path, *, utf8_only: bool = False)
tests/lib/tools/test_file_store.py:31
↓ 5 callers
Function
_disabled
(entry: Any)
tests/lib/tools/toolsets/test_computer_interface.py:53
↓ 5 callers
Function
_downloaded
A `SessionMemoryStores` with one store already downloaded to disk.
tests/lib/tools/memory_sync/test_two_pass.py:24
↓ 5 callers
Function
_drain_one
Pull a single item from a sync iterator; assert there was one.
tests/lib/environments/test_poller_method.py:120
↓ 5 callers
Function
_emit
(event: str, payload: dict[str, Any])
src/anthropic/lib/middleware/_fallbacks.py:1564
↓ 5 callers
Method
_enforce_trailing_slash
(self, url: URL)
src/anthropic/_base_client.py:446
↓ 5 callers
Method
_get_http_client
Return an `httpx2.Client`, lazily creating (and tracking) one we own.
src/anthropic/lib/credentials/_providers.py:430
↓ 5 callers
Function
_is_base_client
True only for the base `Anthropic` / `AsyncAnthropic` classes, not subclasses. Subclasses (`AnthropicAWS`, `AnthropicFoundry`) have their own aut
src/anthropic/_client.py:51
↓ 5 callers
Method
_load_config
Read and cache the config file, resolving `base_url` and `credentials_path`. On Unix, refuses a file that group or others can write.
src/anthropic/lib/credentials/_providers.py:304
↓ 5 callers
Function
_member_use
(name: str, id: str, input: dict[str, Any], family: str = "computer")
tests/lib/tools/toolsets/test_computer_runner.py:56
↓ 5 callers
Function
_noop_tool
(flavour: str, name: str)
tests/lib/tools/toolsets/test_browser_runner.py:368
↓ 5 callers
Function
_ran_result
(tool_use_id: str, label: str)
tests/lib/tools/test_runners.py:1654
↓ 5 callers
Function
_run_sync_tool_use
Drive a tool runner over `messages` and collect the tool_result messages it generated.
tests/lib/tools/test_runners.py:1042
↓ 5 callers
Function
_sync_weather_tool
()
tests/lib/tools/test_runners.py:2503
↓ 5 callers
Function
_to_session_content
(content: Any)
tests/lib/tools/test_session_runner.py:1774
↓ 5 callers
Function
_use
(name: str, input: dict[str, Any], id: str = "toolu_1")
tests/lib/tools/toolsets/test_pipeline.py:52
↓ 5 callers
Function
_within
True if `child` is `root` or a path inside it (both already resolved).
src/anthropic/lib/tools/_skills.py:38
↓ 5 callers
Method
_write_refresh_profile
(self, clean_env: pytest.MonkeyPatch, tmp_path: pathlib.Path)
tests/lib/test_credentials.py:4524
↓ 5 callers
Function
accumulate_event
( *, event: BetaRawMessageStreamEvent, current_snapshot: ParsedBetaMessage[ResponseFormatT] | None
src/anthropic/lib/streaming/_beta_messages.py:457
↓ 5 callers
Function
assert_different_identities
(obj1: object, obj2: object)
tests/test_files.py:110
↓ 5 callers
Function
async_prepare_request_data
`prepare_request_data`, reading `pathlib.Path` inputs without blocking the event loop.
src/anthropic/_utils/_prepare.py:64
↓ 5 callers
Function
beta_grep_tool
(ctx: AgentToolContext)
src/anthropic/lib/tools/agent_toolset.py:840
↓ 5 callers
Function
bounded_error
`checked_error` with no check: each text block cut to the field limit, for a family with nothing to redact.
src/anthropic/lib/tools/_toolsets/_base.py:565
↓ 5 callers
Function
bounded_tab_url
A tab's or download's URL as the model reads it: folded to one line, not parsed, held to `FIELD_MAX`. A longer one becomes `…` plus its first `FIE
src/anthropic/lib/tools/_toolsets/_sanitize.py:99
↓ 5 callers
Function
build
Construct a BaseModel class without validation. This is useful for cases where you need to instantiate a `BaseModel` from an API response as
src/anthropic/_models.py:553
↓ 5 callers
Method
copy
( self, *, method: str | NotGiven = not_given, url: str | NotGiven = not_given
src/anthropic/_request.py:69
↓ 5 callers
Method
create_root
Create the root directory and any missing ancestors; already existing is fine.
src/anthropic/lib/tools/_file_store.py:115
↓ 5 callers
Method
dispose
Remove every store directory that `download` created. Pre-existing directories are left alone — that is `FileStore.dispose`'s own rul
src/anthropic/lib/tools/_memories.py:540
↓ 5 callers
Method
do
(self, name: str, context: BetaToolsetCallContext, input: Any)
tests/lib/tools/toolsets/_computer_fakes.py:44
↓ 5 callers
Method
find
(self, context: BetaToolsetCallContext, input: BetaBrowserFindInput)
src/anthropic/lib/tools/_toolsets/_browser.py:396
↓ 5 callers
Method
for_base_url
Return the provider a client with `base_url` should exchange through. Binds in place, unless another client already bound this instance to a
src/anthropic/lib/credentials/_providers.py:246
↓ 5 callers
Function
get_args
(tp: type[Any])
src/anthropic/_utils/_compat.py:15
↓ 5 callers
Function
get_helper_tag
Get the helper name from an object, if any.
src/anthropic/lib/_stainless_helpers.py:95
↓ 5 callers
Function
hop_refusal
A fallback hop that contributes one text block, then refuses with a fresh token.
tests/lib/test_refusal_fallback_streaming.py:691
↓ 5 callers
Function
is_fatal_status_error
True for a 4xx that retrying will not fix (bad key, missing resource). Aligns with the core client's `_should_retry` policy: 408 / 409 / 429 are
src/anthropic/lib/_retry.py:42
↓ 5 callers
Function
is_mapping_t
(obj: _MappingT | object)
src/anthropic/_utils/_utils.py:190
↓ 5 callers
Method
iter_bytes
A byte-iterator over the decoded response content. This automatically handles gzip, deflate and brotli encoded responses.
src/anthropic/_response.py:388
↓ 5 callers
Method
list
List Files Args: ids: Restrict the result set to Files whose `id` is in this list. At most 100 entries (afte
src/anthropic/resources/files.py:59
↓ 5 callers
Function
make_async_client
(**kwargs: Any)
tests/lib/test_refusal_fallback.py:36
↓ 5 callers
Function
make_lenient_client
A client with the default (non-strict) response validation. The fixture wire's terminal refusal delta self-reports a `{type: "message"}` iter
tests/lib/test_refusal_fallback_streaming.py:81
↓ 5 callers
Function
mcp_tool
Convert an MCP tool to a sync runnable tool for `tool_runner()`. Example: ```py from anthropic.lib.tools.mcp import mcp_tool tools_
src/anthropic/lib/tools/mcp.py:316
↓ 5 callers
Function
model_dump
( model: pydantic.BaseModel, *, exclude: IncEx | None = None, exclude_unset: bool = False,
src/anthropic/_compat.py:139
↓ 5 callers
Function
print_obj
Pretty print an object to a string
tests/lib/utils.py:18
← previous
next →
301–400 of 9,455, ranked by callers