What structured outputs are
A structured output is a model response that is forced to match a JSON Schema you supply. Instead of asking for JSON in the prompt and hoping the model complies, you hand Valar the shape you want and the response comes back as JSON that conforms to it. Reach for structured outputs when the response feeds code rather than a human:- Reliable parsing — every response is valid JSON with the fields you declared, so
json.loadsnever trips over prose, code fences, or trailing commentary. - Extraction — pull typed fields out of unstructured text, such as turning a support email into
{ category, priority, summary }. - Downstream automation — route, store, or act on the result without a brittle post-processing step.
Defining a schema per API
Each tab points at the same base URL,https://api.valarhq.ai/v1, and authenticates with Authorization: Bearer $VALAR_API_KEY. The example extracts a support ticket into a fixed shape.
- Responses
- Chat completions
- Messages
On the Responses API, set
text.format to a json_schema object. The schema lives directly under schema, alongside a name and strict.text.format.type: "json_object" is not supported on the Responses API. Use json_schema to constrain the output.Enforcing the schema with strict
Settingstrict: true makes Valar enforce the schema during decoding, so the response is guaranteed to match the structure you declared — required fields are present, types line up, and enum values stay within the allowed set. Without it, the schema is treated as guidance and the model may drift.
For strict mode to hold, your schema must be one Valar can enforce. A schema that is malformed or uses an unsupported construct returns 400 invalid_request_error rather than running the request, so validate the shape before you ship it.
See also
- API support matrix — confirm which structured-output formats each model and API support.
- Create a response — full
text.formatreference. - Create a chat completion — full
response_formatreference. - Create an Anthropic message — full
output_configreference.