Overview
Schema components enable you to:- Get structured outputs from AI models using JSON Schema
- Version schemas with edgit for consistency
- Share schemas across multiple agents and ensembles
- Validate outputs against well-defined schemas
Quick Start
1. Create a Schema Component
Create a JSON Schema file:2. Reference the Schema
Use the schema in your ensemble:3. Get Structured Output
Schema Reference Formats
Component Reference
Reference a versioned schema from edgit:Inline Schema
Define the schema directly in the YAML:Example Schemas
Invoice Schema
Sentiment Analysis Schema
Schema Versioning
Schema components follow semantic versioning:Provider Support
Anthropic (Claude)
Claude natively supports JSON Schema for structured outputs:claude-opus-4- Best for complex schemasclaude-sonnet-4- Balanced performanceclaude-haiku-4- Fast for simple schemas
OpenAI
OpenAI supports structured outputs via function calling:Cloudflare Workers AI
Best Practices
1. Use Descriptive Field Names
2. Add Descriptions
3. Use Enums for Categories
4. Set Constraints
5. Version Schemas Carefully
6. Test with Different Temperature
Common Patterns
Extraction with Validation
Multi-Schema Workflow
Troubleshooting
Schema Not Found
Error:Failed to resolve schema "schemas/invoice@v1"
Solution:
- Check schema exists:
edgit list schemas - Verify version:
edgit versions schemas/invoice - Use local file path for testing:
./schemas/invoice.json
Invalid JSON Output
Issue: AI returns text instead of JSON Solutions:- Lower temperature:
temperature: 0.1 - Use more capable model:
claude-sonnet-4orclaude-opus-4 - Add explicit instruction in prompt:
Schema Too Complex
Issue: AI struggles with complex nested schemas Solutions:- Break into multiple agents with simpler schemas
- Use
claude-opus-4for complex schemas - Simplify schema structure
- Provide examples in the prompt

