> ## Documentation Index
> Fetch the complete documentation index at: https://docs.compute.prentis.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Structured outputs

> Asking for JSON, and what happens when the model behind your call cannot promise it.

`response_format` asks for the answer in a shape your code can parse instead of prose.

## The three forms

```json theme={null}
{ "response_format": { "type": "text" } }
{ "response_format": { "type": "json_object" } }
{ "response_format": { "type": "json_schema", "json_schema": { "name": "…", "schema": { … } } } }
```

`json_object` promises valid JSON and nothing about its shape. `json_schema` promises the
shape as well, which is almost always what you actually wanted.

<Note>
  With `json_object`, say in the prompt what fields you expect. The constraint is only
  "this parses"; a model given no other instruction will happily return valid JSON with
  different keys every time.
</Note>

## Rejected rather than ignored

If no provider that can serve your model supports the format you asked for, the call
returns `MODEL_CAPABILITY_UNSUPPORTED` — it is not answered as free text.

The reasoning is the same as for [tool calling](/tool-calling): a response that quietly
ignored your schema would parse as prose, pass a shallow test, and fail somewhere far from
here. Prefer the error.

## Tools or schema?

Both get structure out of a model, and they answer different questions:

|                                   | Use                                                                                                  |
| --------------------------------- | ---------------------------------------------------------------------------------------------------- |
| **Structured output**             | You want *data back* — an extraction, a classification, a form filled in.                            |
| **[Tool calling](/tool-calling)** | You want an *action taken* — the model decides to look something up or do something, and you run it. |

Asking for a schema is cheaper and simpler when you do not need the model to choose.

## Next

<CardGroup cols={2}>
  <Card title="Tool calling" icon="wrench" href="/tool-calling">
    When the model should act rather than answer.
  </Card>

  <Card title="Errors" icon="triangle-exclamation" href="/errors">
    `MODEL_CAPABILITY_UNSUPPORTED` in context.
  </Card>
</CardGroup>
