Structured outputs
Get JSON that matches your schema,or a clear error.
Attach a JSON Schema to a workflow. ModelRiver asks the model for that shape, checks every answer against the schema, and tries a backup model if the answer is empty or doesn’t match.
How structured outputs work
You describe the shape once. Every answer is checked before your app sees it.
- 01
Describe the shape
Write a JSON Schema in the console, or import one with a workflow. Add sample data so test mode can return it.
- 02
Ask for it natively
On providers that support schemas, like OpenAI, Google and Mistral, the schema is sent with the request so the model follows it.
- 03
Check every answer
Each answer is checked against your schema. ModelRiver never edits or fills in an answer.
- 04
Fall back if it fails
An empty or mismatched answer counts as a failure, so the next backup model is tried.
The numbers
- 2020-12JSON Schema draft, a safe subset of it
- 256 KBLargest schema you can attach
- 32 levelsDeepest nesting a schema can have
- 10+Providers that receive your schema natively
What it looks like
Your schema in, matching data out, in the same response shape on every provider.
{
"type": "object",
"properties": {
"category": { "type": "string", "enum": ["billing", "bug", "other"] },
"priority": { "type": "integer", "minimum": 1, "maximum": 3 },
"summary": { "type": "string" }
},
"required": ["category", "priority", "summary"]
}{
"data": {
"category": "billing",
"priority": 2,
"summary": "Customer was charged twice for one order."
},
"meta": { "structured_output": true, … }
}Never patched up
If an answer doesn’t fit, ModelRiver doesn’t fix it for you. It tries a backup model or returns an error.
One schema, any provider
The same schema works across providers, so you can switch models without changing your parsing code.
Ready for test mode
The schema’s sample data is what test mode returns, so you can build your app before connecting a provider.
Good to know
Some keywords aren’t allowed
pattern, patternProperties and $dynamicRef are rejected. format is accepted but not checked.
No streaming
Structured answers are checked when they’re complete, so they can’t be streamed.
Checked, even without native support
Cohere, Amazon Bedrock and custom providers don’t receive the schema, and Anthropic gets it only on supported models. Their answers are still checked.
No retry on the same model
A mismatched answer moves the request to the next backup model rather than asking the same model again.
Frequently asked questions
What happens if the model returns invalid JSON?
The answer counts as a failure (invalid_structured_output, or empty_structured_output when nothing came back), and the next backup model is tried. If none is left, you get the error.
Which providers get my schema natively?
OpenAI, Azure OpenAI, Google, Mistral, Groq, DeepSeek, xAI, Qwen, Kimi and MiniMax, plus Anthropic on supported models. Other providers’ answers are checked the same way.
Which JSON Schema features can I use?
A safe subset of draft 2020-12, up to 256 KB and 32 levels deep. pattern, patternProperties and $dynamicRef are rejected, and format isn’t checked.
Can I stream structured outputs?
No. The answer is checked once it is complete, so it comes back in one piece.
Can I try it without a provider?
Yes. Turn on test mode and the workflow returns the sample data you set on the schema.
Works well with
Get typed data from your first prompt
Start on the free plan, attach a schema to a workflow, and every answer is checked.