OpenAI & Anthropic Strict Structured Outputs JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ExtractedTechnicalSnippet",
"type": "object",
"additionalProperties": false,
"required": ["title", "language", "code", "explanation", "tags", "confidence_score"],
"properties": {
"title": {
"type": "string",
"description": "Concise summary of the snippet purpose"
},
"language": {
"type": "string",
"enum": ["typescript", "javascript", "python", "yaml", "sql", "bash", "json"],
"description": "Programming language of the extracted code"
},
"code": {
"type": "string",
"description": "Self-contained, runnable code content"
},
"explanation": {
"type": "string",
"description": "Brief explanation of how the snippet works"
},
"tags": {
"type": "array",
"items": { "type": "string" },
"minItems": 1,
"maxItems": 5,
"description": "Searchable topic keywords"
},
"confidence_score": {
"type": "number",
"minimum": 0.0,
"maximum": 1.0,
"description": "Extraction accuracy score between 0 and 1"
}
}
}