LIVE · Thursday 3 December

Structured Outputs on Open Models: Which Providers Enforce json_schema in Strict Mode, and on Which Models

Nearly every open-model host accepts a JSON Schema now. Far fewer enforce it, the supported-models lists are short, and the schema keywords each one rejects differ enough to decide the choice.

By Surya8 min read

Groq, Cerebras, Amazon Bedrock, Fireworks, DeepInfra and Baseten all document JSON Schema structured outputs on open models that are enforced during generation, so the output matches the schema rather than merely resembling it. Together AI, SambaNova and Cloudflare Workers AI accept response_format with json_schema too, but their docs either say nothing about strict enforcement or, in Cloudflare's case, say outright that the schema cannot be guaranteed. Support is per model, not per provider: Groq's strict mode covers four open models, Cerebras's four, and the schema keywords each will compile differ enough that a schema built for one can be rejected by another.

"Supports structured outputs" means three different things

The phrase covers three mechanisms, and provider pages use the same words for all of them.

The strongest is strict mode with constrained decoding. The provider turns your JSON Schema into a grammar and, at each step of generation, only lets the model choose tokens that keep the output valid against it. The output cannot drift from the schema, because tokens that would break it are never available. Groq and Cerebras both tie this to a flag: strict: true inside the json_schema object. Bedrock describes the same idea as compiling a grammar from your schema.

The middle tier is best-effort JSON Schema. The provider takes the schema, the model is steered towards it, and the response is checked afterwards. Groq is explicit about what that means: in best-effort mode, which is its default when strict is omitted, a response that misses the schema comes back as an HTTP 400 with the message "Generated JSON does not match the expected schema. Please adjust your prompt." Your code has to catch it and retry.

The weakest is JSON mode, response_format: {"type": "json_object"}. It guarantees syntactically valid JSON and nothing about its shape. Groq's docs say JSON Object Mode output "may not match your schema," and both Groq and Together tell you to describe the JSON you want in the prompt as well.

The request shape is the same OpenAI-compatible one almost everywhere:

{
  "model": "openai/gpt-oss-120b",
  "messages": [{"role": "user", "content": "Extract the invoice fields from: ..."}],
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "invoice",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "vendor": {"type": "string"},
          "total": {"type": "number"},
          "due_date": {"type": ["string", "null"]}
        },
        "required": ["vendor", "total", "due_date"],
        "additionalProperties": false
      }
    }
  }
}

Two details in that schema are not optional on strict providers. Groq's docs say every property must appear in required ("Optional fields are not supported") and every object must set additionalProperties: false; an optional field is written as a union with null, as due_date is above. Cerebras and Bedrock impose the same additionalProperties: false rule. Bedrock returns a 400 ValidationException if any object leaves it out.

Who enforces the schema, on which open models

The providers that name their strict-mode models are the easiest to plan around.

Groq's structured-outputs page lists strict mode on openai/gpt-oss-20b, openai/gpt-oss-120b, qwen/qwen3.8-27b and meta-models/muse-spark-open. Best-effort mode adds openai/gpt-oss-safeguard-20b. Every other Groq model gets JSON mode only.

Cerebras lists strict mode on qwen-3.8-27b (shared and dedicated), gpt-oss-120b (shared), and kimi-k2.7-code and gemma-4-31b on dedicated inference only. Its page recommends strict: true over JSON mode wherever it is available.

Bedrock uses the response_format field for open-weight models and outputConfig.textFormat on its Converse API. It does not list covered models on the structured-output page; it sends you to each model's card.

Fireworks says a schema passed as json_schema is "enforced during generation," and it offers a separate grammar mode that takes your own BNF grammar. Its page does not list models. DeepInfra says its json_schema mode "Enforces a strict output schema" and that "The model is constrained to produce only values that match your schema," on "many of our models," found through its model search rather than a list. Baseten supports structured outputs on its Model APIs with one named exception, "Muse Spark Open, which accepts json_schema but doesn't enforce the schema," and on dedicated deployments running vLLM, SGLang or its own engines, except Engine-Builder-LLM with Lookahead speculative decoding and some BIS-LLM configurations such as the overlap scheduler.

The others accept a schema without promising enforcement. Together's JSON mode page documents json_schema and a regex format and says "Every model that supports JSON mode also supports regex mode," but does not mention strict mode or constrained decoding; its serverless models table marks GPT-OSS 120B, Kimi K3, Qwen3.5 9B, GLM-5.3 and others as supporting structured outputs. SambaNova's Responses API uses text.format with json_schema or json_object and does not mention a strict parameter. Cloudflare's Workers AI page, last updated September 14, 2026, lists six older models (three Llama 3.x variants, Hermes 2 Pro, a DeepSeek coder and a DeepSeek R1 distill) and says "Workers AI can't guarantee that the model responds according to the requested JSON Schema."

