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

to_custom_raw_response_wrapper() — anthropic-sdk-python Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  93ff3873_0977_141d_de34_c181b77ec34d["to_custom_raw_response_wrapper()"]
  2e9c15bb_de03_aa91_93be_0e05db0a552e["_response.py"]
  93ff3873_0977_141d_de34_c181b77ec34d -->|defined in| 2e9c15bb_de03_aa91_93be_0e05db0a552e
  839eb1b8_70aa_074d_a52b_fad472cf23c5["get()"]
  93ff3873_0977_141d_de34_c181b77ec34d -->|calls| 839eb1b8_70aa_074d_a52b_fad472cf23c5
  style 93ff3873_0977_141d_de34_c181b77ec34d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/anthropic/_response.py lines 811–831

def to_custom_raw_response_wrapper(
    func: Callable[P, object],
    response_cls: type[_APIResponseT],
) -> Callable[P, _APIResponseT]:
    """Higher order function that takes one of our bound API methods and an `APIResponse` class
    and wraps the method to support returning the given response class directly.

    Note: the given `response_cls` *must* be concrete, e.g. `class BinaryAPIResponse(APIResponse[bytes])`
    """

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

        kwargs["extra_headers"] = extra_headers

        return cast(_APIResponseT, func(*args, **kwargs))

    return wrapped

Subdomains

Calls

Frequently Asked Questions

What does to_custom_raw_response_wrapper() do?
to_custom_raw_response_wrapper() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_response.py.
Where is to_custom_raw_response_wrapper() defined?
to_custom_raw_response_wrapper() is defined in src/anthropic/_response.py at line 811.
What does to_custom_raw_response_wrapper() call?
to_custom_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