npm / @ai-sdk/gateway
@ai-sdk/gateway
What changed in @ai-sdk/gateway 2 to 7, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
62 breaking25 deprecations85 new APIs and options1 performance27 behavior and defaults2 tooling20 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@ai-sdk/gateway 784 changes
Breaking changes 47
OpenTelemetry span collection moved out of ai; install this package and register an OpenTelemetry instance globally to receive traces.
Top-level
generateTextandstreamTextresult content now accumulates across all steps; usefinalStep.contentfor final-step-only values.Renames the tool callback's experimental_context to context, now scoped and typed from the tool's contextSchema.
All packages are ESM-only; consumers using require() must switch to ESM import syntax.
This deprecated option is removed; replace remaining usages with
activeToolsingenerateTextandstreamTextcalls.The deprecated export was removed; use customProvider instead.
The deprecated export was removed; use generateImage instead.
The deprecated type export was removed; use GenerateImageResult instead.
The deprecated option and generateText result property were removed; use output for call options and result access.
The deprecated option was removed; use prepareStep instead.
Removes the tracer property; pass a custom OpenTelemetry Tracer to the OpenTelemetry constructor instead.
Top-level generated-file results now accumulate across all steps; use
finalStep.filesfor final-step-only values.Request bodies are no longer included in generateText and streamText step results by default; opt in with include.requestBody.
generateText no longer includes response bodies by default; opt in with include.responseBody.
The tool-loop stop condition helper is renamed from stepCountIs to isStepCount.
This deprecated function is removed; use
isToolUIPartinstead.Removes the deprecated top-level cachedInputTokens field; use inputTokenDetails.cacheReadTokens instead.
Removes the deprecated top-level reasoningTokens field; use outputTokenDetails.reasoningTokens instead.
The
redirectoption for HTTP and SSE transports now defaults to'error', rejecting redirects by default to help prevent SSRF; set it to'follow'if redirects are needed.The deprecated
{ type: 'media' }tool-result content part is removed; use afilepart for inline tool-result file content.Raises the minimum supported Node.js version to 22; supported versions are 22, 24, and 26.
Renames the telemetry integration callback and tracing-channel event type from onEmbedFinish to onEmbedEnd.
Renames the per-call completion callback for embed and embedMany from experimental_onFinish to onEnd.
Renames the per-call completion callback for rerank from experimental_onFinish to onEnd.
The
onEndcallback follows the updated multi-step result shape: usage and listed collections cover all steps, while final-step-only properties are available onfinalStep.Renames the telemetry integration callback and tracing-channel event type from onRerankFinish to onRerankEnd.
The generation start callback is renamed from experimental_onStart to onStart for generateText, streamText, and agents.
Renames the per-step lifecycle callback from onStepFinish to onStepEnd across text and object generation, agents, workflow agents, and UI message stream helpers.
The per-step start callback is renamed from experimental_onStepStart to onStepStart for generateText, streamText, and agents.
Instructions returned by prepareStep now carry forward to future steps until overridden, rather than applying only to the current step.
Messages returned by prepareStep now form the base for subsequent steps, combined with the previous step's response messages.
The cacheCreationInputTokens field was removed from generateText and streamText responses; use usage.inputTokenDetails.cacheWriteTokens and cacheReadTokens for cache token counts.
When reasoning is enabled with a value other than 'none', reasoning summaries now default to 'detailed'. Set this option to null to keep them disabled.
Register a telemetry integration globally at application startup to enable telemetry collection.
Use runtimeContext for shared generation or agent state visible to prepareStep, events, and step results; shared top-level context usage moves to this name.
Top-level sources now accumulate across all steps; use
finalStep.sourcesfor final-step-only values.Each step's response.messages now contains only messages produced by that step; use result.responseMessages for the full response message history.
Moves the deprecated top-level includeRawChunks option into the include object as rawChunks.
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 fields are rejected by default; move instructions to the top-level instructions option or opt in with allowSystemInMessages: true.
This deprecated type is removed; replace imports and references with
ToolExecutionOptions.Top-level tool-call results now accumulate across all steps; use
finalStep.toolCallsfor final-step-only values.Top-level tool-result results now accumulate across all steps; use
finalStep.toolResultsfor final-step-only values.Pass tool-specific context values keyed by tool name, separating them from shared generation or agent state.
generateTextandstreamTextresultusagenow totals token usage across all steps; usefinalStep.usagefor final-step-only usage.Top-level warnings now accumulate across all steps; use
finalStep.warningsfor final-step-only values.xai(modelId) and xai.languageModel(modelId) now use the xAI Responses API by default; use xai.chat(modelId) to keep using Chat Completions.
Deprecations 21
CallSettings is split into LanguageModelCallOptions and RequestOptions; replace usages with LanguageModelCallOptions & Omit<RequestOptions, 'timeout'>. The deprecated type remains available in v7.
The
@ai-sdk/vueChatclass is deprecated in favor of the reactiveuseChatcomposable.Google provider types, classes, and functions containing GoogleGenerativeAI were renamed to use Google; old names remain available as deprecated aliases.
Use the canonical tool-result content part with
mediaTypeand taggeddatato replaceimage-*and legacyfile-*variants; runtime auto-migration keeps existing outputs working.The user-message
{ type: 'image' }part is deprecated; use afilepart with imagemediaTypeinstead.The
tool()anddynamicTool()property is deprecated; move approval logic totoolApprovalon the call or agent.Renames the final lifecycle callback from onFinish to onEnd for generateText, streamText, agents, and ToolLoopAgent settings; onFinish remains a deprecated alias, and onEnd takes precedence.
Renames experimental_onToolCallFinish for generateText and streamText; the old name remains a deprecated fallback.
Renames experimental_onToolCallStart for generateText and streamText; the old name remains a deprecated fallback.
The
streamTextresult method is deprecated; use the stateless top-level helper to pipe a text stream to a Node.js response.The
streamTextresult method is deprecated; use the stateless top-level helper to pipe a UI message stream to a Node.js response.The top-level final-step provider metadata result property is deprecated; use
finalStep.providerMetadata.The top-level final-step reasoning result property is deprecated; use
finalStep.reasoning.The top-level final-step reasoning text result property is deprecated; use
finalStep.reasoningText.The top-level final-step request result property is deprecated; use
finalStep.request.The top-level final-step response result property is deprecated; use
finalStep.response.Renames the full event stream property from fullStream to stream; fullStream remains available as a deprecated alias.
This result property is deprecated; use
usagefor total token usage across all steps.The
streamTextresult method is deprecated; use top-level stateless text-stream helpers to create the response.The
streamTextresult method is deprecated; use the stateless top-level helper, which can transform any stream.The
streamTextresult method is deprecated; compose top-level stateless helpers to create the UI message stream response.
New APIs and options 7
Declare tool-specific context fields with contextSchema so tool callbacks receive typed context scoped to that tool.
The top-level system prompt option is renamed from system to instructions across functions accepting prompt or messages; system remains a deprecated fallback, and instructions takes precedence when both are provided.
The callback receives instructions for the current step and initialInstructions for the top-level instruction value.
Use the top-level
reasoningoption for provider-agnostic reasoning effort and remove overlapping settings fromproviderOptions, which take precedence if both are present.Models can return files in reasoning as a distinct content type; update exhaustive part handling and account for these files in
contentorreasoningrather than generated-file lists.Move tool approval policy from
needsApprovalontool()ordynamicTool()to per-call or agenttoolApproval, allowing policy to vary by request.The Vue composable exposes reactive refs and recreates the underlying chat when its init object changes, so reactive inputs can flow through without manual orchestration.
Behavior and default changes 8
Repair-tool-call options use instructions instead of system for the current system instructions.
The speech generation function graduated from experimental status and is available under the stable name generateSpeech; the old name remains a deprecated alias.
Renames experimental_include to include for generateText, streamText, and ToolLoopAgent; the old name remains a deprecated alias.
The speech result type has a stable name; the old name remains a deprecated alias.
Telemetry is enabled by default for AI SDK calls once an integration is registered; set isEnabled to false per call to opt out.
Renames experimental_telemetry to telemetry; the old name remains a deprecated alias during the migration window.
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; the old name remains a deprecated alias.
Tooling 1
Run this command to add the migration skill and guide your agent through migrating from AI SDK 6 to 7.
@ai-sdk/gateway 497 changes
Breaking changes 10
AI Gateway access_policy_denied responses (HTTP 403) now map to this error instead of GatewayInternalServerError; it supports isInstance(error) and exposes policyIds, removedModels, and removedProviders when present.
Corrects the result type and schema to match the gateway response, including renamed fields, nullable values, and optional metadata; update code reading removed fields.
Arrays passed directly as state now contain decision state parts; wrap JSON arrays in an object or a json part.
The API name evaluate was renamed to decide.
Unsupported batch request types are now rejected.
Support for Imagen models and their integration was dropped following the API shutdown.
The baseUrl option has been removed from all providers; use baseURL instead.
Changes file part data to be tagged with a type and removes the image part type.
Mints a single-use, short-lived client secret instead of returning the long-lived Gateway credential; expiresAfterSeconds is forwarded and expiresAt is returned.
Forbidden error responses are now mapped to GatewayForbiddenError instead of GatewayInternalServerError.
Deprecations 1
Deprecated in favor of the top-level maxCharsTotal option.
New APIs and options 59
Adds support for the GPT-6.2 Astra model.
Adds support for the GPT-6.2 Sol model.
Adds the Hydrogen model ID, supports its xhigh thinking level in Google Generate Content and Interactions provider options, and maps portable reasoning: 'xhigh' to xhigh only for Hydrogen models.
Adds support for gemini-4-carbon with the same capabilities as gemini-4-argon.
GatewayRealtimeModel provides a server-side realtime WebSocket URL and Authorization header auth, with optional team scoping for trusted server-side clients.
Opt in to streaming decoding of canonical base64 images of at least 64 KiB. Extracted images are returned as Uint8Array; smaller images stay base64 strings, and mixed results are normalized to bytes.
Adds Search and Fetch tools for DeepSeek.
Tako tool errors now accept the gateway_rate_limit case, which exhaustive error switches may need to handle.
Parallel and Tako tool errors gain an optional retryAfter field.
Parallel and Tako tool errors gain an optional statusText field.
API key and token settings now support promises and synchronous or asynchronous callbacks, resolving credentials per authenticated request while preserving existing authentication behavior and synchronous credential serialization.
Adds support for the GPT-6.1 Terra model.
Added kimi-k3.1-pro support to the Moonshot AI provider.
Added kimi-k3.1-pro-highspeed support to the Moonshot AI provider.
Adds experimental streaming speech through the AI Gateway speech WebSocket, callable like speech(modelId); server-side getToken() mints a short-lived speech-bound client secret for browser use.
Adds Voxtral 3 offline transcription and speech model IDs, transcription context phrases and detected language, updated timestamp validation, and speech expressiveness and pronunciation hints.
Adds fetchPolicy.disableCacheFallback.
Adds fetchPolicy.timeoutSeconds.
Adds the location option.
Adds top-level maxCharsTotal; excerpts.maxCharsTotal is deprecated in favor of it.
Accepts the turbo, fast, basic, and advanced modes; one-shot and agentic remain accepted but are deprecated.
Experimental decision calls accept maxOutputTokens and forward it to language-model-backed decisions; native decision providers warn when it is unsupported.
The MiniMax M3.1 Flash model ID is now available in the MiniMax and AI Gateway providers.
Experimental decision calls accept reasoning and forward it to language-model-backed decisions. Language-model adapters keep reasoning disabled when omitted; native decision providers warn when it is unsupported.
Adds support for the GPT-6.1 Sol model.
GatewayProviderOptions now accepts conditional evaluation fallbacks.
Gemini 3.8 speech model IDs were added to Gateway types.
Adds model IDs for GPT-6 Sol and Luna.
Adds support for cancelling batches with experimental_cancelBatch.
Adds the Grok 4.7 model ID.
The has model filter now supports reasoning.
The has model filter now supports tool-use.
Image generation requests are now supported in batches.
Batch requests can now use per-request models.
Adds support for the gpt-6-astra model in the gateway.
Adds support for Fable 5.1, allowing developers to use it through the Gateway.
Accepts a webhookUrl for batch completion webhooks; the gateway provider registers it through the batch callbackUrl contract.
Adds Tako Search tool support to the gateway provider.
DeepSeek V4 Flash Vision Exp now supports image input.
DeepSeek V4 Flash Vision Exp now supports the Files API.
Adds experimental batch API support through the AI Gateway batch routes, with methods to start text batches and check their status and results.
Adds the disallowPromptTraining Gateway provider option.
Adds support for the Exa search tool through the Gateway provider.
Adds optional Vercel team scoping for Gateway authentication; apiKey accepts AI Gateway API keys, Vercel personal access tokens, and Vercel app access tokens.
Adds a constant for the Gateway realtime subprotocol authentication contract.
Adds bidirectional audio/text realtime sessions routed through the AI Gateway using the normalized AI SDK realtime protocol.
Adds GatewayFailedDependencyError for HTTP 424 responses.
Adds get-generation support to the Gateway provider.
Adds the server-side decoder for the versioned Gateway realtime subprotocol authentication contract.
Adds the client-side encoder for the versioned Gateway realtime subprotocol authentication contract.
Adds the hipaaCompliant Gateway provider option.
Adds sort options for Gateway models.
Adds the quotaEntityId Gateway provider option.
Adds the qwen3.7-max model ID to AI Gateway.
Adds reranking() support for Gateway reranking models.
Adds rerankingModel() and reranking() methods for Gateway reranking model support.
Adds serviceTier values flex and priority to GatewayProviderOptions.
Adds speech and transcription model support to the Gateway provider.
Adds spend reporting support to the Gateway provider.
Behavior and default changes 11
String model ids passed to experimental_extract now resolve through the AI Gateway by default.
Results include optional marketCost, surchargeCost, and gatewayCost fields from the AI Gateway generation lookup API; unavailable fields are omitted.
The gateway adapter warns when shared timestampGranularities requests are not forwarded.
Tako tool errors now accept the unknown case, which exhaustive error switches may need to handle.
Now accepts Parallel Search results.
The gateway sends image files in decision state.
Decision refusals are reported as refusal answers.
Conditional evaluation fallback models with any non-empty value are now accepted.
The has provider option now supports quantization conditions.
The video model now implements handleWebhookOption, so generateVideo({ webhook }) registers the factory URL as callbackUrl and awaits delivery instead of falling back to polling.
Provider warnings are surfaced in embedding and reranking responses.
Tooling 1
Conditional evaluation fallbacks are now typed in the Gateway provider.
Fixes and other changes 15
Restores this deprecated optional field on takoSearch results so code that reads it compiles again; Tako always sends 0 and will stop sending it.
The headquarters provider option is now typed.
Transcription responses preserve optional normalized word timings.
Image and video models pass through seed: 0 instead of dropping it; KlingAI reports it as an unsupported setting like any other seed.
Video generation and status responses accept explicit uploaded-video outcomes.
Preserves AbortError and TimeoutError cancellation reasons in speech and transcription input streams, propagating them to output streams without leaving reads pending or causing unhandled rejections.
Batch result downloads limit JSONL rows to 64 MB.
getCredits() now forwards the configured team as a query parameter, preventing authentication errors for credentials that can access multiple teams.
getAvailableModels() now includes evaluation models instead of filtering them out as unknown model types.
The gateway provider now forwards server-returned warnings in doGenerate instead of overwriting them with an empty array.
Preserves retryability returned by the AI Gateway for image results.
Transient network errors while reading successful response bodies are now marked retryable, including for AI Gateway responses.
Gateway errors now support retries.
Adds reranking to modelType validation and types so getAvailableModels() accepts Gateway reranking models.
The Gateway model list is resilient to unknown model types.
@ai-sdk/gateway 332 changes
Breaking changes 5
Removes excerpt, which was never populated.
Removes publishDate, which was never populated.
Removes relevanceScore, which was never populated.
Removes searchId, which was never populated.
The package has a major version bump for AI SDK v6.
Deprecations 3
Marks export_pricing.free_rows as deprecated and optional; Tako always sends 0 and will stop sending it.
The agentic mode is deprecated but remains accepted.
The one-shot mode is deprecated but remains accepted.
New APIs and options 17
Adds the gemini-4-hydrogen model ID for Google Generate Content and Interactions.
Adds support for Hydrogen's xhigh thinking level in Google Generate Content and Interactions provider options.
Adds types for premium pricing fields.
Adds a type for relevance_score.
Adds types for Tako placeholder cards.
Adds the developer-only extraBody option to takoSearch.
Adds the developer-only maxVariableCostUsd option to takoSearch.
Adds the developer-only variableCost option to takoSearch.
Adds a type for usage.variable_cost.
Adds a provider option for resuming responses that used up their maxOutputTokens budget.
Adds the gemini-4-argon model id.
Exposes the first request's prompt token count in Google provider metadata.
Adds Browserbase Search and Fetch tool support.
The has provider option now supports quantization conditions.
Model filtering with has now supports reasoning and tool-use.
Added the gemini-3.8-flash model for use with the Google provider.
Adds support for the GLM-5.3-Flash model through the Z.AI provider and AI Gateway.
Performance 1
Validation schema construction is deferred until first use to reduce provider import time.
Behavior and default changes 4
generateText with the Interactions API now polls background model calls until they finish.
Requests that reach the per-request CONTINUATION cap continue automatically, with usage summed across requests.
The has provider option now accepts structured-output.
Retryability classification is provider-independent and preserved through the AI Gateway; Google and Google Vertex content-filtered results are terminal.
Fixes and other changes 2
Cancellation reasons AbortError and TimeoutError are preserved instead of being wrapped in retryable GatewayResponseError errors with status 500.
Unclassified empty image results are retried, and retry-attempt accounting is preserved.
@ai-sdk/gateway 29 changes
New APIs and options 2
Adds meta/muse-ember to the available language model IDs.
Adds a provider option and provider metadata for resuming responses that used up their maxOutputTokens budget.
Behavior and default changes 4
Requests that reach the per-request CONTINUATION cap are continued automatically, with usage summed across requests and the first request's prompt token count exposed.
Thinking can be disabled up to high effort; when disabled, xhigh and max effort are lowered to high with a warning.
Thinking token budgets are unsupported; enabled thinking with budgetTokens is converted to adaptive thinking with a warning.
Adds provider-independent retryability classification and preserves it through the AI Gateway.
Fixes and other changes 3
Diagnostics from completed attempts are preserved, making them available after retries.
Unclassified empty image results are retried, changing how image-generation failures are handled.
Google Vertex RAI-filtered results are marked terminal, so they are not treated as retryable.