Skip to main content
In Lyzr, Structured Outputs allow an agent’s response to be returned in a machine-readable format such as JSON, YAML, or even tabular data. These are crucial when your agent needs to interact with other systems, APIs, databases, or dashboards. Instead of returning free-form text — which is flexible but difficult to extract meaning from — structured outputs make the agent’s responses actionable, testable, and easier to plug into production-grade workflows.

✨ Why Structured Outputs Matter

✅ Machine Interoperability

Structured outputs can be directly consumed by APIs, connected to automation tools like Zapier, integrated into frontend dashboards, or stored in structured databases like PostgreSQL or MongoDB. Example: Imagine a marketing agent returning campaign stats:
This response can be fed into an analytics dashboard or automation rule.

✅ Predictable Parsing

Instead of using regular expressions or NLP techniques to extract meaning from agent output, you always know what structure to expect. This drastically reduces the complexity of downstream logic.

✅ Enhanced UI Rendering

You can automatically render JSON objects as tables, charts, forms, or timelines in the UI — useful for dashboards, forms, reports, and more.

✅ Validation & Error Detection

You can define strict schemas for agent responses — including required fields, data types, and constraints. This enables robust validation and early detection of hallucinations or formatting mistakes.

🧠 Use Cases with Real Examples

🎯 Lead Scoring Agent

🛠️ Tech Support Ticket Generator

📬 Email Generator for Sales Outreach

📊 Data Summary Agent


🏗️ How to Use Structured Outputs in Lyzr Studio

1. Agent Configuration

When creating or editing an agent in Lyzr Studio:
  • Scroll to the Expected Output Format section.
  • Toggle Structured Output to ON.

2. Define Output Structure

Specify a sample output format or a JSON schema. Example Output Format:

3. Prompt Engineering

Embed structure instructions directly in your prompt:

4. Enable Validation (Optional)

You can enable schema validation within Lyzr to:
  • Reject malformed responses
  • Retry generation
  • Trigger fallback behavior or alerts

✅ Best Practices


🚫 When Not to Use Structured Outputs

  • When you’re building conversational, storytelling, or creative agents.
  • When the output is unpredictable, such as philosophical insights or user interviews.
  • When human readers are the only consumers of the agent’s response.
Use free-form text in those cases.

📌 Summary


🔚 Final Note

By using Structured Outputs in your Lyzr agents, you’re enabling automation, reducing complexity, and building reliable integrations. Treat your agents not just as conversational entities — but as programmable, structured interfaces into your systems.