npm / @ai-sdk/openai-compatible
@ai-sdk/openai-compatible
What changed in @ai-sdk/openai-compatible 1 to 7, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
48 breaking3 security21 deprecations25 new APIs and options1 performance19 behavior and defaults33 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@ai-sdk/openai-compatible 770 changes
Breaking changes 35
The package is ESM-only; consumers using require() must switch to ESM import syntax.
OpenTelemetry span collection moved out of the ai package; install this package and register an OpenTelemetry instance to receive traces.
Tool callback context is now tool-specific, stable, and typed from contextSchema; provide per-tool values through toolsContext rather than shared runtime data.
The deprecated experimental_activeTools option is removed; replace remaining usages with activeTools.
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 generation start callback is renamed to onStart for generateText, streamText, and agents.
The per-step start callback is renamed to onStepStart for generateText, streamText, and agents.
The deprecated option and generateText result property were removed; use output for both call options and result access.
The deprecated option was removed; use prepareStep instead.
The tracer property is removed from experimental_telemetry; pass a custom tracer to the OpenTelemetry constructor instead.
Top-level content, tool, file, source, and warning properties now accumulate values across every step; use finalStep for 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 stop-condition helper is renamed from stepCountIs to isStepCount.
The deprecated function is removed; replace usages with isToolUIPart.
The deprecated top-level cachedInputTokens field is removed; use inputTokenDetails.cacheReadTokens instead.
The deprecated top-level reasoningTokens field is removed; use outputTokenDetails.reasoningTokens instead.
The deprecated tool-result content part type is removed; use the file variant with a tagged data value for inline file content.
The minimum supported Node.js version is 22; supported versions are 22, 24, and 26.
Replaces onEmbedFinish in telemetry integrations and tracing-channel event types.
The callback follows the updated result shape: usage and content-related properties cover all steps, while final-step-only properties are available on finalStep.
Replaces onRerankFinish in telemetry integrations and tracing-channel event types.
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 and are combined with the previous step's response messages.
Register a telemetry integration globally at application startup to enable telemetry collection.
Use runtimeContext for shared generation or agent state visible to orchestration, events, and step results, separate from tool-specific context.
Each step's response.messages now contains only messages produced by that step; use result.responseMessages for the full response history.
onChunk now receives every TextStreamPart, including lifecycle, boundary, and terminal parts; handlers may need to guard chunk types.
System messages in prompt or messages are rejected by default; use the top-level instructions option, or opt in with allowSystemInMessages for existing trusted histories.
Configure per-tool approval on the call or agent, keeping approval policy close to generation and allowing it to vary by request.
The deprecated ToolCallOptions type is removed; use ToolExecutionOptions for imports and type references.
Pass tool-specific context values through toolsContext, keyed by tool name; it becomes required when at least one tool declares contextSchema.
generateText and streamText usage now totals token usage across all steps; use finalStep.usage for final-step-only usage.
Deprecations 19
CallSettings is split into LanguageModelCallOptions and RequestOptions; its deprecated type remains available.
Tool-result file content uses one canonical file variant with a tagged data union and required mediaType; legacy variants are runtime-migrated.
The user-message image content part is deprecated; use a file part with an image mediaType instead.
The tool-level needsApproval property is deprecated; move approval logic to toolApproval on the call or agent.
Replaces onFinish as the final lifecycle callback for generateText, streamText, agents, embed, embedMany, and rerank; onFinish remains a deprecated alias.
Replaces onStepFinish as the per-step lifecycle callback; the old name remains a deprecated alias for user-facing callbacks.
The streamText result method is deprecated; use the top-level stateless helper instead.
The streamText result method is deprecated; use the top-level stateless helper.
The top-level final-step provider metadata result property is deprecated; read it from finalStep instead.
The top-level final-step reasoning result property is deprecated; read it from finalStep instead.
The top-level final-step reasoning text result property is deprecated; read it from finalStep instead.
The top-level final-step request result property is deprecated; read it from finalStep instead.
The top-level final-step response result property is deprecated; read it from finalStep instead.
The top-level includeRawChunks option is deprecated; move it to include.rawChunks.
The full event stream property is renamed to stream; fullStream remains available as a deprecated alias.
totalUsage is deprecated; use usage for token totals across all steps.
The streamText result method is deprecated; use the top-level stateless text-stream helpers instead.
The streamText result method is deprecated; use the stateless top-level helper to transform any stream.
The streamText result method is deprecated; compose the top-level stateless stream helpers instead.
New APIs and options 5
mediaType accepts a full IANA type or a top-level segment; when given a segment, the subtype is auto-detected from inline bytes where possible.
Read final-step-only result values, including reasoning and metadata, through finalStep.
The top-level system prompt option is renamed to instructions. system remains a deprecated fallback, and instructions takes precedence when both are provided.
The prepareStep callback receives initialInstructions, the top-level instruction value from the original call.
Models can return files in reasoning as a distinct content part; update exhaustive handling and account for these parts in content or reasoning rather than generated-files collections.
Behavior and default changes 11
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.
Replaces experimental_include as the stable option for generateText, streamText, and ToolLoopAgent; the old name remains a deprecated alias.
Replaces experimental_onToolCallFinish as the tool execution end callback; the old name remains a deprecated alias.
Replaces experimental_onToolCallStart as the tool execution start callback; the old name remains a deprecated alias.
When migrating to the top-level reasoning option, remove overlapping providerOptions settings because provider-specific settings take precedence.
The speech result type has a stable name; Experimental_SpeechResult remains a deprecated alias.
Telemetry configuration is opt-out once an integration is registered: calls emit events by default, and can opt out with isEnabled: false.
Replaces experimental_telemetry as the stable telemetry option; 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; Experimental_TranscriptionResult remains a deprecated alias.
@ai-sdk/openai-compatible 62 changes
Breaking changes 2
The provider shorthand method textEmbedding has been renamed to embedding.
The provider method textEmbeddingModel has been renamed to embeddingModel.
@ai-sdk/openai-compatible 350 changes
Breaking changes 7
Chat Completions refusals from message.refusal and delta.refusal are returned as text after content; a non-empty refusal with a stop finish reason is reported as content-filter, including when both arrive in the same streamed chunk.
The experimental OpenAI Live method can now resolve asynchronously; await its result before using the connection settings.
Reasoning is now put before text in doGenerate.
Empty chat completion choices now return an AI SDK error.
Truncated chat streams are reported as errors.
The file part data property is now tagged with a type, and the image part type has been removed.
The image part type has been removed.
Security 2
Adds a fetch option so downloads can use a configured transport, including guarded-fetch for opt-in DNS validation on Node.js.
Azure image and Vertex tool-result downloads no longer use provider authentication wrappers, preventing file hosts from receiving provider credentials.
Deprecations 1
A warning is emitted when providerOptions uses kebab-case instead of camelCase.
New APIs and options 9
Provider API key settings can now be promises or synchronous or asynchronous callbacks, resolved per authenticated request while preserving existing authentication behavior and synchronous credential serialization.
Provider token settings can now be promises or synchronous or asynchronous callbacks, resolved per authenticated request while preserving existing authentication behavior and synchronous credential serialization.
OpenAICompatibleChatConfig adds an optional mapReasoning function for mapping the top-level reasoning option.
Supports URL-based image responses.
Supports uploaded file references via file_id.
Adds the portable max reasoning level, widening LanguageModelV4CallOptions['reasoning'] and ReasoningLevel. Exhaustive switches and mappings must handle max.
headers is now optional in provider config types, allowing manually constructed model configs to omit it when auth is provided separately.
Support was added for provider references and for uploading files as supported per provider.
Providers now support a new top-level reasoning parameter.
Performance 1
Provider validation schemas are constructed on first use instead of at package import, reducing package import time.
Behavior and default changes 6
The function returned by createDownload can be passed to generateText and streamText, and the hook now handles generated file URLs as well as other core downloads.
Top-level reasoning now maps to the closest effort level the model supports, rounding down when possible; unsupported none values map to the model's lowest level with a compatibility warning.
Top-level embedding dimensions are now mapped to provider settings.
Capability declarations use confirmed model IDs, leaving unrecognized model names unknown; asynchronous lookups and middleware overrides can also resolve to unknown.
Video file parts are converted to video_url content parts.
Image generation token usage is now reported.
Fixes and other changes 24
Custom download requests receive the call's abort signal, preserving cancellation and timeouts for prompt assets and generated files.
Non-string refusals, such as refusal: false, are ignored instead of causing the response to fail.
Inline text file data is accepted as text content, matching text files supplied as bytes or base64.
A raw verbosity passed through provider options is preserved when textVerbosity is unset; textVerbosity still takes precedence when both are set.
An unset reasoningEffort no longer overwrites a raw reasoning_effort provider option.
An explicit null is sent as "reasoning_effort": null.
String tool call arguments are preserved instead of being altered.
BigInt and circular structures are safely serialized in tool calls and outputs.
Fixed string interpolation in OpenAI-compatible completion errors for unexpected system messages.
Multipart tool results are now supported for compatible providers.
The User-Agent header now follows standards-compliant formatting.
Advertises file-input support for QuiverAI Arrow 2 and Arrow 2 Telos, and marks Together AI Gemini image inputs unsupported by the current single-image request mapping.
Fixes streamed tool calls when IDs are missing, blank, or repeated.
Extracts streaming response metadata after placeholder chunks.
Reasoning streams now remain contiguous when deltas include empty tool call arrays.
Supports text and thinking parts in array-based chat completion content and ignores unknown part types.
Sends reasoning_effort: "none" when top-level reasoning is disabled.
Handles tool call IDs that are empty strings.
Preserves Gemini thought signatures when using custom OpenAI-compatible provider names.
Chat and completion models now honor the camelCase providerOptions key.
Streaming delta chunks from OpenAI-compatible providers may now contain an empty string role.
Streaming tool calls are finalized only after the stream is fully consumed, preventing execution with incomplete arguments when partial JSON happens to be parsable.
Tool-only assistant messages send content: null instead of an empty string.
Provider model classes can cross workflow step boundaries without serialization errors.
@ai-sdk/openai-compatible 219 changes
Breaking changes 2
Streaming refusals are returned as text after any content; a non-empty refusal with a stop finish reason becomes content-filter, including when both arrive in the same chunk. Non-string refusals are ignored.
Non-streaming refusals are returned as text after any content; a non-empty refusal with a stop finish reason becomes content-filter, and non-string refusals are ignored.
Security 1
Supports URL-based image responses with opt-in URL validation and credential origin handling; redirect targets are validated, unsafe request headers stripped, and credentials dropped on cross-origin redirects while existing unvalidated requests are preserved.
Deprecations 1
The textEmbeddingModel and textEmbedding aliases are deprecated in favor of embeddingModel.
New APIs and options 9
Adds EmbeddingModelV3 and replaces textEmbeddingModel with embeddingModel; textEmbeddingModel and textEmbedding aliases are deprecated.
Adds extended token usage support.
Adds support for image editing.
Adds the ImageModelV3 API for providers implementing the v3 specification.
Adds the LanguageModelV3 API for providers implementing the v3 specification.
Exposes the raw finish reason.
Adds support for the textVerbosity provider option.
Adds support for tool execution approval.
Adds support for tool-specific strict mode.
Behavior and default changes 1
Updates the OpenAI specification for MCP approval.
Fixes and other changes 5
For Baseten's DeepSeek V4 Pro 0813 with reasoning enabled, empty structured-output answers are avoided by falling back to JSON prompt instructions while retaining reasoning and SDK output validation; the fallback is reported through request transformation warnings.
Tool calls now preserve string arguments and safely serialize BigInt and circular structures in tool calls and outputs.
Preserves streamed tool calls when their IDs or indices are unreliable.
Preserves unmapped fields in provider usage data, including fields nested in prompt_tokens_details and completion_tokens_details; mapped token counts are unaffected.
Adds ProviderV3 with specificationVersion support for providers implementing the v3 specification.
@ai-sdk/openai-compatible 19 changes
Breaking changes 2
OpenAI-compatible provider settings are now supplied through providerOptions.
The simulateStreaming option was removed.
New APIs and options 2
createOpenAICompatible accepts an optional includeUsage option.
Raw chunk support was added.
Behavior and default changes 1
Providers can omit the function type.
Fixes and other changes 4
For Baseten's DeepSeek V4 Pro 0813, structured-output answers fall back to JSON prompt instructions when reasoning is enabled, preserving reasoning and SDK output validation; the fallback is reported through request transformation warnings.
Preserves streamed tool calls when their IDs and indices are unreliable.
Empty tool calls are now supported.
The tool_call type schema now accepts nullish values.