MCPcopy Create free account

hub / github.com/anthropics/anthropic-sdk-python / functions

Functions4,447 in github.com/anthropics/anthropic-sdk-python

↓ 2 callersMethod_info_to_options
(self, info: PageInfo)
src/anthropic/_base_client.py:218
↓ 2 callersMethod_invoke_provider
Invoke ``self._provider``, tolerating legacy zero-arg callables.
src/anthropic/lib/credentials/_cache.py:76
↓ 2 callersFunction_is_async_callable
Whether calling the given object returns a coroutine. Unlike `inspect.iscoroutinefunction(obj)` this also handles class instances that define
src/anthropic/_middleware.py:73
↓ 2 callersFunction_is_async_cm_factory
True when ``fn`` is a function produced by :func:`contextlib.asynccontextmanager`.
src/anthropic/lib/tools/_beta_functions.py:305
↓ 2 callersFunction_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
↓ 2 callersFunction_iter
()
tests/lib/environments/test_worker.py:142
↓ 2 callersFunction_make
(fn: FunctionT)
src/anthropic/lib/tools/_beta_functions.py:415
↓ 2 callersMethod_make_pin
Pin requests sharing the state to the entry being tried (or warn that there is none).
src/anthropic/lib/middleware/_fallbacks.py:351
↓ 2 callersMethod_make_sse_decoder
(self)
src/anthropic/_base_client.py:505
↓ 2 callersMethod_make_status_error_from_response
( self, response: httpx.Response, )
src/anthropic/_base_client.py:426
↓ 2 callersFunction_make_zip
(path: Path, entries: dict[str, bytes])
tests/lib/tools/test_skills.py:29
↓ 2 callersMethod_maybe_override_cast_to
(self, cast_to: type[ResponseT], options: FinalRequestOptions)
src/anthropic/_base_client.py:646
↓ 2 callersFunction_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 callersFunction_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
↓ 2 callersFunction_merged_body
The non-streaming retry body: the fallback entry merged whole over the original params, plus the refusal's credit token when it minted one.
src/anthropic/lib/middleware/_fallbacks.py:1430
↓ 2 callersFunction_middleware_entry_mode
The raw-response mode the original caller entered the middleware chain with.
src/anthropic/_base_client.py:2616
↓ 2 callersMethod_mutate
(self, request: APIRequest)
tests/test_middleware.py:119
↓ 2 callersFunction_no_transform_needed
(annotation: type)
src/anthropic/_utils/_transform.py:150
↓ 2 callersMethod_parse
(self, *, to: type[_T] | None = None)
src/anthropic/_response.py:129
↓ 2 callersMethod_parse_message_from_event
(self, event: EventStreamMessage)
src/anthropic/lib/bedrock/_stream_decoder.py:55
↓ 2 callersFunction_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 callersFunction_prepare_options
(input_options: FinalRequestOptions)
src/anthropic/lib/bedrock/_client.py:40
↓ 2 callersFunction_prepare_options
(input_options: FinalRequestOptions, *, project_id: str | None, region: str)
src/anthropic/lib/vertex/_client.py:420
↓ 2 callersMethod_prepare_options
(self, options: FinalRequestOptions)
src/anthropic/lib/foundry.py:275
↓ 2 callersMethod_prepare_options
(self, options: FinalRequestOptions)
src/anthropic/lib/foundry.py:502
↓ 2 callersMethod_prepare_request
(self, request: httpx.Request)
src/anthropic/lib/bedrock/_mantle.py:263
↓ 2 callersMethod_primitive_value_to_str
(self, value: PrimitiveData)
src/anthropic/_qs.py:120
↓ 2 callersMethod_process_response
( self, *, cast_to: Type[ResponseT], options: FinalRequestOptions, res
src/anthropic/_base_client.py:1337
↓ 2 callersMethod_process_response
( self, *, cast_to: Type[ResponseT], options: FinalRequestOptions, res
src/anthropic/_base_client.py:2089
↓ 2 callersFunction_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:67
↓ 2 callersFunction_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 callersMethod_read_credentials
Read the credentials file. Re-reads on every call — daemons rotate it. On Unix, verifies the file is not group/world-readable. World-readable
src/anthropic/lib/credentials/_providers.py:321
↓ 2 callersFunction_refusal_category
The policy category that caused the refusal; only the beta surface carries one.
src/anthropic/lib/middleware/_fallbacks.py:1361
↓ 2 callersFunction_refusal_with_tool_use
()
tests/lib/tools/test_runners.py:675
↓ 2 callersFunction_request_id
(resp: httpx.Response)
src/anthropic/lib/credentials/_workload.py:44
↓ 2 callersFunction_require_env
(name: str)
examples/managed-agents-self-hosted-sandbox-worker.py:47
↓ 2 callersFunction_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 callersFunction_resolve_max_bytes
Resolve a configured cap to an effective size limit. ``not_given`` selects ``DEFAULT_MAX_FILE_BYTES``; ``None`` disables the size check (unca
src/anthropic/lib/tools/agent_toolset.py:96
↓ 2 callersFunction_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 callersFunction_resource_contents_to_block
Convert MCP resource contents to an Anthropic content block.
src/anthropic/lib/tools/mcp.py:156
↓ 2 callersFunction_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:97
↓ 2 callersMethod_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:378
↓ 2 callersFunction_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:1378
↓ 2 callersFunction_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:1482
↓ 2 callersFunction_session
()
src/anthropic/lib/tools/agent_toolset.py:443
↓ 2 callersMethod_set_private_attributes
( self, client: SyncAPIClient, model: Type[_T], options: FinalRequestOptions,
src/anthropic/_base_client.py:252
↓ 2 callersMethod_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 callersMethod_should_stop
(self)
src/anthropic/lib/tools/_beta_runner.py:125
↓ 2 callersMethod_should_stream_response_body
(self, request: httpx.Request)
src/anthropic/_base_client.py:675
↓ 2 callersMethod_shrink
(self, request: APIRequest)
tests/test_middleware.py:161
↓ 2 callersMethod_signal
(self)
src/anthropic/lib/tools/_beta_session_runner.py:138
↓ 2 callersMethod_sleep_for_retry
( self, *, retries_taken: int, max_retries: int, options: FinalRequestOptions, response: httpx.Respons
src/anthropic/_base_client.py:1323
↓ 2 callersMethod_sleep_for_retry
( self, *, retries_taken: int, max_retries: int, options: FinalRequestOptions, response: httpx.Respons
src/anthropic/_base_client.py:2075
↓ 2 callersFunction_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:1521
↓ 2 callersMethod_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:335
↓ 2 callersFunction_strip_omit
Drop entries whose value is an `Omit` removal marker.
src/anthropic/_base_client.py:2542
↓ 2 callersFunction_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:1307
↓ 2 callersFunction_to_iteration_usage
( type: Literal["message", "fallback_message"], model: str, usage: dict[str, Any] | None )
src/anthropic/lib/middleware/_fallbacks.py:1496
↓ 2 callersFunction_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:1274
↓ 2 callersFunction_transform_file
(file: FileTypes)
src/anthropic/_files.py:65
↓ 2 callersFunction_union_members
Return the runtime classes in an `Annotated[Union[...], ...]` type alias.
tests/lib/streaming/test_parsed_content_blocks.py:18
↓ 2 callersFunction_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 callersFunction_wait_first
Return as soon as any of ``events`` is set.
src/anthropic/lib/tools/_beta_session_runner.py:704
↓ 2 callersFunction_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 callersFunction_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 callersFunction_warn_once
Emit a log warning at most once per ``key`` per process.
src/anthropic/lib/credentials/_auth.py:22
↓ 2 callersFunction_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:1338
↓ 2 callersMethodabsorb_refusal
Fold a refused hop's outcome in, readying the next hop.
src/anthropic/lib/middleware/_fallbacks.py:1112
↓ 2 callersFunctionaccumulate_event
( *, event: RawMessageStreamEvent, current_snapshot: ParsedMessage[ResponseFormatT] | None, ou
src/anthropic/lib/streaming/_messages.py:433
↓ 2 callersMethodack
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 callersFunctionaclose_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 callersMethodaiter_bytes
(self, chunk_size: int | None = None)
src/anthropic/_legacy_response.py:487
↓ 2 callersMethodarm
(Re)start the idle countdown from now and wake the watchdog.
src/anthropic/lib/tools/_beta_session_runner.py:153
↓ 2 callersFunctionassert_basic_response
(events: list[ParsedMessageStreamEvent[None]], message: Message)
tests/lib/streaming/test_messages.py:29
↓ 2 callersFunctionassert_basic_response
(events: list[ParsedBetaMessageStreamEvent], message: BetaMessage)
tests/lib/streaming/test_beta_messages.py:204
↓ 2 callersFunctionassert_compaction_response
(events: list[ParsedBetaMessageStreamEvent], message: BetaMessage)
tests/lib/streaming/test_beta_messages.py:219
↓ 2 callersFunctionassert_fallback_response
(events: list[ParsedBetaMessageStreamEvent], message: BetaMessage)
tests/lib/streaming/test_beta_messages.py:249
↓ 2 callersFunctionassert_is_file_content
(obj: object, *, key: str | None = None)
src/anthropic/_files.py:35
↓ 2 callersFunctionassert_refusal_response
(message: Message)
tests/lib/streaming/test_messages.py:108
↓ 2 callersFunctionassert_refusal_response
(message: BetaMessage)
tests/lib/streaming/test_beta_messages.py:229
↓ 2 callersFunctionassert_tool_use_response
(events: list[ParsedMessageStreamEvent[None]], message: Message)
tests/lib/streaming/test_messages.py:56
↓ 2 callersFunctionassert_tool_use_response
(events: list[ParsedBetaMessageStreamEvent], message: BetaMessage)
tests/lib/streaming/test_beta_messages.py:209
↓ 2 callersFunctionasync_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 callersFunctionasync_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 callersMethodbegin
The chain state after stream A's chainable refusal.
src/anthropic/lib/middleware/_fallbacks.py:1037
↓ 2 callersFunctionbeta_write_tool
(ctx: AgentToolContext)
src/anthropic/lib/tools/agent_toolset.py:530
↓ 2 callersFunctionbuild_events
( *, event: BetaRawMessageStreamEvent, message_snapshot: ParsedBetaMessage[ResponseFormatT], )
src/anthropic/lib/streaming/_beta_messages.py:336
↓ 2 callersFunctionbuild_events
( *, event: RawMessageStreamEvent, message_snapshot: ParsedMessage[ResponseFormatT], )
src/anthropic/lib/streaming/_messages.py:331
↓ 2 callersMethodclose
Close the response and release the connection. Automatically called if the response body is read to completion.
src/anthropic/_response.py:380
↓ 2 callersMethodclose
Close the response and release the connection. Automatically called if the response body is read to completion.
src/anthropic/_streaming.py:183
↓ 2 callersMethodclose
Close the underlying ``httpx.Client`` if we created it.
src/anthropic/lib/credentials/_workload.py:204
↓ 2 callersFunctioncoerce_boolean
(val: str)
src/anthropic/_utils/_utils.py:336
↓ 2 callersMethodcontinuation
(self)
src/anthropic/lib/middleware/_fallbacks.py:1090
↓ 2 callersMethodcopy
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 callersMethodcopy
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 callersMethodcopy
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 callersMethoddisarm
Cancel the idle countdown; only signals on an actual transition.
src/anthropic/lib/tools/_beta_session_runner.py:158
↓ 2 callersFunctionexchange_federation_assertion
Perform a single RFC 7523 ``jwt-bearer`` exchange and return the resulting :class:`AccessToken`. This is a one-shot convenience wrapper aroun
src/anthropic/lib/credentials/_workload.py:323
↓ 2 callersMethodexecute
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
↓ 2 callersMethodfeed
Process one event, returning the frames to forward for it.
src/anthropic/lib/middleware/_fallbacks.py:811
← previousnext →401–500 of 4,447, ranked by callers