Structured Outputs

Reliable JSON contracts for downstream services and automations

TheRouter.ai supports two output modes: `json_object` for simple object-only formatting and `json_schema` for strict field-level contracts. Prefer `json_schema` for production pipelines where deterministic parsing matters.

json_object
{
  "model": "openai/gpt-4.1",
  "messages": [{ "role": "user", "content": "Return order summary JSON." }],
  "response_format": { "type": "json_object" }
}

Model support

Structured outputs are supported by many OpenAI, Anthropic, Gemini, and select open-source models. Filter model capability metadata for `supported_parameters=structured_outputs` when choosing fallback chains.

Pair with response healing
For non-streaming JSON flows, enable the response-healing plugin to reduce parser failures from minor formatting defects.