npm / ai
ai
What changed in ai 5 to 7, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-17.
ai 7243 changes
Breaking changes 17
Public state forms are normalized into parts before providers are called, with text and JSON objects mapped to text and json parts.
Arrays passed directly as state are interpreted as decision state parts; JSON arrays must be wrapped.
TypeSafe AI rejects file inputs in decision state.
The evaluate API was renamed to decide.
Undetermined generated audio formats now throw InvalidResponseDataError instead of a generic Error.
Provider-executed tool errors bypass the UI stream onError callback, while stream errors and invalid tool calls still invoke it.
Together AI Gemini image inputs are marked unsupported by the current single-image request mapping.
Packages are compiled for an ES2022 runtime target, which may affect the runtime environment required by developers.
URL MIME types are matched exactly so unsupported subtypes are not forwarded to providers.
Histories whose reconstructed schema output differs are rejected, including signed approvals with missing original input.
addToolOutput now rejects continuous sessions.
sendTextMessage now rejects continuous sessions.
Utility input validation now uses InvalidArgumentError, changing the error developers may need to handle.
Unsupported batch request types are now rejected.
Embedding model responses containing no embeddings are now rejected.
Batch operations now support selecting models per request.
Tool execution no longer starts automatically when a model call ends with an unsafe finish reason.
Security 7
Unavailable tools no longer expose persisted output to models.
Default stream reconnection URLs encode chat IDs, reject standalone dot IDs, and preserve custom URLs unchanged.
Tracing-channel context is now filtered according to telemetry allowlists.
URL-backed language model file outputs are securely downloaded and expose actual base64 and byte content, with valid data URLs in UI streams.
Prevents direct execution of tools governed by tool callers.
Default Node.js downloads retain DNS validation and connection pinning when global fetch is wrapped before or after SDK loading.
Prevents streamText from executing tool calls that violate tool choice.
Deprecations 2
Deprecation warnings now use stable codes and are deduplicated.
rawInput is deprecated in output-error UI message parts.
New APIs and options 61
Adds configurable concurrency for tool call execution.
Adds an optional shared citation representation across generated text, stream events, result content, and UI message text parts.
Embedding functions accept a new top-level dimensions setting.
Adds persistent WebSocket chat transport with correlated streaming, backpressure, cancellation, protocol validation, lifecycle handling, and sequence-based resume support.
Experimental decision state now supports ordered text, file, and JSON parts.
OpenAI Decisions and language model adapters now support image input.
Introduces a callback for persisting messages when a UI message step ends.
Adds portable max reasoning with native provider mappings, compatibility coercions, and budget-based fallback support.
ReasoningLevel now includes max, so exhaustive switches and Record mappings must handle the new value.
extractReasoningMiddleware supports custom reasoning delimiters.
WorkflowAgent gains durable non-streaming generation with a shared tool loop, typed output, and a 20-step default.
Tool search can select and rank eligible deferred tools through a search callback.
Tool search supports configuring the maximum number of returned tools.
Experimental streaming lifecycle callbacks were added for speech generation and transcription.
File-input support is advertised for QuiverAI Arrow 2 and Arrow 2 Telos.
Single-image editing capability is included for Together AI FLUX.2 Pro and Flex.
Gemini TTS supports explicit A-law output.
Gemini 3.8 TTS support adds structured speech metadata and per-turn speaker and style controls for prebuilt voices.
Gemini TTS supports explicit mu-law output.
Gemini TTS supports explicit raw PCM output.
customProvider now accepts evaluationModels for experimental evaluation model aliasing and registry resolution.
Registries now expose evaluationModel for evaluation-capable model resolution.
Adds a native tool search tool for applications that need tool discovery.
Adds experimental evaluation of Choice, Score, and Boolean questions against shared state with typed answers and validation.
Adds an error for unsupported evaluation question types.
Applications exchange WebRTC SDP through an application endpoint using api.session.
Experimental client-delegated Live conversations can use browser-direct WebRTC alongside the existing WebSocket path.
The unified factory adds experimental OpenAI Live provider support for server WebSocket sessions with client delegation.
An OpenAI-specific api override is available for early-access models.
Typed AI SDK errors are exposed for UI transport and completion failures.
Image generation requests are now supported in batches.
A type guard for tool output errors was added alongside a stable UI message type.
A stable UI message type and a type guard for tool output errors were added.
Batch cancellation and listing APIs were added for managing batches.
Adds an API for canceling batches.
Adds an API for listing batches.
Array outputs now support maxItems constraints.
Array outputs now support minItems constraints.
onLanguageModelCallStart is formally included in the ToolLoopAgentSettings type.
Adds configurable recovery for provider errors after response streaming begins, with isolated retry attempts and successful-attempt-only results and metadata.
Adds a bounded callback-directed recovery path for streamed provider errors when streamRetries is configured to 0.
Upload results now expose the uploaded file size.
Provider-utils adds a handler for binary stream responses.
Upload results now expose the file creation timestamp.
FilesV4 now supports optionally deleting files.
FilesV4 now supports optional streaming file downloads.
Upload results now expose the file expiration timestamp.
FilesV4 operations can receive an abort signal for cancellation.
FilesV4 operations can receive custom request headers.
FilesV4 now supports optionally retrieving file metadata.
Provider-utils adds streaming multipart uploads with deterministic part ordering and failure-path stream teardown.
Uploads can use a stream data variant for streaming uploads.
Batch operations now support tool calling.
WorkflowAgent now supports signed tool approvals.
Anthropic batch requests now support the full language-model option surface.
Individual image generation calls are now exposed for direct use.
UI message stream end callbacks now provide operation-level outcomes.
UI messages retain the optional approval request reason separately from an approver's response reason.
Manual tool approval statuses can include a reason that is preserved across core, model, and UI approval requests.
The gateway provider registers batch completion webhooks through the batch callbackUrl contract.
Batch completion webhooks can be configured with a webhook URL.
Behavior and default changes 29
Streamed custom-tool input is marked as text so UI clients can display it progressively without JSON parsing.
A warning is logged when the default step limit stops a tool loop.
Model-call spans now record normalized state parts, while outer spans retain public state inputs.
Decision file bytes are serialized as base64 in OpenTelemetry state attributes.
Shared state is labeled in language-model decision prompts.
Decision refusals are reported as refusal answers.
Portable minimal, xhigh, and max retain or receive provider mappings and now return compatibility warnings.
Speech generation and transcription now include telemetry and provider usage propagation.
Provider capability declarations advertise file and mask input support using confirmed model IDs.
Newer and custom model IDs default to structured speech, while legacy formats remain for older models.
UI message stream end callbacks now report consumer cancellation.
Adds telemetry support to experimental_evaluate.
Accepts string model IDs when an evaluation-capable default provider is explicitly configured; evaluation does not implicitly fall back to Gateway.
Tool search now supports direct tool calling.
Code-mode can discover and update tools during a conversation.
Live continuous sessions enforce 128 KiB frame and combined buffered-send budgets using actual encoded wire bytes.
Known Live model IDs route to Live, while unknown IDs retain legacy Realtime defaults.
maxPlaybackBufferSeconds is supported only for continuous PCM sessions.
Runtime context attribution was added to embed, embedMany, and rerank operations.
Runtime context attribution was added to embed, embedMany, and rerank operations.
Runtime context attribution was added to embed, embedMany, and rerank operations.
Google and Google Vertex prompt blocks are now treated as terminal.
Retryability classification is provider-independent and preserved through the AI Gateway.
The core uploadFile helper now forwards abortSignal and headers options.
Parsed structured output is now exposed in streamText end callbacks.
Chats can continue automatically after tool approval denials reach the output-denied state.
OPA requires-approval decisions now surface their reason to human approvers.
Preliminary tool outputs are filtered when ignoreIncompleteToolCalls is enabled.
Chat status remains submitted until response content begins streaming.
Fixes and other changes 127
Raw OpenAI custom-tool input deltas are restored for consumers forwarding them to Responses API clients.
The text encoding is preserved when partial UI messages are saved and resumed.
Workflow now passes runtime context when telemetry.includeRuntimeContext allows it.
Rejects approved tool calls without results before sending later context to providers.
Fixes validation of rounded choice probabilities.
Prevents duplicate message parts when replayed streams are resumed.
Reports incomplete model streams with no output as errors.
Updates streaming chat messages by stable ID.
Updates tool outputs in the message containing the matching tool call.
Prevents a second resume request on mount when a chat is already submitted or streaming.
Discards unrelated message state when reading resumed streams.
chunkMs and firstChunkMs stop when model responses end, retries receive fresh timeout budgets, and stepMs still covers local tools.
Stopping now waits for chat stream cleanup to complete.
Repeated tool approval responses no longer trigger duplicate continuation requests.
Provider-executed tool calls are preserved when streams are resumed.
Async sendAutomaticallyWhen failures from tool updates are now propagated.
Gateway keeps its existing string and JSON request format and rejects file inputs.
Pending result promises are rejected and pending streams are canceled when the abort signal fires.
Nova 2 portable xhigh now sends maxReasoningEffort high instead of max and returns a compatibility warning.
Chat reconnect URLs no longer contain duplicate slashes.
Provider options are now preserved from approval-only tool messages.
V2 provider-reported total tokens are now preserved in raw usage.
The latest error is now published after repeated failed stream resume attempts.
WebKit network errors are now recognized.
Silent audio now returns successful empty transcripts.
Tool approval state is preserved when resuming streams.
Tool approval inputs created in another JavaScript realm are accepted when unchanged.
Merged UI message streams are canceled when the consumer disconnects.
Tool approvals are cleared when addToolOutput runs.
Partial reasoning tags are preserved when streamed text parts end.
Pending tool approvals superseded by user messages are ignored.
All tool content is pruned when retaining zero trailing messages.
Idle UI message streams remain open through optional SSE heartbeats.
Active UI message parts now continue when resuming after a disconnect.
Tool metadata is now preserved from tool output chunks.
Response streams are canceled when clients disconnect.
Static tool input errors are stored in the current input field.
Unhandled stream completion rejections are prevented in non-Node runtimes.
Original opaque URI strings are preserved in tagged file URLs during prompt conversion.
Google embedMany calls with more than 100 values now preserve multimodal alignment across automatic batches.
Content length is validated before Google embedding requests are sent.
Each automatic batch validates provider options after middleware transforms them.
Headerless audio formats are identified correctly.
Direct transport stream callbacks now preserve message history.
Empty speech transcripts are rejected before requests are sent.
Completed streamed tool input callbacks are routed to repaired tools.
Tool approvals can resume from earlier messages.
Manually approved tool inputs produced by schema transforms are executed while preserving approved inputs during revalidation.
Transformed UI tool inputs are validated against reconstructed output before returning them as static tool parts.
Video models are preserved when using legacy fallback providers.
Native WAV responses are preserved without adding a second header.
Opaque file URI strings are preserved during provider serialization.
UI message validation now preserves parsed metadata and data values.
Reasoning file parts are now pruned when reasoning is removed.
Cancellation is propagated to batch file downloads.
Reasoning extraction streams now preserve overlapping text blocks.
Replacement completion requests remain loading and cancellable when an earlier request settles.
Validated toolsContext is forwarded to host-executed tools in alignment with ToolLoopAgent.
Stops pending tool-call repairs when generation is cancelled.
Preserves file data when adapting v3 language models.
Base64 text data URLs are decoded using their declared charset.
Query parameters are preserved in chat reconnect URLs.
Chat transport requests no longer include duplicate content types.
Input callbacks receive tool-specific context.
Preliminary tool outputs no longer complete chats prematurely.
Raw speech audio format metadata is preserved.
Node stream responses preserve multiple Set-Cookie headers.
Polling timeouts are enforced for in-flight video status requests.
WorkflowAgent supports deferred tool discovery.
Provider file and skill upload APIs are preserved when using wrapProvider.
Input available callbacks are skipped for invalid streamed tool calls.
Null and empty-string JSON partial outputs are now streamed.
onEnd is no longer called after aborting a multi-step text stream.
Streamed step results now report the model selected by prepareStep.
Prompt attachment downloads are canceled when model calls are aborted or time out.
Provider metadata is preserved when simulating text streams.
Serialized tool outputs now preserve properties named after object prototypes.
Streamed JSON fences are stripped before arbitrary trailing whitespace.
Streamed response metadata fallbacks now use the model selected by prepareStep.
Structured output is streamed from the final tool-loop step.
Telemetry spans are closed when provider response streams fail.
Tool calls required by retained pending approvals are preserved.
Unhandled rejections are prevented when reading a UI message stream stops early.
Evaluation model IDs are resolved through AI Gateway when no default provider is configured, including string aliases in custom providers.
Abnormal realtime WebSocket close diagnostics are now reported through onError.
Oversized manual operations remain recoverable, while startup and automatic audio failures close the session.
Abnormal realtime WebSocket close codes and reasons are reported through the session error path.
Automatically denied tool calls in UI streams now settle instead of remaining unresolved.
Tool output JSON values are now serialized.
Invalid reranking provider indices are now rejected.
validateUIMessages now accepts inferred tools.
Receiver rejections are observed before generation starts, preventing unhandled rejections while preserving start error precedence.
Calls atob without a receiver for Cloudflare Workers compatibility.
Unclassified empty image results are retried.
Retry-attempt accounting is preserved during result retries.
Abort signals are supported when the global AbortSignal is not a constructor.
Embedding responses are rejected when their count does not match the input values.
Image call diagnostics are preserved when no image is generated.
Provider metadata is preserved when failed tool calls are converted.
Replacing a message in sendMessage now uses a new message ID.
Text data URLs are now decoded in Node.js.
onLanguageModelCallEnd is formally included in the ToolLoopAgentSettings type.
Tool part titles are preserved when UI messages are validated.
Fallback errors are surfaced when HTTP responses have empty bodies.
Skips smoothStream delays while the document is hidden.
Provider metadata stays on corresponding smoothStream chunks without carrying into later metadata-free deltas.
onAbort callbacks now expose the call ID and abort reason.
generateText no longer accepts responses that violate required tool choices.
Approval descriptors are preserved in UI message streams.
Canonical hashes now preserve the positions of undefined elements in arrays.
Gateway now sums image-generation costs across split requests.
Anthropic provider metadata now preserves native message batch request counts.
Tool approval secrets are now allowed in prepareCall.
smoothStream now handles stateful and empty-match regular expressions.
Tool approval secrets are now allowed in ToolLoopAgent settings.
Stream cancellation is handled when it occurs before an inner stream is registered.
Persisted typed tool calls are validated against current schemas, with incompatible history loaded as dynamic tool parts.
Structured output is parsed when providers return text without a finishReason.
Active text and reasoning parts are preserved when another merged UI message stream finishes a step.
Continues approved generateText, streamText, and WorkflowAgent turns with a model-visible tool error when revalidated tool input is invalid.
Allows nullish metadata schemas for UI messages with branded IDs.
Prevents duplicate IDs for text and reasoning parts.
Exceptions in streaming onChunk and onError callbacks no longer terminate the stream or mask provider errors.
Multi-step text generation now stops for client tool approval when a provider-executed tool has a deferred result.
Result promises are rejected and failed completion is reported when the provider stream errors.
Partial UI message parts are cleared when a WorkflowAgent model-call step is retried.
Declaration emit now works for exported values that infer an Output type.
ai 623 changes
Breaking changes 3
Automatic chat resumption no longer occurs when completed tool output is followed by terminal text without completed stream state.
Inherited names no longer resolve as registered providers.
Rejects responses that do not satisfy a required or specifically selected tool choice.
Security 1
Unavailable tools, including names matching Object.prototype properties, no longer expose persisted output to models.
New APIs and options 3
Streamed input is marked as text so UI clients can display it progressively without JSON parsing.
Exposes normalized response content for opt-in recovery from tool choice violations.
Allows tool approval secrets in ToolLoopAgent settings and prepareCall.
Performance 1
Avoids repeatedly cloning accumulated text while preserving independent snapshots for mutable nested values.
Behavior and default changes 1
Google and Google Vertex content-filtered results are treated as terminal and are not retried.
Fixes and other changes 14
Final provider tool-call inputs remain JSON-encoded after streamed input uses text encoding.
Prevents global type conflicts when multiple SDK versions are used.
Hydrated partial static tool input is preserved across stream resumptions.
Custom URLs returned by prepareReconnectToStreamRequest remain unchanged.
Prototype-named tools are preserved as own properties without changing lookup object prototypes.
Agent UI streams can use original messages as input.
Preserves media types on tool result file URLs and matches full MIME types exactly when checking native URL support.
Google embedMany now keeps per-value multimodal content aligned across automatic batches and validates content and provider options.
Streamed tool input callbacks now await start and delta callbacks before onInputAvailable on newer Node.js versions.
Retry-attempt accounting is preserved during image-result retries.
Approved turns continue with a model-visible tool error when revalidated tool input is invalid.
Aborted, errored, or cancelled calls no longer retain per-call state through abort cleanup listeners.
Exceptions in streaming onChunk callbacks no longer terminate the stream or mask provider errors.
Exceptions in streaming onError callbacks no longer terminate the stream or mask provider errors.
ai 512 changes
Breaking changes 2
Prototype-named tools and providers are preserved as own properties, while inherited names no longer resolve as registered providers.
createTestServer and TestResponseController are no longer re-exported here; import them from @ai-sdk/test-server/with-vitest instead.
Security 1
Deleted tools named after Object.prototype properties no longer expose persisted output to models.
New APIs and options 1
Exported isDynamicToolUIPart from the ai package, making it available for application code.
Behavior and default changes 3
Diagnostics from completed attempts are preserved, giving developers more information when retries occur.
Google Vertex RAI-filtered results are treated as terminal and are not retried.
OpenAI and Azure OpenAI embedding requests are split by a conservative UTF-8 byte budget derived from aggregate token limits, alongside input count limits.
Fixes and other changes 5
Prototype-named provider metadata no longer causes image metadata aggregation to fail.
Result retryability classification is preserved through the AI Gateway.
Manual continuations can reuse JSON tool outputs containing undefined object properties.
Transient network errors while reading successful response bodies are now marked retryable, including AI Gateway responses.
Mocks now return configured results in order starting with the first call.