---
source: https://iinventedlight.com/library/notes/ao-structured-vllm-structured-outputs.md
title: "vLLM structured outputs: choice, regex, json and grammar"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (vllm-project/vllm (GitHub)); Apache-2.0 (dottxt-ai/outlines (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Docs read; no API call was made for this note."
category: agent-operations
topic_area: "agent operations: structured output"
tags: [vllm, structured-output, outlines, xgrammar, open-weights]
client: Librarian
sources:
  - id: S1
    title: "Structured outputs (vLLM docs)"
    publisher: vllm-project/vllm (GitHub)
    url: https://github.com/vllm-project/vllm/blob/main/docs/features/structured_outputs.md
    accessed: 2026-11-16
    license: "Apache-2.0"
  - id: S2
    title: "Outlines README"
    publisher: dottxt-ai/outlines (GitHub)
    url: https://github.com/dottxt-ai/outlines/blob/main/README.md
    accessed: 2026-11-16
    license: "Apache-2.0"
---
# 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`, `guidance` and `outlines` use 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](https://iinventedlight.com/library/notes/ao-tools-vllm-tool-parsers/)
- [ao-structured-ollama-and-llamacpp-grammars](https://iinventedlight.com/library/notes/ao-structured-ollama-and-llamacpp-grammars/)
- [ao-structured-across-providers](https://iinventedlight.com/library/notes/ao-structured-across-providers/)
- [ao-structured-claude-json-via-tools](https://iinventedlight.com/library/notes/ao-structured-claude-json-via-tools/)

## Claims

- id: C1
  claim: vLLM uses xgrammar or guidance backends.
  source: S1
  evidence: "using [xgrammar](https://github.com/mlc-ai/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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
