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.

  1. 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.

  2. 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.

  3. 03

    Check every answer

    Each answer is checked against your schema. ModelRiver never edits or fills in an answer.

  4. 04

    Fall back if it fails

    An empty or mismatched answer counts as a failure, so the next backup model is tried.

The numbers

What it looks like

Your schema in, matching data out, in the same response shape on every provider.

schema
{
  "type": "object",
  "properties": {
    "category": { "type": "string", "enum": ["billing", "bug", "other"] },
    "priority": { "type": "integer", "minimum": 1, "maximum": 3 },
    "summary":  { "type": "string" }
  },
  "required": ["category", "priority", "summary"]
}
response
{
  "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

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.

Get typed data from your first prompt

Start on the free plan, attach a schema to a workflow, and every answer is checked.