vLLM structured outputs: choice, regex, json and grammar
Answer: vLLM supports the generation of structured outputs using xgrammar or guidance as backends. A request can use extra_body={"structured_outputs": {"choice": ["positive", "negative"]}}. A JSON schema request uses response_format with "type": "json_schema".
Migration
Older guided_* fields are replaced by structured_outputs: guided_json -> {"structured_outputs": {"json": ...}} or StructuredOutputsParams(json=...), and so on for guided_regex, guided_choice and guided_grammar.
Details
- The supported regex syntax depends on the structured output backend:
xgrammar,guidanceandoutlinesuse Rust-style regex. - You can use reasoning with any provided structured outputs feature.
Outlines
Outlines guarantees structured outputs during generation rather than fixing bad outputs after generation. You pass an output type such as Literal["Yes", "No"], int or a Pydantic model.
See also
- ao-tools-vllm-tool-parsers
- ao-structured-ollama-and-llamacpp-grammars
- ao-structured-across-providers
- ao-structured-claude-json-via-tools
Claims
- id: C1 claim: vLLM uses xgrammar or guidance backends. source: S1 evidence: "using xgrammar or [guidance]"
- id: C2 claim: choice is passed in structured_outputs. source: S1 evidence: "extra_body={\"structured_outputs\": {\"choice\": [\"positive\", \"negative\"]}}"
- id: C3 claim: Outlines constrains during generation. source: S2 evidence: "Outlines guarantees structured outputs during generation"
Sources
- [S1] Structured outputs (vLLM docs). vllm-project/vllm (GitHub). https://github.com/vllm-project/vllm/blob/main/docs/features/structured_outputs.md . License: Apache-2.0. Accessed 2026-11-16.
- [S2] Outlines README. dottxt-ai/outlines (GitHub). https://github.com/dottxt-ai/outlines/blob/main/README.md . License: Apache-2.0. Accessed 2026-11-16.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: vllm-project/vllm (GitHub), Structured outputs (vLLM docs), Apache-2.0 (https://raw.githubusercontent.com/vllm-project/vllm/main/LICENSE); dottxt-ai/outlines (GitHub), Outlines README, Apache-2.0 (https://raw.githubusercontent.com/dottxt-ai/outlines/main/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: vllm-project/vllm (GitHub), Structured outputs (vLLM docs), Apache-2.0 (https://raw.githubusercontent.com/vllm-project/vllm/main/LICENSE); dottxt-ai/outlines (GitHub), Outlines README, Apache-2.0 (https://raw.githubusercontent.com/dottxt-ai/outlines/main/LICENSE).
Cite this
iinventedlight. 2026. "vLLM structured outputs: choice, regex, json and grammar." iinventedlight Library, iil:note:gne24ggp, version of 2026-11-16. https://iinventedlight.com/library/notes/ao-structured-vllm-structured-outputs/. License: CC-BY-4.0.
@misc{iil_note_gne24ggp,
author = {{iinventedlight}},
title = {{vLLM structured outputs: choice, regex, json and grammar}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-16},
url = {https://iinventedlight.com/library/notes/ao-structured-vllm-structured-outputs/},
note = {Permanent ID iil:note:gne24ggp. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/ao-structured-vllm-structured-outputs.md.