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 and soti_schema_plus packages 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
| Provider | Tools + Typed Output | Method |
|---|---|---|
| OpenAI | ✅ | Native response_format |
| Anthropic | ✅ | return_result tool |
| ✅ | Double agent orchestrator | |
| Together | ✅ | OpenAI-compatible |
| OpenRouter | ✅ | OpenAI-compatible |
| Ollama | ❌ | Coming soon |
| Cohere | ❌ | API limitation |
Examples
Next Steps
- Tool Calling - Extend with functions
- Multi-turn Chat - Structured conversations

