to_model_kwargs() — langchain Function Reference
Architecture documentation for the to_model_kwargs() function in structured_output.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 0d29750e_a10c_2bb6_92ee_0217de4e6087["to_model_kwargs()"] 6e90be30_70b3_e6e9_2090_a66fcbf5f221["ProviderStrategy"] 0d29750e_a10c_2bb6_92ee_0217de4e6087 -->|defined in| 6e90be30_70b3_e6e9_2090_a66fcbf5f221 style 0d29750e_a10c_2bb6_92ee_0217de4e6087 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/agents/structured_output.py lines 285–304
def to_model_kwargs(self) -> dict[str, Any]:
"""Convert to kwargs to bind to a model to force structured output.
Returns:
The kwargs to bind to a model.
"""
# OpenAI:
# - see https://platform.openai.com/docs/guides/structured-outputs
json_schema: dict[str, Any] = {
"name": self.schema_spec.name,
"schema": self.schema_spec.json_schema,
}
if self.schema_spec.strict:
json_schema["strict"] = True
response_format: dict[str, Any] = {
"type": "json_schema",
"json_schema": json_schema,
}
return {"response_format": response_format}
Domain
Subdomains
Source
Frequently Asked Questions
What does to_model_kwargs() do?
to_model_kwargs() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/structured_output.py.
Where is to_model_kwargs() defined?
to_model_kwargs() is defined in libs/langchain_v1/langchain/agents/structured_output.py at line 285.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free