claude-api

Installation
Summary

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_control must 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-after header 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
SKILL.md

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:

Related skills
Installs
331
GitHub Stars
776
First Seen
Jan 20, 2026