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
↓ 2 callers
Method
_iter_events
(self)
src/anthropic/_streaming.py:74
↓ 2 callers
Function
_make
(fn: FunctionT)
src/anthropic/lib/tools/_beta_functions.py:415
↓ 2 callers
Method
_make_pin
Pin requests sharing the state to the entry being tried (or warn that there is none).
src/anthropic/lib/middleware/_fallbacks.py:370
↓ 2 callers
Method
_make_sse_decoder
(self)
src/anthropic/_base_client.py:505
↓ 2 callers
Method
_make_status_error_from_response
( self, response: httpx.Response, )
src/anthropic/_base_client.py:426
↓ 2 callers
Function
_make_zip
(path: Path, entries: dict[str, bytes])
tests/lib/tools/test_skills.py:29
↓ 2 callers
Method
_maybe_override_cast_to
(self, cast_to: type[ResponseT], options: FinalRequestOptions)
src/anthropic/_base_client.py:646
↓ 2 callers
Function
_maybe_transform_key
Transform the given `data` based on the annotations provided in `type_`. Note: this function only looks at `Annotated` types that contain `Proper
src/anthropic/_utils/_transform.py:131
↓ 2 callers
Function
_merged_body
The non-streaming retry body: the fallback entry applied as a patch against the original params, plus the refusal's credit token when it minted on
src/anthropic/lib/middleware/_fallbacks.py:1501
↓ 2 callers
Function
_middleware_entry_mode
The raw-response mode the original caller entered the middleware chain with.
src/anthropic/_base_client.py:2616
↓ 2 callers
Function
_middleware_name
(middleware: object)
src/anthropic/_middleware.py:66
↓ 2 callers
Method
_mutate
(self, request: APIRequest)
tests/test_middleware.py:119
↓ 2 callers
Function
_no_transform_needed
(annotation: type)
src/anthropic/_utils/_transform.py:150
↓ 2 callers
Method
_open
Open the wire for this hop: its message_start (raw for stream A; suppressed or id-rewritten for a spliced hop), the queued seam frames,
src/anthropic/lib/middleware/_fallbacks.py:962
↓ 2 callers
Method
_parse
(self, *, to: type[_T] | None = None)
src/anthropic/_response.py:129
↓ 2 callers
Method
_parse_message_from_event
(self, event: EventStreamMessage)
src/anthropic/lib/bedrock/_stream_decoder.py:55
↓ 2 callers
Function
_passthrough_sse
Forward a decoded event in its original wire bytes, preserving SSE fields beyond `event:`/`data:` (`id:`, `retry:`, comment lines). Falls back to
src/anthropic/lib/middleware/_fallbacks.py:1543
↓ 2 callers
Function
_prepare_middleware_options
Build the options the base middleware handler hands to `_attempt_request()`. Returns a copy so that mutations made by the request pipeline never
src/anthropic/_base_client.py:2626
↓ 2 callers
Function
_prepare_options
(input_options: FinalRequestOptions)
src/anthropic/lib/bedrock/_client.py:40
↓ 2 callers
Function
_prepare_options
(input_options: FinalRequestOptions, *, project_id: str | None, region: str)
src/anthropic/lib/vertex/_client.py:420
↓ 2 callers
Method
_prepare_options
(self, options: FinalRequestOptions)
src/anthropic/lib/foundry.py:275
↓ 2 callers
Method
_prepare_options
(self, options: FinalRequestOptions)
src/anthropic/lib/foundry.py:502
↓ 2 callers
Method
_prepare_request
(self, request: httpx.Request)
src/anthropic/lib/bedrock/_mantle.py:263
↓ 2 callers
Method
_process_response
( self, *, cast_to: Type[ResponseT], options: FinalRequestOptions, res
src/anthropic/_base_client.py:1337
↓ 2 callers
Method
_process_response
( self, *, cast_to: Type[ResponseT], options: FinalRequestOptions, res
src/anthropic/_base_client.py:2089
↓ 2 callers
Method
_process_response_data
( self, *, data: object, cast_to: type[ResponseT], response: httpx.Res
src/anthropic/_base_client.py:678
↓ 2 callers
Function
_project_from_credentials
Best-effort project from an explicit credentials object — service-account / impersonated credentials usually know theirs.
src/anthropic/lib/google_cloud/_client.py:176
↓ 2 callers
Function
_raise_token_endpoint_error
Raise a redacted :class:`WorkloadIdentityError` from a non-200 token-endpoint response. Shared between the jwt-bearer exchange path in this modul
src/anthropic/lib/credentials/_workload.py:75
↓ 2 callers
Function
_read_active_config_pointer
Return the stripped contents of ``<config_dir>/active_config``, or ``None`` if the pointer file is missing or empty.
src/anthropic/lib/credentials/_constants.py:88
↓ 2 callers
Method
_read_credentials
Read the credentials file. Re-reads on every call — daemons rotate it. Secret values in the returned dict (every string field not in
src/anthropic/lib/credentials/_providers.py:329
↓ 2 callers
Function
_refusal_category
The policy category that caused the refusal; only the beta surface carries one.
src/anthropic/lib/middleware/_fallbacks.py:1398
↓ 2 callers
Function
_refusal_with_tool_use
()
tests/lib/tools/test_runners.py:680
↓ 2 callers
Function
_reject_skip_auth_conflict
( *, skip_auth: bool, token_provider: object | None, credentials: object | None, )
src/anthropic/lib/google_cloud/_client.py:163
↓ 2 callers
Function
_request
(*, extra: str = "vertex")
src/anthropic/lib/_extras/_google_auth.py:38
↓ 2 callers
Function
_require_env
(name: str)
examples/managed-agents-observe-tool-calls.py:45
↓ 2 callers
Function
_resolve_base_url
base_url (arg or ``ANTHROPIC_GOOGLE_CLOUD_BASE_URL``, resolved by the caller) > derived template. Returns ``None`` when derivation must wait
src/anthropic/lib/google_cloud/_client.py:133
↓ 2 callers
Method
_resolve_deferred_base_url
Derive and set the real base URL once the project is known. Called on every request (after the project back-fill from ADC, if any); a
src/anthropic/lib/google_cloud/_client.py:111
↓ 2 callers
Method
_resolve_denied
Resolve a denied call without executing it. The denial itself resolves the call server-side — no result event will ever be posted for
src/anthropic/lib/tools/_beta_session_runner.py:756
↓ 2 callers
Function
_resolve_mantle_config
Resolve and validate all Mantle client configuration. Returns (resolved_api_key, resolved_base_url, use_sigv4, merged_headers).
src/anthropic/lib/bedrock/_mantle.py:106
↓ 2 callers
Function
_resolve_under
Assert ``candidate`` resolves to a descendant of ``base``, return it verbatim. The containment check uses ``resolve(strict=False)`` on both sides
src/anthropic/lib/credentials/_constants.py:161
↓ 2 callers
Function
_resource_contents_to_block
Convert MCP resource contents to an Anthropic content block.
src/anthropic/lib/tools/mcp.py:156
↓ 2 callers
Function
_result_content
The content blocks the runner computed and posted back, as carried in ``result`` (the flat ``content`` convenience field was removed).
tests/lib/tools/test_session_runner.py:110
↓ 2 callers
Method
_route_tool_event
Enqueue ``ev`` for dispatch, honoring its evaluated permission. A builtin call the server gated behind user confirmation (``evaluated
src/anthropic/lib/tools/_beta_session_runner.py:678
↓ 2 callers
Method
_run
Drive the session tool loop, yielding an iterator of :class:`DispatchedToolCall`. :meth:`__aiter__` (and the module-level :func:`_run_
src/anthropic/lib/tools/_beta_session_runner.py:464
↓ 2 callers
Function
_run_sync_tool_use
Drive a tool runner over ``messages`` and collect the tool_result messages it generated.
tests/lib/tools/test_runners.py:823
↓ 2 callers
Function
_seamed_http_response
A copy of the served hop's response with `seams` prepended to its `content`, or `None` when the body isn't the expected message shape. The ca
src/anthropic/lib/middleware/_fallbacks.py:1415
↓ 2 callers
Function
_serialize_sse
Serialize an event back to its SSE wire form (`event: ...\\ndata: ...\\n\\n`). Multi-line `data` is emitted as one `data:` line per line, matchin
src/anthropic/lib/middleware/_fallbacks.py:1553
↓ 2 callers
Method
_set_private_attributes
( self, client: SyncAPIClient, model: Type[_T], options: FinalRequestOptions,
src/anthropic/_base_client.py:252
↓ 2 callers
Method
_should_retry_exception
Whether an exception raised by a request attempt should be retried. Also returns the HTTP response behind the failure, when there is one, so
src/anthropic/_base_client.py:877
↓ 2 callers
Method
_should_stop
(self)
src/anthropic/lib/tools/_beta_runner.py:125
↓ 2 callers
Method
_should_stream_response_body
(self, request: httpx.Request)
src/anthropic/_base_client.py:675
↓ 2 callers
Method
_shrink
(self, request: APIRequest)
tests/test_middleware.py:161
↓ 2 callers
Function
_spliced_http_response
A synthetic response standing in for `original`, with `stream` as its body. The spliced frames are emitted post-decode, so the original's con
src/anthropic/lib/middleware/_fallbacks.py:1592
↓ 2 callers
Method
_start_index
The chain entry this request starts at (-1 = the original params). Only an explicit `BetaFallbackState` pin moves the start; without one
src/anthropic/lib/middleware/_fallbacks.py:354
↓ 2 callers
Function
_strip_omit
Drop entries whose value is an `Omit` removal marker.
src/anthropic/_base_client.py:2542
↓ 2 callers
Function
_strip_seam_blocks
A copy of `body` with `{type: "fallback"}` seam blocks filtered out of the replayed message history; `body` itself when there are none. An as
src/anthropic/lib/middleware/_fallbacks.py:1344
↓ 2 callers
Function
_strip_top
Drop the leading ``top`` component from ``safe`` (an already-confined relative path). Returns ``""`` for the bare top-dir entry itself.
src/anthropic/lib/tools/_skills.py:82
↓ 2 callers
Method
_surface_call
Yield ``call`` to the consumer, tolerating a consumer that left early. ``BrokenResourceError`` — the consumer broke out of the iterator;
src/anthropic/lib/tools/_beta_session_runner.py:778
↓ 2 callers
Function
_to_iteration_usage
( type: Literal["message", "fallback_message"], model: str, usage: dict[str, Any] | None )
src/anthropic/lib/middleware/_fallbacks.py:1567
↓ 2 callers
Function
_to_prefill_blocks
Convert a hop's accumulated response blocks to the appended assistant turn. A `fallback_has_prefill_claim` refusal guarantees the partial output
src/anthropic/lib/middleware/_fallbacks.py:1311
↓ 2 callers
Function
_user_agent
``User-Agent`` value sent on token-endpoint POSTs. Computed lazily so this module doesn't need to import ``_version`` at module load time (th
src/anthropic/lib/credentials/_constants.py:56
↓ 2 callers
Function
_warn_env_shadow
Warn when an ``ANTHROPIC_API_KEY`` / ``ANTHROPIC_AUTH_TOKEN`` from the environment is set alongside signals that would normally drive profile /
src/anthropic/_client.py:99
↓ 2 callers
Function
_warn_explicit_shadow
Warn when an explicit ``api_key=`` / ``auth_token=`` argument shadows an explicit ``credentials=`` provider. Call *after* any copy-inheritance
src/anthropic/_client.py:87
↓ 2 callers
Function
_warn_once
Emit a log warning at most once per ``key`` per process.
src/anthropic/lib/credentials/_auth.py:22
↓ 2 callers
Function
_with_middleware_headers
A copy of `request` with `betas` appended to its `anthropic-beta` header (skipping values already present) and the middleware's helper-telemetry t
src/anthropic/lib/middleware/_fallbacks.py:1375
↓ 2 callers
Method
absorb_refusal
Fold a refused hop's outcome in, readying the next hop.
src/anthropic/lib/middleware/_fallbacks.py:1149
↓ 2 callers
Function
accumulate_event
( *, event: RawMessageStreamEvent, current_snapshot: ParsedMessage[ResponseFormatT] | None, ou
src/anthropic/lib/streaming/_messages.py:433
↓ 2 callers
Method
ack
Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating se
src/anthropic/resources/beta/environments/work.py:252
↓ 2 callers
Function
aclose_runnable_tool
Run a runnable tool's optional cleanup. Drives the legacy ``aclose`` / ``close`` attribute (awaited if it returns an awaitable) and, when the
src/anthropic/lib/tools/_beta_functions.py:311
↓ 2 callers
Method
aiter_bytes
(self, chunk_size: int | None = None)
src/anthropic/_legacy_response.py:487
↓ 2 callers
Function
assert_basic_response
(events: list[ParsedMessageStreamEvent[None]], message: Message)
tests/lib/streaming/test_messages.py:29
↓ 2 callers
Function
assert_basic_response
(events: list[ParsedBetaMessageStreamEvent], message: BetaMessage)
tests/lib/streaming/test_beta_messages.py:204
↓ 2 callers
Function
assert_compaction_response
(events: list[ParsedBetaMessageStreamEvent], message: BetaMessage)
tests/lib/streaming/test_beta_messages.py:219
↓ 2 callers
Function
assert_fallback_credit_response
(message: BetaMessage)
tests/lib/streaming/test_beta_messages.py:263
↓ 2 callers
Function
assert_fallback_response
(events: list[ParsedBetaMessageStreamEvent], message: BetaMessage)
tests/lib/streaming/test_beta_messages.py:249
↓ 2 callers
Function
assert_refusal_response
(message: Message)
tests/lib/streaming/test_messages.py:108
↓ 2 callers
Function
assert_refusal_response
(message: BetaMessage)
tests/lib/streaming/test_beta_messages.py:229
↓ 2 callers
Function
assert_tool_use_response
(events: list[ParsedMessageStreamEvent[None]], message: Message)
tests/lib/streaming/test_messages.py:56
↓ 2 callers
Function
assert_tool_use_response
(events: list[ParsedBetaMessageStreamEvent], message: BetaMessage)
tests/lib/streaming/test_beta_messages.py:209
↓ 2 callers
Function
async_to_custom_raw_response_wrapper
Higher order function that takes one of our bound API methods and an `APIResponse` class and wraps the method to support returning the given respo
src/anthropic/_response.py:837
↓ 2 callers
Function
async_to_custom_streamed_response_wrapper
Higher order function that takes one of our bound API methods and an `APIResponse` class and wraps the method to support streaming and returning t
src/anthropic/_response.py:755
↓ 2 callers
Method
begin
The chain state after stream A's chainable refusal. `body` is the original request params (pre-pin) — the base every hop patches; `in
src/anthropic/lib/middleware/_fallbacks.py:1067
↓ 2 callers
Function
beta_write_tool
(ctx: AgentToolContext)
src/anthropic/lib/tools/agent_toolset.py:619
↓ 2 callers
Method
bind_base_url
Adopt the owning client's ``base_url`` as a fallback for the token exchange. Slots between the config file's own ``base_url`` field and
src/anthropic/lib/credentials/_providers.py:228
↓ 2 callers
Function
build_events
( *, event: BetaRawMessageStreamEvent, message_snapshot: ParsedBetaMessage[ResponseFormatT], )
src/anthropic/lib/streaming/_beta_messages.py:336
↓ 2 callers
Function
build_events
( *, event: RawMessageStreamEvent, message_snapshot: ParsedMessage[ResponseFormatT], )
src/anthropic/lib/streaming/_messages.py:331
↓ 2 callers
Method
close
Close the response and release the connection. Automatically called if the response body is read to completion.
src/anthropic/_response.py:380
↓ 2 callers
Method
close
Close the response and release the connection. Automatically called if the response body is read to completion.
src/anthropic/_streaming.py:183
↓ 2 callers
Method
close
Close the owned ``httpx.Client`` if we created one.
src/anthropic/lib/credentials/_providers.py:409
↓ 2 callers
Method
close
Close the underlying ``httpx.Client`` if we created it.
src/anthropic/lib/credentials/_workload.py:215
↓ 2 callers
Function
coerce_boolean
(val: str)
src/anthropic/_utils/_utils.py:336
↓ 2 callers
Method
content_blocks
The accumulated content blocks, in start order.
src/anthropic/lib/middleware/_fallbacks.py:1242
↓ 2 callers
Method
continuation
(self)
src/anthropic/lib/middleware/_fallbacks.py:1124
↓ 2 callers
Method
copy
Create a new client instance re-using the same options given to the current client with optional overriding.
src/anthropic/lib/foundry.py:208
↓ 2 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:479
↓ 2 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/_client.py:241
↓ 2 callers
Method
copy
( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] — narrows `credentials` to No
src/anthropic/lib/aws/_client.py:376
↓ 2 callers
Method
disarm
Cancel the idle countdown; only signals on an actual transition.
src/anthropic/lib/tools/_beta_session_runner.py:198
↓ 2 callers
Function
error_response
(message: str, status: int)
tests/lib/test_refusal_fallback_streaming.py:101
↓ 2 callers
Method
execute
Execute a memory command and return the result. This method dispatches to the appropriate handler method based on the command type (v
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:108
← previous
next →
401–500 of 4,911, ranked by callers