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

# Structured Outputs

> Configure named outputs for an AI step and link them to later Flow steps.

Structured outputs are named values produced by an AI step. Configure them in the step's **Parameters** sidebar, then use them as linked inputs in later steps.

<h2 id="understanding-structured-outputs">
  Understanding structured outputs
</h2>

Each output variable has a name, a **Data type** selector, a **Make array** control, and a required description. Add as many outputs as the AI step needs.

**Why use structured outputs:**

* Keep related results as separate, named values.
* Describe the value and data type the AI step should return.
* Link a selected output directly to a downstream input.
* Use **Make array** when an output needs multiple values of the same type.

<h2 id="configure-output-variables">
  Configure output variables
</h2>

Output variables are defined in an AI step's **Parameters** tab.

<Steps>
  <Step title="Open the AI step parameters">
    Open the agent's **Flow**, select the AI step that produces the result, and keep **Parameters** selected in the sidebar.
  </Step>

  <Step title="Add Output Variable">
    In **Output variables**, select **Add new**.
  </Step>

  <Step title="Configure the output">
    Enter the output name, select a **Data type**, optionally enable **Make array**, and provide the required description.
  </Step>

  <Step title="Add more outputs when needed">
    Select **Add new** again to define another value for the same node.
  </Step>
</Steps>

<h3 id="multiple-output-variables">
  Multiple output variables
</h3>

Use one output variable for each value a later step needs. For example, an AI step can return a summary, search terms, and a title as separate outputs.

<Frame>
  <img src="https://mintcdn.com/beamai/5sjMFBB-gamSkrEM/02-building-agents/agent-configuration/structured-outputs/ai-step-output-variables-current.png?fit=max&auto=format&n=5sjMFBB-gamSkrEM&q=85&s=638d57b7390cd01a7ae0bdc0acb77e95" alt="An AI step's Output variables section with separate bug_summary, search_keywords, and title outputs, each with a data type and description." width="520" height="680" data-path="02-building-agents/agent-configuration/structured-outputs/ai-step-output-variables-current.png" />
</Frame>

<h2 id="data-types">
  Data types
</h2>

**String:** Text data of any length. Use for names, descriptions, categories.

**Number:** Numeric values including integers and decimals. Use for IDs, quantities, amounts, scores.

**Boolean:** True or false values. Use for flags, status indicators, yes/no determinations.

**Object:** Nested data for complex, grouped values. Select **Object** in **Data type**, then select **Define structure** to add the properties the object should contain.

<Frame>
  <img src="https://mintcdn.com/beamai/5sjMFBB-gamSkrEM/02-building-agents/agent-configuration/structured-outputs/output-data-type-menu-current.png?fit=max&auto=format&n=5sjMFBB-gamSkrEM&q=85&s=5117a863e95964639b9b615d3682cb36" alt="The output variable Data type menu with Object available as a type." width="520" height="500" data-path="02-building-agents/agent-configuration/structured-outputs/output-data-type-menu-current.png" />
</Frame>

**Enum:** Constrained to specific allowed values. Use for fixed categories, status values.

**Example:**

```text theme={null}
Variable: priority_level
Type: Enum
Allowed values: HIGH, MEDIUM, LOW
```

<h2 id="key-principles">
  Key principles
</h2>

<h3 id="sequential-processing">
  Order related values clearly
</h3>

For a complex extraction, group related outputs together and use names that make their relationship clear.

**Example:**

```json theme={null}
{
  "request_summary": "<String>",
  "urgency_analysis": "<String>",
  "is_urgent": "<Boolean>",
  "category_reasoning": "<String>",
  "category": "<String>",
  "priority": "<Number>"
}
```

<h3 id="reason-first">
  Keep rationale when it is useful
</h3>

If a later step or reviewer needs the rationale behind a classification, add a separate reasoning output alongside the final value.

**Poor Design:**

```json theme={null}
{
  "category": "<String // The email category>"
}
```

**Better Design:**

```json theme={null}
{
  "category_reasoning": "<String // Analysis of why this category fits>",
  "category": "<String // The email category>"
}
```

This keeps the classification and its explanation as distinct values that later steps can use independently.

<h3 id="descriptions-are-directives">
  Descriptions are directives
</h3>

The description is a direct instruction to the AI. Be explicit.

**Examples:**

**Simple extraction:**

```text theme={null}
"Extract the 7-digit customer ID, numbers only"
```

**Conditional logic:**

```text theme={null}
"Extract language as ISO-639-1 code. If unknown, return 'N/A'"
```

**Constrained values:**

```text theme={null}
"Classify as one of: EXACT_MATCH, SIMILAR_MATCH, MISMATCH, or N/A"
```

<h3 id="unique-naming">
  Unique naming
</h3>

Give each output a clear, unique name so it is easy to choose in a later step.

**Good naming:**

* `email_classifier_category`
* `invoice_extractor_total`
* `customer_analysis_id`

**Avoid:**

* `result`, `output`, `data` (too generic, likely duplicated)

<h2 id="linking-outputs-to-downstream-nodes">
  Linking outputs to downstream nodes
