Skip to content

vllm.parser

Modules:

  • abstract_parser –
  • beam –

    Parser for Beam checkpoints.

  • chat_parsing –

    Response parsing: convert model-emitted text into the assistant-message

  • cohere_command –

    Cohere Command parser.

  • deepseek_v32 –

    DeepSeek V3.2 parser: DSML tool calls with function_calls wrapper.

  • deepseek_v4 –

    DeepSeek V4 parser: <think>/</think>

  • deepseek_v41 –

    DeepSeek V4.1 reasoning and spaced DSML tool calls.

  • engine –

    Streaming parser engine framework for tool call and reasoning extraction.

  • gemma4 –

    Gemma4 parser.

  • glm47_moe –

    GLM-4.7 parser for reasoning and tool calls.

  • granite –

    Granite parser for JSON-array tool calls.

  • granite_thinking –

    Granite 4.2 thinking parser.

  • granite_toolcall –

    Granite 4.2 tool-call parser.

  • harmony –
  • inkling –

    Inkling parser: typed content blocks parsed by a single state machine.

  • kimi_k2 –

    Kimi K2 parser for reasoning and tool calls.

  • kimi_k3 –
  • ling3 –

    Ling3 parser for reasoning and tool calls.

  • llama_json –
  • metrics –

    Prometheus metrics for the parsers.

  • mimo –

    MiMo's compact XML parameters contain verbatim string values.

  • minicpmv –

    MiniCPM-V family parser.

  • minimax_m2 –

    MiniMax M2 parser for XML-style tool calls.

  • minimax_m3 –

    MiniMax M3 parser for namespace-delimited XML-style tool calls.

  • mistral –
  • muse –

    Muse Spark parser: recipient-routed messages parsed by one state machine.

  • nemotron_v3 –

    Nemotron V3 parser.

  • parser_manager –
  • plamo3 –
  • qwen3 –

    Qwen3 parser for tool calls and reasoning.

  • response_template –

    Unified vLLM parser backed by checkpoint response_template metadata.

  • response_template_grammar –

    Structural tags for tool calls and answers, derived from a response template.

  • ripple –

    Ricursive Ripple parser for reasoning and tool calls.

  • seed_oss –

    seed_oss parser for tool calls and reasoning.

  • step3p5 –

    Step-3.5 / Step-3.7 parser for tool calls and reasoning.

  • utils –
  • zaya –

    ZAYA1 parser for tool calls and reasoning.

Classes:

  • DelegatingParser –

    A Parser implementation that delegates to separate ReasoningParser and

  • HarmonyParser –
  • Parser –

    Parse model output into reasoning, content and tool calls.

  • ParserManager –

    Provides a unified Parser by composing reasoning and tool parser adapters.

DelegatingParser

Bases: Parser

A Parser implementation that delegates to separate ReasoningParser and ToolParser instances.

This is the recommended base class for creating model-specific parsers that combine existing reasoning and tool parser implementations. Subclasses should set self._reasoning_parser and self._tool_parser in their __init__ method.

If either parser is None, the corresponding methods will return default values (no reasoning extraction, no tool calls).

Methods:

_append_unstreamed_tool_args(delta_message)

Append parsed-but-unstreamed tool-call arguments to delta_message.

_flush_engine_parsers(delta_message)

Flush buffered state from engine-based parsers at stream end.

count_reasoning_tokens(token_ids)

Count reasoning tokens through the configured reasoning parser.

finalize_generation(delta_message, request, state)

Finalize generation for cases where generation was incomplete. For example, if streaming terminated before reasoning ended

HarmonyParser

Bases: DelegatingParser

Methods:

  • parse –

    Parse Harmony output from token IDs.

_harmony_parser property

Lazily initializes the Harmony parser.

_normalize_recipient(recipient) staticmethod

Remove constrained formats misparsed into recipients by older Harmony.

parse(model_output, request, enable_auto_tools=False, model_output_token_ids=())

Parse Harmony output from token IDs.

Tool calls are always extracted regardless of enable_auto_tools. Callers must decide whether to surface them.

Parser

Parse model output into reasoning, content and tool calls.

The serving layer holds one Parser per request and calls only the members defined here. ParserEngine implements them over a single declarative engine; DelegatingParser composes a legacy ReasoningParser / ToolParser pair.

