unstale

npm / @ai-sdk/cohere

@ai-sdk/cohere

What changed in @ai-sdk/cohere 2 to 7, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.

42 breaking2 security11 deprecations16 new APIs and options2 performance17 behavior and defaults13 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

@ai-sdk/cohere 757 changes

Breaking changes 35

  • OpenTelemetry span collection is no longer built into ai; install this package and register an OpenTelemetry instance globally to receive traces.

    7.0.0upgrade guide

  • System messages in prompt or messages are rejected by default; set allowSystemInMessages: true to retain support for existing trusted chat histories.

    7.0.0upgrade guide

  • CallSettings is split into LanguageModelCallOptions and RequestOptions; custom wrappers should use LanguageModelCallOptions & Omit<RequestOptions, 'timeout'>.

    7.0.0upgrade guide

  • Top-level content, tool-call and result collections, files, sources, and warnings on generateText and streamText results now accumulate values across every step. Use finalStep for final-step-only values.

    7.0.0upgrade guide

  • Tool callback experimental_context is renamed to context and is now tool-specific, typed from contextSchema, and supplied through toolsContext rather than shared runtime data.

    7.0.0upgrade guide

  • The deprecated experimental_customProvider export is removed; replace it with customProvider, whose options and behavior are unchanged.

    7.0.0upgrade guide

  • The package is ESM-only; consumers using require() must switch to ESM import syntax.

    4.0.0, 7.0.0release notesupgrade guide

  • The deprecated option has been removed. Replace remaining usages with activeTools in generateText and streamText calls.

    7.0.0upgrade guide

  • The deprecated result type export is removed; use GenerateImageResult instead.

    7.0.0upgrade guide

  • The tracer property is removed from experimental_telemetry; pass a custom tracer to the OpenTelemetry constructor instead.

    7.0.0upgrade guide

  • Use finalStep to access final-step reasoning, request, response, and provider metadata previously exposed as top-level result properties.

    7.0.0upgrade guide

  • The deprecated experimental_generateImage export is removed; use generateImage instead.

    7.0.0upgrade guide

  • Move streamText's deprecated top-level includeRawChunks option into include.rawChunks.

    7.0.0upgrade guide

  • generateText and streamText no longer include request bodies in step results by default; opt in with include.requestBody.

    7.0.0upgrade guide

  • generateText no longer includes response bodies by default; opt in with include.responseBody.

    7.0.0upgrade guide

  • The tool-loop stop condition helper stepCountIs is renamed to isStepCount.

    7.0.0upgrade guide

  • The deprecated function has been removed. Replace remaining usages with isToolUIPart.

    7.0.0upgrade guide

  • The deprecated top-level cachedInputTokens field is removed; read inputTokenDetails.cacheReadTokens instead.

    7.0.0upgrade guide

  • The deprecated top-level reasoningTokens field is removed; read outputTokenDetails.reasoningTokens instead.

    7.0.0upgrade guide

  • The deprecated tool-result content part type has been removed. Use the file variant with mediaType and tagged data for inline file content.

    7.0.0upgrade guide

  • The minimum supported Node.js version is 22; supported versions are 22, 24, and 26.

    4.0.0, 7.0.0release notesupgrade guide

  • Telemetry integrations and tracing-channel subscribers use onEmbedEnd instead of onEmbedFinish.

    7.0.0upgrade guide

  • The onEnd callback for generateText, streamText, and agents follows the updated result shape: usage and collections cover all steps, while final-step-only values are on finalStep.

    7.0.0upgrade guide

  • Telemetry integrations and tracing-channel subscribers use onRerankEnd instead of onRerankFinish.

    7.0.0upgrade guide

  • The generation start callback experimental_onStart is renamed to onStart for generateText, streamText, and agents.

    7.0.0upgrade guide

  • The per-step start callback experimental_onStepStart is renamed to onStepStart for generateText, streamText, and agents.

    7.0.0upgrade guide

  • The deprecated experimental_output option and result property are removed; use output for both call options and result access.

    7.0.0upgrade guide

  • The deprecated experimental_prepareStep option is removed; use prepareStep instead.

    7.0.0upgrade guide

  • Shared generation or agent runtime data is provided through runtimeContext, separate from per-tool context supplied through toolsContext.

    7.0.0upgrade guide

  • Each step's response.messages now contains only messages produced by that step; use result.responseMessages for the full response history.

    7.0.0upgrade guide

  • onChunk now receives every TextStreamPart, including lifecycle, boundary, and terminal parts; handlers should guard the chunk types they process.

    7.0.0upgrade guide

  • The deprecated type has been removed. Replace imports and type references with ToolExecutionOptions.

    7.0.0upgrade guide

  • Provide tool-specific context values through toolsContext, keyed by tool name; when any tool declares contextSchema, toolsContext becomes required and includes only contextual tools.

    7.0.0upgrade guide

  • Projects without ESM configuration must add "type": "module" to package.json or use .mjs files.

    7.0.0upgrade guide

  • generateText and streamText usage now totals token usage across all steps. Use finalStep.usage for the previous final-step-only behavior.

    7.0.0upgrade guide

