Structured outputs

Features

Structured outputs

When you need output you can parse, constrain the model to a JSON Schema. Neural Router routes only to models that support the schema and validates the response before returning it.

JSON object mode

For free-form JSON, set response_format: { "type": "json_object" }. The model returns valid JSON without a fixed shape.

Schema mode

For a guaranteed shape, pass a json_schema with strict: true:

request
{
  "model": "auto",
  "messages": [
    { "role": "user", "content": "Extract the invoice fields." }
  ],
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "invoice",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "number": { "type": "string" },
          "total_usd": { "type": "number" },
          "due_date": { "type": "string" }
        },
        "required": ["number", "total_usd", "due_date"],
        "additionalProperties": false
      }
    }
  }
}

With strict enabled, the response is guaranteed to conform — fields and types match, and no extra keys are added.

Routing & support

Not every model supports schema mode. When you set a strict schema, the router restricts candidates to models that do, so "auto" stays safe. If you pin a model that doesn't support it, the request returns a clear error rather than unstructured text.