> ## Documentation Index
> Fetch the complete documentation index at: https://learn.workflow.dog/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Structured AI Output

> Turn unstructured text or files into predictable fields for later actions.

AI responses are easiest to automate when the model returns a small,
schema-defined object instead of prose.

```text theme={null}
message, document, or image
  → OpenAI Chat with Structured Output
  → typed object properties
  → conditions, storage, and service actions
```

## Design the schema around decisions

Start from what later actions need. For an intake workflow, that might be:

```json theme={null}
{
  "type": "object",
  "properties": {
    "summary": {
      "type": "string",
      "description": "One sentence describing the request"
    },
    "category": {
      "type": "string",
      "enum": ["question", "bug", "billing"]
    },
    "priority": {
      "type": "string",
      "enum": ["low", "normal", "high"]
    },
    "customerEmail": {
      "type": ["string", "null"]
    }
  },
  "required": ["summary", "category", "priority", "customerEmail"],
  "additionalProperties": false
}
```

Use enums for values that control a branch. Use nullable fields when the source
may legitimately omit a value. Avoid collecting fields no downstream action
uses.

## Configure Chat

1. Add [OpenAI Chat](/reference/actions/openai/chat).
2. Connect the source text to **Prompt**.
3. Add images or PDFs under **Files** when the model must inspect them.
4. Turn on **Structured Output**.
5. Paste the JSON schema.
6. Expose the detected properties you need as outputs.

<Note>
  Enabling Structured Output replaces the normal text **Response** with
  **Structured Response**. Review existing connections when changing this
  setting.
</Note>

## Route and validate

Connect enum outputs to conditions or case selection. Connect extracted text
only to actions that accept missing or nullable values when the schema permits
them.

For high-impact work, add deterministic validation after the model:

* check that an email address is valid,
* confirm a number is in the allowed range,
* require human review before sending or deleting,
* reject categories outside the schema,
* preserve the original source for audit and correction.

## Handle failure deliberately

Enable the Chat action's **Succeeded?** and **Error** meta outputs. Use them to
send failures to a recovery branch without treating invented fallback data as
real extraction.

<Warning>
  A valid schema controls the response shape, not the truth of its contents.
  Treat model-produced values as untrusted whenever they can spend money, modify
  access, send external messages, or make irreversible changes.
</Warning>

Use [Files and structured data](/building/files-and-structured-data) for
downstream object and file handling, and
[Troubleshoot workflow runs](/guides/troubleshooting-runs) when a model or
provider request fails.
