Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/anthropics/anthropic-sdk-python
/ functions
Functions
1,183 in github.com/anthropics/anthropic-sdk-python
⨍
Functions
1,183
◇
Types & classes
417
↳
Endpoints
7
↓ 174 callers
Method
get
(self, __key: str)
src/anthropic/_types.py:172
↓ 141 callers
Function
assert_matches_type
( type_: Any, value: object, *, path: list[str], allow_none: bool = False, )
tests/utils.py:48
↓ 89 callers
Method
parse
(self, query: str)
src/anthropic/_qs.py:36
↓ 88 callers
Method
create
[Legacy] Create a Text Completion. The Text Completions API is a legacy API. We recommend using the [Messages API](https://d
src/anthropic/resources/completions.py:53
↓ 73 callers
Method
construct
( # pyright: ignore[reportIncompatibleMethodOverride] __cls: Type[ModelT], _fields_set: set[s
src/anthropic/_models.py:197
↓ 50 callers
Function
make_request_options
Create a dict of type RequestOptions without keys of NotGiven values.
src/anthropic/_base_client.py:1900
↓ 39 callers
Function
is_given
(obj: NotGivenOr[_T])
src/anthropic/_utils/_utils.py:122
↓ 34 callers
Method
retrieve
Get a specific model. The Models API response can be used to determine information about a specific model or resolve a model
src/anthropic/resources/models.py:41
↓ 32 callers
Method
list
List available models. The Models API response can be used to determine which models are available for use in the API. More
src/anthropic/resources/models.py:79
↓ 31 callers
Method
_build_request
( self, options: FinalRequestOptions, *, retries_taken: int = 0, )
src/anthropic/_base_client.py:445
↓ 29 callers
Method
post
( self, path: str, *, cast_to: Type[ResponseT], body: Body | None = No
src/anthropic/_base_client.py:1231
↓ 24 callers
Function
transform
( data: _T, expected_type: object, use_async: bool, )
tests/test_transform.py:26
↓ 20 callers
Method
close
Close the response and release the connection. Automatically called if the response body is read to completion.
src/anthropic/_streaming.py:131
↓ 19 callers
Function
maybe_transform
Wrapper over `transform()` that allows `None` to be passed. See `transform()` for more details.
src/anthropic/_utils/_transform.py:74
↓ 19 callers
Function
strip_not_given
(obj: None)
src/anthropic/_utils/_utils.py:287
↓ 18 callers
Method
cancel
Batches may be canceled any time before processing ends. Once cancellation is initiated, the batch enters a `canceling` state, at whi
src/anthropic/resources/messages/batches.py:222
↓ 18 callers
Method
delete
( self, path: str, *, cast_to: Type[ResponseT], body: Body | None = No
src/anthropic/_base_client.py:1309
↓ 16 callers
Method
count_tokens
Count the number of tokens in a Message. The Token Count API can be used to count the number of tokens in a Message, includi
src/anthropic/resources/messages/messages.py:993
↓ 16 callers
Method
json
Read and decode the JSON response content.
src/anthropic/_response.py:372
↓ 15 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:440
↓ 15 callers
Method
copy
Create a new client instance re-using the same options given to the current client with optional overriding.
src/anthropic/_client.py:184
↓ 14 callers
Function
get_origin
(t: type[Any])
src/anthropic/_compat.py:37
↓ 12 callers
Method
aclose
(self)
src/anthropic/_legacy_response.py:510
↓ 12 callers
Function
get_args
(t: type[Any])
src/anthropic/_compat.py:31
↓ 11 callers
Function
iter_next
(iter: Iterator[ServerSentEvent] | AsyncIterator[ServerSentEvent])
tests/test_streaming.py:232
↓ 11 callers
Method
read
Read and return the binary response content.
src/anthropic/_response.py:357
↓ 10 callers
Function
body
()
tests/test_streaming.py:15
↓ 10 callers
Function
make_event_iterator
( content: Iterator[bytes], *, sync: bool, client: Anthropic, async_client: AsyncAnthropic
tests/test_streaming.py:244
↓ 10 callers
Method
to_dict
Recursively generate a dictionary representation of the model, optionally specifying which fields to include or exclude. By default, fields t
src/anthropic/_models.py:115
↓ 9 callers
Function
assert_empty_iter
(iter: Iterator[ServerSentEvent] | AsyncIterator[ServerSentEvent])
tests/test_streaming.py:239
↓ 9 callers
Function
async_to_streamed_response_wrapper
Higher order function that takes one of our bound API methods and wraps it to support streaming and returning the raw `APIResponse` object directl
src/anthropic/_response.py:706
↓ 9 callers
Method
decode
(self, line: str)
src/anthropic/_streaming.py:355
↓ 9 callers
Method
get
( self, path: str, *, cast_to: Type[ResponseT], options: RequestOption
src/anthropic/_base_client.py:1185
↓ 9 callers
Method
stream
Create a Message stream
src/anthropic/resources/messages/messages.py:931
↓ 9 callers
Function
to_streamed_response_wrapper
Higher order function that takes one of our bound API methods and wraps it to support streaming and returning the raw `APIResponse` object directl
src/anthropic/_response.py:687
↓ 8 callers
Method
parse
(self, *, to: type[_T])
src/anthropic/_response.py:304
↓ 8 callers
Method
parse
(self, *, to: type[_T])
src/anthropic/_response.py:413
↓ 7 callers
Function
async_maybe_transform
Wrapper over `async_transform()` that allows `None` to be passed. See `async_transform()` for more details.
src/anthropic/_utils/_transform.py:252
↓ 7 callers
Function
extract_type_arg
(typ: type, index: int)
src/anthropic/_utils/_typing.py:76
↓ 7 callers
Function
extract_type_var_from_base
Given a type like `Foo[T]`, returns the generic type variable `T`. This also handles the case where a concrete subclass is given, e.g. ```py
src/anthropic/_utils/_typing.py:84
↓ 7 callers
Method
get_max_retries
(self, max_retries: int)
src/anthropic/_models.py:789
↓ 7 callers
Function
is_dict
(obj: object)
src/anthropic/_utils/_utils.py:160
↓ 7 callers
Function
is_list
(obj: object)
src/anthropic/_utils/_utils.py:164
↓ 7 callers
Function
is_mapping
(obj: object)
src/anthropic/_utils/_utils.py:152
↓ 7 callers
Method
parse
(self, *, to: type[_T])
src/anthropic/_legacy_response.py:97
↓ 7 callers
Method
request
( self, cast_to: Type[ResponseT], options: FinalRequestOptions, remaining_retr
src/anthropic/_base_client.py:914
↓ 7 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:266
↓ 6 callers
Method
__class__
(self)
src/anthropic/_utils/_proxy.py:48
↓ 6 callers
Function
assert_different_identities
(obj1: object, obj2: object)
tests/test_deepcopy.py:4
↓ 6 callers
Function
basic_response
()
tests/lib/streaming/test_messages.py:56
↓ 6 callers
Function
deepcopy_minimal
Minimal reimplementation of copy.deepcopy() that will only copy certain object types: - mappings, e.g. `dict` - list This is done for pe
src/anthropic/_utils/_utils.py:172
↓ 6 callers
Function
extract_response_type
Given a type like `APIResponse[T]`, returns the generic type variable `T`. This also handles the case where a concrete subclass is given, e.g.
src/anthropic/_response.py:857
↓ 6 callers
Function
foo
(a: str | None = None)
tests/test_required_args.py:10
↓ 6 callers
Method
get_final_message
Waits until the stream has been read to completion and returns the accumulated `Message` object.
src/anthropic/lib/streaming/_messages.py:75
↓ 6 callers
Function
is_annotated_type
(typ: type)
src/anthropic/_utils/_typing.py:20
↓ 6 callers
Function
model_dump
( model: pydantic.BaseModel, *, exclude: IncEx | None = None, exclude_unset: bool = False,
src/anthropic/_compat.py:133
↓ 6 callers
Method
model_dump_json
Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json Generates a JSON representation of the model using
src/anthropic/_models.py:322
↓ 5 callers
Method
__get_proxied__
(self)
src/anthropic/_utils/_proxy.py:54
↓ 5 callers
Function
async_to_httpx_files
(files: None)
src/anthropic/_files.py:84
↓ 5 callers
Method
iter_bytes
A byte-iterator over the decoded response content. This automatically handles gzip, deflate and brotli encoded responses.
src/anthropic/_response.py:384
↓ 5 callers
Function
model_copy
(model: _ModelT, *, deep: bool = False)
src/anthropic/_compat.py:121
↓ 5 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:265
↓ 5 callers
Method
request
( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, str
src/anthropic/_base_client.py:1497
↓ 5 callers
Function
set_pydantic_config
Add a pydantic config for the given type. Note: this is a no-op on Pydantic v1.
src/anthropic/_models.py:683
↓ 5 callers
Function
to_httpx_files
(files: None)
src/anthropic/_files.py:42
↓ 4 callers
Method
__init__
(self, message: str, request: httpx.Request, *, body: object | None)
src/anthropic/_exceptions.py:40
↓ 4 callers
Method
__init__
( self, *, url: URL, )
src/anthropic/_base_client.py:125
↓ 4 callers
Method
_calculate_retry_timeout
( self, remaining_retries: int, options: FinalRequestOptions, response_headers
src/anthropic/_base_client.py:686
↓ 4 callers
Function
_get_open_connections
(client: Anthropic | AsyncAnthropic)
tests/test_client.py:53
↓ 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:67
↓ 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:67
↓ 4 callers
Function
construct_type_unchecked
Loose coercion to the expected type with construction of nested values. Note: the returned value from this function is not guaranteed to match th
src/anthropic/_models.py:431
↓ 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:114
↓ 4 callers
Function
is_type_alias_type
Return whether the provided argument is an instance of `TypeAliasType`. ```python type Int = int is_type_alias_type(Int) # > True
src/anthropic/_utils/_typing.py:53
↓ 4 callers
Function
iter_next
(iter: Iterator[_T] | AsyncIterator[_T])
tests/decoders/test_jsonl.py:67
↓ 4 callers
Function
parse_obj
(model: type[_ModelT], value: object)
src/anthropic/_compat.py:79
↓ 4 callers
Method
to_json
Generates a JSON string representing this model as it would be received from or sent to the API (but with indentation). By default, fields th
src/anthropic/_models.py:153
↓ 4 callers
Function
update_env
(**new_env: str | Omit)
tests/utils.py:146
↓ 3 callers
Function
_get_annotated_type
If the given type is an `Annotated` type then it is returned, if not `None` is returned. This also unwraps the type when applicable, e.g. `Requir
src/anthropic/_utils/_transform.py:111
↓ 3 callers
Method
_get_page_items
(self)
src/anthropic/_base_client.py:177
↓ 3 callers
Method
_request_api_list
( self, model: Type[object], page: Type[SyncPageT], options: FinalRequestOptio
src/anthropic/_base_client.py:1166
↓ 3 callers
Function
add_request_id
(obj: BaseModel, request_id: str | None)
src/anthropic/_models.py:691
↓ 3 callers
Method
aiter_bytes
Given an iterator that yields raw binary data, iterate over it & yield every event encountered
src/anthropic/_streaming.py:333
↓ 3 callers
Function
body
()
tests/decoders/test_jsonl.py:16
↓ 3 callers
Method
close
Close the underlying HTTPX client. The client will *not* be usable after this.
src/anthropic/_base_client.py:874
↓ 3 callers
Method
copy
Create a new client instance re-using the same options given to the current client with optional overriding.
src/anthropic/_client.py:404
↓ 3 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:38
↓ 3 callers
Function
is_file_content
(obj: object)
src/anthropic/_files.py:27
↓ 3 callers
Function
is_iterable
(obj: object)
src/anthropic/_utils/_utils.py:168
↓ 3 callers
Function
is_list_type
(typ: type)
src/anthropic/_utils/_typing.py:24
↓ 3 callers
Function
is_mapping_t
(obj: _MappingT | object)
src/anthropic/_utils/_utils.py:156
↓ 3 callers
Function
is_union_type
(typ: type)
src/anthropic/_utils/_typing.py:34
↓ 3 callers
Method
iter_bytes
(self, chunk_size: int | None = None)
src/anthropic/_legacy_response.py:437
↓ 3 callers
Function
make_jsonl_iterator
( content: Iterator[bytes], *, sync: bool, line_type: type[_T], )
tests/decoders/test_jsonl.py:78
↓ 3 callers
Method
next_page_info
(self)
src/anthropic/_base_client.py:175
↓ 3 callers
Function
parse_datetime
(value: Union[datetime, StrBytesIntFloat])
src/anthropic/_compat.py:28
↓ 3 callers
Method
read
Read and return the binary response content.
src/anthropic/_response.py:464
↓ 3 callers
Function
strip_annotated_type
(typ: type)
src/anthropic/_utils/_typing.py:69
↓ 3 callers
Function
to_async_iter
(iter: Iterator[_T])
tests/lib/streaming/test_messages.py:61
↓ 2 callers
Method
__anext__
(self)
src/anthropic/_streaming.py:181
next →
1–100 of 1,183, ranked by callers