_convert_to_anthropic_output_config_format() — langchain Function Reference
Architecture documentation for the _convert_to_anthropic_output_config_format() function in chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 5bd44152_3323_2e97_ed23_07de137480d2["_convert_to_anthropic_output_config_format()"] a85819c7_917d_4c71_2864_a19e68947340["chat_models.py"] 5bd44152_3323_2e97_ed23_07de137480d2 -->|defined in| a85819c7_917d_4c71_2864_a19e68947340 954f0cfe_731b_ac1b_0145_b5a3d210030b["_get_request_payload()"] 954f0cfe_731b_ac1b_0145_b5a3d210030b -->|calls| 5bd44152_3323_2e97_ed23_07de137480d2 a484b53c_8c1c_5314_de44_ea0330c8aed2["with_structured_output()"] a484b53c_8c1c_5314_de44_ea0330c8aed2 -->|calls| 5bd44152_3323_2e97_ed23_07de137480d2 style 5bd44152_3323_2e97_ed23_07de137480d2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/langchain_anthropic/chat_models.py lines 1905–1924
def _convert_to_anthropic_output_config_format(schema: dict | type) -> dict[str, Any]:
"""Convert JSON schema, Pydantic model, or `TypedDict` into `output_config.format`.
See Claude docs on [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs).
Args:
schema: A JSON schema dict, Pydantic model class, or TypedDict.
Returns:
A dict with `type` and `schema` keys suitable for `output_config.format`.
"""
from anthropic import transform_schema
is_pydantic_class = isinstance(schema, type) and is_basemodel_subclass(schema)
if is_pydantic_class or isinstance(schema, dict):
json_schema = transform_schema(schema)
else:
# TypedDict
json_schema = transform_schema(convert_to_json_schema(schema))
return {"type": "json_schema", "schema": json_schema}
Domain
Subdomains
Source
Frequently Asked Questions
What does _convert_to_anthropic_output_config_format() do?
_convert_to_anthropic_output_config_format() is a function in the langchain codebase, defined in libs/partners/anthropic/langchain_anthropic/chat_models.py.
Where is _convert_to_anthropic_output_config_format() defined?
_convert_to_anthropic_output_config_format() is defined in libs/partners/anthropic/langchain_anthropic/chat_models.py at line 1905.
What calls _convert_to_anthropic_output_config_format()?
_convert_to_anthropic_output_config_format() is called by 2 function(s): _get_request_payload, with_structured_output.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free