</h2>

To use an output in a later step, select that input's fill-method menu, choose **Linked fill**, then select the output variable.

<Frame>
  <img src="https://mintcdn.com/beamai/5sjMFBB-gamSkrEM/02-building-agents/agent-configuration/structured-outputs/linked-fill-dropdown-current.png?fit=max&auto=format&n=5sjMFBB-gamSkrEM&q=85&s=fe67549e43b15ac4809d1ce7c8b8e0b9" alt="A downstream integration step's input variable with the Linked fill menu open and an output variable selected." width="520" height="600" data-path="02-building-agents/agent-configuration/structured-outputs/linked-fill-dropdown-current.png" />
</Frame>

The variable picker lists output variables from earlier steps in the Flow.

See [Variables & State](/02-building-agents/agent-configuration/variables-state/variables-state) for detailed linking patterns.

<h2 id="common-patterns">
  Common patterns
</h2>

**Classification + Data Extraction:**

```json theme={null}
{
  "classification": "<String // SALES, SUPPORT, or BILLING>",
  "customer_id": "<String // 7-digit customer ID>",
  "urgency_level": "<Number // 1-5 scale>"
}
```

Use: Branch workflow based on `classification`, pass `customer_id` to CRM lookup, use `urgency_level` for prioritization.

**Validation with Confidence:**

```json theme={null}
{
  "extracted_value": "<String>",
  "confidence_score": "<Number // 0-100>",
  "needs_review": "<Boolean // true if confidence < 80>"
}
```

Use: Branch on `needs_review` - high confidence → automate, low confidence → human review.

**Handling Arrays:**

For multiple values of the same type, enable **Make array** for the output variable:

```text theme={null}
Variable: products
Data type: String
Make array: enabled
Description: Product names found in the order
```

Use **Object** and **Define structure** when each array item needs its own nested properties.

<h2 id="best-practices">
  Best practices
</h2>

**Naming Conventions:**

* Prefix with tool purpose: `email_classifier_category`, `invoice_extractor_total`
* Use descriptive names: `customer_priority_score` not `score`
* Avoid generic names: Don't use `result`, `output`, `data`

**Separation of Concerns:**

Don't combine everything into one field. Split outputs logically:

```json theme={null}
{
  "customer_name": "<String // Customer's full name>",
  "customer_email": "<String // Customer's email address>",
  "order_id": "<String // 8-character order ID>",
  "priority": "<Number // Priority level 1-5>"
}
```

**Error Handling:**

Design outputs to capture extraction confidence:

```json theme={null}
{
  "extracted_date": "<String // Date in YYYY-MM-DD format>",
  "date_confidence": "<String // HIGH, MEDIUM, LOW, or NONE>",
  "extraction_notes": "<String // Any issues or assumptions made>"
}
```

**Performance Optimization:**

Minimize unnecessary reasoning fields in high-volume workflows. Use reasoning for critical extractions, skip for simple operations.

<h2 id="troubleshooting">
  Troubleshooting
</h2>

<AccordionGroup>
  <Accordion title="Wrong Data Type">
    **Issue:** AI returns string when you expected number

    **Solutions:**

    * Make description more explicit: "Extract as a number, digits only, no text"
    * Check if source data actually contains the expected type
    * Add validation in description: "If not a number, return 0"
  </Accordion>

  <Accordion title="Inconsistent Formats">
    **Issue:** AI returns dates in different formats

    **Solutions:**

    * Be prescriptive: "Return date in YYYY-MM-DD format exactly"
    * Provide examples in description: "Format: 2024-01-15"
    * Use constrained values (Enum) when possible
  </Accordion>

  <Accordion title="Missing Fields">
    **Issue:** Some outputs are empty or null

    **Solutions:**

    * Add fallback instructions: "If not found, return 'N/A'"
    * Check if AI has access to required input data
    * Verify previous nodes are passing data correctly
  </Accordion>

  <Accordion title="Linked variable not accessible">
    **Issue:** Downstream node can't access structured output

    **Solutions:**

    * Confirm the source step runs before the step that consumes it
    * Open the destination input's fill-method menu and select **Linked fill**
    * Select the expected output variable from the variable picker
  </Accordion>
</AccordionGroup>

<h2 id="next-steps">
  Next steps
</h2>

<CardGroup cols={2}>
  <Card title="Variables & State" icon="arrow-right-arrow-left" href="/02-building-agents/agent-configuration/variables-state/variables-state">
    Learn how to link structured outputs between nodes
  </Card>

  <Card title="Selecting Tools" icon="wrench" href="/02-building-agents/agent-fundamentals/tools-integrations/tools-integrations">
    Choose AI steps and integrations for an agent Flow.
  </Card>

  <Card title="Integrations" icon="plug" href="/02-building-agents/agent-configuration/integrations/integrations">
    Pass linked outputs to integration steps.
  </Card>

  <Card title="Creating Flows" icon="diagram-project" href="/02-building-agents/agent-fundamentals/flow-configuration/flow-configuration">
    Use structured outputs for branching and routing
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.