---
title: "Structured output (JSON mode)"
canonical: "https://router.xark.io/glossary/structured-output"
description: "Structured output is a request setting — response_format on an OpenAI-compatible API — that constrains a model to answer with valid JSON."
section: "glossary"
updated: "2026-09-02"
source: "https://router.xark.io/glossary/structured-output.md"
---

# Structured output (JSON mode)

*Also known as: JSON mode, json_object, json_schema, response_format, constrained decoding.*

Structured output is a request setting — response_format on an OpenAI-compatible API — that constrains a model to answer with valid JSON, either free-form or conforming to a schema you supply, rather than with prose your code then has to parse out.

There are two levels and the difference matters. json_object asks only for syntactically valid JSON of any shape, so your parser succeeds and your field access still fails. json_schema binds the response to a schema you provide, which is the version that removes a whole class of bug rather than moving it one line later.

Where it is implemented as constrained decoding, the guarantee is structural: at each step the sampler is restricted to tokens that keep the output valid against the grammar, so malformed JSON becomes impossible rather than unlikely. Where it is implemented as an instruction in the prompt, it is a request the model usually honours, which is a different thing entirely.

The schema is input tokens, on every request, exactly like a tool definition. A verbose schema with long descriptions on every field is paid for on every extraction, so a schema is worth editing for length the same way a system prompt is.

A conforming answer is not a correct one. Constrained decoding guarantees shape, never semantics — the fields will be present and typed, and the values in them can still be invented. Validation of the content stays your job.

## What it costs you

The real price of structured output is measured in retries, and a retry is billed in full. A response that fails to parse has already consumed its input and its output before it is discarded, so the cost of one usable record is the cost of every attempt it took to get one. That makes an enforced schema — a fixed, known number of input tokens per request — reliably cheaper than a requested one, whose cost is a variable number of whole discarded generations. Pairing it with a low temperature is the other half of the same saving.

## Worked example

Extracting one record from a 4,000-token document on DeepSeek V4 Pro — input plus a 300-token JSON reply — costs $0.00129. Across 100,000 documents that is $128.50, and a 5% malformed rate adds $6.43 for records you parse and throw away.

## Related terms

- [Temperature](https://router.xark.io/glossary/temperature.md) — Temperature is a sampling parameter that controls how much randomness a model uses when choosing each next token: at 0 it takes the most likely token every time, and higher values raise the chance of less likely tokens being picked.
- [Tool calling (function calling)](https://router.xark.io/glossary/tool-calling.md) — Tool calling is the mechanism by which a model, given a set of function schemas alongside the prompt, replies with a structured request to invoke one of them instead of with prose — your own code runs the function and sends the result back as a further message for the model to continue from.
- [Token](https://router.xark.io/glossary/token.md) — A token is the unit of text a language model reads and writes — roughly four characters of English, or about three quarters of a word — and it is also the unit that every language model API bills by.

## See also

- [Structured data extraction: what it costs](https://router.xark.io/use-cases/structured-data-extraction)
- [API documentation](https://router.xark.io/docs)