Models Class — anthropic-sdk-python Architecture
Architecture documentation for the Models class in models.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD feefa0ea_204d_3792_0bc0_49d99e6cc984["Models"] 32bd9d9e_8b62_b229_7718_45771b424c40["SyncAPIResource"] feefa0ea_204d_3792_0bc0_49d99e6cc984 -->|extends| 32bd9d9e_8b62_b229_7718_45771b424c40 4a949196_7222_6f5f_da12_31c9260bb10f["models.py"] feefa0ea_204d_3792_0bc0_49d99e6cc984 -->|defined in| 4a949196_7222_6f5f_da12_31c9260bb10f ee35b435_81a8_75ef_9df3_ccdaaf570af6["with_raw_response()"] feefa0ea_204d_3792_0bc0_49d99e6cc984 -->|method| ee35b435_81a8_75ef_9df3_ccdaaf570af6 41f3ff67_48f3_2c9f_2e93_5c6bd1dcfe22["with_streaming_response()"] feefa0ea_204d_3792_0bc0_49d99e6cc984 -->|method| 41f3ff67_48f3_2c9f_2e93_5c6bd1dcfe22 14c9f0c3_35bc_6c50_343b_3991164794b7["retrieve()"] feefa0ea_204d_3792_0bc0_49d99e6cc984 -->|method| 14c9f0c3_35bc_6c50_343b_3991164794b7 0dbf0a80_fae2_982e_20ea_fe7e9c8b14ea["list()"] feefa0ea_204d_3792_0bc0_49d99e6cc984 -->|method| 0dbf0a80_fae2_982e_20ea_fe7e9c8b14ea
Relationship Graph
Source Code
src/anthropic/resources/models.py lines 24–152
class Models(SyncAPIResource):
@cached_property
def with_raw_response(self) -> ModelsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
"""
return ModelsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> ModelsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
"""
return ModelsWithStreamingResponse(self)
def retrieve(
self,
model_id: str,
*,
betas: List[AnthropicBetaParam] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ModelInfo:
"""
Get a specific model.
The Models API response can be used to determine information about a specific
model or resolve a model alias to a model ID.
Args:
model_id: Model identifier or alias.
betas: Optional header to specify the beta version(s) you want to use.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not model_id:
raise ValueError(f"Expected a non-empty value for `model_id` but received {model_id!r}")
extra_headers = {
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
**(extra_headers or {}),
}
return self._get(
f"/v1/models/{model_id}",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=ModelInfo,
)
def list(
self,
*,
after_id: str | Omit = omit,
before_id: str | Omit = omit,
limit: int | Omit = omit,
betas: List[AnthropicBetaParam] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> SyncPage[ModelInfo]:
"""
List available models.
Domain
Defined In
Extends
Source
Frequently Asked Questions
What is the Models class?
Models is a class in the anthropic-sdk-python codebase, defined in src/anthropic/resources/models.py.
Where is Models defined?
Models is defined in src/anthropic/resources/models.py at line 24.
What does Models extend?
Models extends SyncAPIResource.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free