npm / @ai-sdk/moonshotai
@ai-sdk/moonshotai
What changed in @ai-sdk/moonshotai 0.0 to 7, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
45 breaking11 deprecations16 new APIs and options2 performance16 behavior and defaults1 tooling16 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@ai-sdk/moonshotai 756 changes
Breaking changes 34
OpenTelemetry span collection is no longer built into the ai package. Install this package and register an OpenTelemetry instance globally to continue receiving traces.
System messages in prompt or messages are rejected by default; set allowSystemInMessages to true to retain the previous behavior for trusted messages.
CommonJS exports are removed; consumers using require() must switch to ESM import syntax.
Tool callbacks receive tool-specific context, inferred from contextSchema and supplied through toolsContext, replacing experimental_context. Shared generation or agent state now flows through runtimeContext.
Use customProvider instead of the removed experimental_customProvider export; its options and behavior are unchanged.
The deprecated option has been removed; replace it with activeTools.
The deprecated experimental_prepareStep option was removed; replace it with prepareStep.
The tracer property is removed from experimental_telemetry; pass a custom tracer to the OpenTelemetry constructor instead.
Use generateImage instead of the removed experimental_generateImage export.
Use GenerateImageResult instead of the removed Experimental_GenerateImageResult type export.
Top-level content, tool calls and results, files, sources, and warnings now accumulate values across every step. Use finalStep for final-step-only values.
Use isStepCount instead of stepCountIs in tool-loop stop conditions.
The deprecated function has been removed; replace usages with isToolUIPart.
CallSettings is split into LanguageModelCallOptions for model-facing options and RequestOptions for transport options.
The top-level cachedInputTokens field is removed; use inputTokenDetails.cacheReadTokens instead.
The top-level reasoningTokens field is removed; use outputTokenDetails.reasoningTokens instead.
The deprecated tool-result content part type has been removed. Use the file variant for inline tool-result file content.
The minimum supported Node.js version is raised to 22; supported versions are 22, 24, and 26.
Replaces onEmbedFinish in telemetry integrations and tracing-channel events for individual embedding model calls.
The callback follows the updated result shape: usage and content-related properties cover all steps, while final-step-only values are available on finalStep.
Replaces onRerankFinish in telemetry integrations and tracing-channel events for individual reranking model calls.
The generation start callback for generateText, streamText, and agents is renamed from experimental_onStart to onStart.
The per-step start callback for generateText, streamText, and agents is renamed from experimental_onStepStart to onStepStart.
The deprecated experimental_output option and result property were removed; use output for call options and read result.output.
Instructions returned from prepareStep now carry forward to future steps until another instructions or system override is returned.
Messages returned from prepareStep now become the base for subsequent steps, combined with the prior step's response messages.
Register a telemetry integration globally at application startup; this is required to receive OpenTelemetry traces and enables telemetry for AI SDK calls.
Request bodies are no longer included in generateText and streamText step results by default; generateText response bodies are also excluded. Opt in with include.requestBody and, for generateText, include.responseBody.
Each step's response.messages now contains only messages produced by that step, rather than accumulated history. Use result.responseMessages for the full response message history.
onChunk now receives every TextStreamPart, including lifecycle, boundary, and terminal parts; handlers that assume the previous subset should guard chunk types.
Telemetry becomes enabled by default for AI SDK calls once an integration is registered. Set isEnabled to false to opt out of a specific call, or register no integration to disable telemetry globally.
The deprecated type has been removed; replace usages with ToolExecutionOptions.
Replace totalUsage with usage, which now contains token usage across all steps.
generateText and streamText usage now totals token usage across all steps, matching the former totalUsage behavior. Use finalStep.usage for final-step-only usage.
Deprecations 10
Tool-result file content now has a canonical variant with a tagged data union and required mediaType; legacy image-* and file-* variants are deprecated and auto-migrated at runtime.
Final-step reasoning, request, response, and provider metadata are available through finalStep; their top-level result aliases are deprecated.
The user-message image part is deprecated; use a file part with image mediaType instead.
Move raw chunk inclusion from the top-level includeRawChunks option into include.rawChunks. The old option continues to work as a deprecated alias.
The top-level system prompt option and related prepareStep, repair, and lifecycle fields are renamed to instructions; system remains a deprecated fallback, and instructions takes precedence when both are provided.
The tool() and dynamicTool() property is deprecated. Move approval logic to the per-call or agent toolApproval setting.
Replaces onFinish as the final lifecycle callback for generateText, streamText, agents, embed, embedMany, and rerank. The old name remains a deprecated alias; onEnd takes precedence when both are provided.
Replaces onStepFinish for per-step lifecycle callbacks across generation, agents, and UI message stream helpers. The old name remains a deprecated alias for user-facing callbacks; onStepEnd takes precedence.
The full event stream returned by streamText is now available as stream. fullStream remains available as a deprecated alias.
Result methods for converting or piping UI and text streams are deprecated but still work in v7. Use stateless helpers exported from ai instead.
New APIs and options 2
The top-level option is the provider-agnostic way to control reasoning effort; overlapping providerOptions settings take precedence and can bypass it.
Models can return files in reasoning traces as a distinct part type. Update exhaustive part handling and account for these files in content or reasoning rather than result.files or step.files.
Behavior and default changes 9
mediaType accepts a full IANA type or a top-level segment; a subtype is auto-detected from inline bytes where possible.
The speech generation function graduated from experimental status and is now named generateSpeech; the old name remains a deprecated alias.
Replaces experimental_include for generateText, streamText, and ToolLoopAgent. The old name remains a deprecated alias; 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 fallback.
Replaces experimental_onToolCallStart as a tool execution callback for generateText and streamText. The old name remains a deprecated fallback.
The speech result type is now named SpeechResult; the old name remains a deprecated alias.
Replaces experimental_telemetry as the stable telemetry configuration option for AI SDK functions and agents. The old name remains a deprecated alias, and telemetry behavior is otherwise unchanged.
The transcription API graduated from experimental status and is now named transcribe; the old name remains a deprecated alias.
The transcription result type is now named TranscriptionResult; the old name remains a deprecated alias.
Tooling 1
Run the v7 codemod command from the project root to apply the available v6-to-v7 code transformations.
@ai-sdk/moonshotai 68 changes
Breaking changes 7
The function is async in AI SDK 6, so callers must await its result.
Provider method textEmbedding was renamed to embedding; update calls that select an embedding model.
Provider method textEmbeddingModel was renamed to embeddingModel; update calls that select an embedding model.
Function tool definitions no longer accept a name property; use the key in the tools object to set the function tool name.
The parameter is now an object with an output property; update implementations to destructure output.
Replaces Experimental_Agent; its system parameter is now instructions, and stopWhen defaults to isStepCount(20).
The unknown finish reason is removed and is now returned as other.
Deprecations 1
Renames ToolCallOptions; update references to the type.
@ai-sdk/moonshotai 323 changes
Breaking changes 3
For Kimi K3 models, unsupported reasoning levels now map to the closest supported level, rounding down when possible. Disabling reasoning maps to the model's lowest level with a compatibility warning.
Affected provider, parsing, and transport error paths that previously left the finish reason as other now report error.
Moonshot AI streams that end cleanly without the provider completion signal now report interrupted and preserve partial output without emitting an error solely for the interruption. Applications must handle this finish reason.
New APIs and options 7
Provider API key settings now support promises and synchronous or asynchronous callbacks, resolving credentials per authenticated request while preserving existing authentication behavior and synchronous credential serialization.
Provider token settings now support promises and synchronous or asynchronous callbacks, resolving credentials per authenticated request while preserving existing authentication behavior and synchronous credential serialization.
Reports cache write tokens.
Adds support for the kimi-k3.1-pro model.
Adds support for the kimi-k3.1-pro-highspeed model.
Adds support for prompt cache options.
Adds max as a portable reasoning level, widening LanguageModelV4CallOptions['reasoning'] and the derived ReasoningLevel type. Exhaustive switches and mappings must handle it.
Performance 1
Provider validation schemas are constructed on first use instead of during import, reducing package import time.
Behavior and default changes 3
Known model ID suggestions now derive from each provider’s model catalog declarations, so catalog updates automatically update autocomplete while preserving existing suggestions, endpoint-specific lists, and support for custom model IDs.
Unknown model IDs retain JSON schemas for structured output instead of silently falling back to JSON object mode, supporting future Moonshot models.
Provider config types make headers optional, allowing custom provider implementations to omit them when constructing model configs.
Fixes and other changes 9
Tool and response schemas now accept root unions of objects, including local $ref branches, while keeping a root type: "object" beside anyOf.
The User-Agent header now complies with standards.
Fixes streamed tool calls when their IDs are missing, blank, or repeated.
Preserves reasoning streams across empty tool-call deltas.
Preserves documented Moonshot API error codes in HTTP and streaming errors.
Preserves complete raw usage objects.
Prevents negative text output token counts when providers report reasoning tokens by treating Perplexity reasoning tokens separately from completion tokens.
Fixes handling of empty string tool call IDs.
Provider model classes include WORKFLOW_SERIALIZE and WORKFLOW_DESERIALIZE static methods, enabling models to cross workflow step boundaries without serialization errors.
@ai-sdk/moonshotai 215 changes
Breaking changes 1
Strict validation is enabled by default for Moonshot structured outputs.
New APIs and options 5
Adds provider-specific names for Moonshot AI system, user, and assistant messages.
Adds first-class support for Moonshot V1 auto and vision-preview model IDs while retaining support for custom and retired model IDs.
Adds Moonshot AI Partial Mode support for continuing a final assistant message.
Adds predicted output support.
Adds the Moonshot AI provider for use with the AI SDK.
Behavior and default changes 3
Adds support for Kimi K3 dynamic tool-loading system messages.
Maximum output tokens are sent using the current Moonshot request field.
Official Moonshot V1 models use native JSON Schema structured outputs.
Fixes and other changes 6
Choice-level usage is preserved in Moonshot streaming responses.
Moonshot streaming tool calls without indices are accepted.
Moonshot structured output schemas are normalized.
Unsupported image and video media types are rejected before Moonshot chat requests are sent.
Non-object root schemas now fail with a clear client-side error instead of Moonshot's opaque 400.
Tool schemas are normalized for Moonshot's MFJS validator: tuple items become prefixItems, and type next to anyOf moves into the branches. The original schema remains in use for AI SDK result validation.
@ai-sdk/moonshotai 0.05 changes
New APIs and options 2
Adds support for chat log probabilities.
Adds support for Moonshot predicted outputs.
Performance 1
Moonshot tool and response schemas normalize object items and rewritten tuple items once, avoiding repeated normalization.
Behavior and default changes 1
Supports Partial Mode for final assistant message prefixes.
Fixes and other changes 1
Preserves Moonshot chat response metadata in generated and streamed responses.