parse_response() — anthropic-sdk-python Function Reference
Architecture documentation for the parse_response() function in _response.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 51968ef1_a0a2_526c_4683_a580fc7a3d49["parse_response()"] aa7d21d4_f6f0_8301_73f8_2ea17597e81e["_response.py"] 51968ef1_a0a2_526c_4683_a580fc7a3d49 -->|defined in| aa7d21d4_f6f0_8301_73f8_2ea17597e81e 003dda82_b050_1266_a7d3_b3e2e3c50b4a["parse_text()"] 51968ef1_a0a2_526c_4683_a580fc7a3d49 -->|calls| 003dda82_b050_1266_a7d3_b3e2e3c50b4a style 51968ef1_a0a2_526c_4683_a580fc7a3d49 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/anthropic/lib/_parse/_response.py lines 49–72
def parse_response(
*,
output_format: ResponseFormatT | NotGiven,
response: Message,
) -> ParsedMessage[ResponseFormatT]:
content_list: list[ParsedContentBlock[ResponseFormatT]] = []
for content in response.content:
if content.type == "text":
content_list.append(
construct_type_unchecked(
type_=ParsedTextBlock[ResponseFormatT],
value={**content.to_dict(), "parsed_output": parse_text(content.text, output_format)},
)
)
else:
content_list.append(content) # type: ignore
return construct_type_unchecked(
type_=ParsedMessage[ResponseFormatT],
value={
**response.to_dict(),
"content": content_list,
},
)
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does parse_response() do?
parse_response() is a function in the anthropic-sdk-python codebase, defined in src/anthropic/lib/_parse/_response.py.
Where is parse_response() defined?
parse_response() is defined in src/anthropic/lib/_parse/_response.py at line 49.
What does parse_response() call?
parse_response() calls 1 function(s): parse_text.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free