# Structured Outputs

Source: https://staging-docs.aiand.com/capabilities/structured-outputs/

Structured outputs make the model emit JSON that conforms to a schema you supply — no parsing failures, no missing fields.

## JSON mode

The simplest form. Set `response_format` to `json_object`:

```json
{
  "model": "...",
  "messages": [...],
  "response_format": { "type": "json_object" }
}
```

The model is guaranteed to return syntactically valid JSON. Shape is up to your prompt.

## Strict JSON Schema

For guaranteed shape, pass a schema:

```python
response = client.chat.completions.create(
    model="...",
    messages=[{"role": "user", "content": "Extract: Jane Doe, jane@example.com"}],
    response_format={
        "type": "json_schema",
        "json_schema": {
            "name": "contact",
            "strict": True,
            "schema": {
                "type": "object",
                "properties": {
                    "name": {"type": "string"},
                    "email": {"type": "string"},
                },
                "required": ["name", "email"],
                "additionalProperties": False,
            },
        },
    },
)
```

When `strict: true`, output is constrained to match the schema exactly — no extra fields, no missing required keys.

## With the OpenAI Python SDK

The SDK can derive the schema from a Pydantic model via `client.chat.completions.parse()` (or `responses.parse()`).

<Aside type="note">
  `response_format` is honored at the model layer — support depends on the model, not a dedicated capability flag. Models with `tool_calling` generally also handle strict JSON schemas. See the [Catalog](/models/catalog/).
</Aside>
