npm / @ai-sdk/anthropic
@ai-sdk/anthropic
What changed in @ai-sdk/anthropic 2 to 7, from its official release notes, upgrade guides and advisories. Sources checked 2026-12-05.
57 breaking2 security10 deprecations96 new APIs and options3 performance38 behavior and defaults62 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@ai-sdk/anthropic 761 changes
Breaking changes 40
OpenTelemetry span collection moved out of the ai package. Install this package and register an OpenTelemetry instance globally to receive OpenTelemetry traces.
Set allowSystemInMessages to true to retain system messages in existing chat histories; the notes warn to use it only for trusted messages.
Removed cacheCreationInputTokens from providerMetadata.
The deprecated top-level LanguageModelUsage field was removed; use inputTokenDetails.cacheReadTokens instead.
CallSettings is split into LanguageModelCallOptions and RequestOptions; replace usages with LanguageModelCallOptions & Omit<RequestOptions, 'timeout'>.
AI SDK packages are ESM-only; replace require() with ESM imports and use type: module or .mjs files as needed.
Replaces experimental_context in tool callbacks and is now stable. Tool-specific context is typed from contextSchema and supplied through toolsContext, rather than using one shared runtime context.
The deprecated option is removed. Replace remaining usages with activeTools.
The deprecated export was removed; use customProvider instead. Its options and behavior are unchanged.
The deprecated export was removed; use generateImage instead.
The deprecated result type export was removed; use GenerateImageResult instead.
The deprecated generation option and result property were removed; use output for call options and result access.
The deprecated option was removed; use prepareStep instead.
The tracer property was removed. Pass a custom OpenTelemetry Tracer to the OpenTelemetry constructor instead.
Move the deprecated top-level streamText includeRawChunks option to include.rawChunks.
generateText and streamText no longer include request bodies in step results by default. Opt in with include.requestBody when your application reads those bodies.
generateText no longer includes response bodies by default. Opt in with include.responseBody when your application reads those bodies.
Use isStepCount in tool-loop stop conditions instead of stepCountIs.
The deprecated function is removed. Replace remaining usages with isToolUIPart.
The deprecated { type: 'media' } tool-result content part is removed. Use the file content part with tagged data for inline file content.
Raised the minimum supported Node.js version to 22; supported versions are 22, 24, and 26.
Replaces onEmbedFinish in telemetry integrations and tracing-channel events for individual embedding model calls.
Replaces experimental_onFinish as the per-call completion callback for embed and embedMany operations.
Replaces experimental_onFinish as the per-call completion callback for rerank operations.
The onEnd callback follows the result changes: usage and content-related properties include all steps, while final-step-only properties are available on finalStep.
Replaces onRerankFinish in telemetry integrations and tracing-channel events for individual reranking model calls.
The generation start callback is now named onStart instead of experimental_onStart.
The per-step start callback is now named onStepStart instead of experimental_onStepStart.
Instructions returned from prepareStep now carry forward to future steps until another instructions or system override is returned.
Messages returned from prepareStep now form the base for subsequent steps, together with the previous step's response messages.
The deprecated top-level LanguageModelUsage field was removed; use outputTokenDetails.reasoningTokens instead.
Register a telemetry integration globally at application startup to enable telemetry collection.
Top-level content, tool, file, source, and warning properties on generateText and streamText results now accumulate values across every step; use finalStep for final-step-only values.
Use runtimeContext for shared generation or agent state visible in prepareStep, events, and step results; it is separate from each tool's scoped context.
Each StepResult now contains only the response messages produced by that step. Use result.responseMessages for the full response message history.
onChunk now receives every TextStreamPart, including lifecycle, boundary, and terminal parts; handlers should guard the chunk types they process.
System messages in prompt or messages are rejected by default; move instructions to the top-level instructions option or opt in with allowSystemInMessages.
The deprecated type is removed. Replace remaining usages with ToolExecutionOptions.
Pass tool-specific context values through toolsContext, keyed by tool name. Tools with a contextSchema receive typed, scoped context; toolsContext is required when at least one tool declares contextSchema.
generateText and streamText usage now reports token usage across all steps. Use finalStep.usage for the previous final-step-only value; totalUsage is deprecated.
Deprecations 8
Tool-result file and image content now has a canonical file variant with tagged data and a required mediaType; legacy variants are deprecated and auto-migrated at runtime.
Top-level reasoning, reasoningText, request, response, and providerMetadata result properties are deprecated; use finalStep to read final-step reasoning and metadata.
The { type: 'image', image, mediaType? } user-message content part is deprecated. Use a file part with an image mediaType instead.
The tool() and dynamicTool() property is deprecated. Move approval logic to toolApproval on the call or agent to keep policy configurable per request.
Replaces onFinish as the final lifecycle callback for generateText, streamText, agents, and ToolLoopAgent settings. onFinish remains a deprecated alias, and onEnd takes precedence when both are provided.
Replaces onStepFinish for per-step lifecycle callbacks across text and object generation, agents, workflow agents, and UI message stream helpers. The old name remains a deprecated alias for user-facing callbacks.
Replaces StreamTextResult.fullStream as the property for accessing the full event stream. fullStream remains a deprecated alias.
The result methods toUIMessageStream, toUIMessageStreamResponse, pipeUIMessageStreamToResponse, toTextStreamResponse, and pipeTextStreamToResponse are deprecated; use the stateless top-level helpers.
New APIs and options 2
Declare tool-specific context fields with contextSchema so tool callbacks receive a typed context limited to those fields.
The top-level system prompt option is now instructions across prompt- and messages-accepting functions and related callbacks; system remains a deprecated fallback, with instructions taking precedence.
Behavior and default changes 10
The speech generation function graduated from experimental status and is available under the stable name generateSpeech; the old name remains a deprecated alias.
Replaces experimental_include for generateText, streamText, and ToolLoopAgent. The old name remains a deprecated alias, and include takes precedence if both are provided.
Replaces experimental_onToolCallFinish as a tool execution callback for generateText and streamText. The old name remains a deprecated alias and is only used as a fallback.
Replaces experimental_onToolCallStart as a tool execution callback for generateText and streamText. The old name remains a deprecated alias and is only used as a fallback.
When using the top-level reasoning option, remove overlapping providerOptions reasoning settings; provider-specific settings take precedence and can bypass the top-level configuration.
The speech result type has a stable name; Experimental_SpeechResult remains a deprecated alias.
Replaces experimental_telemetry as the stable telemetry configuration option. The old name remains a deprecated alias during the migration window.
Once a telemetry integration is registered, AI SDK calls emit telemetry events by default; set isEnabled to false to opt out of a specific call.
The transcription API graduated from experimental status and is available under the stable name transcribe; the old name remains a deprecated alias.
The transcription result type has a stable name; Experimental_TranscriptionResult remains a deprecated alias.
Fixes and other changes 1
Models can return files in reasoning under a distinct reasoning-file content type; update exhaustive part handling to support it.
@ai-sdk/anthropic 61 changes
New APIs and options 1
The Anthropic provider adds structuredOutputMode to control structured output generation, with outputFormat, jsonTool, and auto modes. auto uses native output_format when supported and otherwise falls back to jsonTool.
@ai-sdk/anthropic 4130 changes
Breaking changes 14
MCP connector tools are disabled in specified structured-output fallback and tool-choice scenarios.
Rejects conflicting inline tool additions in specified fallback and internal JSON response tool scenarios, validating only definitions emitted in the request.
Adds a typed stream-part union variant; exhaustive stream-part switches must handle it even when ping emission is not opted into.
Anthropic streams that end cleanly without the provider completion signal now report interrupted, preserving partial output without emitting an error solely for the interruption. Applications must handle interrupted in finish-reason switches, mappings, and custom validation.
Renames evaluate to decide.
For Claude Sonnet 5.5, disabled thinking is replaced with
between_tools,reasoning: 'none'maps tobetween_tools, and budget-based thinking is converted to adaptive thinking.For models that always use adaptive thinking, unsupported disabled or budget-based thinking settings are dropped,
reasoning: 'none'maps toeffort: 'low', and a warning is emitted.Unsupported batch request types are now rejected.
The package is ESM-only; consumers using require() must switch to ESM import syntax.
The Anthropic facade has been removed; use the anthropic object or the createAnthropic function instead.
The baseUrl option has been removed from all providers; use baseURL instead.
File part data is now tagged with a type, and the image part type was removed.
Rolled image-* tool output types into their equivalent file-* types.
The model-specific topK setting has been removed from the Anthropic provider; use the standard topK setting instead.
Security 1
Actions are tied to the returned member name; disabled or unavailable members are rejected before tool calls, and member configuration is applied to local input validation.
Deprecations 1
Anthropic between_tools mappings now emit a compatibility warning.
New APIs and options 55
Adds experimental extraction models backed by structured language model output.
Adds support for creating and continuing message threads, with automatic beta headers and thread error details for application-managed recovery.
Supports adding tools by value in mid-conversation through toolChanges.
Adds support for deleting files, retrieving metadata, and streaming downloads of generated files; downloads remain restricted to files generated by tools or skills.
Enables Anthropic typed streaming heartbeat parts; they are disabled by default and do not require raw chunks.
Adds MiniMax support for standard and priority admission tiers and exposes the applied tier, when returned, in Anthropic-compatible generation, stream, and batch metadata.
Adds a Vertex Anthropic opt-in allowing auto to use native structured output for Claude 4.5 and newer when enabled by Google Cloud policy; tool emulation remains the default.
Supported Claude 5 models on Bedrock now support native structured output and strict tools.
Forwards providerOptions.vertex.labels as a header.
A typed AnthropicCitation export is available for citation data.
A typed AnthropicTextProviderMetadata export is available for text provider metadata.
Adds Claude Haiku 5.5 as a known model with a 128k max output token limit, adaptive thinking, and all five effort levels. Thinking can be disabled up to high effort; xhigh and max are lowered to high with a warning…
Adds the portable max reasoning level, widening LanguageModelV4CallOptions['reasoning'] and requiring exhaustive consumers to handle max.
Exposes message-start usage through custom stream parts.
Adds Claude Sonnet 5.5 as a supported model ID in @ai-sdk/anthropic.
Adds the
between_toolsthinking type, the lowest thinking setting on Claude Sonnet 5.5.Supports on-demand compaction and preserves signed compaction blocks.
Adds Claude Opus 5.5 as a supported model.
Adds the computer use toolset required for computer use on Claude Opus 5.5.
Adds the safeguards provider option for the dangerous tool use classifier.
Adds experimental Choice, Score, and Boolean evaluations through Messages structured output, with exact labels, validated score bounds, and prompted Boolean P(true) estimates validated to be in [0, 1].
Adds 20260318 web search and web fetch tools with response inclusion controls.
Image generation requests are now supported in batches.
Adds batch cancellation support.
Adds batch listing support.
Batch requests can now use per-request models, allowing developers to select a model for each request in a batch.
Adds support for Fable 5.1 in the Anthropic provider.
Upload results now expose byteSize.
Upload results now expose createdAt.
FilesV4 now optionally supports deleting files.
provider-utils adds deleteFromApi.
FilesV4 now optionally supports streaming file downloads.
Upload results now expose expiresAt.
FilesV4 call options now accept abortSignal.
FilesV4 call options now accept headers.
FilesV4 now optionally supports retrieving file metadata.
provider-utils adds streaming multipart uploads with deterministic part ordering and failure-path stream teardown.
Upload data now supports the
{ type: 'stream' }variant.Accepts webhookUrl for batch completions; the gateway provider registers it, while direct Anthropic and OpenAI batch providers return an unsupported warning when it is provided.
The gateway provider exports typed async-job metadata for batch completions.
Sandbox command execution accepts optional abortSignal parameters.
Added the advisor tool.
Added support for claude-fable-5 and the fallbacks API parameter.
Added support for Opus 4.7 and relevant API enhancements.
Added support for the claude-opus-4-8 model.
Added the fallbacks API parameter.
Added the inference_geo provider option.
Added support for passing metadata.user_id.
Added provider references and support for uploading files and provider skills using the provider references abstraction.
Added readFile to the Experimental_Sandbox abstraction.
Added a top-level reasoning parameter to the provider spec, supported by generateText and streamText.
Added support for passing a provider instance to uploadFile as shorthand.
Added support for passing a provider instance to uploadSkill as shorthand.
Provider models can cross workflow step boundaries without serialization errors; provider config headers are optional, and serializeModel is available to third-party provider authors.
Added writeFile to the Experimental_Sandbox abstraction.
Performance 1
Provider validation schemas and Anthropic provider option schemas are constructed on first use, reducing package import time.
Behavior and default changes 14
Known model ID suggestions are derived from provider model catalog declarations, so catalog updates automatically update autocomplete while preserving existing suggestions, endpoint-specific lists, and support for custom IDs.
Bedrock and Anthropic fall back when schemas use recursive references, open objects, or more than ten optional properties; JSON-tool fallback excludes disabled and unselected application tools.
Use native structured outputs for models that reject forced tool use even when the provider disables them by default; self-referencing schemas continue to use the JSON response tool.
Supports synchronous and asynchronous token providers, including workload identity federation helpers, and resolves tokens before each request while preserving existing authentication headers and beta-header behavior.
Provider-returned identifiers are now encoded in credentialed follow-up request paths.
For Claude Haiku 5.5, an enabled thinking configuration with budgetTokens is converted to adaptive thinking with a warning because the model does not support thinking token budgets.
For Claude Sonnet 5.5,
structuredOutputMode: 'jsonTool'falls back to native structured outputs with a warning.For Claude Sonnet 5.5,
requiredand named tool choices fall back toautowith a warning because forced tool use is rejected.For models that reject forced tool use, requesting
jsonToolfalls back to native structured outputs with a warning.For models that reject forced tool use,
requiredand named tool choices fall back toautowith a warning.Preserved thinking support now covers prefix_mismatch_behavior: 'error'.
Batch requests support the full language-model option surface.
The bash tool now automatically uses a sandbox.
The extended thinking effort parameter is GA and no longer requires the effort-2025-11-24 beta header.
Fixes and other changes 44
Ignored inline tool additions on the initial system message remain warning-only in specified fallback cases; tool-choice restrictions are validated only for inline definitions emitted in the outgoing request.
Metadata reads and uploads expose consistent media type, size, creation time, expiration, and provider metadata when available.
Omits foreign-provider empty signature text when replaying history through Anthropic or Bedrock, preserving Bedrock’s native reasoning-history handling.
Keeps provider metadata when converting results to response messages so it can be passed back in subsequent requests.
Tiers belonging to another known provider are omitted with an unsupported-setting warning instead of being forwarded as incompatible values.
Preserves text and complete function-call order, including standalone thought signatures on empty text or reasoning parts.
Avoids adding the structured-output beta header for providers without strict tool support.
Stream retries forward pings without storing them as generated content or sending them to UI message streams; typed pings do not flush partial words during stream smoothing.
Valid JSON string tool input is parsed, and BigInt values and cycles in tool results are safely serialized.
When the model responds in text without calling the JSON response tool, return that final answer instead of dropping it.
Keep the JSON response tool for schemas native structured outputs cannot represent, including open objects and schemas with more than 10 optional properties.
Schema sanitization keeps definitions and $defs next to a top-level $ref so the reference still resolves.
Fixes serialization of Anthropic models using API keys or synchronous auth tokens while preserving support for asynchronous token providers.
Empty streams continue to be rejected for interrupted responses.
Support provider-referenced files in tool results.
When manual thinking is enabled with a required or named tool choice, falls back to automatic tool choice with a warning to avoid an Anthropic API 400 error.
Named tool choices send only the selected tool.
Retrieved web-search sources are kept separate from normalized inline citations on text parts and text-end events.
Tools are preserved when tool calls are disabled.
Failed tool search results are preserved in conversation history.
Generation, streaming, and batch results preserve every supported web and document citation kind, with document source compatibility and web citation source fallbacks when retrieval results are unavailable.
Avoids unsupported strict mode warnings when tools set strict to false.
Uses the JSON tool fallback for structured output on Amazon Bedrock.
JSONL rows are limited to 64 MB during batch result downloads.
Adds the required beta when replaying server-side fallback blocks.
Preserves invalid toolset calls.
Preserves server-side fallback boundaries when replaying assistant messages.
The User-Agent header is now standards-compliant.
After pruning, missing source code execution caller metadata is omitted before a subsequent user message and a warning is emitted; active tool continuations retain caller metadata.
With
between_toolsthinking on Claude Sonnet 5.5,xhighandmaxeffort are lowered tohighwith a warning because the API rejects them.Empty compaction blocks are omitted from replay.
Uses the documented beta header for per-message effort.
Recognizes dated Google Vertex Claude 4 model IDs when selecting model capabilities.
The core uploadFile() helper now forwards abortSignal.
The core uploadFile() helper now forwards headers.
Provider metadata now preserves native message batch request counts.
Stopped adding this beta header for claude-opus-4-7.
Unsupported JSON schema validation properties are sanitized before use.
Preserved the error code returned by the model.
The mutual-exclusivity check applies only to known Anthropic models; non-Anthropic models using the compatible API can send both parameters.
Propagated the providerOption to Anthropic tool results.
Aligned tool result output content file part types with top-level message file part types.
The provider now skips passing the beta header for tool search tools.
Fixed remaining errors from Anthropic code_execution tool dynamic calls following the latest web_fetch or web_search calls.
@ai-sdk/anthropic 352 changes
Breaking changes 2
By-value system-message tool additions now require request-level opt-in, preventing client UI history from introducing undeclared provider tools or replacing server-configured tool restrictions.
On Claude Sonnet 5.5, disabled thinking is replaced with
between_toolsthinking and budget-based thinking is converted to adaptive thinking.
Deprecations 1
Renames textEmbeddingModel to embeddingModel; textEmbeddingModel and textEmbedding are also marked deprecated aliases.
New APIs and options 26
Adds support for MiniMax M3.1 Flash, including reasoning effort, image detail, video input and frame sampling, prompt cache control, and sampling controls.
Adds the Claude Haiku 5.5 model ID to @ai-sdk/anthropic.
Adds support for Agent Skills.
Adds support for the ANTHROPIC_BASE_URL environment variable.
Adds support for the 2025-08-25 code execution tool.
Exposes the container from the response in provider metadata.
Adds support for Anthropic context_management.
Adds the effort provider option for Opus 4.5.
Adds extended token usage support.
Adds support for flexible tool output content.
Adds LanguageModelV3.
Adds Anthropic MCP connector support.
Adds the Anthropic memory tool.
Adds support for programmatic tool calling with Anthropic.
Allows custom names for Anthropic provider-defined tools.
Supports a custom provider name in the Anthropic provider.
Exposes the raw finish reason.
Exposes stop_sequence in provider metadata.
Adds Anthropic-native structured outputs.
Adds the text_editor_20250728 tool for Claude 4 models, with optional max_characters and no undo_edit command support.
Adds support for tool calling with structured output.
Adds support for tool execution approval.
Adds support for tool input examples.
Adds support for Anthropic's new tool search tools.
Adds strict mode that can be configured per tool.
Adds the Anthropic web fetch tool.
Performance 2
Construction of Anthropic provider option schemas is deferred until first use to reduce package import time.
Validation schema construction is deferred until first use to reduce provider import time.
Behavior and default changes 8
Supported Claude 5 models on Bedrock gain native structured output and strict tools. In automatic mode, Bedrock and Anthropic fall back for unsupported schemas; explicit outputFormat selection is unchanged.
For models that always use adaptive thinking, the provider drops unsupported disabled or budget-based thinking settings and emits a warning.
Enables fine grained tool streaming by default.
The Opus 4.5 maxOutputTokens limit increases from 32000 to 64000.
Defaults and limits maxTokens based on the selected model.
The provider version is added to the user-agent header.
Tool results can include PDF files, including PDFs and images supplied by URL.
Updates the Anthropic web search tools.
Fixes and other changes 13
Valid JSON string tool input is now parsed correctly.
After pruning conversation history, dangling caller metadata whose source code execution call is missing is omitted before a subsequent user message, with a warning; retained tool calls and results are preserved, and active tool continuations are unchanged.
Effort updates are preserved on empty system messages at the beginning of a conversation, including consecutive updates.
Retains beta features supplied by the user.
Returns file_id for code-execution-20250825 so output files can be downloaded.
Throws a 500 error when the first stream chunk is an error.
Does not limit maxTokens when the model ID is unknown.
Adds validation for Anthropic prompt caching.
Adds specificationVersion to ProviderV3.
Corrects raw usage information returned by the Anthropic provider.
Clamps temperature to the valid 0–1 range and emits warnings.
Uses the default thinking budget when none is specified.
Streaming tool calls without arguments now send {} as the tool input.
@ai-sdk/anthropic 224 changes
Breaking changes 1
Anthropic provider settings switch to providerOptions.
Security 1
Actions stay tied to the returned member name; disabled or unavailable members are rejected before tool calls are emitted, and member configuration is applied to local input validation, which rejects malformed streamed member input.
New APIs and options 12
Adds the Claude Fable 5.2 model ID with the same capabilities as Claude Fable 5.1, including 128k max output tokens, adaptive thinking, and native structured outputs by default.
Adds Claude Haiku 5.5 as a supported model, recognized with a 128k maximum output token limit and all five effort levels.
Adds cache control for tools.
Adds text support for citations.
Adds Claude v4 models to the provider.
Adds an option to disable parallel tool use.
Supports JSON response schemas via tool calls.
Adds raw chunk support, including support in streamText onChunk.
Adds the text_editor_20250429 tool for Claude 4 models.
Enables streaming tool calls.
Adds support for URL-based PDF documents in the Anthropic provider.
Adds support for server-side web search tool calls.
Behavior and default changes 6
Supported Claude 5 models on Bedrock can use native structured output. In automatic mode, Bedrock and Anthropic fall back when schemas contain recursive references, open objects, or more than ten optional properties.
When thinking is disabled, it is supported up to
higheffort;xhighandmaxare lowered tohighwith a warning.For claude-sonnet-5-5, budget-based thinking is converted to adaptive thinking.
For claude-sonnet-5-5, disabled thinking is replaced with between_tools thinking, with a warning.
For models that reject forced tool use, required and named tool choices fall back to auto, with a warning.
Provider metadata now includes raw Anthropic usage information.
Fixes and other changes 4
Final JSON text is preserved when a model does not call the JSON response tool, and tool preambles are kept out of structured output. Streaming buffers text until the message finishes.
Avoids forcing structured-output tools for incompatible Claude models on Amazon Bedrock.
Tool calls are preserved when using JSON structured output.
Client tool calls are ordered after provider-executed tool results.