_response.py — anthropic-sdk-python Source File
Architecture documentation for _response.py, a python file in the anthropic-sdk-python codebase. 31 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR 2e9c15bb_de03_aa91_93be_0e05db0a552e["_response.py"] 87f621ac_b3e0_a225_72b3_99f9818f3002["_types.py"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> 87f621ac_b3e0_a225_72b3_99f9818f3002 0a69184e_7509_e793_afa4_1a03f37f5311["NoneType"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> 0a69184e_7509_e793_afa4_1a03f37f5311 6dadb144_3070_6111_357f_214554108905["__init__.py"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> 6dadb144_3070_6111_357f_214554108905 3912cc3f_b0e8_a732_b8e2_613b018b830d["_models.py"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> 3912cc3f_b0e8_a732_b8e2_613b018b830d 17ce5647_6f06_0676_a4a5_e378a3f57cb1["BaseModel"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> 17ce5647_6f06_0676_a4a5_e378a3f57cb1 68781e77_0c04_76c0_39da_f86210b5c63c["is_basemodel"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> 68781e77_0c04_76c0_39da_f86210b5c63c 11423f8f_08a1_b61d_0443_80db1a1d5485["add_request_id"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> 11423f8f_08a1_b61d_0443_80db1a1d5485 3d69c2f4_e6b6_2dd4_bdc8_383d4a3bc953["_constants.py"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> 3d69c2f4_e6b6_2dd4_bdc8_383d4a3bc953 8d141d22_ab1c_b4a1_744c_99e460d07454["_streaming.py"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> 8d141d22_ab1c_b4a1_744c_99e460d07454 3c15a36b_3b82_93a8_fe82_3d955b1934ca["Stream"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> 3c15a36b_3b82_93a8_fe82_3d955b1934ca 03fc0a8b_1c63_1aee_ef30_754aeebc2ff6["AsyncStream"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> 03fc0a8b_1c63_1aee_ef30_754aeebc2ff6 d418996b_1a10_4fe8_0fe5_007be2e08653["is_stream_class_type"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> d418996b_1a10_4fe8_0fe5_007be2e08653 941ce251_c4b2_51eb_76d8_a3a9127c15e5["extract_stream_chunk_type"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> 941ce251_c4b2_51eb_76d8_a3a9127c15e5 b3e43638_c882_dccb_b00e_ddc6b5147130["_exceptions.py"] 2e9c15bb_de03_aa91_93be_0e05db0a552e --> b3e43638_c882_dccb_b00e_ddc6b5147130 style 2e9c15bb_de03_aa91_93be_0e05db0a552e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from __future__ import annotations
import os
import inspect
import logging
import datetime
import functools
from types import TracebackType
from typing import (
TYPE_CHECKING,
Any,
Union,
Generic,
TypeVar,
Callable,
Iterator,
AsyncIterator,
cast,
overload,
)
from typing_extensions import Awaitable, ParamSpec, override, get_origin
import anyio
import httpx
import pydantic
from ._types import NoneType
from ._utils import is_given, extract_type_arg, is_annotated_type, is_type_alias_type, extract_type_var_from_base
from ._models import BaseModel, is_basemodel, add_request_id
from ._constants import RAW_RESPONSE_HEADER, OVERRIDE_CAST_TO_HEADER
from ._streaming import Stream, AsyncStream, is_stream_class_type, extract_stream_chunk_type
from ._exceptions import AnthropicError, APIResponseValidationError
from ._decoders.jsonl import JSONLDecoder, AsyncJSONLDecoder
if TYPE_CHECKING:
from ._models import FinalRequestOptions
from ._base_client import BaseClient
P = ParamSpec("P")
R = TypeVar("R")
_T = TypeVar("_T")
_APIResponseT = TypeVar("_APIResponseT", bound="APIResponse[Any]")
_AsyncAPIResponseT = TypeVar("_AsyncAPIResponseT", bound="AsyncAPIResponse[Any]")
log: logging.Logger = logging.getLogger(__name__)
class BaseAPIResponse(Generic[R]):
_cast_to: type[R]
_client: BaseClient[Any, Any]
_parsed_by_type: dict[type[Any], Any]
_is_sse_stream: bool
_stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None
_options: FinalRequestOptions
http_response: httpx.Response
retries_taken: int
"""The number of retries made. If no retries happened this will be `0`"""
// ... (813 more lines)
Domain
Subdomains
Functions
- _models()
- async_to_custom_raw_response_wrapper()
- async_to_custom_streamed_response_wrapper()
- async_to_raw_response_wrapper()
- async_to_streamed_response_wrapper()
- extract_response_type()
- to_custom_raw_response_wrapper()
- to_custom_streamed_response_wrapper()
- to_raw_response_wrapper()
- to_streamed_response_wrapper()
Classes
Dependencies
- APIResponseValidationError
- AnthropicError
- AsyncStream
- BaseClient
- BaseModel
- FinalRequestOptions
- NoneType
- Stream
- __init__.py
- __init__.py
- _base_client.py
- _constants.py
- _decoders.jsonl
- _exceptions.py
- _models.py
- _streaming.py
- _types.py
- add_request_id
- anyio
- datetime
- extract_stream_chunk_type
- functools
- httpx
- inspect
- is_basemodel
- is_stream_class_type
- logging
- os
- pydantic
- typing
- typing_extensions
Source
Frequently Asked Questions
What does _response.py do?
_response.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, AsyncAPI subdomain.
What functions are defined in _response.py?
_response.py defines 10 function(s): _models, async_to_custom_raw_response_wrapper, async_to_custom_streamed_response_wrapper, async_to_raw_response_wrapper, async_to_streamed_response_wrapper, extract_response_type, to_custom_raw_response_wrapper, to_custom_streamed_response_wrapper, to_raw_response_wrapper, to_streamed_response_wrapper.
What does _response.py depend on?
_response.py imports 31 module(s): APIResponseValidationError, AnthropicError, AsyncStream, BaseClient, BaseModel, FinalRequestOptions, NoneType, Stream, and 23 more.
What files import _response.py?
_response.py is imported by 3 file(s): __init__.py, _base_client.py, _types.py.
Where is _response.py in the architecture?
_response.py is located at src/anthropic/_response.py (domain: AnthropicClient, subdomain: AsyncAPI, directory: src/anthropic).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free