Hugging Face Inference Providers passes json_schema with strict through to whichever provider serves the request, which makes the provider choice the deciding factor. Its own guide recommends "selecting a specific provider and model" for structured outputs rather than automatic routing.

The schema subset is where projects break

Constrained decoding only works on the parts of JSON Schema a provider can compile into a grammar, and each compiles a different subset. This is the detail most likely to decide which provider fits an existing schema.

Schema feature Cerebras strict Bedrock Fireworks
Recursive schemas No No Yes
External $ref No No No
allOf No Yes, with limits Yes
pattern No Yes, without lookaround Yes, uncompilable regexes ignored
minItems / maxItems No minItems 0 or 1 only Yes

Groq's page is shorter on this. It says only that it supports "a JSON Schema subset with specific constraints for performance and reliability." It lists the supported types (string, number, boolean, integer, object, array, enum and anyOf) and shows $defs with $ref, including a recursive reference, but it does not mention a list of unsupported keywords or size limits.

Of the providers here, Cerebras has the tightest rules and is the most explicit about them. Its strict mode caps the counted schema text (property names, definition names and enum strings, not descriptions) at 5,000 characters and nesting at 10 levels, and rejects recursion, external $ref, oneOf, allOf, not, pattern, format, minItems and maxItems. It adds: "Treat unlisted JSON Schema keywords as unsupported."

Bedrock supports pattern and string formats such as date-time, email and uuid, but not minimum, maximum, minLength, maxLength or recursion, and allows at most 12 optional properties and 16 union-typed ones. It also has a cost the others do not document: the first request with a new schema compiles a grammar, which "can take up to approximately 90 seconds." Compiled grammars are cached for 24 hours, and Bedrock tells you to set a client read timeout of at least 120 seconds.

Fireworks accepts the widest range of the three, including oneOf, recursive references and length and size constraints, with one trap: a pattern regex it cannot compile, such as one using lookahead, is silently dropped and the field becomes an unconstrained string, without failing the request.

What still breaks when strict mode is on

Three things go wrong even with enforcement.

Truncation is the first. Constrained decoding controls which tokens are allowed, not how many. Bedrock's docs say that if a response reaches the token limit "the model stops with a max_tokens stop reason and returns incomplete JSON, even when structured outputs is enabled." Fireworks, DeepInfra and Baseten say the same in their own words; Baseten's client raises LengthFinishReasonError. Check finish_reason before you parse.

Feature conflicts are the second. Groq says streaming and tool use "are not currently supported with Structured Outputs." Cerebras warns against combining tools and response_format unless a model's docs say it works, and suggests calling tools first and formatting in a second request. Cloudflare's JSON mode does not support streaming. Fireworks says that "Using response_format with json_schema disables reasoning output," which matters for reasoning models such as gpt-oss. Bedrock is the exception here: its structured outputs work on its streaming APIs as well as on batch and cross-region inference.

The guarantee itself is the third. Groq's docs describe strict mode as one that "Never errors or produces invalid JSON." A Hugging Face forum report posted on August 21, 2026 describes openai/gpt-oss-20b routed to Groq in strict mode returning HTTP 400 errors labelled json_validate_failed, with one test case succeeding in none of five calls. A reply three days later could not reproduce it in 12 calls, and the thread shows no response from Groq. How often strict mode fails on any provider has not been measured independently.

Custom and routed models

Most of this assumes a catalogue model. Teams serving their own fine-tuned open model have fewer documented options: Baseten covers dedicated deployments on vLLM, SGLang and its engines with the exceptions above, and Bedrock and Fireworks enforce schemas on the models they serve without listing which. Parsec, a small language model lab, serves models post-trained on a customer's traffic and routes per turn, sending requests its model is not confident about to a closed frontier model; its inference page does not mention structured outputs or json_schema, and its only code sample uses the Anthropic SDK. Routing of any kind raises the same issue Hugging Face flags: if the model behind a request can change, so can the schema support.

Bottom line

If you need the schema enforced on a named open model, start with Groq or Cerebras, which list their strict-mode models, and check your schema against their keyword rules first: Groq for recursion and anyOf, Cerebras only if your schema is flat and under its size limits. If your schema uses oneOf, recursion or regex patterns, Fireworks compiles the widest subset of the providers compared here, as long as you test that each pattern is actually enforced. On AWS, Bedrock adds streaming and batch support at the cost of a first-request compile of up to about 90 seconds. On Together, SambaNova or Cloudflare, treat the schema as best-effort and validate every response. On any provider, check finish_reason, keep tools and streaming in separate requests where the docs say so, and run one test call with your real schema before you depend on it.

Sources

More in Products

All Products →