MCPcopy Create free account

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

Functions5,068 in github.com/anthropics/anthropic-sdk-python

↓ 2 callersFunction_config_file_path
Path to ``<config_dir>/configs/<profile>.json`` (non-secret, 0644).
src/anthropic/lib/credentials/_constants.py:179
↓ 2 callersMethod_convert_to_legacy_response
Convert an `APIResponse` / `AsyncAPIResponse` into the equivalent `LegacyAPIResponse`.
src/anthropic/_base_client.py:662
↓ 2 callersFunction_credit_token
The refusal's minted credit token; only the beta surface carries one.
src/anthropic/lib/middleware/_fallbacks.py:1391
↓ 2 callersFunction_credit_token_param
The retry's `fallback_credit_token`, in the object form. `best_effort` keeps the retry serving even when redemption fails — a bare string wou
src/anthropic/lib/middleware/_fallbacks.py:53
↓ 2 callersFunction_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:1191
↓ 2 callersFunction_default_worker_id
()
src/anthropic/lib/environments/_poller.py:46
↓ 2 callersFunction_expects_response_wrapper
Whether the given `cast_to` asks for the `APIResponse` wrapper itself.
src/anthropic/_base_client.py:2648
↓ 2 callersMethod_fallback
(self, request: APIRequest)
tests/test_middleware.py:137
↓ 2 callersFunction_from_unix_seconds
(seconds: Union[int, float])
src/anthropic/_utils/_datetime_parse.py:44
↓ 2 callersFunction_fs_reason
Map a filesystem ``OSError`` to a consistent, runtime-independent phrase. The raw ``OSError`` string is platform-specific (``[Errno 2] ENOENT: ..
src/anthropic/lib/tools/agent_toolset.py:160
↓ 2 callersMethod_get_azure_ad_token
(self)
src/anthropic/lib/foundry.py:262
↓ 2 callersMethod_get_azure_ad_token
(self)
src/anthropic/lib/foundry.py:487
↓ 2 callersMethod_get_last_assistant_message
(self)
src/anthropic/lib/tools/_beta_runner.py:393
↓ 2 callersMethod_get_last_assistant_message
(self)
src/anthropic/lib/tools/_beta_runner.py:625
↓ 2 callersFunction_get_numeric
(value: StrBytesIntFloat, native_expected_type: str)
src/anthropic/_utils/_datetime_parse.py:33
↓ 2 callersFunction_get_params
(client: BaseClient[Any, Any])
tests/test_client.py:46
↓ 2 callersMethod_get_token
(self)
src/anthropic/lib/google_cloud/_client.py:325
↓ 2 callersMethod_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:382
↓ 2 callersFunction_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 callersMethod_has_static_credential
(request: httpx.Request)
src/anthropic/lib/credentials/_auth.py:85
↓ 2 callersFunction_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
↓ 2 callersMethod_idempotency_key
(self)
src/anthropic/_base_client.py:901
↓ 2 callersFunction_infer_region
Infer the AWS region from the environment variables or from the boto3 session if available.
src/anthropic/lib/bedrock/_client.py:72
↓ 2 callersMethod_info_to_options
(self, info: PageInfo)
src/anthropic/_base_client.py:217
↓ 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 callersMethod_iter_events
(self)
src/anthropic/_streaming.py:74
↓ 2 callersFunction_keeps_base_url
Whether a ``copy()`` stays on the parent's deployment. Tokens are only valid for the deployment that minted them, so the parent's :class:`Tok
src/anthropic/_client.py:85
↓ 2 callersFunction_make
(fn: FunctionT)
src/anthropic/lib/tools/_beta_functions.py:420
↓ 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:370
↓ 2 callersMethod_make_sse_decoder
(self)
src/anthropic/_base_client.py:504
↓ 2 callersMethod_make_status_error_from_response
( self, response: httpx.Response, )
src/anthropic/_base_client.py:425
↓ 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:645
↓ 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_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 callersFunction_middleware_entry_mode
The raw-response mode the original caller entered the middleware chain with.
src/anthropic/_base_client.py:2616
↓ 2 callersFunction_middleware_name
(middleware: object)
src/anthropic/_middleware.py:66
↓ 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_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 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_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 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
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:1070
↓ 2 callersMethod_prepare_request
(self, request: httpx.Request)
src/anthropic/lib/bedrock/_mantle.py:263
↓ 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:2090
↓ 2 callersMethod_process_response_data
( self, *, data: object, cast_to: type[ResponseT], response: httpx.Res
src/anthropic/_base_client.py:677
↓ 2 callersFunction_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 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:76
↓ 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. Secret values in the returned dict (every string field not in
src/anthropic/lib/credentials/_providers.py:357
↓ 2 callersFunction_refusal_category
The policy category that caused the refusal; only the beta surface carries one.
src/anthropic/lib/middleware/_fallbacks.py:1398
↓ 2 callersFunction_refusal_with_tool_use
()
tests/lib/tools/test_runners.py:679
↓ 2 callersFunction_reject_skip_auth_conflict
( *, skip_auth: bool, token_provider: object | None, credentials: object | None, )
src/anthropic/lib/google_cloud/_client.py:163
↓ 2 callersFunction_request
(*, extra: str = "vertex")
src/anthropic/lib/_extras/_google_auth.py:38
↓ 2 callersFunction_require_env
(name: str)
examples/managed-agents-observe-tool-calls.py:45
↓ 2 callersFunction_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 callersMethod_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 callersMethod_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:777
↓ 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_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:179
↓ 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:114
↓ 2 callersMethod_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:699
↓ 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:485
↓ 2 callersFunction_run_sync_tool_use
Drive a tool runner over ``messages`` and collect the tool_result messages it generated.
tests/lib/tools/test_runners.py:822
↓ 2 callersFunction_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:46
↓ 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:1415
↓ 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:1553
↓ 2 callersMethod_set_private_attributes
( self, client: SyncAPIClient, model: Type[_T], options: FinalRequestOptions,
src/anthropic/_base_client.py:251
↓ 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:876
↓ 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:674
↓ 2 callersMethod_shrink
(self, request: APIRequest)
tests/test_middleware.py:161
↓ 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:1592
↓ 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:354
↓ 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:1344
↓ 2 callersFunction_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:114
↓ 2 callersMethod_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:799
↓ 2 callersFunction_to_iteration_usage
( type: Literal["message", "fallback_message"], model: str, usage: dict[str, Any] | None )
src/anthropic/lib/middleware/_fallbacks.py:1567
↓ 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:1311
↓ 2 callersFunction_tool_runner_responses
()
tests/lib/test_vertex.py:44
↓ 2 callersFunction_tool_runner_responses
()
tests/lib/test_bedrock.py:343
↓ 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_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:106
↓ 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:94
↓ 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:1375
↓ 2 callersFunction_zip_unix_mode
(info: zipfile.ZipInfo)
src/anthropic/lib/tools/_skills.py:98
↓ 2 callersMethodabsorb_refusal
Fold a refused hop's outcome in, readying the next hop.
src/anthropic/lib/middleware/_fallbacks.py:1149
↓ 2 callersFunctionaccumulate_event
( *, event: RawMessageStreamEvent, current_snapshot: ParsedMessage[ResponseFormatT] | None, ou
src/anthropic/lib/streaming/_messages.py:441
↓ 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
← previousnext →401–500 of 5,068, ranked by callers