Deprecations 11

  • Tool-result image-* and legacy file-* variants are deprecated in favor of a canonical file variant with mediaType and tagged data; runtime auto-migration keeps existing outputs working.

    7.0.0upgrade guide

  • Use the file message part with data and mediaType instead of the deprecated image user-message part.

    7.0.0upgrade guide

  • The tool() and dynamicTool() property is deprecated. Move approval logic to toolApproval on the generation call or agent so policy can vary by request.

    7.0.0upgrade guide

  • The final lifecycle callback for generateText, streamText, agents, embed, embedMany, and rerank is named onEnd; onFinish and experimental_onFinish remain deprecated aliases where noted.

    7.0.0upgrade guide

  • The per-step lifecycle callback is renamed from onStepFinish; the old name remains a deprecated alias for user-facing callbacks, and telemetry integrations should implement onStepEnd.

    7.0.0upgrade guide

  • The generateText and streamText tool-finish callback is renamed from experimental_onToolCallFinish; the old name remains a deprecated alias.

    7.0.0upgrade guide

  • The generateText and streamText tool-start callback is renamed from experimental_onToolCallStart; the old name remains a deprecated alias.

    7.0.0upgrade guide

  • Top-level reasoning, reasoningText, request, response, and providerMetadata result properties are deprecated; use finalStep for final-step values.

    7.0.0upgrade guide

  • The full event stream property is renamed to stream; fullStream remains available as a deprecated alias.

    7.0.0upgrade guide

  • totalUsage is deprecated; use usage for token usage accumulated across all steps.

    7.0.0upgrade guide

  • The streamText result helper methods are deprecated but still work in v7 with warnings. Use top-level stateless helpers to compose transformations over any stream or textStream.

    7.0.0upgrade guide

New APIs and options 2

  • The top-level prompt option system is renamed to instructions across prompt- and message-accepting APIs, prepareStep results, repair callbacks, and lifecycle event data; system remains a deprecated fallback.

    7.0.0upgrade guide

  • Some models can return files in reasoning under a distinct reasoning-file part type; update exhaustive part handling and account for these files in content or reasoning.

    7.0.0upgrade guide

Behavior and default changes 9

  • The speech generation function graduates from experimental status and is available under the stable name generateSpeech; the old name remains a deprecated alias.

    7.0.0upgrade guide

  • The include option replaces experimental_include for generateText, streamText, and ToolLoopAgent; the old name remains a deprecated alias and include takes precedence if both are supplied.

    7.0.0upgrade guide

  • Instructions returned from prepareStep carry forward into future steps until another instructions or system override is returned.

    7.0.0upgrade guide

  • Messages returned from prepareStep become the base for subsequent steps, combined with response messages from the previous step.

    7.0.0upgrade guide

  • When migrating reasoning settings to the top-level reasoning option, remove overlapping providerOptions settings; provider-specific settings take precedence if both are present.

    7.0.0upgrade guide

  • Experimental_SpeechResult is renamed to the stable SpeechResult type; the old name remains a deprecated alias.

    7.0.0upgrade guide

  • Telemetry configuration is renamed from experimental_telemetry; the old name remains a deprecated alias, and telemetry events are emitted by default after an integration is registered.

    7.0.0upgrade guide

  • The transcription API graduates from experimental status and is available under the stable name transcribe; the old name remains a deprecated alias.

    7.0.0upgrade guide

  • Experimental_TranscriptionResult is renamed to the stable TranscriptionResult type; the old name remains a deprecated alias.

    7.0.0upgrade guide

@ai-sdk/cohere 62 changes

Breaking changes 2

  • Provider method textEmbedding was renamed to embedding; update Cohere provider calls to use the new name.

    6.0.0upgrade guide

  • Use embeddingModel to create an embedding model; it replaces textEmbeddingModel.

    3.0.0, 6.0.0release notesupgrade guide

@ai-sdk/cohere 428 changes

Breaking changes 3

  • Usage conversion no longer substitutes billed units for token counts; responses without tokens report undefined token counts, including in streaming.

    3.0.76, 4.0.77release notesrelease notes

  • The baseUrl option has been removed from all providers; use baseURL instead.

    4.0.0upgrade guide

  • The data property is tagged with a type, and the image part type is removed.

    4.0.0release notes

