Structured outputs work with all supported models and can be combined with claim refinement and fact-checking capabilities for verified, structured data extraction.
Overview
Structured outputs allow you to:- Ensure consistent response formats across all API calls with type safety
- Extract specific data fields from unstructured text reliably
- Validate responses against predefined Pydantic models or JSON schemas
- Simplify parsing by receiving guaranteed, type-safe structures
- Combine with claim refinement for iteratively improved accuracy
- Integrate evaluation metrics for quality assurance
Using Pydantic Models (Recommended)
The recommended approach is using theparse() method with Pydantic models for full type safety and validation:
Alternative: JSON Schema Format
You can also use JSON schema format directly with the regularcreate() method:
Response Format
Structured Output Response
Advanced Examples
Data Extraction from Text
Extract multiple data points from complex text:Fact-Checking with Structured Output
Combine CheckThat AI’s fact-checking capabilities with structured outputs:Schema Validation
CheckThat AI validates all structured outputs against your JSON schema:Best Practices
Schema Design Guidelines
Schema Design Guidelines
Keep schemas focused and specific:
- Define clear, descriptive property names
- Use enums for categorical data to ensure consistency
- Set appropriate constraints (min/max values, string lengths)
- Include descriptions for complex fields
Performance Optimization
Performance Optimization
Optimize for speed and accuracy:
- Use simpler schemas for faster processing
- Avoid deeply nested objects when possible
- Set reasonable array size limits
- Consider model capabilities when designing schemas
- Shorter property names reduce token usage
- Use enums instead of free-form text where possible
- Balance between structure detail and token cost
Error Recovery
Error Recovery
Handle validation failures gracefully:
Common Use Cases
Data Extraction
Extract structured information from unstructured text, documents, or web content.
Content Classification
Categorize content with consistent taxonomies and confidence scores.
Fact-Check Reports
Generate standardized fact-checking reports with evidence and sources.
Survey Analysis
Process survey responses into structured data for analysis.

