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

to_raw_response_wrapper() — anthropic-sdk-python Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  b1e1249f_af25_75f9_44e3_23d268fe9469["to_raw_response_wrapper()"]
  f3a9224d_bdab_aa4b_9f5e_877302fb10bc["_legacy_response.py"]
  b1e1249f_af25_75f9_44e3_23d268fe9469 -->|defined in| f3a9224d_bdab_aa4b_9f5e_877302fb10bc
  afc80c40_7ec9_e8a7_8063_f2ab74bc2ee7["get()"]
  b1e1249f_af25_75f9_44e3_23d268fe9469 -->|calls| afc80c40_7ec9_e8a7_8063_f2ab74bc2ee7
  style b1e1249f_af25_75f9_44e3_23d268fe9469 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/_legacy_response.py lines 375–389

def to_raw_response_wrapper(func: Callable[P, R]) -> Callable[P, LegacyAPIResponse[R]]:
    """Higher order function that takes one of our bound API methods and wraps it
    to support returning the raw `APIResponse` object directly.
    """

    @functools.wraps(func)
    def wrapped(*args: P.args, **kwargs: P.kwargs) -> LegacyAPIResponse[R]:
        extra_headers: dict[str, str] = {**(cast(Any, kwargs.get("extra_headers")) or {})}
        extra_headers[RAW_RESPONSE_HEADER] = "true"

        kwargs["extra_headers"] = extra_headers

        return cast(LegacyAPIResponse[R], func(*args, **kwargs))

    return wrapped

Subdomains

Calls

Frequently Asked Questions

What does to_raw_response_wrapper() do?
to_raw_response_wrapper() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_legacy_response.py.
Where is to_raw_response_wrapper() defined?
to_raw_response_wrapper() is defined in src/anthropic/_legacy_response.py at line 375.
What does to_raw_response_wrapper() call?
to_raw_response_wrapper() calls 1 function(s): get.

Analyze Your Own Codebase

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

Try Supermodel Free