Home / Class/ AsyncModels Class — anthropic-sdk-python Architecture

AsyncModels Class — anthropic-sdk-python Architecture

Architecture documentation for the AsyncModels class in models.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  a6e95d4e_9283_0e25_429d_0380a2f1939e["AsyncModels"]
  f98629a5_73f4_23f2_1f7f_c8db837848d1["AsyncAPIResource"]
  a6e95d4e_9283_0e25_429d_0380a2f1939e -->|extends| f98629a5_73f4_23f2_1f7f_c8db837848d1
  aaf44c70_9358_3dce_9005_4fb1dbf27b38["models.py"]
  a6e95d4e_9283_0e25_429d_0380a2f1939e -->|defined in| aaf44c70_9358_3dce_9005_4fb1dbf27b38
  befb458e_f213_4178_96d6_7415a0ebd5dc["with_raw_response()"]
  a6e95d4e_9283_0e25_429d_0380a2f1939e -->|method| befb458e_f213_4178_96d6_7415a0ebd5dc
  2a2a1143_ca06_b618_1c11_ee3c73ea7fd5["with_streaming_response()"]
  a6e95d4e_9283_0e25_429d_0380a2f1939e -->|method| 2a2a1143_ca06_b618_1c11_ee3c73ea7fd5
  bbd7ed9c_37d4_5075_b234_b72b6239686d["retrieve()"]
  a6e95d4e_9283_0e25_429d_0380a2f1939e -->|method| bbd7ed9c_37d4_5075_b234_b72b6239686d
  40dcd9bc_e982_8e79_0a92_102f712f7c24["list()"]
  a6e95d4e_9283_0e25_429d_0380a2f1939e -->|method| 40dcd9bc_e982_8e79_0a92_102f712f7c24

Relationship Graph

Source Code

src/anthropic/resources/beta/models.py lines 155–283

class AsyncModels(AsyncAPIResource):
    @cached_property
    def with_raw_response(self) -> AsyncModelsWithRawResponse:
        """
        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 AsyncModelsWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> AsyncModelsWithStreamingResponse:
        """
        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 AsyncModelsWithStreamingResponse(self)

    async 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,
    ) -> BetaModelInfo:
        """
        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 await self._get(
            f"/v1/models/{model_id}?beta=true",
            options=make_request_options(
                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
            ),
            cast_to=BetaModelInfo,
        )

    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,
    ) -> AsyncPaginator[BetaModelInfo, AsyncPage[BetaModelInfo]]:
        """
        List available models.

Frequently Asked Questions

What is the AsyncModels class?
AsyncModels is a class in the anthropic-sdk-python codebase, defined in src/anthropic/resources/beta/models.py.
Where is AsyncModels defined?
AsyncModels is defined in src/anthropic/resources/beta/models.py at line 155.
What does AsyncModels extend?
AsyncModels extends AsyncAPIResource.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free