Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/anthropics/anthropic-sdk-python
/ functions
Functions
4,447 in github.com/anthropics/anthropic-sdk-python
⨍
Functions
4,447
◇
Types & classes
1,509
↳
Endpoints
24
↓ 966 callers
Method
get
(self, __key: str)
src/anthropic/_types.py:203
↓ 878 callers
Function
assert_matches_type
( type_: Any, value: object, *, path: list[str], allow_none: bool = False, )
tests/utils.py:49
↓ 491 callers
Method
parse
(self, query: str)
src/anthropic/_qs.py:32
↓ 358 callers
Method
create
[Legacy] Create a Text Completion. The Text Completions API is a legacy API. We recommend using the [Messages API](https://p
src/anthropic/resources/completions.py:49
↓ 330 callers
Function
is_given
(obj: _T | NotGiven | Omit)
src/anthropic/_utils/_utils.py:156
↓ 270 callers
Method
post
( self, path: str, *, cast_to: Type[ResponseT], body: Body | None = No
src/anthropic/_base_client.py:1470
↓ 260 callers
Function
make_request_options
Create a dict of type RequestOptions without keys of NotGiven values.
src/anthropic/_base_client.py:2370
↓ 231 callers
Function
strip_not_given
(obj: None)
src/anthropic/_utils/_utils.py:306
↓ 214 callers
Method
list
(self, _session_id: str, *, limit: int = 1000, extra_headers: Any = None)
tests/lib/tools/test_session_runner.py:190
↓ 213 callers
Method
retrieve
(self, session_id: str, *, betas: Any = None)
tests/lib/environments/test_worker.py:79
↓ 175 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
↓ 136 callers
Method
delete
( self, path: str, *, cast_to: Type[ResponseT], body: Body | None = No
src/anthropic/_base_client.py:1590
↓ 130 callers
Method
update
Update Vault Args: display_name: Updated human-readable name for the vault. 1-255 characters. metadata: Metadat
src/anthropic/resources/beta/vaults/vaults.py:164
↓ 119 callers
Method
construct
( # pyright: ignore[reportIncompatibleMethodOverride] __cls: Type[ModelT], _fields_set: set[s
src/anthropic/_models.py:221
↓ 115 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:709
↓ 115 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:690
↓ 97 callers
Function
maybe_transform
Wrapper over `transform()` that allows `None` to be passed. See `transform()` for more details.
src/anthropic/_utils/_transform.py:78
↓ 84 callers
Method
archive
Archive Vault Args: betas: Optional header to specify the beta version(s) you want to use. extra_headers: Send
src/anthropic/resources/beta/vaults/vaults.py:338
↓ 80 callers
Method
_build_request
( self, options: FinalRequestOptions, *, retries_taken: int = 0, )
src/anthropic/_base_client.py:508
↓ 70 callers
Function
sse_response
(body: str)
tests/lib/test_refusal_fallback_streaming.py:93
↓ 65 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:421
↓ 61 callers
Function
transform
( data: _T, expected_type: object, use_async: bool, )
tests/test_transform.py:27
↓ 57 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:122
↓ 54 callers
Function
message_body
(*, model: str = "claude-opus-4-6")
tests/test_middleware.py:62
↓ 52 callers
Function
ev
Serialize one event payload as an SSE frame (its `type` is the event name).
tests/lib/test_refusal_fallback_streaming.py:105
↓ 51 callers
Method
stream
(self, _session_id: str, *, extra_headers: Any = None)
tests/lib/tools/test_session_runner.py:180
↓ 46 callers
Method
close
(self)
tests/lib/test_credentials.py:2677
↓ 46 callers
Function
parse_datetime
(value: Union[datetime, StrBytesIntFloat])
src/anthropic/_utils/_compat.py:44
↓ 43 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
↓ 43 callers
Function
make_sync_client
(**kwargs: Any)
tests/test_middleware.py:54
↓ 40 callers
Method
get_token
Return a valid bearer token, refreshing if necessary.
src/anthropic/lib/credentials/_cache.py:105
↓ 38 callers
Method
call
(self, input: dict[str, Any])
tests/lib/tools/test_session_runner.py:224
↓ 38 callers
Method
json
(self)
src/anthropic/_request.py:58
↓ 34 callers
Method
to_dict
Recursively generate a dictionary representation of the model, optionally specifying which fields to include or exclude. By default, fields t
src/anthropic/_models.py:139
↓ 33 callers
Method
decode
(self, line: str)
src/anthropic/_streaming.py:471
↓ 32 callers
Function
collect
(stream: Stream[BetaRawMessageStreamEvent])
tests/lib/test_refusal_fallback_streaming.py:148
↓ 32 callers
Function
create_stream
( client: Anthropic, *, betas: List[AnthropicBetaParam] | Omit = omit )
tests/lib/test_refusal_fallback_streaming.py:193
↓ 30 callers
Function
make_async_client
(**kwargs: Any)
tests/test_middleware.py:58
↓ 30 callers
Function
make_sync_client
(**kwargs: Any)
tests/lib/test_refusal_fallback_streaming.py:73
↓ 29 callers
Function
is_dict
(obj: object)
src/anthropic/_utils/_utils.py:194
↓ 29 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:293
↓ 28 callers
Function
message
(model: str, **overrides: Any)
tests/lib/test_refusal_fallback.py:40
↓ 27 callers
Function
foo
(a: str | None = None)
tests/test_required_args.py:10
↓ 27 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:89
↓ 26 callers
Method
download
Download File Args: file_id: ID of the File. betas: Optional header to specify the beta version(s) you want to
src/anthropic/resources/beta/files.py:187
↓ 26 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:472
↓ 25 callers
Function
_run_with_fakes
( *, events: FakeAsyncEvents, tools: list[Any], max_idle: float | None = None, environment
tests/lib/tools/test_session_runner.py:240
↓ 25 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:578
↓ 25 callers
Function
get_response
Convert a fixture file into a stream of bytes for testing.
tests/lib/streaming/helpers.py:18
↓ 25 callers
Function
merge_headers
Merge header mappings, with later mappings taking precedence on a key clash, exactly like `_merge_mappings`. The exception is the headers in
src/anthropic/_base_client.py:2581
↓ 24 callers
Method
read
Read and return the binary response content.
src/anthropic/_response.py:360
↓ 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
_as_dict
(value: object)
src/anthropic/lib/middleware/_fallbacks.py:1450
↓ 23 callers
Function
_terminated
()
tests/lib/tools/test_session_runner.py:89
↓ 23 callers
Method
cancel
Batches may be canceled any time before processing ends. Once cancellation is initiated, the batch enters a `canceling` state, at whi
src/anthropic/resources/messages/batches.py:238
↓ 23 callers
Function
create_message
( client: Anthropic, *, betas: List[AnthropicBetaParam] | Omit = omit, fallbacks: List[BetaFal
tests/lib/test_refusal_fallback.py:74
↓ 23 callers
Function
make_sync_client
(**kwargs: Any)
tests/lib/test_refusal_fallback.py:32
↓ 23 callers
Method
model_dump_json
Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json Generates a JSON representation of the model using
src/anthropic/_models.py:364
↓ 22 callers
Function
_tool_use
(id: str, name: str, input: dict[str, Any])
tests/lib/tools/test_session_runner.py:71
↓ 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
Function
refusal
(model: str, fallback_credit_token: str | None = None)
tests/lib/test_refusal_fallback.py:57
↓ 20 callers
Method
get
( self, path: str, *, cast_to: Type[ResponseT], options: RequestOption
src/anthropic/_base_client.py:1424
↓ 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
tool_runner
( self, *, max_tokens: int, messages: Iterable[BetaMessageParam], mode
src/anthropic/resources/beta/messages/messages.py:1426
↓ 19 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:1320
↓ 19 callers
Function
get_args
(t: type[Any])
src/anthropic/_compat.py:30
↓ 19 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:113
↓ 18 callers
Method
aclose
(self)
src/anthropic/_legacy_response.py:513
↓ 18 callers
Function
request_bodies
(respx_mock: MockRouter)
tests/lib/test_refusal_fallback_streaming.py:156
↓ 17 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:546
↓ 17 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
↓ 17 callers
Function
model_copy
(model: _ModelT, *, deep: bool = False)
src/anthropic/_compat.py:122
↓ 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
↓ 17 callers
Method
to_json
Generates a JSON string representing this model as it would be received from or sent to the API (but with indentation). By default, fields th
src/anthropic/_models.py:177
↓ 16 callers
Function
delta
(event_id: str, text: str, index: int | None = None)
tests/lib/sessions/test_accumulate.py:43
↓ 16 callers
Function
iter_next
(iter: Iterator[_T] | AsyncIterator[_T])
tests/test_streaming.py:254
↓ 16 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:53
↓ 16 callers
Method
write
(profile: str, *, with_base_url: Optional[str])
tests/lib/test_credentials.py:360
↓ 15 callers
Function
beta_tool
(func: FunctionT)
src/anthropic/lib/tools/_beta_functions.py:343
↓ 15 callers
Function
is_list
(obj: object)
src/anthropic/_utils/_utils.py:198
↓ 14 callers
Function
_mock_messages_endpoint
(respx_mock: MockRouter)
tests/lib/test_credentials.py:1862
↓ 14 callers
Method
add
Add Session Resource Args: file_id: ID of a previously uploaded file. mount_path: Mount path in the container.
src/anthropic/resources/beta/sessions/resources.py:296
↓ 14 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:834
↓ 14 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:128
↓ 14 callers
Function
fold
( msg: BetaManagedAgentsAgentMessageEvent, ev: BetaManagedAgentsDeltaEvent, )
tests/lib/sessions/test_accumulate.py:34
↓ 14 callers
Function
is_mapping
(obj: object)
src/anthropic/_utils/_utils.py:186
↓ 14 callers
Method
send
Send Events Args: events: Events to send to the `session`. betas: Optional header to specify the beta version(s
src/anthropic/resources/beta/sessions/events.py:150
↓ 14 callers
Method
start
(self)
examples/memory/basic.py:50
↓ 14 callers
Method
stop
(self, work_id: str, **kwargs: Any)
tests/lib/environments/test_poller_method.py:66
↓ 14 callers
Method
stream
Create a Message stream
src/anthropic/resources/messages/messages.py:1085
↓ 13 callers
Function
TypeAdapter
(*_args: Any, **_kwargs: Any)
src/anthropic/_models.py:904
↓ 13 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
↓ 13 callers
Function
_send_message
(client: Anthropic)
tests/lib/test_credentials.py:1880
↓ 13 callers
Method
add
Add two numbers.
tests/lib/tools/test_functions.py:473
↓ 13 callers
Method
close
(self)
src/anthropic/_client.py:415
↓ 13 callers
Method
close
(self)
src/anthropic/_client.py:826
↓ 13 callers
Method
copy
( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] — subclass intentionally drop
src/anthropic/lib/aws/_client.py:167
↓ 13 callers
Function
extract_type_arg
(typ: type, index: int)
src/anthropic/_utils/_typing.py:83
↓ 13 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
↓ 13 callers
Method
insert
Insert text at a specific line number in a memory file.
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:149
next →
1–100 of 4,447, ranked by callers