If you've ever tried to get structured data out of an LLM with a prompt like "Please respond in valid JSON with the following fields..." , you already know the story. It works 95% of the time. The other 5% it returns prose, fenced markdown, a trailing apology, or — my personal favorite — { "name": "Alice", "age": 30, } with a trailing comma that explodes your parser at 3 AM. This guide walks through a technique that makes Claude return JSON that conforms to your schema on every single call , with no regex parsing and no retry loops. It works because we're not really asking Claude for JSON — we're tricking it into a code path that produces JSON as a side effect. About this guide. I'm one of the maintainers of claudeapi.com , a third-party Claude API gateway. All code below targets the official Anthropic endpoint ( api.anthropic.com ); a comparison of alternative gateways for developers in restricted regions appears near the end. Skip it if you're on the official endpoint and it works fine for you.…