Documentation Index
Fetch the complete documentation index at: https://mintlify.com/langchain-ai/langchain/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Output parsers transform raw LLM text into structured data. They support both complete outputs and streaming partial outputs.BaseOutputParser
Base class for parsing LLM outputs. Source:langchain_core.output_parsers.base:136
Inherits: BaseLLMOutputParser, RunnableSerializable[LanguageModelOutput, T]
Type Parameters
The output type after parsing
Properties
Input type for the parser (
str | BaseMessage)Output type after parsing (inferred from generic)
Core Methods
parse
Text output from the LLM
Parsed output
parse_result
List of generation candidates from the LLM
Whether to parse partial results (useful for streaming)
Parsed output
aparse
parse.
aparse_result
parse_result.
invoke
get_format_instructions
Format instructions to include in the prompt
JsonOutputParser
Parse LLM output as JSON. Source:langchain_core.output_parsers.json:31
Inherits: BaseCumulativeTransformOutputParser[Any]
Properties
Optional Pydantic model for validation
Methods
parse_result
If
True, parse partial JSON (useful for streaming)Parsed JSON object (dict or list)
parse
Example
PydanticOutputParser
Parse LLM output into a Pydantic model. Source:langchain_core.output_parsers.pydantic
Inherits: BaseOutputParser[TBaseModel]
Type Parameters
Pydantic model type to parse into
Properties
Pydantic model class to parse into
Constructor
Pydantic model class
Methods
parse
Validated Pydantic model instance
Example
StrOutputParser
Simple parser that returns the text output as a string. Source:langchain_core.output_parsers.string
Inherits: BaseOutputParser[str]
Methods
parse
Example
CommaSeparatedListOutputParser
Parse output into a comma-separated list. Source:langchain_core.output_parsers.list
Inherits: BaseOutputParser[list[str]]
Methods
parse
Example
XMLOutputParser
Parse XML output into a dictionary. Source:langchain_core.output_parsers.xml
Inherits: BaseOutputParser[dict]
Properties
Optional list of tags to parse. If
None, parses all tags.Methods
parse
Example
OpenAIToolsOutputParser
Parse tool calls from OpenAI format. Source:langchain_core.output_parsers.openai_tools
Inherits: BaseGenerationOutputParser
Methods
parse_result
List of tool call dictionaries
JsonOutputKeyToolsParser
Extract specific tools from OpenAI tool calls and parse as JSON. Source:langchain_core.output_parsers.openai_tools
Inherits: BaseGenerationOutputParser
Properties
Name of the tool to extract
Whether to return only the first matching tool call
Example
PydanticToolsParser
Parse tool calls into Pydantic models. Source:langchain_core.output_parsers.openai_tools
Inherits: BaseGenerationOutputParser
Properties
List of Pydantic model classes corresponding to tools
Whether to return only the first tool call
Example
BaseCumulativeTransformOutputParser
Base class for parsers that support streaming with partial outputs. Source:langchain_core.output_parsers.transform
Inherits: BaseOutputParser[T]
Methods
transform
atransform
transform.
OutputParserException
Exception raised when output parsing fails. Source:langchain_core.exceptions
Inherits: ValueError
Properties
The output from the LLM that failed to parse
Optional observation about why parsing failed
Whether to send the error back to the LLM for correction