Model wrapper that returns outputs formatted to match the given schema.
with_structured_output(
self,
schema: _DictOrPydanticClass | None = None,
*,
method: Literal['function_calling', 'json_mode', 'json_schema'] = 'function_calling',
include_raw: bool = False,
strict: bool | None = None,
tools: list | None = None,
**kwargs: Any = {}
) -> Runnable[LanguageModelInput, _DictOrPydantic]langchain-openai 0.3.12Support for tools added.
langchain-openai 0.3.21Pass kwargs through to the model.
| Name | Type | Description |
|---|---|---|
schema | _DictOrPydanticClass | None | Default: NoneThe output schema. Can be passed in as:
If See |
method | Literal['function_calling', 'json_mode', 'json_schema'] | Default: 'function_calling'The method for steering model generation, one of:
|
include_raw | bool | Default: FalseIf If an error occurs during model output parsing it will be raised. If If an error occurs during output parsing it will be caught and returned as well. The final output is always a |
strict | bool | None | Default: None
|
tools | list | None | Default: NoneA list of tool-like objects to bind to the chat model. Requires that:
If a model elects to call a tool, the resulting Example
|
kwargs | Any | Default: {}Additional keyword args are passed through to the model. |