By Sagar Shankaran, Founder of CallSphere
Three structured-output approaches, three different reliability profiles. The 2026 best practices for getting clean structured output from LLMs.
Key takeaways
Production AI systems consume LLM outputs programmatically. Structured outputs (JSON, XML) parse cleanly; free-form prose does not. The reliability of structured output decides whether your downstream code can rely on it.
By 2026 three approaches dominate: JSON Schema validation, XML tagging, and native function-calling. This piece compares them.
flowchart TB
JSON[JSON Schema validation] --> Strong1[Strong: machine-readable, validated]
XML[XML tagging] --> Strong2[Strong: human-readable, flexible]
Func[Function-call mode] --> Strong3[Strong: native LLM support, most reliable]
The structured-output API ("response_format": json_schema) constrains the model to produce valid JSON matching your schema:
{
"type": "object",
"properties": {
"intent": { "type": "string", "enum": ["book", "cancel", "reschedule"] },
"patient_id": { "type": "string" }
},
"required": ["intent"]
}
Modern providers (OpenAI, Anthropic, Google) support schema-constrained generation. Output is guaranteed to parse and match the schema.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
The model produces XML-tagged output:
<intent>book</intent>
<patient_id>a1b2c3</patient_id>
<rationale>The user explicitly asked to schedule.</rationale>
Anthropic's Claude is particularly tuned to XML tags.
The model emits a tool call with structured arguments:
function_call: book_appointment(patient_id="a1b2c3", start_time="2026-04-25T10:00:00")
Native function-calling APIs handle the structuring.
flowchart TD
Q1{Output triggers an action?} -->|Yes| Func2[Function call]
Q1 -->|No| Q2{Pure structured data?}
Q2 -->|Yes| JSON2[JSON Schema]
Q2 -->|No, mixed prose + struct| XML2[XML tags]
Good: flat structure with explicit types
{
"intent": "string with enum",
"confidence": "number 0-1",
"extracted_entities": ["array of strings"]
}
Avoid: deeply nested with anyOf branches
{
"result": {
"type": "anyOf...",
"subtype": { "anyOf": ... }
}
}
Frontier models in 2026 handle reasonable nesting well; pathologically nested schemas remain risky.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
Beyond schema validation:
The schema validates structure; your code validates semantics.
For complex outputs, combine:
The 2026 pattern that works: structured shell, free-form internals where flexibility helps.
For maximum reliability, use the provider's native structured-output mode and benchmark.

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
GPT-Realtime-2 brings GPT-5-class reasoning into voice. What that means for tool-call reliability, structured output, and production agent design.
OpenAI's parallel function calling can cut latency in half — or burn money on dependent calls. The architecture, code, and an eval that proves the win.
Your agent picked the wrong tool 12% of the time and the final answer was still right. That's a latent bug. Here's the eval pipeline that surfaces it.
Enterprise CIO Guide perspective on Skills let Claude agents load tool packs on demand without ballooning the system prompt — a quietly important architectural win.
Anthropic publishes Claude's system prompts. What do they encode, what does this say about Anthropic's strategy, and what can enterprise prompt engineers actually learn from them?
SMB Founder Playbook perspective on Skills let Claude agents load tool packs on demand without ballooning the system prompt — a quietly important architectural win.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco
Watch how CallSphere handles real customer calls, schedules appointments, and processes payments — live.