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
↓ 37 callers
Function
stream_events
(*, index: object = 0)
tests/test_open_telemetry.py:588
↓ 37 callers
Method
to_dict
(self)
tests/lib/tools/toolsets/_stubs.py:52
↓ 36 callers
Function
call
The model calls `lookup(key=key)` with the id `toolu_<key>`. `json_input` is the input as sent, which may be cut off.
tests/lib/tools/test_runner_eager_tools.py:801
↓ 36 callers
Function
messages_resource
(client: Any, *, beta: bool)
tests/test_open_telemetry.py:750
↓ 35 callers
Function
events_of
What the stream yields, whether it is the sync or the async one.
tests/lib/tools/test_runner_eager_tools.py:1173
↓ 35 callers
Method
get_token
Return a valid bearer token, refreshing if necessary.
src/anthropic/lib/credentials/_cache.py:179
↓ 35 callers
Method
times
(self, kind: str)
tests/lib/tools/_fake_sessions_api.py:176
↓ 35 callers
Function
tool_result
(tool_use_id: str, content: str = "Sunny in San Francisco")
tests/lib/threads/helpers.py:196
↓ 34 callers
Function
create_message
( client: Anthropic, *, betas: List[AnthropicBetaParam] | Omit = omit, fallbacks: List[BetaFal
tests/lib/test_refusal_fallback.py:82
↓ 34 callers
Method
now
(self)
tests/lib/tools/_fake_sessions_api.py:303
↓ 34 callers
Function
to_async_iter
Convert a synchronous iterator to an asynchronous one.
tests/lib/streaming/helpers.py:25
↓ 33 callers
Method
run
(self)
tests/lib/environments/test_worker.py:224
↓ 32 callers
Function
span_id
(span: ReadableSpan | Span)
tests/lib/tools/test_open_telemetry.py:157
↓ 31 callers
Function
call_client
What `invoke` returns for a client of `spans`: the synchronous one, or else the asynchronous one, awaited.
tests/test_open_telemetry.py:2904
↓ 31 callers
Function
first_reply
The timeline up to the second request, which is everything about the first reply.
tests/lib/tools/test_runner_eager_tools.py:868
↓ 31 callers
Function
make_async_client
(**kwargs: Any)
tests/test_middleware.py:59
↓ 31 callers
Function
run
()
tests/lib/tools/toolsets/test_browser_runner.py:394
↓ 31 callers
Function
run_poller
( steps: Sequence[Step] = (), *, sync: bool, until: float = 100, items: Sequence[str] = (S
tests/lib/environments/_schedules.py:142
↓ 31 callers
Method
times
(self, kind: str)
tests/lib/environments/_fake_work_api.py:178
↓ 30 callers
Method
append_messages
Add one or more messages to the conversation history. This invalidates the cached tool response, i.e. if tools were already called, then they
src/anthropic/lib/tools/_beta_runner.py:338
↓ 30 callers
Function
parent_id
(span: ReadableSpan)
tests/lib/tools/test_open_telemetry.py:163
↓ 30 callers
Function
request_bodies
(respx_mock: MockRouter)
tests/lib/test_refusal_fallback.py:112
↓ 29 callers
Function
_tool_use_response
(tool_name: str, tool_use_id: str, input: Union[Dict[str, Any], None] = None)
tests/lib/tools/test_runners.py:970
↓ 29 callers
Function
attached
(notes: Path, access: str = "read_write")
tests/lib/tools/memory_sync/test_e2e_memory.py:32
↓ 29 callers
Function
construct_type
Loose coercion to the expected type with construction of nested values. If the given value does not match the expected type then it is returned a
src/anthropic/_models.py:670
↓ 29 callers
Function
provider
()
tests/lib/test_google_cloud.py:435
↓ 29 callers
Function
request_bodies
(respx_mock: MockRouter)
tests/lib/test_refusal_fallback_streaming.py:165
↓ 29 callers
Function
state_block
(content: Any)
tests/lib/tools/toolsets/_fakes.py:319
↓ 29 callers
Function
stream_response
A streamed reply. With `message_stop=False` the body ends after `message_delta`, as when the connection drops just before the last event.
tests/lib/threads/helpers.py:415
↓ 28 callers
Function
_send_message
(client: Anthropic)
tests/lib/test_credentials.py:2457
↓ 28 callers
Function
call
Creates a Message with a synchronous or an asynchronous client.
tests/test_open_telemetry.py:3777
↓ 28 callers
Function
default_credentials
Resolve a `CredentialResult` from the environment per the credential-resolution spec. First match wins. Implements steps 2-5 of the spec prec
src/anthropic/lib/credentials/_chain.py:76
↓ 28 callers
Method
open
Resolve `root`; creates nothing — only `create_root` makes the folder.
src/anthropic/lib/tools/_file_store.py:100
↓ 27 callers
Method
generate_tool_call_response
Generate a MessageParam by calling tool functions with any tool use blocks from the last message. Note the tool call response is cached, repe
src/anthropic/lib/tools/_beta_runner.py:770
↓ 27 callers
Method
start
(self)
examples/memory/basic.py:50
↓ 27 callers
Method
time
(self)
tests/lib/tools/_fake_sessions_api.py:1005
↓ 27 callers
Method
tool_result
Run one member `tool_use` and build its `tool_result` block, for callers driving `messages.create` themselves. Follows the tool runne
src/anthropic/lib/tools/_toolsets/_runnable.py:139
↓ 27 callers
Function
update_env
(**new_env: str | Omit)
tests/utils.py:165
↓ 26 callers
Method
clear
(input: dict[str, Any])
tests/lib/tools/test_open_telemetry.py:2218
↓ 26 callers
Function
deepcopy_with_paths
Copy only the containers along the given paths. Used to guard against mutation by extract_files without copying the entire structure. Only di
src/anthropic/_files.py:144
↓ 26 callers
Function
merge_headers
Compose header layers into a single layer: a plain mapping, as `default_headers=` and `extra_headers=` accept, that still carries an `Omit` for ev
src/anthropic/_base_client.py:2824
↓ 26 callers
Function
requests
(route: Any)
tests/test_open_telemetry.py:235
↓ 26 callers
Function
tool_use
(tool_use_id: str, name: str = "get_weather")
tests/lib/threads/helpers.py:189
↓ 26 callers
Function
transform_schema
Transforms a JSON schema to ensure it conforms to the API's expectations. A pydantic model's JSON schema is generated the first time the mod
src/anthropic/lib/_parse/_transform.py:110
↓ 25 callers
Function
_send_message_async
(client: AsyncAnthropic)
tests/lib/test_credentials.py:3521
↓ 25 callers
Function
extract_files
Recursively extract files from the given dictionary based on specified paths. A path may look like this ['foo', 'files', '<array>', 'data'].
src/anthropic/_utils/_utils.py:37
↓ 25 callers
Function
require
(condition: object)
tests/lib/tools/_fake_sessions_api.py:193
↓ 25 callers
Method
root
(self)
src/anthropic/lib/tools/_file_store.py:119
↓ 25 callers
Method
to_dict
(self)
tests/lib/test_stainless_helpers.py:24
↓ 24 callers
Method
add_tools
Give the model more tools without changing the `tools` param, which would miss the prompt cache. The definitions are sent in `tool_addition`
src/anthropic/lib/tools/_beta_runner.py:469
↓ 24 callers
Method
close
(self)
tests/test_open_telemetry.py:646
↓ 24 callers
Function
get_args
(t: type[Any])
src/anthropic/_compat.py:30
↓ 24 callers
Method
put
( self, path: str, *, cast_to: Type[ResponseT], body: Body | None = No
src/anthropic/_base_client.py:1720
↓ 24 callers
Method
texts_sent
(self, id: str)
tests/lib/tools/_fake_sessions_api.py:182
↓ 23 callers
Function
_copy_client_with_bearer_auth
Return a copy of `client` authenticated with `auth_token` as Bearer. The returned sub-client inherits the parent's full configuration via `cl
src/anthropic/lib/_scoped_client.py:32
↓ 23 callers
Function
_requested_urls
(respx_mock: MockRouter)
tests/lib/test_google_cloud.py:1504
↓ 23 callers
Method
copy
( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride] — narrows `credentials` to No
src/anthropic/lib/aws/_client.py:181
↓ 23 callers
Function
make_client
(client_cls: ClientClass, **kwargs: Any)
tests/test_header_case_sensitivity.py:29
↓ 23 callers
Function
request_betas
(respx_mock: MockRouter)
tests/lib/threads/helpers.py:944
↓ 23 callers
Method
results
Streams the results of a Message Batch as a `.jsonl` file. Each line in the file is a JSON object containing the result of a single
src/anthropic/resources/messages/batches.py:397
↓ 22 callers
Method
defer_tool_call
Hold a tool call of the current reply until you are done with the reply, which is when it runs without `run_tools_eagerly`: at the end of the
src/anthropic/lib/tools/_beta_runner.py:1012
↓ 22 callers
Function
make_async_runner
(*, stream: Literal[False] = False, **fields: Any)
tests/lib/threads/helpers.py:104
↓ 22 callers
Method
of
(self, *kinds: str, client: str | None = None)
tests/lib/environments/_fake_work_api.py:172
↓ 22 callers
Method
retrieve_metadata
Get File Metadata Args: file_id: ID of the File. workspace_id: Optional header to select the Workspace for this
src/anthropic/resources/files.py:257
↓ 22 callers
Function
unsupported_response
(*unsupported: str)
tests/lib/threads/helpers.py:917
↓ 22 callers
Method
upload
Upload File Args: file: The file to upload. Only the final path component of the part's `filename` is kept;
src/anthropic/resources/files.py:316
↓ 21 callers
Function
_mock_messages_endpoint
(respx_mock: MockRouter)
tests/lib/test_credentials.py:2416
↓ 21 callers
Function
build
(client: Anthropic | AsyncAnthropic, **options: Any)
tests/test_header_case_sensitivity.py:34
↓ 21 callers
Function
run
( client: Anthropic, *, conversation_id: str | None = None, **kwargs: Any )
tests/lib/tools/test_open_telemetry.py:190
↓ 21 callers
Method
thread
Start a message thread: a conversation the server holds between turns, so each request sends only the new messages. Takes the arguments of `cr
src/anthropic/resources/beta/messages/messages.py:1963
↓ 21 callers
Method
write
(self, path: str, content: str)
tests/lib/tools/memory_sync/_fake_anthropic.py:61
↓ 20 callers
Method
add
(self, chunk: bytes)
src/anthropic/lib/tools/agent_toolset.py:779
↓ 20 callers
Method
approve
Approve a pending spend limit increase request. Writes a per-user spend limit at `amount` for the requester and transitions the
src/anthropic/resources/organization/spend_limits/increase_requests.py:154
↓ 20 callers
Method
deny
Deny a pending spend limit increase request. Idempotent on `denied`; denying an already-`approved` request returns 400. Anth
src/anthropic/resources/organization/spend_limits/increase_requests.py:219
↓ 20 callers
Method
download
Download every attached store's memories to disk. `session` arrives already fetched — one snapshot shared with the skills download.
src/anthropic/lib/tools/_memories.py:287
↓ 20 callers
Function
get_directory_snapshot
Get a snapshot of directory contents with relative paths.
tests/lib/tools/memory_tools/test_filesystem.py:67
↓ 20 callers
Method
redact
Redact a Memory Version Args: memory_store_id: The ID of the memory store that holds the version (`memstore_...`).
src/anthropic/resources/beta/memory_stores/memory_versions.py:261
↓ 19 callers
Function
_assert_not_in_sdk_frame_locals
(exc: BaseException, *secrets: str)
tests/lib/test_credentials.py:5186
↓ 19 callers
Function
beta_grep_tool
Searches with the first `rg` on `PATH` that resolves to somewhere outside `workdir` and `allowed_roots`, or with a built-in search when there is n
src/anthropic/lib/tools/agent_toolset.py:1125
↓ 19 callers
Method
delete
(self, memory_id: str, *, memory_store_id: str, **kwargs: Any)
tests/lib/tools/memory_sync/test_memory_sync.py:691
↓ 19 callers
Function
fake_anthropic
An `AsyncAnthropic`-shaped client with one memory store named `notes`. The store lands at `{workdir}/memory/notes`. Returns the client to han
tests/lib/tools/memory_sync/_fake_anthropic.py:187
↓ 19 callers
Function
is_dict
(obj: object)
src/anthropic/_utils/_utils.py:194
↓ 19 callers
Method
kinds
(self)
tests/lib/environments/_fake_work_api.py:175
↓ 19 callers
Function
make_client
()
tests/lib/threads/helpers.py:54
↓ 19 callers
Method
model_dump
Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump Generate a dictionary representation of the model, opti
src/anthropic/_models.py:369
↓ 19 callers
Function
refusal
(browser: FakeBrowser, context: BetaToolsetCallContext, name: str, input: Any)
tests/lib/tools/toolsets/_fakes.py:324
↓ 19 callers
Function
sent_requests
(respx_mock: MockRouter)
tests/lib/threads/helpers.py:931
↓ 19 callers
Function
updated
(path: str, content: str, *, was: str)
tests/lib/tools/memory_sync/_fake_anthropic.py:77
↓ 19 callers
Method
view
View the contents of a memory path.
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:136
↓ 19 callers
Method
write
(profile: str, *, with_base_url: Optional[str])
tests/lib/test_credentials.py:415
↓ 18 callers
Function
_requests
(respx_mock: MockRouter)
tests/lib/tools/toolsets/test_browser_runner.py:59
↓ 18 callers
Method
create
Start an asynchronous job that uses past sessions to produce a reorganized version of a memory store and get back the dream to poll f
src/anthropic/resources/beta/dreams.py:51
↓ 18 callers
Method
fork
A copy with the same history, request fields, tools and options that continues from no stored reply and has no turn in flight.
src/anthropic/lib/threads/_thread_state.py:156
↓ 18 callers
Function
mcp_content
Convert a single MCP content block to an Anthropic content block. Handles text, image, and embedded resource content types. Raises `Unsupport
src/anthropic/lib/tools/mcp.py:119
↓ 18 callers
Function
results_sent
The tool results the runner sent back for the first reply.
tests/lib/tools/test_runner_eager_tools.py:879
↓ 18 callers
Function
settled
The result of a call on either runner: awaited on the async one.
tests/lib/tools/test_runner_eager_tools.py:1183
↓ 18 callers
Function
sse
`message` as the response of a streamed request.
tests/lib/tools/test_open_telemetry.py:97
↓ 17 callers
Function
_end_turn
()
tests/lib/tools/toolsets/test_runner.py:60
↓ 17 callers
Function
error_logs
Messages the middleware logged at ERROR — refusals surfaced rather than retried.
tests/lib/test_refusal_fallback_streaming.py:41
↓ 17 callers
Method
get_tracer
(self, *args: Any, **kwargs: Any)
tests/test_tracing.py:75
← previous
next →
101–200 of 13,873, ranked by callers