What's New
This release brings the response layer up to date with the Anthropic API changes shipped between April and July 2026: new usage fields, server-side fallback, compaction, and cache diagnostics.
New usage fields
Three additions to usage on Messages responses:
$response->usage->outputTokensDetails?->thinkingTokens; // how many billed output tokens were reasoning
$response->usage->speed; // 'fast' or 'standard' on fast mode requests
$response->usage->iterations; // per-attempt records under the fallback and compaction betasWhen streaming, outputTokensDetails arrives on the final message_delta event.
Server-side fallback (beta)
When a refused request is retried on another model (the fallbacks parameter with the server-side-fallback-2026-07-01 beta header), the response now parses fully:
fallbackcontent blocks mark the handoff:$block->from->modeland$block->to->modelusage->iterationsrecords every attempt: amessageentry for a declined model, afallback_messageentry for the model that served the turnstop_details->recommended_modelnames a model to retry directly when the fallback itself was rate limitedstop_details->categorynow coversfrontier_llm,reasoning_extraction, andgeneral_harmsalongsidecyberandbio
Compaction (beta)
Under the compact-2026-01-12 beta, responses can include a compaction content block whose content is a string summary. The SDK now handles that block, the compaction_delta stream event, the top-level context_management response field, and the stop_reason: 'compaction' value that appears with pause_after_compaction. All of it was verified against live API responses, including the quirk that iteration entries under this beta carry no model key.
foreach ($response->content as $block) {
if ($block->type === 'compaction') {
$block->content; // 'Summary of the conversation: ...'
}
}
$response->context_management; // ['applied_edits' => [...]] or nullCache diagnostics (beta)
With the cache-diagnosis-2026-04-07 header and a diagnostics request parameter, the API reports where two consecutive requests diverged:
$response->diagnostics?->cache_miss_reason?->type; // 'system_changed'
$response->diagnostics?->cache_miss_reason?->cache_missed_input_tokens; // 41850On streams, diagnostics arrives on the message_start event.
Documentation
The Messages, Thinking, Streaming, and Server Tools guides now cover refusal handling with fallback, compaction, cache diagnostics, thinking token usage, and the latest server tool versions (web_search_20260318, web_fetch_20260318, code_execution_20260521).
Full Changelog: 1.7.0...1.8.0