Turn AI responses into a structured JSON output
Learn how to transform AI responses into a structured JSON output on Digibee, making your Agent’s results predictable and ready for deterministic integration flows.
This article extends the sentiment analysis API you assembled in the previous quickstart. You can now transform unstructured answers into structured outputs, ensuring your API always returns consistent, machine-readable results ready to be used in deterministic integration flows.

Prerequisites
Before continuing, make sure you have completed the Create your first AI Agent for sentiment analysis quickstart, including:
Selecting an LLM provider
Choosing a model
Configuring the account
Once the agent is properly configured, you can proceed to define a JSON Schema for the response.
Configuring a JSON Schema
A JSON Schema defines a predefined JSON structure with enforced fields and data types that the AI must follow in its response. See the configuration method below:
In the Agent Component, click the gear icon (⚙️) next to the Model parameter.
Enable Use JSON Schema.
Add the following JSON Schema:
In the previous quickstart, the output format is flexible. By introducing a JSON Schema here, you ensure the response is always returned in a well-defined, structured format.
Testing the Agent
Use the following System and User Messages configured from the previous quickstart:
System message:
User message:
Before: Without JSON Schema
Without a JSON Schema, the Agent may return an unstructured response, for example:
The response format can change each time, which makes it difficult to process automatically.
After: With JSON Schema
With a JSON Schema configured, the Agent always returns a well-defined and predictable structure:
This ensures the output is always consistent and easy for other systems to read and use.
Result
Congratulations! You now have a sentiment analysis API that returns structured data in a consistent format, ideal for routing logic or storing in databases.
Related topics
Use an MCP Server tool to connect AI agents to external systems: Use tools to retrieve external data through the Deepwiki MCP Server.
Insurance claim analysis with AI: Build a multi-agent system to help review insurance claims.
AI expense report validation system: Explore a real-world implementation in this How-to guide.
Agent Component — Complete configuration guide: Explore all the configuration options for this component.
Last updated
Was this helpful?