Structured outputs for Anthropic Claude models on Amazon Bedrock
Amazon Bedrock now adds native structured‑output support for all Anthropic Claude models on both the bedrock‑runtime and bedrock‑mantle endpoints, delivering schema‑compliant JSON via constrained decoding. The service validates JSON Schema Draft 2020‑12, compiles a grammar artifact (cached for 24 hours), and streams typed events for real‑time use, eliminating post‑generation parsing and retries. This deterministic output reduces token usage and inference cost, making Claude‑based pipelines production‑ready at scale.
⚡ Key Takeaways
- Structured outputs are available for **all Anthropic Claude models** on **bedrock‑runtime** and **bedrock‑mantle** endpoints.
- Constrained decoding enforces a **JSON Schema Draft 2020‑12** subset during token generation.
- First request with a new schema incurs extra latency for **grammar compilation**, but subsequent calls are faster thanks to a **24‑hour cache**.
- Supports **batch inference**, **cross‑Region inference**, and **streaming typed events** for real‑time responses.
- Outputs are **type‑safe**, always include required fields, and reduce token count, lowering inference cost for high‑volume workloads.
Engineers can integrate Claude models without custom JSON parsing or retry loops, achieving reliable, cost‑effective data extraction and automation pipelines that scale across AWS regions.
✅ Practical Steps
- Include a **JSON schema** (conforming to Draft 2020‑12) in your Bedrock request payload when calling Claude via **Boto3** or the **Messages API**.
- For high‑throughput jobs, use **batch inference** on the bedrock‑runtime endpoint and enable **cross‑Region inference** to distribute load without extra setup.
- To receive real‑time results, enable **streaming** and handle the returned **typed events** in your application.
Want the full story? Read the original article.
Read on AWS ML Blog ↗