Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/anthropics/anthropic-sdk-python
/ functions
Functions
13,873 in github.com/anthropics/anthropic-sdk-python
⨍
Functions
13,873
◇
Types & classes
4,472
↳
Endpoints
93
↓ 4 callers
Function
_member_use
(name: str, id: str, input: dict[str, Any])
tests/lib/tools/toolsets/test_browser_runner.py:52
↓ 4 callers
Function
_mock_skill
Mocks the lookup of the skill's version, and returns the route of its download.
tests/lib/tools/test_skills.py:478
↓ 4 callers
Method
_prepare_options
(self, options: FinalRequestOptions)
src/anthropic/lib/foundry.py:481
↓ 4 callers
Function
_read_env
Return the first non-None value from the given env vars, or None.
src/anthropic/lib/aws/_credentials.py:22
↓ 4 callers
Function
_refusal
The refusal behind the `ToolError` a call raises: its cause, whose own text is what the model reads.
tests/lib/tools/toolsets/test_refusals.py:47
↓ 4 callers
Function
_require_https
Reject non-`https://` token-endpoint URLs. Localhost is allowed for testing so `base_url="http://localhost:8080"` works against a local serve
src/anthropic/lib/credentials/_constants.py:112
↓ 4 callers
Function
_run_tool_use
`_run_sync_tool_use` for either client.
tests/lib/tools/test_runners.py:2246
↓ 4 callers
Function
_runner_class
(*, sync: bool, stream: bool)
tests/lib/tools/test_runners.py:3573
↓ 4 callers
Function
_secure_mkdir
Create `path` and any missing parents with `mode`, regardless of umask. `Path.mkdir(parents=True, mode=...)` and `os.makedirs(mode=...)` apply th
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:308
↓ 4 callers
Function
_session_with_skills
(*skill_ids: str)
tests/lib/tools/test_skills.py:496
↓ 4 callers
Function
_sse_body
( id: str, text: str = "Hello there!", *, tool_use_id: str | None = None, container: str |
tests/lib/threads/helpers.py:675
↓ 4 callers
Method
_status_event
(self, prefix: str, stop_reason: str | None, status: str, ids: list[str])
tests/lib/tools/_fake_sessions_api.py:733
↓ 4 callers
Function
_tar_file
( name: str, data: bytes, *, mode: int = 0o644, type: bytes = tarfile.REGTYPE )
tests/lib/tools/test_skills.py:102
↓ 4 callers
Function
_targz_bytes
(entries: dict[str, bytes])
tests/lib/tools/test_skills.py:70
↓ 4 callers
Method
_toolset_confirm
The approval gate: every call about to run is shown to `confirm` first, inside the pipeline and under the lock, so no override of `execute` or
src/anthropic/lib/tools/_toolsets/_base.py:324
↓ 4 callers
Method
_toolset_member_method
Resolve `name` through the registry before touching the instance: `getattr(self, name)` on raw model output would reach `__init__` or any othe
src/anthropic/lib/tools/_toolsets/_base.py:238
↓ 4 callers
Method
_turn_options
The runner's request options for a turn on `thread`. A turn's `extra_headers` replace the thread's, so the runner's helper tags go on top of t
src/anthropic/lib/tools/_beta_runner.py:278
↓ 4 callers
Function
_weather_tool
A `get_weather(location, units)` tool over `run`, synchronous or asynchronous.
tests/lib/tools/test_runners.py:2235
↓ 4 callers
Function
_zip_entry
(name: str, *, mode: int, create_system: int = 3)
tests/lib/tools/test_skills.py:127
↓ 4 callers
Function
accumulate_event
( *, event: RawMessageStreamEvent, current_snapshot: ParsedMessage[ResponseFormatT] | None, js
src/anthropic/lib/streaming/_messages.py:480
↓ 4 callers
Method
aclose
(self)
src/anthropic/lib/credentials/_close.py:19
↓ 4 callers
Method
aiter_bytes
Given an iterator that yields raw binary data, iterate over it & yield every event encountered
src/anthropic/_streaming.py:371
↓ 4 callers
Function
as_sent
A copy of `value` with every model in it dumped as a request body sends it.
src/anthropic/lib/threads/_thread_state.py:641
↓ 4 callers
Function
async_interrupted_stream_response
( id: str, text: str, *, error: type[httpx2.TransportError] | None = None )
tests/lib/threads/helpers.py:502
↓ 4 callers
Function
async_requester
A method shaped like a generated streaming method, whose response is `body`.
tests/utils.py:242
↓ 4 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:844
↓ 4 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:762
↓ 4 callers
Function
backoff
Exponential backoff for `attempt` (1-indexed), capped at `cap`.
src/anthropic/lib/_retry.py:43
↓ 4 callers
Function
beta_headers
(respx_mock: MockRouter)
tests/lib/test_refusal_fallback_streaming.py:170
↓ 4 callers
Function
body
()
tests/decoders/test_jsonl.py:19
↓ 4 callers
Function
bounded_result
`result` as it is rendered: the line a pure action returned is folded to one line and cut, so one that is only whitespace or control characters be
src/anthropic/lib/tools/_toolsets/_computer.py:410
↓ 4 callers
Function
chat_message
(role: str, *parts: dict[str, Any])
tests/test_open_telemetry.py:295
↓ 4 callers
Function
cleaning_up_for
(seconds: float, seen: list[str])
tests/lib/tools/test_session_runner.py:112
↓ 4 callers
Method
close
Close the response and release the connection. Automatically called if the response body is read to completion.
src/anthropic/lib/streaming/_beta_messages.py:94
↓ 4 callers
Method
close
Close the response and release the connection. Automatically called if the response body is read to completion.
src/anthropic/lib/streaming/_messages.py:90
↓ 4 callers
Function
common_arguments
(client_class: ClientClass)
tests/lib/test_client_copy.py:194
↓ 4 callers
Function
confirm_context
What the `confirm` callable is told: the member, its parsed input and the `tool_use` being answered. Built from values the pipeline already holds,
src/anthropic/lib/tools/_toolsets/_computer.py:425
↓ 4 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:213
↓ 4 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:273
↓ 4 callers
Function
count
How many items the list `value` has, and `None` for anything else, such as a list that the request lacks.
src/anthropic/lib/_tracing/_attributes.py:54
↓ 4 callers
Function
create
(client: AnthropicBedrockMantle, user_profile_id: str | Omit, extra_body: object)
tests/lib/test_bedrock_mantle.py:457
↓ 4 callers
Method
create
Create a new memory file with the specified content.
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:141
↓ 4 callers
Function
cut_tool_stream_events
The events of `tool_stream_events` up to a delta that leaves the input of its `tool_use` block open.
tests/test_open_telemetry.py:781
↓ 4 callers
Method
dispose
Remove every store directory that `download` created. Pre-existing directories are left alone — that is `FileStore.dispose`'s own rul
src/anthropic/lib/tools/_memories.py:562
↓ 4 callers
Function
error_text
`repr(exc)` as the `is_error` result the model reads, well formed and cut to the field limit: a driver's exception can embed a page-sized payload
src/anthropic/lib/tools/_toolsets/_sanitize.py:75
↓ 4 callers
Function
events_up_to_message_delta
The events of a stream that ends before `message_stop`, whose `message_delta` has all that one can have.
tests/test_open_telemetry.py:836
↓ 4 callers
Method
expires_at
(self, now: float)
tests/lib/environments/test_worker_properties.py:128
↓ 4 callers
Function
extract_type_arg
(typ: type, index: int)
src/anthropic/_utils/_typing.py:83
↓ 4 callers
Function
finish_api_call_span
Records the call's `result` on its span, and ends the span. The body of a stream or of an unread raw response keeps the span until the applicatio
src/anthropic/lib/_tracing/_api_call.py:39
↓ 4 callers
Function
folded
`text` on one line, not yet cut: line breaks, control and bidi characters folded to spaces, a lone surrogate to U+FFFD, the ends trimmed. For a va
src/anthropic/lib/tools/_toolsets/_sanitize.py:52
↓ 4 callers
Function
get_async_library
()
src/anthropic/_utils/_utils.py:435
↓ 4 callers
Method
get_tracer
(self, *args: Any, **kwargs: Any)
tests/test_open_telemetry.py:8151
↓ 4 callers
Method
hash_file
One file's sha256; `None` when absent. Shares `hashtree`'s cache.
src/anthropic/lib/tools/_file_store.py:203
↓ 4 callers
Function
helper_headers
(respx_mock: MockRouter)
tests/lib/test_refusal_fallback.py:691
↓ 4 callers
Function
hook_refusal
The rule for an exception out of a developer hook (`confirm`, `url_policy`, the file policy): a `ToolsetUsageError` stops the run, a `ToolError` i
src/anthropic/lib/tools/_toolsets/_runnable.py:235
↓ 4 callers
Function
id_headers
The response headers that a reply's `_request_id` and `_workspace_id` come from.
tests/lib/threads/helpers.py:322
↓ 4 callers
Function
interrupted_stream_response
A streamed reply cut off in its text block, once `text` has arrived: the body ends there, or reading on raises `error`.
tests/lib/threads/helpers.py:492
↓ 4 callers
Function
is_annotated_type
(typ: type)
src/anthropic/_utils/_typing.py:21
↓ 4 callers
Function
is_async_token_provider
True for an `async def` function, an object whose `__call__` is one, or a `functools.partial` of either.
src/anthropic/lib/credentials/_types.py:85
↓ 4 callers
Method
is_closed
Whether or not the response body has been closed. If this is False then there is response data that has not been read yet. You must e
src/anthropic/_response.py:115
↓ 4 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 are
src/anthropic/lib/_retry.py:56
↓ 4 callers
Method
is_path_visible
(self, path: str)
src/anthropic/lib/tools/_toolsets/_security.py:238
↓ 4 callers
Function
is_running
(pid: object)
tests/lib/tools/test_agent_toolset.py:979
↓ 4 callers
Method
is_waited_on
(self)
src/anthropic/lib/tools/_beta_session_runner.py:852
↓ 4 callers
Method
item
(self, item: object)
src/anthropic/_tracing.py:526
↓ 4 callers
Function
make_async_client
()
tests/lib/threads/helpers.py:58
↓ 4 callers
Function
make_jsonl_iterator
( content: Iterator[bytes], *, sync: bool, line_type: type[_T], )
tests/decoders/test_jsonl.py:138
↓ 4 callers
Function
mcp_message
Convert an MCP prompt message to an Anthropic `BetaMessageParam`.
src/anthropic/lib/tools/mcp.py:230
↓ 4 callers
Function
mock_results
(respx_mock: MockRouter)
tests/api_resources/beta/messages/test_batches.py:23
↓ 4 callers
Function
mock_results
(respx_mock: MockRouter)
tests/api_resources/messages/test_batches.py:23
↓ 4 callers
Method
move
Rename `src` to `dst`; an existing `dst` is refused. The banned store root as either end does nothing.
src/anthropic/lib/tools/_file_store.py:220
↓ 4 callers
Function
openapi_dumps_str
`openapi_dumps`, as a `str`; for transports that send text frames.
src/anthropic/_utils/_json.py:30
↓ 4 callers
Function
parse_obj
(model: type[_ModelT], value: object)
src/anthropic/_compat.py:75
↓ 4 callers
Function
parse_text
(text: str, output_format: ResponseFormatT | NotGiven)
src/anthropic/lib/_parse/_response.py:16
↓ 4 callers
Function
performed
(actions: list[Step], steps: list[Step] | None = None, **options: Any)
tests/lib/environments/test_fake_work_api.py:27
↓ 4 callers
Function
performing
(*actions: Step)
tests/lib/tools/test_session_runner_properties.py:593
↓ 4 callers
Function
print_obj
Pretty print an object to a string
tests/lib/utils.py:18
↓ 4 callers
Function
quote
Add single quotation marks around the given string. Does *not* do any escaping.
src/anthropic/_utils/_utils.py:221
↓ 4 callers
Method
read
(self)
tests/lib/environments/test_worker_properties.py:318
↓ 4 callers
Method
record
(self, tool_use: BetaToolUseBlock, result: BetaToolResultBlockParam)
src/anthropic/lib/tools/_beta_runner.py:1707
↓ 4 callers
Method
record_reply
Record `message` as the turn's reply, for the next turn to continue from. A refused turn is not recorded, and the next turn starts a new threa
src/anthropic/lib/threads/_thread_state.py:310
↓ 4 callers
Function
requester
A method shaped like a generated streaming method, whose response is `body`.
tests/utils.py:226
↓ 4 callers
Function
requeued_and_claimed
(at: float)
tests/lib/environments/test_worker.py:68
↓ 4 callers
Function
response_ids
(*replies: BetaMessage)
tests/lib/threads/helpers.py:327
↓ 4 callers
Method
result
The result of the call, as far as the call has got.
src/anthropic/_tracing.py:342
↓ 4 callers
Function
run_with_a_browser_toolset
Runs the loop of a tool runner that has a browser toolset on `reply` and then `FINAL`, and returns the route. A streamed reply is read to its end
tests/lib/tools/test_open_telemetry.py:268
↓ 4 callers
Method
runnable
(self, session: FakeSession)
tests/lib/tools/test_session_runner_properties.py:253
↓ 4 callers
Function
same_message
Whether `a` and `b` are sent as the same message. A recorded reply holds its content blocks as models, and the caller gives the same blocks back a
src/anthropic/lib/threads/_thread_state.py:635
↓ 4 callers
Function
schedule
(data: st.DataObject, kinds: list[list[Step]], gaps: list[float])
tests/lib/tools/test_session_runner_properties.py:139
↓ 4 callers
Function
set_content_attributes
Sets the content attributes of `span` within `limit`, the client's `max_content_bytes`. `limit` is in bytes of UTF-8. Each of `attributes` is set
src/anthropic/lib/_tracing/_content.py:118
↓ 4 callers
Function
share_message_snapshot
Lets the span of the API call that returned `stream` take its output content from `reader`.
src/anthropic/lib/_tracing/_streaming.py:152
↓ 4 callers
Function
signature_without_evaluating_annotations
Like `inspect.signature()`, for callers that only need parameter names, kinds and defaults. Python 3.14 evaluates annotations lazily and `inspect
src/anthropic/_utils/_reflection.py:9
↓ 4 callers
Function
slow_stream_closes
Makes closing a response stream wait, as closing a connection does, and lists each close as it starts and finishes.
tests/lib/tools/test_open_telemetry.py:232
↓ 4 callers
Method
start_turn
Stage `messages` and start the turn that sends them. The turn goes out even if nothing is staged then.
src/anthropic/lib/threads/_thread_state.py:248
↓ 4 callers
Method
state
(self, context: BetaToolsetCallContext)
tests/lib/tools/toolsets/_fakes.py:64
↓ 4 callers
Method
statuses
(self, kind: str)
tests/lib/tools/_fake_sessions_api.py:179
↓ 4 callers
Function
thread_logs
The (level, message) pairs logged under the `anthropic.lib.threads` logger or its children.
tests/lib/threads/helpers.py:954
↓ 4 callers
Function
timestamp
(at: float | None)
tests/lib/environments/_fake_work_api.py:519
↓ 4 callers
Function
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:821
↓ 4 callers
Function
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:737
← previous
next →
601–700 of 13,873, ranked by callers