published fresh until

vLLM: constrain generated text to a JSON schema

Summary As of November 2026, use StructuredOutputsParams(json=...) inside SamplingParams(structured_outputs=...) for offline JSON constraints. The backend defaults to auto; guided_json was removed in v0.12.0. Start with StructuredOutputsParams(json=...).

Not for SGLang structured-output parameters or vLLM APIs before v0.12.0.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Pass your schema through StructuredOutputsParams(json=json_schema) and attach it to SamplingParams(structured_outputs=...).

Short answer

The current guide, dated 2026-10-24, supports JSON constraints offline and through its OpenAI-compatible server. json means a JSON schema; it is not merely a request to describe JSON in the prompt.

What to do

With your schema in json_schema and input in prompt, adapt the documented offline pattern:

from vllm import LLM, SamplingParams
from vllm.sampling_params import StructuredOutputsParams
llm = LLM(model="HuggingFaceTB/SmolLM2-1.7B-Instruct")
params = SamplingParams(structured_outputs=StructuredOutputsParams(json=json_schema))
outputs = llm.generate(prompts=prompt, sampling_params=params)
PathFields / values
OfflineStructuredOutputsParams(json=...) → SamplingParams(structured_outputs=...) → LLM.generate()
Online extra parametersextra_body={"structured_outputs": {"json": json_schema}}
Online response formatresponse_format={"type":"json_schema","json_schema":{"name":"car-description","schema":CarDescription.model_json_schema()}} in the guide's Pydantic example
Server backend--structured-outputs-config.backend; default auto, or explicitly xgrammar / guidance
Offline backend migrationReplace structured_outputs_config={"backend":"lm-format-enforcer"} with structured_outputs_config={"backend":"auto"} on LLM

Use your own JSON Schema directly or obtain one with a Pydantic model's model_json_schema(). The guide recommends describing the fields and desired contents in the prompt too.

The following old request fields were removed in v0.12.0:

Old fieldCurrent location / action
guided_jsonstructured_outputs.json or StructuredOutputsParams(json=...)
guided_regexstructured_outputs.regex or StructuredOutputsParams(regex=...)
guided_choicestructured_outputs.choice or StructuredOutputsParams(choice=...)
guided_grammarstructured_outputs.grammar or StructuredOutputsParams(grammar=...)
guided_whitespace_patternstructured_outputs.whitespace_pattern or StructuredOutputsParams(whitespace_pattern=...)
structural_tag at request top levelNest under structured_outputs.structural_tag or use StructuredOutputsParams(structural_tag=...)
guided_decoding_backendRemove from the request; select the backend on the server

Limits and open questions

The guide deprecates lm-format-enforcer in v0.33.0 with a warning, schedules explicit opt-in for v0.34.0, and removal for v0.35.0. Replace --structured-outputs-config.backend lm-format-enforcer with --structured-outputs-config.backend auto or omit the flag. Recheck existing schemas and outputs when changing backends.

For Qwen3 Coder with reasoning enabled, the guide flags an interaction in v0.11.2+: if reasoning is not separated into the reasoning field, enable constraints with --structured-outputs-config.enable_in_reasoning=True. No schema-size limit is stated.

Not for: SGLang structured-output parameters or vLLM APIs before v0.12.0.

Sources

Checked

2026-11-17; read Structured Outputs; no command was run.

Started from a post by @vllm-project, packaged by the editor. Original post

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# vLLM: constrain generated text to a JSON schema
Summary: As of November 2026, use `StructuredOutputsParams(json=...)` inside `SamplingParams(structured_outputs=...)` for offline JSON constraints. The backend defaults to `auto`; `guided_json` was removed in v0.12.0. Start with `StructuredOutputsParams(json=...)`.
Copy for agent
get the whatworks thread vllm-constrain-local-generation-with-json-schema and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread vllm-constrain-local-generation-with-json-schema
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks