Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/anthropics/anthropic-sdk-python
/ functions
Functions
12,274 in github.com/anthropics/anthropic-sdk-python
⨍
Functions
12,274
◇
Types & classes
3,937
↳
Endpoints
46
↓ 38 callers
Function
texts
(content: Any)
tests/lib/tools/toolsets/_fakes.py:315
↓ 37 callers
Method
resolve
Stage one of a call: the registry row for `name`, or the refusal the model reads (an unknown name, a member this application disabled, or one
src/anthropic/lib/tools/_toolsets/_base.py:213
↓ 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
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
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
↓ 33 callers
Function
beta_read_tool
(ctx: AgentToolContext)
src/anthropic/lib/tools/agent_toolset.py:689
↓ 32 callers
Function
to_async_iter
Convert a synchronous iterator to an asynchronous one.
tests/lib/streaming/helpers.py:25
↓ 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
span_id
(span: ReadableSpan | Span)
tests/lib/tools/test_open_telemetry.py:147
↓ 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
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
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:669
↓ 29 callers
Function
parent_id
(span: ReadableSpan)
tests/lib/tools/test_open_telemetry.py:153
↓ 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
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
↓ 28 callers
Function
provider
()
tests/lib/test_google_cloud.py:435
↓ 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
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
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
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
↓ 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
Method
root
(self)
src/anthropic/lib/tools/_file_store.py:119
↓ 25 callers
Method
start
(self)
examples/memory/basic.py:50
↓ 25 callers
Method
to_dict
(self)
tests/lib/test_stainless_helpers.py:24
↓ 25 callers
Function
transform_schema
Transforms a JSON schema to ensure it conforms to the API's expectations. Args: json_schema (Dict[str, Any]): The original JSON sche
src/anthropic/lib/_parse/_transform.py:98
↓ 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
Method
put
( self, path: str, *, cast_to: Type[ResponseT], body: Body | None = No
src/anthropic/_base_client.py:1708
↓ 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
get_args
(t: type[Any])
src/anthropic/_compat.py:30
↓ 23 callers
Function
iter_work
Iterate work items claimed from a self-hosted environment. Each yielded `BetaSelfHostedWork` has already been ack'd. The `work` resource must
src/anthropic/lib/environments/_poller.py:84
↓ 23 callers
Function
make_client
(client_cls: ClientClass, **kwargs: Any)
tests/test_header_case_sensitivity.py:29
↓ 23 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:2808
↓ 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:395
↓ 22 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:31
↓ 22 callers
Function
_fake_client
(work: _FakeWorkResource, sessions: _FakeSessions)
tests/lib/environments/test_worker.py:153
↓ 22 callers
Function
_send_message
(client: Anthropic)
tests/lib/test_credentials.py:2452
↓ 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
Method
get_tracer
(self, *args: Any, **kwargs: Any)
tests/test_tracing.py:75
↓ 22 callers
Function
make_async_runner
(*, stream: Literal[False] = False, **fields: Any)
tests/lib/threads/helpers.py:104
↓ 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
Function
updated
(path: str, content: str, *, was: str)
tests/lib/tools/memory_sync/_fake_anthropic.py:77
↓ 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:2411
↓ 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:180
↓ 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:1933
↓ 21 callers
Method
write
(self, path: str, content: str)
tests/lib/tools/memory_sync/_fake_anthropic.py:61
↓ 20 callers
Function
_install_scoped_client
Intercept the shared bearer-auth client factory. Returns the list of args the factory was called with so a test can assert on the helper-tele
tests/lib/environments/test_worker.py:159
↓ 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:282
↓ 20 callers
Function
get_directory_snapshot
Get a snapshot of directory contents with relative paths.
tests/lib/tools/memory_tools/test_filesystem.py:67
↓ 19 callers
Function
_assert_not_in_sdk_frame_locals
(exc: BaseException, *secrets: str)
tests/lib/test_credentials.py:4861
↓ 19 callers
Function
_send_message_async
(client: AsyncAnthropic)
tests/lib/test_credentials.py:3317
↓ 19 callers
Function
_tool_confirmation
The user's allow/deny verdict for an ask-gated (`always_ask`) tool call.
tests/lib/tools/test_session_runner.py:100
↓ 19 callers
Method
add
Add Session Resource Args: file_id: ID of a previously uploaded file. mount_path: Mount path in the container.
src/anthropic/resources/beta/sessions/resources.py:351
↓ 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
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:368
↓ 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
Method
view
View the contents of a memory path.
src/anthropic/lib/tools/_beta_builtin_memory_tool.py:136
↓ 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
Method
invalidate
Clear the cached token so the next `get_token` re-invokes the provider. Also sets a one-shot `force_refresh` flag so on-disk providers skip
src/anthropic/lib/credentials/_cache.py:324
↓ 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:87
↓ 18 callers
Method
start_as_current_span
(self, name: str, *args: Any, **kwargs: Any)
tests/test_tracing.py:64
↓ 17 callers
Method
__anext__
(self)
src/anthropic/_streaming.py:186
↓ 17 callers
Function
_end_turn
()
tests/lib/tools/toolsets/test_runner.py:60
↓ 17 callers
Function
_idle_end_turn
()
tests/lib/tools/test_session_runner.py:127
↓ 17 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:861
↓ 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
Function
fake_session
An `EnvironmentWorker` pointed at a fake client; one work item queued.
tests/lib/tools/memory_sync/test_e2e_memory.py:41
↓ 17 callers
Function
resolve_auth_mode
Determine whether to use SigV4 auth. Returns True for SigV4, False for API key. Auth precedence: 1. api_key constructor arg → API key mode
src/anthropic/lib/aws/_credentials.py:31
↓ 17 callers
Function
resource_ids
The attributes of `span` that hold the ID of an API object.
tests/test_open_telemetry.py:6950
↓ 17 callers
Method
retrieve
(self, memory_id: str, *, memory_store_id: str, **kwargs: Any)
tests/lib/tools/memory_sync/test_memory_sync.py:682
↓ 17 callers
Method
see
Adds a stream event to the timeline, as the caller saw it.
tests/lib/tools/test_runner_eager_tools.py:1084
↓ 17 callers
Function
sent_requests
(respx_mock: MockRouter)
tests/lib/test_bedrock_mantle.py:453
← previous
next →
101–200 of 12,274, ranked by callers