Home / Function/ _process_response_data() — anthropic-sdk-python Function Reference

_process_response_data() — anthropic-sdk-python Function Reference

Architecture documentation for the _process_response_data() function in _base_client.py from the anthropic-sdk-python codebase.

Function python AnthropicClient SyncAPI calls 3 called by 2

Entity Profile

Dependency Diagram

graph TD
  518c8bd6_474a_7933_381f_46a8c55e9f51["_process_response_data()"]
  842ce0be_ea56_b939_960f_13eb61230daf["BaseClient"]
  518c8bd6_474a_7933_381f_46a8c55e9f51 -->|defined in| 842ce0be_ea56_b939_960f_13eb61230daf
  58686c44_d8b1_cf13_381b_6cff1300f441["_parse()"]
  58686c44_d8b1_cf13_381b_6cff1300f441 -->|calls| 518c8bd6_474a_7933_381f_46a8c55e9f51
  368da297_37b7_ab67_d177_ee29db8d5086["_parse()"]
  368da297_37b7_ab67_d177_ee29db8d5086 -->|calls| 518c8bd6_474a_7933_381f_46a8c55e9f51
  18b1ba83_3e17_a5a3_fd52_d68fd9b6f945["validate_type()"]
  518c8bd6_474a_7933_381f_46a8c55e9f51 -->|calls| 18b1ba83_3e17_a5a3_fd52_d68fd9b6f945
  1f1fa4b5_5943_136f_2cef_23465a8f7aee["construct_type()"]
  518c8bd6_474a_7933_381f_46a8c55e9f51 -->|calls| 1f1fa4b5_5943_136f_2cef_23465a8f7aee
  581be520_0d1b_4636_66cb_735f8146e861["build()"]
  518c8bd6_474a_7933_381f_46a8c55e9f51 -->|calls| 581be520_0d1b_4636_66cb_735f8146e861
  style 518c8bd6_474a_7933_381f_46a8c55e9f51 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/_base_client.py lines 644–666

    def _process_response_data(
        self,
        *,
        data: object,
        cast_to: type[ResponseT],
        response: httpx.Response,
    ) -> ResponseT:
        if data is None:
            return cast(ResponseT, None)

        if cast_to is object:
            return cast(ResponseT, data)

        try:
            if inspect.isclass(cast_to) and issubclass(cast_to, ModelBuilderProtocol):
                return cast(ResponseT, cast_to.build(response=response, data=data))

            if self._strict_response_validation:
                return cast(ResponseT, validate_type(type_=cast_to, value=data))

            return cast(ResponseT, construct_type(type_=cast_to, value=data))
        except pydantic.ValidationError as err:
            raise APIResponseValidationError(response=response, body=data) from err

Subdomains

Called By

Frequently Asked Questions

What does _process_response_data() do?
_process_response_data() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_base_client.py.
Where is _process_response_data() defined?
_process_response_data() is defined in src/anthropic/_base_client.py at line 644.
What does _process_response_data() call?
_process_response_data() calls 3 function(s): build, construct_type, validate_type.
What calls _process_response_data()?
_process_response_data() is called by 2 function(s): _parse, _parse.

Analyze Your Own Codebase

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

Try Supermodel Free