Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/anthropics/anthropic-sdk-python
/ functions
Functions
5,068 in github.com/anthropics/anthropic-sdk-python
⨍
Functions
5,068
◇
Types & classes
1,620
↳
Endpoints
13
↓ 6 callers
Function
_requests_to
(respx_mock: MockRouter, base_url: str)
tests/lib/test_credentials.py:1991
↓ 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:79
↓ 6 callers
Method
_validate_path
Validate and resolve memory paths
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:673
↓ 6 callers
Method
_walk_sync_auth
(client: Anthropic)
tests/lib/test_credentials.py:3213
↓ 6 callers
Method
_workload_provider
(self, handler: Callable[[httpx.Request], httpx.Response])
tests/lib/test_credentials.py:3556
↓ 6 callers
Method
aclose
(self)
src/anthropic/lib/middleware/_fallbacks.py:1634
↓ 6 callers
Method
append_messages
Add one or more messages to the conversation history. This invalidates the cached tool response, i.e. if tools were already called, then they
src/anthropic/lib/tools/_beta_runner.py:111
↓ 6 callers
Function
beta_async_tool
(func: AsyncFunctionT)
src/anthropic/lib/tools/_beta_functions.py:473
↓ 6 callers
Function
beta_glob_tool
(ctx: AgentToolContext)
src/anthropic/lib/tools/agent_toolset.py:758
↓ 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:847
↓ 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:868
↓ 6 callers
Function
foo
(a: str | None = None)
tests/test_required_args.py:10
↓ 6 callers
Method
invalidate
Clear the cached token so the next :meth:`get_token` re-invokes the provider. Also sets a one-shot ``force_refresh`` flag so on-disk provider
src/anthropic/lib/credentials/_cache.py:177
↓ 6 callers
Function
is_annotated_type
(typ: type)
src/anthropic/_utils/_typing.py:21
↓ 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:275
↓ 6 callers
Method
parse
( self, *, max_tokens: int, messages: Iterable[MessageParam], model: M
src/anthropic/resources/messages/messages.py:1200
↓ 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
Method
run
Poll the environment and service each claimed session until cancelled. Loops forever; cancel the task (or wrap it in :func:`asyncio.wait_for`
src/anthropic/lib/environments/_worker.py:298
↓ 6 callers
Method
stop
Track a content_block_stop, shifting `event["index"]`.
src/anthropic/lib/middleware/_fallbacks.py:1268
↓ 6 callers
Method
to_dict
(self)
src/anthropic/lib/tools/_beta_functions.py:183
↓ 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:510
↓ 5 callers
Method
__get_proxied__
(self)
src/anthropic/_utils/_proxy.py:57
↓ 5 callers
Method
__init__
( self, *, url: URL, )
src/anthropic/_base_client.py:147
↓ 5 callers
Function
_drain_one
Pull a single item from a sync iterator; assert there was one.
tests/lib/environments/test_poller_method.py:116
↓ 5 callers
Function
_emit
(event: str, payload: dict[str, Any])
src/anthropic/lib/middleware/_fallbacks.py:1539
↓ 5 callers
Method
_get_http_client
Return an ``httpx.Client``, lazily creating (and tracking) one we own.
src/anthropic/lib/credentials/_providers.py:429
↓ 5 callers
Function
_is_base_client
True only for the base ``Anthropic`` / ``AsyncAnthropic`` classes, not subclasses. Subclasses (``AnthropicAWS``, ``AnthropicFoundry``) have their
src/anthropic/_client.py:57
↓ 5 callers
Function
_is_status
(err: Exception, code: int)
src/anthropic/lib/environments/_poller.py:42
↓ 5 callers
Method
_load_config
Read and cache the config file, resolving ``base_url`` and ``credentials_path``.
src/anthropic/lib/credentials/_providers.py:306
↓ 5 callers
Function
_to_session_content
(content: Any)
tests/lib/tools/test_session_runner.py:1679
↓ 5 callers
Method
_write_refresh_profile
(self, clean_env: pytest.MonkeyPatch, tmp_path: pathlib.Path)
tests/lib/test_credentials.py:3633
↓ 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:74
↓ 5 callers
Function
beta_write_tool
(ctx: AgentToolContext)
src/anthropic/lib/tools/agent_toolset.py:677
↓ 5 callers
Method
copy
( self, *, method: str | NotGiven = not_given, url: str | NotGiven = not_given
src/anthropic/_request.py:69
↓ 5 callers
Function
drive
()
tests/lib/tools/test_session_runner.py:572
↓ 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
src/anthropic/lib/credentials/_providers.py:246
↓ 5 callers
Method
handle_item
Service a single, already-claimed work item without the poll loop. Builds the per-session :class:`AgentToolContext` (workdir from this
src/anthropic/lib/environments/_worker.py:329
↓ 5 callers
Function
helper_header
The ``x-stainless-helper: <value>`` header dict, for passing into a ``merge_headers`` call or as ``extra_headers``/``default_headers``. Typin
src/anthropic/lib/_stainless_helpers.py:72
↓ 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:674
↓ 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 ar
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:391
↓ 5 callers
Method
list
List available models. The Models API response can be used to determine which models are available for use in the API. More
src/anthropic/resources/models.py:89
↓ 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:: from anthropic.lib.tools.mcp import mcp_tool tools
src/anthropic/lib/tools/mcp.py:354
↓ 5 callers
Function
print_obj
Pretty print an object to a string
tests/lib/utils.py:18
↓ 5 callers
Method
provider
(*, force_refresh: bool = False)
tests/lib/test_credentials.py:1647
↓ 5 callers
Method
request
( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, str
src/anthropic/_base_client.py:1822
↓ 5 callers
Function
serving_stream
(model: str = FALLBACK_MODEL, message_id: str = "msg_b")
tests/lib/test_refusal_fallback_streaming.py:928
↓ 5 callers
Function
set_pydantic_config
Add a pydantic config for the given type. Note: this is a no-op on Pydantic v1.
src/anthropic/_models.py:842
↓ 4 callers
Method
__init__
(self, message: str, request: httpx.Request, *, body: object | None)
src/anthropic/_exceptions.py:49
↓ 4 callers
Function
_adrain_one
(ait: AsyncIterator[Any])
tests/lib/environments/test_poller_method.py:124
↓ 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:1467
↓ 4 callers
Function
_assert_credential_chain_off
(client: AnthropicGoogleCloud | AsyncAnthropicGoogleCloud)
tests/lib/test_google_cloud.py:914
↓ 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:647
↓ 4 callers
Method
_calculate_retry_timeout
( self, remaining_retries: int, options: FinalRequestOptions, response_headers
src/anthropic/_base_client.py:817
↓ 4 callers
Function
_chunk_bytes_to_sse
(raw: bytes)
src/anthropic/lib/bedrock/_stream_decoder.py:68
↓ 4 callers
Function
_format_file_size
(bytes_size: int)
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:363
↓ 4 callers
Method
_get_last_message
(self)
src/anthropic/lib/tools/_beta_runner.py:388
↓ 4 callers
Method
_get_last_message
(self)
src/anthropic/lib/tools/_beta_runner.py:620
↓ 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:1240
↓ 4 callers
Function
_install_aiter_work
(monkeypatch: pytest.MonkeyPatch, items: list[Any])
tests/lib/environments/test_worker.py:123
↓ 4 callers
Function
_json_dumps
(value: Any)
src/anthropic/lib/middleware/_fallbacks.py:1517
↓ 4 callers
Function
_mock_token_exchange
(respx_mock: MockRouter, base_url: str, token: str)
tests/lib/test_credentials.py:1976
↓ 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:306
↓ 4 callers
Function
_tar_file
( name: str, data: bytes, *, mode: int = 0o644, type: bytes = tarfile.REGTYPE )
tests/lib/tools/test_skills.py:61
↓ 4 callers
Function
_within
True if ``child`` is ``root`` or a path inside it (both already resolved).
src/anthropic/lib/tools/_skills.py:37
↓ 4 callers
Function
_work_item
(*, work_type: str = "session", work_id: str = "w_1", session_id: str = "s_1")
tests/lib/environments/test_worker.py:119
↓ 4 callers
Function
_zip_entry
(name: str, *, mode: int, create_system: int = 3)
tests/lib/tools/test_skills.py:86
↓ 4 callers
Method
aiter_bytes
Given an iterator that yields raw binary data, iterate over it & yield every event encountered
src/anthropic/_streaming.py:449
↓ 4 callers
Method
aread
(self)
src/anthropic/_legacy_response.py:488
↓ 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_grep_tool
(ctx: AgentToolContext)
src/anthropic/lib/tools/agent_toolset.py:803
↓ 4 callers
Function
beta_headers
(respx_mock: MockRouter)
tests/lib/test_refusal_fallback_streaming.py:166
↓ 4 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:552
↓ 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
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
is_type_alias_type
Return whether the provided argument is an instance of `TypeAliasType`. ```python type Int = int is_type_alias_type(Int) # > True
src/anthropic/_utils/_typing.py:59
↓ 4 callers
Function
iter_next
(iter: Iterator[_T] | AsyncIterator[_T])
tests/decoders/test_jsonl.py:68
↓ 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
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
Method
set_messages_params
Update the parameters for the next API call. This invalidates any cached tool responses. Args: params (ParsedMessageCrea
src/anthropic/lib/tools/_beta_runner.py:96
↓ 4 callers
Function
update_env
(**new_env: str | Omit)
tests/utils.py:154
↓ 4 callers
Method
worker
()
tests/lib/test_credentials.py:1621
↓ 3 callers
Method
__init__
(self, *, cache_control: BetaCacheControlEphemeralParam | None = None)
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:87
↓ 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:755
↓ 3 callers
Function
_async_read_file_content
(full_path: AsyncPath, memory_path: str)
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:651
← previous
next →
201–300 of 5,068, ranked by callers