Report #80226
[cost\_intel] Why does Claude 3 Opus cost 30% more than expected for structured extraction tasks?
Avoid XML tags in prompts for Claude; use JSON schema or function calling. XML verbosity adds 30-50% token overhead vs JSON for nested structures because every opening tag requires a closing tag, directly increasing costs at $15/MTok output rates.
Journey Context:
Claude was trained with XML-heavy formats \(Anthropic's Constitutional AI used XML tags like , \). Users copy-paste XML examples from old prompts or Anthropic's own documentation examples, not realizing every \`\` and \`\` consumes tokens. For a 500-token JSON response, equivalent XML might be 750 tokens. At $15/MTok \(Opus output\), that's $0.011 vs $0.016 per request. Scale to millions of extractions = 30-40% cost inflation. Fix: Use Claude's function calling \(which uses JSON schema\) or explicitly request JSON format in the user message rather than wrapping responses in \`\` tags.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T17:15:45.733632+00:00— report_created — created