Structured Outputs Beta — Native JSON Schema Enforcement in the Claude API
Anthropic has launched a Structured Outputs beta for the Claude API, introducing native JSON schema enforcement that guarantees Claude's response conforms to a developer-specified schema without requiring post-processing validation. The feature, accessible by passing a response_format parameter with a JSON schema definition, uses a constrained decoding approach during generation to ensure schema compliance at the token level rather than relying solely on instruction-following.
# Python — native structured output
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
response_format={
"type": "json_schema",
"json_schema": {
"name": "extraction_result",
"schema": {
"type": "object",
"properties": {
"entities": {"type": "array", "items": {"type": "string"}},
"sentiment": {"type": "string", "enum": ["positive","negative","neutral"]},
"confidence": {"type": "number"}
},
"required": ["entities", "sentiment", "confidence"]
}
}
},
messages=[{"role": "user", "content": "Analyse: ..."}]
)
The beta is available to all API customers on Sonnet 4.5 and Opus 4.5. Anthropic notes that structured outputs mode is incompatible with extended thinking in this initial release; the combination is on the roadmap for a later update.