Methods:

  • adjust_request –

    Adjust the request parameters for tool calling.

  • count_reasoning_tokens –

    Return the number of reasoning tokens in generated token IDs.

  • is_reasoning_end –

    Check if the reasoning content ends in the input_ids.

  • parse –

    Parse a complete model output, extracting reasoning and tool calls.

  • parse_delta –

    Parse a single streaming delta, orchestrating reasoning then

  • set_history_tool_call_count –

    Seed the history count when request.messages is not available.

  • set_prompt_token_ids –

    Provide the exact rendered prompt to parsers that need prefix state.

Attributes:

reasoning_parser property

The underlying reasoning parser, if any.

tool_parser property

The underlying tool parser, if any.

adjust_request(request)

Adjust the request parameters for tool calling.

Can be overridden by subclasses to modify request parameters (e.g., setting structured output schemas for tool calling).

Parameters:

Returns:

count_reasoning_tokens(token_ids)

Return the number of reasoning tokens in generated token IDs.

is_reasoning_end(input_ids) abstractmethod

Check if the reasoning content ends in the input_ids.

Called with the rendered prompt to decide whether generation starts after reasoning. Must be a pure function of the input_ids.

Parameters:

  • input_ids

    (list[int]) –

    The token IDs of the model output.

Returns:

  • bool –

    True if the reasoning content ends in the input_ids.

parse(model_output, request, enable_auto_tools=False, model_output_token_ids=()) abstractmethod

Parse a complete model output, extracting reasoning and tool calls.

Parameters:

  • model_output

    (str) –

    The complete model-generated string.

  • request

    (ChatCompletionRequest | ResponsesRequest) –

    The request object used to generate the output.

  • enable_auto_tools

    (bool, default: False ) –

    Whether to enable automatic tool call parsing.

  • model_output_token_ids

    (Sequence[int], default: () ) –

    The generated raw output token IDs.

Returns:

  • tuple[str | None, str | None, list[FunctionCall] | None] –

    A tuple of (reasoning, content, tool_calls).

parse_delta(delta_text, delta_token_ids, request, prompt_token_ids=None, *, finished) abstractmethod

Parse a single streaming delta, orchestrating reasoning then tool call extraction via internal stream state.

set_history_tool_call_count(count)

Seed the history count when request.messages is not available.

set_prompt_token_ids(prompt_token_ids)

Provide the exact rendered prompt to parsers that need prefix state.

ParserManager

Provides a unified Parser by composing reasoning and tool parser adapters.

Methods:

get_parser(tool_parser_name=None, reasoning_parser_name=None, enable_auto_tools=False, model_name=None, is_harmony=False, tool_strict_level=None, tokenizer=None) classmethod

Get a Parser that handles both reasoning and tool parsing.

Composes the individual parsers into a DelegatingParser subclass.

Parameters:

  • tool_parser_name

    (str | None, default: None ) –

    The name of the tool parser.

  • reasoning_parser_name

    (str | None, default: None ) –

    The name of the reasoning parser.

  • enable_auto_tools

    (bool, default: False ) –

    Whether auto tool choice is enabled.

  • model_name

    (str | None, default: None ) –

    The model name for parser-specific warnings.

  • is_harmony

    (bool, default: False ) –

    Whether the selected model uses the Harmony format. If True, HarmonyParser is always returned.

  • tool_strict_level

    (str | None, default: None ) –

    Server-side floor for tool-call structural tags (--tool-strict-level), or None for the tool parser's default level.

  • tokenizer

    (TokenizerLike | None, default: None ) –

    Tokenizer the composed parser is validated against at startup (see validate_parser_tokenizer), including its response_template metadata when a response-template parser is selected. None skips the check (e.g. skip_tokenizer_init).

Returns:

  • type[Parser] | None –

    A Parser class, or None if neither parser is specified.

get_reasoning_parser(reasoning_parser_name) classmethod

Get the reasoning parser based on the name.

get_tool_parser(tool_parser_name=None, enable_auto_tools=False, model_name=None) classmethod

Get the tool parser based on the name.

validate_parser_tokenizer(parser_cls, tokenizer, tool_parser_name=None, reasoning_parser_name=None, model_name=None) classmethod

Fail at startup if the tokenizer lacks what the parsers need.