Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/anthropics/anthropic-sdk-python
/ functions
Functions
4,911 in github.com/anthropics/anthropic-sdk-python
⨍
Functions
4,911
◇
Types & classes
1,594
↳
Endpoints
26
↓ 1 callers
Function
_build_federation_result
Build a :class:`CredentialResult` for the env-var federation path (step 4 in the precedence spec). Returns ``None`` if the required trio isn't
src/anthropic/lib/credentials/_chain.py:29
↓ 1 callers
Method
_build_headers
(self, options: FinalRequestOptions, *, retries_taken: int = 0)
src/anthropic/_base_client.py:457
↓ 1 callers
Method
_build_middleware_chain
Build the middleware invocation chain. The chain only depends on the immutable `self._middleware` tuple so it is built once at constr
src/anthropic/_base_client.py:1199
↓ 1 callers
Method
_build_middleware_chain
Build the middleware invocation chain. The chain only depends on the immutable `self._middleware` tuple so it is built once at constr
src/anthropic/_base_client.py:1945
↓ 1 callers
Function
_build_result_event
Build the result-event params matching ``ev``'s tool-call kind. A custom tool call (``agent.custom_tool_use``) is answered with a ``user.cust
src/anthropic/lib/tools/_beta_session_runner.py:323
↓ 1 callers
Method
_call_oidc_federation
(self, auth: Dict[str, Any], *, force_refresh: bool = False)
src/anthropic/lib/credentials/_providers.py:622
↓ 1 callers
Method
_call_provider
Call the provider, retrying once on a 401 from the token endpoint.
src/anthropic/lib/credentials/_cache.py:88
↓ 1 callers
Method
_call_user_oauth
Interactive-login profile. With a ``client_id`` in the auth block, we run the refresh_token grant on expiry; without one, we treat the
src/anthropic/lib/credentials/_providers.py:495
↓ 1 callers
Method
_check_and_compact
Check token usage and compact messages if threshold exceeded. Returns True if compaction was performed, False otherwise.
src/anthropic/lib/tools/_beta_runner.py:188
↓ 1 callers
Method
_check_and_compact
Check token usage and compact messages if threshold exceeded. Returns True if compaction was performed, False otherwise.
src/anthropic/lib/tools/_beta_runner.py:477
↓ 1 callers
Method
_cleanup_skills
Remove the skill directories :meth:`setup_skills` downloaded. Only the directories this context created are removed — a pre-existing
src/anthropic/lib/tools/agent_toolset.py:280
↓ 1 callers
Function
_coerce_expires_at
Parse a credentials-file ``expires_at`` field into Unix seconds.
src/anthropic/lib/credentials/_providers.py:58
↓ 1 callers
Function
_collect_files
(directory: Path, relative_to: Path, files: list[FileTypes])
src/anthropic/lib/_files.py:19
↓ 1 callers
Function
_construct_field
(value: object, field: FieldInfo, key: str)
src/anthropic/_models.py:495
↓ 1 callers
Function
_convert_tool_result
Convert MCP ``CallToolResult`` to a value suitable for returning from ``call()``.
src/anthropic/lib/tools/mcp.py:312
↓ 1 callers
Function
_create_pydantic_model
(type_: _T)
src/anthropic/_models.py:901
↓ 1 callers
Method
_create_schema_from_function
Create JSON schema from function signature using pydantic.
src/anthropic/lib/tools/_beta_functions.py:216
↓ 1 callers
Function
_credentials_file_path
Path to ``<config_dir>/credentials/<profile>.json`` (secret, 0600).
src/anthropic/lib/credentials/_constants.py:186
↓ 1 callers
Function
_custom_tool_result
(custom_tool_use_id: str)
tests/lib/tools/test_session_runner.py:98
↓ 1 callers
Function
_dec
(*_: Any, **__: Any)
src/anthropic/_models.py:911
↓ 1 callers
Function
_deepcopy_with_paths
(item: _T, paths: Sequence[Sequence[str]], index: int)
src/anthropic/_files.py:148
↓ 1 callers
Function
_default_bash_env
The environment for the bash subprocess, with the runner's own credentials scrubbed. The bash tool runs model-issued commands, so it must nev
src/anthropic/lib/tools/agent_toolset.py:142
↓ 1 callers
Function
_download_and_extract
Stream the skill archive to a temp file, then extract it into ``dest``.
src/anthropic/lib/tools/_skills.py:235
↓ 1 callers
Function
_drive_hop
Feed one hop's SSE events through `reader`, yielding the frames to forward.
src/anthropic/lib/middleware/_fallbacks.py:1006
↓ 1 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:1018
↓ 1 callers
Method
_ensure_access_token
(self)
src/anthropic/lib/vertex/_client.py:166
↓ 1 callers
Method
_ensure_access_token
(self)
src/anthropic/lib/vertex/_client.py:330
↓ 1 callers
Function
_entered
()
src/anthropic/lib/tools/_beta_functions.py:561
↓ 1 callers
Method
_execute
Run ``ev``'s tool, post its result, and surface the dispatched call. ``confirmation`` is the verdict that released the call onto the work
src/anthropic/lib/tools/_beta_session_runner.py:824
↓ 1 callers
Function
_extract_field_schema_pv2
(model: type[BaseModel], field_name: str)
src/anthropic/_models.py:807
↓ 1 callers
Function
_extract_items
( obj: object, path: Sequence[str], *, index: int, flattened_key: str | None, array_fo
src/anthropic/_utils/_utils.py:75
↓ 1 callers
Function
_fill_missing_from_env
Fill empty profile fields from corresponding ANTHROPIC_* env vars. The profile file is authoritative — this only fills fields the file left u
src/anthropic/lib/credentials/_providers.py:86
↓ 1 callers
Method
_finalize_middleware_result
Convert the `APIResponse` returned by the middleware chain into the value the original caller expects. The middleware chain operates on `APIR
src/anthropic/_base_client.py:1237
↓ 1 callers
Method
_finalize_middleware_result
Convert the `AsyncAPIResponse` returned by the middleware chain into the value the original caller expects. The middleware chain operates on
src/anthropic/_base_client.py:1989
↓ 1 callers
Function
_force_stop_quietly
Best-effort ``work.stop(force=True)`` for an item that can't be processed. A 409 just means the work already stopped; anything else is logged but
src/anthropic/lib/environments/_poller.py:176
↓ 1 callers
Function
_format_data
(data: object, format_: PropertyFormat, format_template: str | None)
src/anthropic/_utils/_transform.py:238
↓ 1 callers
Method
_gen
(self)
tests/lib/tools/test_session_runner.py:156
↓ 1 callers
Method
_generate_tool_call_response
(self)
src/anthropic/lib/tools/_beta_runner.py:330
↓ 1 callers
Method
_generate_tool_call_response
(self)
src/anthropic/lib/tools/_beta_runner.py:639
↓ 1 callers
Method
_get_description_from_docstring
Extract description from parsed docstring.
src/anthropic/lib/tools/_beta_functions.py:207
↓ 1 callers
Function
_get_extra_fields_type
(cls: type[pydantic.BaseModel])
src/anthropic/_models.py:510
↓ 1 callers
Method
_get_last_assistant_message_content
(self)
src/anthropic/lib/tools/_beta_runner.py:400
↓ 1 callers
Method
_get_last_assistant_message_content
(self)
src/anthropic/lib/tools/_beta_runner.py:632
↓ 1 callers
Method
_get_page
(self)
src/anthropic/_base_client.py:314
↓ 1 callers
Function
_get_parameters_info
(fn: BaseFunctionTool[Any])
tests/lib/tools/test_functions.py:444
↓ 1 callers
Function
_get_session
( *, aws_access_key: str | None, aws_secret_key: str | None, aws_session_token: str | None,
src/anthropic/lib/bedrock/_auth.py:14
↓ 1 callers
Function
_get_session
( *, aws_access_key: str | None, aws_secret_key: str | None, aws_session_token: str | None,
src/anthropic/lib/aws/_auth.py:14
↓ 1 callers
Method
_get_token
(self)
src/anthropic/lib/google_cloud/_client.py:561
↓ 1 callers
Method
_handle_request
(self)
src/anthropic/lib/tools/_beta_runner.py:184
↓ 1 callers
Method
_handle_request
(self)
src/anthropic/lib/tools/_beta_runner.py:473
↓ 1 callers
Function
_has_active_profile_config
Tighter auto-discover check for the tier-1 credential chain. Returns ``True`` only if the *active* profile's config file exists. The previous
src/anthropic/lib/credentials/_constants.py:193
↓ 1 callers
Function
_has_auto_discoverable_credentials
True if the environment / filesystem contains signals that would normally drive the tier-1 (profile) or tier-2 (env federation) paths of :func
src/anthropic/lib/credentials/_constants.py:230
↓ 1 callers
Function
_heartbeat_loop
Keep the work-item lease alive while a session is being served. ``work`` must be bound to a sub-client authenticated for the environment; thi
src/anthropic/lib/environments/_worker.py:90
↓ 1 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
↓ 1 callers
Method
_invoke_provider
Invoke ``self._provider``, tolerating legacy zero-arg callables.
src/anthropic/lib/credentials/_cache.py:76
↓ 1 callers
Function
_is_async_cm_factory
True when ``fn`` is a function produced by :func:`contextlib.asynccontextmanager`.
src/anthropic/lib/tools/_beta_functions.py:305
↓ 1 callers
Function
_is_supported_resource_mime_type
(mime_type: str | None)
src/anthropic/lib/tools/mcp.py:90
↓ 1 callers
Function
_is_sync_cm_factory
True when ``fn`` is a function produced by :func:`contextlib.contextmanager`. ``contextmanager`` wraps the generator function with ``functools.wr
src/anthropic/lib/tools/_beta_functions.py:293
↓ 1 callers
Function
_iter
()
tests/lib/environments/test_worker.py:142
↓ 1 callers
Method
_iter_chunks
Given an iterator that yields raw binary data, iterate over it and yield individual SSE chunks
src/anthropic/_streaming.py:437
↓ 1 callers
Method
_iter_events
(self)
src/anthropic/_streaming.py:242
↓ 1 callers
Function
_make_async_iterator
(iterable: Iterable[T], counter: Optional[Counter] = None)
tests/test_client.py:100
↓ 1 callers
Method
_make_status_error
( self, err_msg: str, *, body: object, response: httpx.Response, )
src/anthropic/_base_client.py:448
↓ 1 callers
Method
_make_status_error
( self, err_msg: str, *, body: object, response: httpx.Response, )
src/anthropic/_client.py:931
↓ 1 callers
Function
_make_sync_iterator
(iterable: Iterable[T], counter: Optional[Counter] = None)
tests/test_client.py:93
↓ 1 callers
Function
_make_targz_modes
(path: Path, entries: dict[str, tuple[bytes, int]])
tests/lib/tools/test_skills.py:52
↓ 1 callers
Function
_make_zip_modes
(path: Path, entries: dict[str, tuple[bytes, int]])
tests/lib/tools/test_skills.py:43
↓ 1 callers
Function
_media_type_literal_values
Extract the values of a ``Required[Literal[...]]`` TypedDict field.
tests/lib/tools/test_agent_toolset.py:217
↓ 1 callers
Function
_merge_mappings
Merge two mappings of the same type, removing any values that are instances of `Omit`. In cases with duplicate keys the second mapping takes prec
src/anthropic/_base_client.py:2547
↓ 1 callers
Function
_migrate_legacy_config
Adapter: convert a flat legacy config dict into the new nested shape. Many tests in this file predate the schema migration and pass legacy fl
tests/lib/test_credentials.py:88
↓ 1 callers
Method
_note_confirmation
Record an allow/deny verdict and release the held call it gates, if any.
src/anthropic/lib/tools/_beta_session_runner.py:722
↓ 1 callers
Method
_params_from_url
(self, url: URL)
src/anthropic/_base_client.py:214
↓ 1 callers
Method
_parse
(self, *, to: type[_T] | None = None)
src/anthropic/_legacy_response.py:199
↓ 1 callers
Method
_parse_retry_after_header
Returns a float of the number of seconds (not milliseconds) to wait after retrying, or None if unspecified. About the Retry-After header: htt
src/anthropic/_base_client.py:784
↓ 1 callers
Function
_parse_timezone
(value: Optional[str])
src/anthropic/_utils/_datetime_parse.py:56
↓ 1 callers
Function
_patch
`overrides` applied flat against `base`: a key set to a value overrides it, a key explicitly `None` unsets it, an absent key keeps the base value.
src/anthropic/lib/middleware/_fallbacks.py:1488
↓ 1 callers
Method
_prepare_options
Hook for mutating the given options
src/anthropic/_base_client.py:1064
↓ 1 callers
Method
_prepare_options
Hook for mutating the given options
src/anthropic/_base_client.py:1803
↓ 1 callers
Method
_prepare_request
This method is used as a callback for mutating the `Request` object after it has been constructed. This is useful for cases where you
src/anthropic/_base_client.py:1071
↓ 1 callers
Method
_prepare_request
This method is used as a callback for mutating the `Request` object after it has been constructed. This is useful for cases where you
src/anthropic/_base_client.py:1810
↓ 1 callers
Method
_prepare_url
Merge a URL argument together with any 'base_url' on the client, to create the URL used for the outgoing request.
src/anthropic/_base_client.py:492
↓ 1 callers
Function
_prepend_seam_blocks
(response: APIResponse[Any], seams: list[dict[str, Any]])
src/anthropic/lib/middleware/_fallbacks.py:1437
↓ 1 callers
Function
_prepend_seam_blocks_async
(response: AsyncAPIResponse[Any], seams: list[dict[str, Any]])
src/anthropic/lib/middleware/_fallbacks.py:1452
↓ 1 callers
Method
_primitive_value_to_str
(self, value: PrimitiveData)
src/anthropic/_qs.py:120
↓ 1 callers
Function
_pycon_match
(match: Match[str])
scripts/utils/ruffen-docs.py:52
↓ 1 callers
Function
_read_binary_block
Read an image/PDF as a base64 ``image``/``document`` content block. The text cap does not apply here — its 256 KiB default would reject most
src/anthropic/lib/tools/agent_toolset.py:538
↓ 1 callers
Method
_read_credentials_if_exists
``_read_credentials`` variant that returns ``None`` on absence instead of raising — used by the federation disk-cache path where a mis
src/anthropic/lib/credentials/_providers.py:607
↓ 1 callers
Function
_read_json
(response: httpx.Response)
src/anthropic/lib/middleware/_fallbacks.py:1525
↓ 1 callers
Function
_read_json_async
(response: httpx.Response)
src/anthropic/lib/middleware/_fallbacks.py:1532
↓ 1 callers
Method
_reconcile
Read full history and enqueue every tool-call event still unanswered. Two-pass: read the whole history before emitting so a tool-call whose
src/anthropic/lib/tools/_beta_session_runner.py:553
↓ 1 callers
Function
_referenced_tool_name
The locally runnable tool name a tool-change reference resolves to. Only ``tool_reference`` names a runnable tool; ``mcp_tool_reference`` / `
src/anthropic/lib/tools/_tool_dispatch.py:110
↓ 1 callers
Method
_request_api_list
( self, model: Type[_T], page: Type[AsyncPageT], options: FinalRequestOptions,
src/anthropic/_base_client.py:2157
↓ 1 callers
Function
_require
Fall back to ``env_var`` for ``value``; raise a clear error if still empty. The ``ANTHROPIC_*`` env vars are the ones the ``ant worker poll --on-
src/anthropic/lib/environments/_worker.py:154
↓ 1 callers
Function
_require_env
(name: str)
examples/managed-agents-self-hosted-sandbox-worker.py:47
↓ 1 callers
Function
_resolve_skill_version
Resolve ``version`` to the concrete numeric timestamp the ``/v1/skills/{id}/versions/{version}`` endpoints require. ``session.agent.skills[].
src/anthropic/lib/tools/_skills.py:169
↓ 1 callers
Function
_run_session_tools
Internal: drive a :class:`SessionToolRunner` as an async context manager. Kept as a thin module-level shim because :class:`~anthropic.lib.env
src/anthropic/lib/tools/_beta_session_runner.py:965
↓ 1 callers
Function
_safe_member_name
Return ``name`` as a confined relative path, or raise on path-traversal. Strips ``.`` components; rejects absolute paths and any ``..`` component
src/anthropic/lib/tools/_skills.py:44
↓ 1 callers
Function
_scoped_client
Build the runner's request client. With an environment key, defer to :func:`_copy_client_with_bearer_auth` for a Bearer-only sub-client. With
src/anthropic/lib/tools/_beta_session_runner.py:288
↓ 1 callers
Function
_sdk_frame_locals
(code name, locals) for every traceback frame owned by the anthropic package, across the full ``__context__`` / ``__cause__`` chain.
tests/lib/test_credentials.py:3209
↓ 1 callers
Method
_send_result
Post ``tool_result`` back to the session, retrying transient failures. ``tool_use_id`` is the originating tool-call event id — passed
src/anthropic/lib/tools/_beta_session_runner.py:888
← previous
next →
601–700 of 4,911, ranked by callers