Basic JSON
You can pass a JSON schema to theoutputSchema parameter of the Agent.send
method. The schema is used to constrain the LLM’s response to a specific JSON
object shape.
Parsed Map
You can also pass a type to thesendFor method. By default, dartantic already
knows how to parse the LLM’s response to a Map<String, dynamic>.
Custom Types
If you’d like to parse the JSON output to a custom type, you can pass a type to thesendFor method along with the outputFromJson parameter.
Schema Generation
Hand-writing schemas and JSON serialization is a lot of boilerplate. Consider using thejson_serializable package to automate this:
Streaming
You can stream structured JSON from the provider by passing theoutputSchema
parameter to the sendStream method.
With Tools
Most providers support both tools and typed output in the same request, allowing you to gather information via tools and return structured results:Provider Support
Google’s Double Agent Pattern: Google’s API doesn’t support tools and typed
output in a single call, but dartantic handles this transparently with a
two-phase approach: first executing tools, then requesting structured output
with the tool results.
See the typed output
example
for working code.
Examples
Next Steps
- Tool Calling - Extend with functions
- Multi-turn Chat - Structured conversations

