Structured Output CLI
Generate type-safe structured JSON output using the PraisonAI CLI.Commands
Generate Structured Output
Schema File Format
Create a JSON schema file:Options
| Option | Short | Description |
|---|---|---|
--model | -m | Model to use (e.g., openai/gpt-4o-mini) |
--schema | Inline JSON schema | |
--schema-file | -f | Path to JSON schema file |
--temperature | -t | Temperature (0-1, default: 0.1) |
--max-tokens | Maximum output tokens | |
--timeout | Request timeout in ms | |
--json | Output raw JSON | |
--verbose | -v | Verbose output |
Examples
Data Extraction
Classification
Sentiment Analysis
sentiment.json:
Complex Nested Output
order.json:
Using Different Providers
Piping and Scripting
Pipe Input
Use in Scripts
JSON Lines Output
Error Handling
Environment Variables
Exit Codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Invalid arguments |
| 3 | Schema validation error |
| 4 | API error |
Best Practices
- Use schema files for complex schemas
- Set low temperature (0.1) for consistent output
- Validate output with
jqor similar tools - Handle errors in scripts
- Use
--jsonflag for machine-readable output