Security 2

  • @ai-sdk/provider-utils has an Uncontrolled Resource Consumption issue

    4.0.33security advisory

  • Streamed tool call arguments are parsed more defensively against prototype keys.

    4.0.0release notes

New APIs and options 7

  • Provider 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.

    4.0.73release notes

  • Adds max as a portable reasoning level, widening the reasoning option type; exhaustive switches and mappings must handle it.

    4.0.56release notes

  • Cohere embeddings now support selecting embedding formats.

    4.0.55release notes

  • Cohere models can now receive images.

    4.0.0release notes

  • Adds support for provider references and uploading files where supported by the provider.

    4.0.0release notes

  • Providers support a new top-level reasoning parameter.

    4.0.0release notes

  • Provider model classes can cross workflow step boundaries using serialization and deserialization methods.

    4.0.0release notes

Performance 1

  • Construction is deferred until first use to reduce package import time.

    4.0.66release notes

Behavior and default changes 5

  • 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 custom model IDs.

    4.0.84release notes

  • Non-streaming responses now tolerate partial citations, untitled documents, and tool-sourced citations instead of failing validation; document citations without a title use "Document".

    2.0.49, 4.0.77release notesrelease notes

  • Non-streaming v2 chat responses now use Cohere's id; generation_id remains supported for compatibility with proxies and mocks.

    3.0.76, 4.0.77release notesrelease notes

  • The Cohere embedding outputDimension option now allows 768 and 2048 for Embed 5 models.

    3.0.68, 4.0.55release notesrelease notes

  • Provider config types make headers optional, so manually constructed model configs can omit them.

    4.0.0release notes

Fixes and other changes 10

  • Reranking responses no longer require meta, avoiding validation failures when it is omitted with Zod >= 4.4.

    4.0.78release notes

  • streamText now emits source parts for cited documents in Cohere RAG responses; tool-only citations and citation-start events without citations are not emitted as sources.

    2.0.49, 3.0.76, 4.0.77release notesrelease notesrelease notes

  • Streamed null tool arguments are normalized to an empty object so tools without parameters can execute, matching non-streaming calls.

    4.0.76release notes

  • Preserves string tool call arguments and safely serializes BigInt and circular structures in tool calls and outputs.

    2.0.48, 3.0.75, 4.0.74release notesrelease notesrelease notes

  • Base64-encoded file data is decoded before being sent to Cohere as document text.

    4.0.71release notes

  • Cohere streams that end cleanly without a provider completion signal now report interrupted, preserving partial output without emitting an error solely for the interruption.

    4.0.67release notes

  • Top-level embedding dimensions are mapped to provider settings, allowing the requested dimensions to be passed through.

    4.0.59release notes

  • Usage details now report cached input tokens.

    4.0.56release notes

  • The User-Agent header is now standards-compliant.

    4.0.52release notes

  • Preserves complete raw usage objects returned by the Cohere provider.

    3.0.59, 4.0.33release notesrelease notes

@ai-sdk/cohere 37 changes

New APIs and options 3

Performance 1

  • Validation schema construction is deferred until first use to reduce provider import time.

    2.0.46, 3.0.73release notesrelease notes

Behavior and default changes 3

  • Non-streaming responses now tolerate missing citation fields, incomplete documents, tool-sourced citations, and absent usage token counts instead of failing validation.

    3.0.76release notes

  • Token usage information is extended.

    3.0.0release notes

  • Requests now include the provider version in the user-agent header.

    3.0.0release notes

@ai-sdk/cohere 29 changes

Breaking changes 2

  • Cohere now uses providerOptions.

    2.0.0release notes

  • Renamed rawResponse to response in the embedding-model-v2 interface.

    2.0.0release notes

New APIs and options 4

  • Added citations support for text documents in Cohere.

    2.0.0release notes

  • Added a v2 interface for embedding models.

    2.0.0release notes

  • Added support for raw chunks.

    2.0.0release notes

  • Added a response body field to the embedding-model-v2 interface.

    2.0.0release notes

Fixes and other changes 3

  • Usage conversion no longer substitutes billed units for tokens; responses without tokens report undefined token counts, avoiding unrelated numbers and negative counts after cached tokens are subtracted.

    2.0.49release notes

  • Non-streaming generation now reads the response id from Cohere's v2 id field, retaining generation_id for compatibility with v1 proxies and mocks.

    2.0.49release notes

  • Fixed Cohere tool calling.

    2.0.0release notes