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
↓ 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
_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_page_items
(self)
src/anthropic/_base_client.py:211
↓ 3 callers
Function
_idle_end_turn
()
tests/lib/tools/test_session_runner.py:93
↓ 3 callers
Function
_interpolate
Replace {name} placeholders in `template`, quoting each value with `quoter`. Placeholder names are looked up in `values`. Raises: Ke
src/anthropic/_utils/_path.py:47
↓ 3 callers
Function
_is_supported_image_type
(mime_type: str)
src/anthropic/lib/tools/mcp.py:86
↓ 3 callers
Method
_iter_events
(self)
src/anthropic/_streaming.py:74
↓ 3 callers
Method
_make_status_error
( self, err_msg: str, *, body: object, response: httpx.Response, )
src/anthropic/_client.py:512
↓ 3 callers
Function
_read_file_content
(full_path: Path, memory_path: str)
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:354
↓ 3 callers
Method
_request_api_list
( self, model: Type[object], page: Type[SyncPageT], options: FinalRequestOptio
src/anthropic/_base_client.py:1405
↓ 3 callers
Function
_require_env
(name: str)
examples/managed-agents-observe-tool-calls.py:45
↓ 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:239
↓ 3 callers
Function
_safe_json
(text: str)
src/anthropic/lib/middleware/_fallbacks.py:1439
↓ 3 callers
Function
_seam_block
The synthetic `fallback` content block marking one model boundary.
src/anthropic/lib/middleware/_fallbacks.py:1368
↓ 3 callers
Method
_should_retry
(self, response: httpx.Response)
src/anthropic/_base_client.py:842
↓ 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
add_request_id
(obj: BaseModel, request_id: str | None)
src/anthropic/_models.py:844
↓ 3 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
↓ 3 callers
Function
body
()
tests/decoders/test_jsonl.py:17
↓ 3 callers
Method
call
(self, input: object)
src/anthropic/lib/tools/_tool_dispatch.py:34
↓ 3 callers
Method
close
Close the owned ``httpx.Client`` if we created one.
src/anthropic/lib/credentials/_providers.py:387
↓ 3 callers
Function
consume_async_iterator
(iterator: AsyncIterator[Any])
src/anthropic/_utils/_streams.py:10
↓ 3 callers
Function
consume_sync_iterator
(iterator: Iterator[Any])
src/anthropic/_utils/_streams.py:5
↓ 3 callers
Method
content_blocks
The accumulated content blocks, in start order.
src/anthropic/lib/middleware/_fallbacks.py:1205
↓ 3 callers
Method
create
Create a new memory file with the specified content.
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:139
↓ 3 callers
Function
create_stream_async
(client: AsyncAnthropic)
tests/lib/test_refusal_fallback_streaming.py:205
↓ 3 callers
Function
error_response
(message: str, status: int)
tests/lib/test_refusal_fallback_streaming.py:101
↓ 3 callers
Method
finish
The outcome once the hop's stream is fully consumed (or cut early).
src/anthropic/lib/middleware/_fallbacks.py:962
↓ 3 callers
Method
get_max_retries
(self, max_retries: int)
src/anthropic/_models.py:961
↓ 3 callers
Function
handler
(req: httpx.Request)
tests/lib/test_scoped_client.py:126
↓ 3 callers
Method
has_next_page
(self)
src/anthropic/pagination.py:36
↓ 3 callers
Function
human_join
(seq: Sequence[str], *, delim: str = ", ", final: str = "or")
src/anthropic/_utils/_utils.py:207
↓ 3 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
↓ 3 callers
Function
is_file_content
(obj: object)
src/anthropic/_files.py:29
↓ 3 callers
Function
is_iterable
(obj: object)
src/anthropic/_utils/_utils.py:202
↓ 3 callers
Function
is_list_type
(typ: type)
src/anthropic/_utils/_typing.py:25
↓ 3 callers
Function
is_sequence_type
(typ: type)
src/anthropic/_utils/_typing.py:29
↓ 3 callers
Function
is_union_type
(typ: type)
src/anthropic/_utils/_typing.py:40
↓ 3 callers
Method
iter_bytes
(self, chunk_size: int | None = None)
src/anthropic/_legacy_response.py:440
↓ 3 callers
Method
json
Read and decode the JSON response content.
src/anthropic/_response.py:375
↓ 3 callers
Function
json_response
(body: Any, status: int)
tests/lib/test_refusal_fallback_streaming.py:97
↓ 3 callers
Function
make_async_bedrock_client
(**kwargs: Any)
tests/test_middleware.py:1808
↓ 3 callers
Function
make_async_client
(**kwargs: Any)
tests/lib/test_refusal_fallback_streaming.py:77
↓ 3 callers
Function
make_async_mantle_client
(**kwargs: Any)
tests/test_middleware.py:1824
↓ 3 callers
Function
make_bedrock_client
(**kwargs: Any)
tests/test_middleware.py:1804
↓ 3 callers
Function
make_jsonl_iterator
( content: Iterator[bytes], *, sync: bool, line_type: type[_T], )
tests/decoders/test_jsonl.py:79
↓ 3 callers
Function
make_mantle_client
(**kwargs: Any)
tests/test_middleware.py:1820
↓ 3 callers
Function
make_vertex_client
(**kwargs: Any)
tests/test_middleware.py:1812
↓ 3 callers
Function
mcp_resource_to_file
Convert MCP resource contents to a file tuple for ``files.upload()``. Returns a ``(filename, content_bytes, mime_type)`` tuple compatible with
src/anthropic/lib/tools/mcp.py:278
↓ 3 callers
Method
next_page_info
(self)
src/anthropic/_base_client.py:209
↓ 3 callers
Method
read
Read and return the binary response content.
src/anthropic/_response.py:467
↓ 3 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
↓ 3 callers
Method
start
(cls, workdir: str | os.PathLike[str], *, env: Optional[Mapping[str, str]] = None)
src/anthropic/lib/tools/agent_toolset.py:316
↓ 3 callers
Function
strip_annotated_type
(typ: type)
src/anthropic/_utils/_typing.py:76
↓ 2 callers
Method
__aenter__
(self)
src/anthropic/lib/tools/agent_toolset.py:247
↓ 2 callers
Method
__aenter__
(self)
tests/lib/tools/test_session_runner.py:134
↓ 2 callers
Method
__enter__
(self)
src/anthropic/_streaming.py:172
↓ 2 callers
Method
__exit__
( self, exc_type: type[BaseException] | None, exc: BaseException | None, exc_t
src/anthropic/lib/streaming/_messages.py:73
↓ 2 callers
Method
__init__
( self, *, raw: httpx.Response, cast_to: type[R], client: BaseClient[A
src/anthropic/_response.py:62
↓ 2 callers
Method
__init__
( self, *, resource: str | None = None, api_key: str | None = None, az
src/anthropic/lib/foundry.py:97
↓ 2 callers
Method
__init__
( self, *, params: ParseMessageCreateParamsBase[ResponseFormatT], options: Req
src/anthropic/lib/tools/_beta_runner.py:68
↓ 2 callers
Function
_active_profile
Resolve the active profile name. ``ANTHROPIC_PROFILE`` env var → ``<config_dir>/active_config`` pointer file → ``"default"`` literal. The res
src/anthropic/lib/credentials/_constants.py:98
↓ 2 callers
Method
_applicable_body
The request's JSON body when this middleware applies to it, `None` otherwise.
src/anthropic/lib/middleware/_fallbacks.py:309
↓ 2 callers
Method
_apply
(self, request: httpx.Request, token: str)
src/anthropic/lib/credentials/_auth.py:88
↓ 2 callers
Function
_archive_file_mode
Reduce an archive entry's Unix mode to ``0o755`` if it is executable, ``0o644`` otherwise. Skill bundles can ship executable scripts (e.g. ``
src/anthropic/lib/tools/_skills.py:94
↓ 2 callers
Function
_array_suffix
(array_format: ArrayFormat, array_index: int)
src/anthropic/_utils/_utils.py:61
↓ 2 callers
Function
_async_atomic_write_file
(target_path: AsyncPath, content: str)
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:610
↓ 2 callers
Function
_async_transform_file
(file: FileTypes)
src/anthropic/_files.py:107
↓ 2 callers
Function
_async_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:322
↓ 2 callers
Method
_atomic_write_credentials
Atomic write to the credentials file (NOT the config file).
src/anthropic/lib/credentials/_providers.py:407
↓ 2 callers
Function
_atomic_write_file
(target_path: Path, content: str)
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:281
↓ 2 callers
Method
_attempt_request
Prepare, build and send a single HTTP attempt. Returns the response regardless of its status code, along with the prepared options it
src/anthropic/_base_client.py:1265
↓ 2 callers
Method
_attempt_request
Prepare, build and send a single HTTP attempt. Returns the response regardless of its status code, along with the prepared options it
src/anthropic/_base_client.py:2017
↓ 2 callers
Function
_basic_config
()
src/anthropic/_utils/_logs.py:8
↓ 2 callers
Function
_bind_credentials_base_url
If the credential provider supports ``bind_base_url``, pass it the client's resolved ``base_url`` so the token exchange and API calls hit the
src/anthropic/_client.py:73
↓ 2 callers
Function
_close_credentials
Release any resources owned by a credential provider, if it exposes ``close()``.
src/anthropic/_client.py:66
↓ 2 callers
Function
_coerce_expires_at
Parse a credentials-file ``expires_at`` field into Unix seconds.
src/anthropic/lib/credentials/_providers.py:50
↓ 2 callers
Function
_collect_error
(match: Match[str])
scripts/utils/ruffen-docs.py:39
↓ 2 callers
Function
_config_file_path
Path to ``<config_dir>/configs/<profile>.json`` (non-secret, 0644).
src/anthropic/lib/credentials/_constants.py:179
↓ 2 callers
Method
_convert_to_legacy_response
Convert an `APIResponse` / `AsyncAPIResponse` into the equivalent `LegacyAPIResponse`.
src/anthropic/_base_client.py:663
↓ 2 callers
Function
_convert_tool_result
Convert MCP ``CallToolResult`` to a value suitable for returning from ``call()``.
src/anthropic/lib/tools/mcp.py:312
↓ 2 callers
Function
_credit_token
The refusal's minted credit token; only the beta surface carries one.
src/anthropic/lib/middleware/_fallbacks.py:1354
↓ 2 callers
Function
_declined_iteration_entries
The `usage.iterations` entries a declined hop contributes to the chain. The hop's refusal self-reports its iterations: adopt them, retyped to
src/anthropic/lib/middleware/_fallbacks.py:1154
↓ 2 callers
Function
_default_worker_id
()
src/anthropic/lib/environments/_poller.py:46
↓ 2 callers
Function
_drive_hop
Feed one hop's SSE events through `reader`, yielding the frames to forward.
src/anthropic/lib/middleware/_fallbacks.py:977
↓ 2 callers
Function
_drive_hop_async
Feed one hop's SSE events through `reader`, yielding the frames to forward. The outcome is read from `reader.finish()` afterwards — async generat
src/anthropic/lib/middleware/_fallbacks.py:989
↓ 2 callers
Method
_enforce_trailing_slash
(self, url: URL)
src/anthropic/_base_client.py:421
↓ 2 callers
Function
_expects_response_wrapper
Whether the given `cast_to` asks for the `APIResponse` wrapper itself.
src/anthropic/_base_client.py:2648
↓ 2 callers
Method
_fallback
(self, request: APIRequest)
tests/test_middleware.py:137
↓ 2 callers
Function
_from_unix_seconds
(seconds: Union[int, float])
src/anthropic/_utils/_datetime_parse.py:44
↓ 2 callers
Method
_get_azure_ad_token
(self)
src/anthropic/lib/foundry.py:262
↓ 2 callers
Method
_get_azure_ad_token
(self)
src/anthropic/lib/foundry.py:487
↓ 2 callers
Method
_get_last_assistant_message
(self)
src/anthropic/lib/tools/_beta_runner.py:382
↓ 2 callers
Method
_get_last_assistant_message
(self)
src/anthropic/lib/tools/_beta_runner.py:614
↓ 2 callers
Function
_get_numeric
(value: StrBytesIntFloat, native_expected_type: str)
src/anthropic/_utils/_datetime_parse.py:33
↓ 2 callers
Method
_handle_item
The per-item body shared by :meth:`run`'s poll loop and :meth:`handle_item`. Runs a :class:`SessionToolRunner` for the work item's session wh
src/anthropic/lib/environments/_worker.py:376
↓ 2 callers
Function
_has_explicit_active_config
True if the user wrote a non-empty ``active_config`` pointer file. This is an explicit opt-in signal equivalent to setting ``ANTHROPIC_PROFILE``:
src/anthropic/lib/credentials/_constants.py:208
↓ 2 callers
Method
_has_static_credential
(request: httpx.Request)
src/anthropic/lib/credentials/_auth.py:85
↓ 2 callers
Method
_idempotency_key
(self)
src/anthropic/_base_client.py:902
↓ 2 callers
Function
_infer_region
Infer the AWS region from the environment variables or from the boto3 session if available.
src/anthropic/lib/bedrock/_client.py:72
← previous
next →
301–400 of 4,447, ranked by callers