claude-api
Build with Claude Messages API using structured outputs for guaranteed JSON schema validation.
- Structured outputs (v0.69.0+) guarantee JSON format compliance with two modes: JSON outputs for data extraction and strict tool use for validated function parameters; always validate semantic correctness as models can still hallucinate
- Supports prompt caching with up to 90% cost savings;
cache_controlmust be placed on the LAST block, with 1,024+ token minimum for Sonnet and 2,048+ for Haiku - Covers streaming SSE, tool use with error handling, vision image processing (JPEG/PNG/WebP/GIF, max 5MB), and rate limit retry logic with
retry-afterheader respect - Prevents 16 documented errors including MCP 2-minute timeout issues, U+2028 Unicode sanitization in tool results, streaming error handling (fixed in v0.71.2), and structured output hallucination risks
- Active models: Claude Opus 4.5, Claude Sonnet 4.5, Claude Haiku 4.5, Claude Opus 4; Claude 3.5/3.7 Sonnet retired as of Oct 2025
Claude API - Structured Outputs & Error Prevention Guide
Package: @anthropic-ai/sdk@0.71.2 Breaking Changes: Oct 2025 - Claude 3.5/3.7 models retired, Nov 2025 - Structured outputs beta Last Updated: 2026-01-09
What's New in v0.69.0+ (Nov 2025)
Major Features:
1. Structured Outputs (v0.69.0, Nov 14, 2025) - CRITICAL ⭐
Guaranteed JSON schema conformance - Claude's responses strictly follow your JSON schema with two modes.
⚠️ ACCURACY CAVEAT: Structured outputs guarantee format compliance, NOT accuracy. Models can still hallucinate—you get "perfectly formatted incorrect answers." Always validate semantic correctness (see below).
JSON Outputs (output_format) - For data extraction and formatting:
More from jezweb/claude-skills
tailwind-v4-shadcn
|
2.7Ktanstack-query
|
2.5Kshadcn-ui
Install and configure shadcn/ui components for React projects. Guides component selection, installation order, dependency management, customisation with semantic tokens, and common UI recipes (forms, data tables, navigation, modals). Use after tailwind-theme-builder has set up the theme infrastructure, when adding components, building forms, creating data tables, or setting up navigation.
2.5Ktailwind-theme-builder
>
2.2Kfastapi
|
2.0Kcolor-palette
>
1.9K