Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/anthropics/anthropic-sdk-python
/ functions
Functions
6,358 in github.com/anthropics/anthropic-sdk-python
⨍
Functions
6,358
◇
Types & classes
2,013
↳
Endpoints
17
↓ 1,488 callers
Function
assert_matches_type
( type_: Any, value: object, *, path: list[str], allow_none: bool = False, )
tests/utils.py:48
↓ 998 callers
Method
get
(self, __key: str)
src/anthropic/_types.py:198
↓ 819 callers
Method
parse
(self, query: str)
src/anthropic/_qs.py:32
↓ 433 callers
Function
make_request_options
Create a dict of type RequestOptions without keys of NotGiven values.
src/anthropic/_base_client.py:2257
↓ 416 callers
Method
create
(self, memory_store_id: str, **kwargs: Any)
tests/lib/tools/memory_sync/test_memory_sync.py:685
↓ 387 callers
Method
list
(self, _session_id: str, *, limit: int = 1000, extra_headers: Any = None)
tests/lib/tools/test_session_runner.py:212
↓ 356 callers
Function
is_given
(obj: _T | NotGiven | Omit)
src/anthropic/_utils/_utils.py:156
↓ 339 callers
Method
retrieve
(self, session_id: str, *, betas: Any = None)
tests/lib/environments/test_worker.py:141
↓ 338 callers
Method
post
( self, path: str, *, cast_to: Type[ResponseT], body: Body | None = No
src/anthropic/_base_client.py:1431
↓ 313 callers
Function
strip_not_given
(obj: None)
src/anthropic/_utils/_utils.py:306
↓ 295 callers
Function
path_template
Interpolate {name} placeholders in `template` from keyword arguments. Args: template: The template string containing {name} placeholders.
src/anthropic/_utils/_path.py:78
↓ 198 callers
Method
update
(self, memory_id: str, *, memory_store_id: str, **kwargs: Any)
tests/lib/tools/memory_sync/test_memory_sync.py:688
↓ 176 callers
Method
delete
(self, memory_id: str, *, memory_store_id: str, **kwargs: Any)
tests/lib/tools/memory_sync/test_memory_sync.py:691
↓ 161 callers
Function
maybe_transform
Wrapper over `transform()` that allows `None` to be passed. See `transform()` for more details.
src/anthropic/_utils/_transform.py:78
↓ 148 callers
Method
archive
Archive a Dream Args: betas: Optional header to specify the beta version(s) you want to use. extra_headers: Sen
src/anthropic/resources/beta/dreams.py:243
↓ 121 callers
Method
get
The file's bytes; ``None`` when absent.
src/anthropic/lib/tools/_file_store.py:151
↓ 80 callers
Method
construct
( # pyright: ignore[reportIncompatibleMethodOverride] __cls: Type[ModelT], _fields_set: set[s
src/anthropic/_models.py:227
↓ 74 callers
Method
stream
(self, _session_id: str, *, extra_headers: Any = None)
tests/lib/tools/test_session_runner.py:202
↓ 69 callers
Method
_build_request
( self, options: FinalRequestOptions, *, retries_taken: int = 0, )
src/anthropic/_base_client.py:497
↓ 69 callers
Function
run_sync
Drive one reconcile pass without clock bookkeeping. The public cadence path (``sync_if_due`` plus the clock) is exercised by the worker tests
tests/lib/tools/memory_sync/conftest.py:33
↓ 68 callers
Function
_write_profile
Test helper: lay out ``configs/<profile>.json`` and optionally ``credentials/<profile>.json`` under ``config_dir``. Accepts either the new ne
tests/lib/test_credentials.py:126
↓ 67 callers
Function
async_maybe_transform
Wrapper over `async_transform()` that allows `None` to be passed. See `async_transform()` for more details.
src/anthropic/_utils/_transform.py:286
↓ 54 callers
Function
message_body
(*, model: str = "claude-opus-4-6")
tests/test_middleware.py:61
↓ 52 callers
Method
add
Add two numbers.
tests/lib/tools/test_functions.py:473
↓ 52 callers
Method
call
(self, input: dict[str, Any])
tests/lib/tools/test_session_runner.py:247
↓ 52 callers
Method
remove
Delete a file or subtree; absent — and the banned store root — do nothing.
src/anthropic/lib/tools/_file_store.py:232
↓ 49 callers
Function
async_to_raw_response_wrapper
Higher order function that takes one of our bound API methods and wraps it to support returning the raw `APIResponse` object directly.
src/anthropic/_response.py:801
↓ 49 callers
Function
async_to_streamed_response_wrapper
Higher order function that takes one of our bound API methods and wraps it to support streaming and returning the raw `APIResponse` object directl
src/anthropic/_response.py:713
↓ 49 callers
Function
to_raw_response_wrapper
Higher order function that takes one of our bound API methods and wraps it to support returning the raw `APIResponse` object directly.
src/anthropic/_response.py:784
↓ 49 callers
Function
to_streamed_response_wrapper
Higher order function that takes one of our bound API methods and wraps it to support streaming and returning the raw `APIResponse` object directl
src/anthropic/_response.py:694
↓ 46 callers
Function
get_response
Convert a fixture file into a stream of bytes for testing.
tests/lib/streaming/helpers.py:18
↓ 45 callers
Method
get_final_message
Waits until the stream has been read to completion and returns the accumulated `Message` object.
src/anthropic/lib/streaming/_messages.py:93
↓ 43 callers
Method
close
(self)
tests/lib/test_credentials.py:2952
↓ 42 callers
Function
_run_with_fakes
( *, events: FakeAsyncEvents, tools: list[Any], max_idle: float | None = None, environment
tests/lib/tools/test_session_runner.py:280
↓ 42 callers
Function
make_sync_client
(**kwargs: Any)
tests/test_middleware.py:53
↓ 41 callers
Method
json
(self)
src/anthropic/_request.py:58
↓ 40 callers
Function
_terminated
()
tests/lib/tools/test_session_runner.py:106
↓ 39 callers
Function
_tool_use
( id: str, name: str, input: dict[str, Any], *, evaluated_permission: str | None = None, )
tests/lib/tools/test_session_runner.py:75
↓ 39 callers
Method
run
Run Deployment Now Args: betas: Optional header to specify the beta version(s) you want to use. extra_headers:
src/anthropic/resources/beta/deployments.py:487
↓ 38 callers
Function
sse_response
(body: str)
tests/lib/test_refusal_fallback_streaming.py:93
↓ 36 callers
Method
decode
(self, line: str)
src/anthropic/_streaming.py:427
↓ 36 callers
Method
tool_runner
( self, *, max_tokens: int, messages: Iterable[BetaMessageParam], mode
src/anthropic/resources/beta/messages/messages.py:1313
↓ 34 callers
Method
cancel
Cancel a Dream Args: betas: Optional header to specify the beta version(s) you want to use. extra_headers: Send
src/anthropic/resources/beta/dreams.py:290
↓ 34 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:416
↓ 33 callers
Function
message
(model: str, **overrides: Any)
tests/lib/test_refusal_fallback.py:40
↓ 32 callers
Function
make_sync_client
(**kwargs: Any)
tests/lib/test_refusal_fallback.py:32
↓ 31 callers
Function
collect
(stream: Stream[BetaRawMessageStreamEvent])
tests/lib/test_refusal_fallback_streaming.py:153
↓ 31 callers
Function
create_stream
( client: Anthropic, *, betas: List[AnthropicBetaParam] | Omit = omit )
tests/lib/test_refusal_fallback_streaming.py:198
↓ 31 callers
Method
download
Download File Args: file_id: ID of the File. extra_headers: Send extra headers extra_query: Add addi
src/anthropic/resources/files.py:155
↓ 30 callers
Function
make_async_client
(**kwargs: Any)
tests/test_middleware.py:57
↓ 30 callers
Function
make_sync_client
(**kwargs: Any)
tests/lib/test_refusal_fallback_streaming.py:73
↓ 30 callers
Function
merge_headers
Compose header layers into a single layer: a plain mapping, as `default_headers=` and `extra_headers=` accept, that still carries an `Omit` for ev
src/anthropic/_base_client.py:2481
↓ 30 callers
Function
transform
( data: _T, expected_type: object, use_async: bool, )
tests/test_transform.py:27
↓ 29 callers
Function
create_message
( client: Anthropic, *, betas: List[AnthropicBetaParam] | Omit = omit, fallbacks: List[BetaFal
tests/lib/test_refusal_fallback.py:74
↓ 27 callers
Function
refusal
(model: str, fallback_credit_token: str | None = None)
tests/lib/test_refusal_fallback.py:57
↓ 26 callers
Function
provider
()
tests/lib/test_google_cloud.py:248
↓ 25 callers
Method
root
(self)
src/anthropic/lib/tools/_file_store.py:119
↓ 24 callers
Method
open
Resolve ``root``; creates nothing — only :meth:`create_root` makes the folder.
src/anthropic/lib/tools/_file_store.py:100
↓ 24 callers
Method
put
( self, path: str, *, cast_to: Type[ResponseT], body: Body | None = No
src/anthropic/_base_client.py:1511
↓ 24 callers
Function
to_async_iter
Convert a synchronous iterator to an asynchronous one.
tests/lib/streaming/helpers.py:25
↓ 24 callers
Function
transform_schema
Transforms a JSON schema to ensure it conforms to the API's expectations. Args: json_schema (Dict[str, Any]): The original JSON sche
src/anthropic/lib/_parse/_transform.py:54
↓ 23 callers
Function
beta_read_tool
(ctx: AgentToolContext)
src/anthropic/lib/tools/agent_toolset.py:667
↓ 22 callers
Method
count_tokens
Count the number of tokens in a Message. The Token Count API can be used to count the number of tokens in a Message, includi
src/anthropic/resources/messages/messages.py:1227
↓ 22 callers
Function
default_credentials
Resolve a :class:`CredentialResult` from the environment per the credential-resolution spec. First match wins. Implements steps 2-5 of the sp
src/anthropic/lib/credentials/_chain.py:76
↓ 22 callers
Method
get_token
Return a valid bearer token, refreshing if necessary.
src/anthropic/lib/credentials/_cache.py:105
↓ 22 callers
Function
make_client
(client_cls: ClientClass, **kwargs: Any)
tests/test_header_case_sensitivity.py:29
↓ 22 callers
Method
until_done
Blocks until the stream has been consumed
src/anthropic/lib/streaming/_messages.py:122
↓ 21 callers
Function
build
(client: Anthropic | AsyncAnthropic, **options: Any)
tests/test_header_case_sensitivity.py:34
↓ 21 callers
Function
construct_type
Loose coercion to the expected type with construction of nested values. If the given value does not match the expected type then it is returned a
src/anthropic/_models.py:584
↓ 21 callers
Function
parse_datetime
(value: Union[datetime, StrBytesIntFloat])
src/anthropic/_utils/_compat.py:44
↓ 21 callers
Method
sleep
(self, _seconds: float)
tests/lib/environments/test_poller_method.py:336
↓ 21 callers
Method
to_dict
(self)
tests/lib/tools/test_session_runner.py:260
↓ 20 callers
Method
aclose
(self)
src/anthropic/lib/middleware/_fallbacks.py:1632
↓ 20 callers
Function
deepcopy_with_paths
Copy only the containers along the given paths. Used to guard against mutation by extract_files without copying the entire structure. Only di
src/anthropic/_files.py:126
↓ 20 callers
Function
get_directory_snapshot
Get a snapshot of directory contents with relative paths.
tests/lib/tools/memory_tools/test_filesystem.py:42
↓ 20 callers
Method
upload
Upload File Args: file: The file to upload expires_in_seconds: Seconds from upload until the file expires and i
src/anthropic/resources/files.py:226
↓ 19 callers
Function
_assert_not_in_sdk_frame_locals
(exc: BaseException, *secrets: str)
tests/lib/test_credentials.py:3538
↓ 19 callers
Method
download
Download every attached store's memories to disk. ``session`` arrives already fetched — one snapshot shared with the skills download.
src/anthropic/lib/tools/_memories.py:275
↓ 19 callers
Function
extract_files
Recursively extract files from the given dictionary based on specified paths. A path may look like this ['foo', 'files', '<array>', 'data'].
src/anthropic/_utils/_utils.py:37
↓ 18 callers
Function
_fake_client
(work: _FakeWorkResource, sessions: _FakeSessions)
tests/lib/environments/test_worker.py:146
↓ 18 callers
Method
create
Create a Dream Args: model: Model identifier and configuration applied to every pipeline stage. output_behavior
src/anthropic/resources/beta/dreams.py:53
↓ 18 callers
Function
fake_anthropic
An ``AsyncAnthropic``-shaped client with one memory store named ``notes``. The store lands at ``{workdir}/memory/notes``. Returns the client to
tests/lib/tools/memory_sync/_fake_anthropic.py:187
↓ 18 callers
Function
iter_work
Iterate work items claimed from a self-hosted environment. Each yielded :class:`BetaSelfHostedWork` has already been ack'd. The ``work`` reso
src/anthropic/lib/environments/_poller.py:83
↓ 18 callers
Function
mcp_content
Convert a single MCP content block to an Anthropic content block. Handles text, image, and embedded resource content types. Raises :class:`Un
src/anthropic/lib/tools/mcp.py:135
↓ 18 callers
Method
model_dump
Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump Generate a dictionary representation of the model, opti
src/anthropic/_models.py:299
↓ 18 callers
Method
read
Read and return the binary response content.
src/anthropic/_response.py:360
↓ 18 callers
Function
request_bodies
(respx_mock: MockRouter)
tests/lib/test_refusal_fallback.py:99
↓ 18 callers
Function
request_bodies
(respx_mock: MockRouter)
tests/lib/test_refusal_fallback_streaming.py:161
↓ 18 callers
Method
retrieve_metadata
Get File Metadata Args: file_id: ID of the File. extra_headers: Send extra headers extra_query: Add
src/anthropic/resources/files.py:191
↓ 18 callers
Function
updated
(path: str, content: str, *, was: str)
tests/lib/tools/memory_sync/_fake_anthropic.py:77
↓ 18 callers
Method
write
(self, path: str, content: str)
tests/lib/tools/memory_sync/_fake_anthropic.py:61
↓ 17 callers
Function
_send_message
(client: Anthropic)
tests/lib/test_credentials.py:2013
↓ 17 callers
Function
fake_session
An ``EnvironmentWorker`` pointed at a fake client; one work item queued.
tests/lib/tools/memory_sync/test_e2e_memory.py:41
↓ 17 callers
Function
resolve_auth_mode
Determine whether to use SigV4 auth. Returns True for SigV4, False for API key. Auth precedence: 1. api_key constructor arg → API key mode
src/anthropic/lib/aws/_credentials.py:31
↓ 16 callers
Function
_install_scoped_client
Intercept the shared bearer-auth client factory. Returns the list of args the factory was called with so a test can assert on the helper-tele
tests/lib/environments/test_worker.py:152
↓ 16 callers
Method
retrieve
(self, memory_id: str, *, memory_store_id: str, **kwargs: Any)
tests/lib/tools/memory_sync/test_memory_sync.py:682
↓ 15 callers
Function
_copy_client_with_bearer_auth
Return a copy of ``client`` authenticated with ``auth_token`` as Bearer. The returned sub-client inherits the parent's full configuration via
src/anthropic/lib/_scoped_client.py:30
↓ 15 callers
Function
_extract_skill_archive
Extract a skill download (a zip or tar.* archive) from disk into ``dest``. Skill bundles are wrapped in a single directory named after the skill;
src/anthropic/lib/tools/_skills.py:141
↓ 15 callers
Function
beta_tool
(func: FunctionT)
src/anthropic/lib/tools/_beta_functions.py:349
↓ 15 callers
Method
get
( self, path: str, *, cast_to: Type[ResponseT], options: RequestOption
src/anthropic/_base_client.py:1385
next →
1–100 of 6,358, ranked by callers