get_required_header() — anthropic-sdk-python Function Reference
Architecture documentation for the get_required_header() function in _utils.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD d16eb43f_13fb_1826_ada5_f06d07a647ec["get_required_header()"] 875202ec_3744_577d_9ec4_ed9fbc6aaf41["_utils.py"] d16eb43f_13fb_1826_ada5_f06d07a647ec -->|defined in| 875202ec_3744_577d_9ec4_ed9fbc6aaf41 2566fa30_a0b2_d15a_1637_ea0e212c7daa["is_mapping_t()"] d16eb43f_13fb_1826_ada5_f06d07a647ec -->|calls| 2566fa30_a0b2_d15a_1637_ea0e212c7daa style d16eb43f_13fb_1826_ada5_f06d07a647ec fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/anthropic/_utils/_utils.py lines 372–388
def get_required_header(headers: HeadersLike, header: str) -> str:
lower_header = header.lower()
if is_mapping_t(headers):
# mypy doesn't understand the type narrowing here
for k, v in headers.items(): # type: ignore
if k.lower() == lower_header and isinstance(v, str):
return v
# to deal with the case where the header looks like Stainless-Event-Id
intercaps_header = re.sub(r"([^\w])(\w)", lambda pat: pat.group(1) + pat.group(2).upper(), header.capitalize())
for normalized_header in [header, lower_header, header.upper(), intercaps_header]:
value = headers.get(normalized_header)
if value:
return value
raise ValueError(f"Could not find {header} header")
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does get_required_header() do?
get_required_header() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/_utils/_utils.py.
Where is get_required_header() defined?
get_required_header() is defined in src/anthropic/_utils/_utils.py at line 372.
What does get_required_header() call?
get_required_header() calls 1 function(s): is_mapping_t.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free