FinalRequestOptions Class — anthropic-sdk-python Architecture
Architecture documentation for the FinalRequestOptions class in _models.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 650dd236_1578_b957_3fd7_c129ccfee18e["FinalRequestOptions"] f30eca5a_2fa0_68c1_64aa_b52331a2dcc8["NotGiven"] 650dd236_1578_b957_3fd7_c129ccfee18e -->|extends| f30eca5a_2fa0_68c1_64aa_b52331a2dcc8 650dd236_1578_b957_3fd7_c129ccfee18e["FinalRequestOptions"] 650dd236_1578_b957_3fd7_c129ccfee18e -->|extends| 650dd236_1578_b957_3fd7_c129ccfee18e 3912cc3f_b0e8_a732_b8e2_613b018b830d["_models.py"] 650dd236_1578_b957_3fd7_c129ccfee18e -->|defined in| 3912cc3f_b0e8_a732_b8e2_613b018b830d fa54541f_e19a_261b_1d26_4ba1cc3ee993["get_max_retries()"] 650dd236_1578_b957_3fd7_c129ccfee18e -->|method| fa54541f_e19a_261b_1d26_4ba1cc3ee993 d58471b8_799b_6583_1307_086d2b49c27a["_strip_raw_response_header()"] 650dd236_1578_b957_3fd7_c129ccfee18e -->|method| d58471b8_799b_6583_1307_086d2b49c27a 4e74c968_63fc_ca6c_ccf4_c01326e7060e["construct()"] 650dd236_1578_b957_3fd7_c129ccfee18e -->|method| 4e74c968_63fc_ca6c_ccf4_c01326e7060e
Relationship Graph
Source Code
src/anthropic/_models.py lines 856–918
class FinalRequestOptions(pydantic.BaseModel):
method: str
url: str
params: Query = {}
headers: Union[Headers, NotGiven] = NotGiven()
max_retries: Union[int, NotGiven] = NotGiven()
timeout: Union[float, Timeout, None, NotGiven] = NotGiven()
files: Union[HttpxRequestFiles, None] = None
idempotency_key: Union[str, None] = None
post_parser: Union[Callable[[Any], Any], NotGiven] = NotGiven()
follow_redirects: Union[bool, None] = None
content: Union[bytes, bytearray, IO[bytes], Iterable[bytes], AsyncIterable[bytes], None] = None
# It should be noted that we cannot use `json` here as that would override
# a BaseModel method in an incompatible fashion.
json_data: Union[Body, None] = None
extra_json: Union[AnyMapping, None] = None
if PYDANTIC_V1:
class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated]
arbitrary_types_allowed: bool = True
else:
model_config: ClassVar[ConfigDict] = ConfigDict(arbitrary_types_allowed=True)
def get_max_retries(self, max_retries: int) -> int:
if isinstance(self.max_retries, NotGiven):
return max_retries
return self.max_retries
def _strip_raw_response_header(self) -> None:
if not is_given(self.headers):
return
if self.headers.get(RAW_RESPONSE_HEADER):
self.headers = {**self.headers}
self.headers.pop(RAW_RESPONSE_HEADER)
# override the `construct` method so that we can run custom transformations.
# this is necessary as we don't want to do any actual runtime type checking
# (which means we can't use validators) but we do want to ensure that `NotGiven`
# values are not present
#
# type ignore required because we're adding explicit types to `**values`
@classmethod
def construct( # type: ignore
cls,
_fields_set: set[str] | None = None,
**values: Unpack[FinalRequestOptionsInput],
) -> FinalRequestOptions:
kwargs: dict[str, Any] = {
# we unconditionally call `strip_not_given` on any value
# as it will just ignore any non-mapping types
key: strip_not_given(value)
for key, value in values.items()
}
if PYDANTIC_V1:
return cast(FinalRequestOptions, super().construct(_fields_set, **kwargs)) # pyright: ignore[reportDeprecated]
return super().model_construct(_fields_set, **kwargs)
if not TYPE_CHECKING:
# type checkers incorrectly complain about this assignment
model_construct = construct
Domain
Defined In
Extends
Source
Frequently Asked Questions
What is the FinalRequestOptions class?
FinalRequestOptions is a class in the anthropic-sdk-python codebase, defined in src/anthropic/_models.py.
Where is FinalRequestOptions defined?
FinalRequestOptions is defined in src/anthropic/_models.py at line 856.
What does FinalRequestOptions extend?
FinalRequestOptions extends NotGiven, FinalRequestOptions.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free