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@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.
System messages in prompt or messages are rejected by default; set allowSystemInMessages: true to retain support for existing trusted chat histories.
CallSettings is split into LanguageModelCallOptions and RequestOptions; custom wrappers should use LanguageModelCallOptions & Omit<RequestOptions, 'timeout'>.
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.
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.
The deprecated experimental_customProvider export is removed; replace it with customProvider, whose options and behavior are unchanged.
The package is ESM-only; consumers using require() must switch to ESM import syntax.
The deprecated option has been removed. Replace remaining usages with activeTools in generateText and streamText calls.
The deprecated result type export is removed; use GenerateImageResult instead.
The tracer property is removed from experimental_telemetry; pass a custom tracer to the OpenTelemetry constructor instead.
Use finalStep to access final-step reasoning, request, response, and provider metadata previously exposed as top-level result properties.
The deprecated experimental_generateImage export is removed; use generateImage instead.
Move streamText's deprecated top-level includeRawChunks option into include.rawChunks.
generateText and streamText no longer include request bodies in 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 stepCountIs is renamed to isStepCount.
The deprecated function has been removed. Replace remaining usages with isToolUIPart.
The deprecated top-level cachedInputTokens field is removed; read inputTokenDetails.cacheReadTokens instead.
The deprecated top-level reasoningTokens field is removed; read outputTokenDetails.reasoningTokens instead.
The deprecated tool-result content part type has been removed. Use the file variant with mediaType and tagged data for inline file content.
The minimum supported Node.js version is 22; supported versions are 22, 24, and 26.
Telemetry integrations and tracing-channel subscribers use onEmbedEnd instead of onEmbedFinish.
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.
Telemetry integrations and tracing-channel subscribers use onRerankEnd instead of onRerankFinish.
The generation start callback experimental_onStart is renamed to onStart for generateText, streamText, and agents.
The per-step start callback experimental_onStepStart is renamed to onStepStart for generateText, streamText, and agents.
The deprecated experimental_output option and result property are removed; use output for both call options and result access.
The deprecated experimental_prepareStep option is removed; use prepareStep instead.
Shared generation or agent runtime data is provided through runtimeContext, separate from per-tool context supplied through toolsContext.
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 should guard the chunk types they process.
The deprecated type has been removed. Replace imports and type references with ToolExecutionOptions.
Provide tool-specific context values through toolsContext, keyed by tool name; when any tool declares contextSchema, toolsContext becomes required and includes only contextual tools.
Projects without ESM configuration must add "type": "module" to package.json or use .mjs files.
generateText and streamText usage now totals token usage across all steps. Use finalStep.usage for the previous final-step-only behavior.
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.
Use the file message part with data and mediaType instead of the deprecated image user-message part.
The tool() and dynamicTool() property is deprecated. Move approval logic to toolApproval on the generation call or agent so policy can vary by request.
The final lifecycle callback for generateText, streamText, agents, embed, embedMany, and rerank is named onEnd; onFinish and experimental_onFinish remain deprecated aliases where noted.
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.
The generateText and streamText tool-finish callback is renamed from experimental_onToolCallFinish; the old name remains a deprecated alias.
The generateText and streamText tool-start callback is renamed from experimental_onToolCallStart; the old name remains a deprecated alias.
Top-level reasoning, reasoningText, request, response, and providerMetadata result properties are deprecated; use finalStep for final-step values.
The full event stream property is renamed to stream; fullStream remains available as a deprecated alias.
totalUsage is deprecated; use usage for token usage accumulated across all steps.
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.
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.
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.
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.
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.
Instructions returned from prepareStep carry forward into future steps until another instructions or system override is returned.
Messages returned from prepareStep become the base for subsequent steps, combined with response messages from the previous step.
When migrating reasoning settings to the top-level reasoning option, remove overlapping providerOptions settings; provider-specific settings take precedence if both are present.
Experimental_SpeechResult is renamed to the stable SpeechResult type; the old name remains a deprecated alias.
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.
The transcription API graduates from experimental status and is available under the stable name transcribe; the old name remains a deprecated alias.
Experimental_TranscriptionResult is renamed to the stable TranscriptionResult type; the old name remains a deprecated alias.
@ai-sdk/cohere 62 changes
Breaking changes 2
Provider method textEmbedding was renamed to embedding; update Cohere provider calls to use the new name.
Use embeddingModel to create an embedding model; it replaces textEmbeddingModel.
@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.
The baseUrl option has been removed from all providers; use baseURL instead.
The data property is tagged with a type, and the image part type is removed.
Security 2
@ai-sdk/provider-utils has an Uncontrolled Resource Consumption issue
Streamed tool call arguments are parsed more defensively against prototype keys.
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.
Adds max as a portable reasoning level, widening the reasoning option type; exhaustive switches and mappings must handle it.
Cohere embeddings now support selecting embedding formats.
Cohere models can now receive images.
Adds support for provider references and uploading files where supported by the provider.
Providers support a new top-level reasoning parameter.
Provider model classes can cross workflow step boundaries using serialization and deserialization methods.
Performance 1
Construction is deferred until first use to reduce package import time.
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.
Non-streaming responses now tolerate partial citations, untitled documents, and tool-sourced citations instead of failing validation; document citations without a title use "Document".
Non-streaming v2 chat responses now use Cohere's
id;generation_idremains supported for compatibility with proxies and mocks.The Cohere embedding outputDimension option now allows 768 and 2048 for Embed 5 models.
Provider config types make headers optional, so manually constructed model configs can omit them.
Fixes and other changes 10
Reranking responses no longer require meta, avoiding validation failures when it is omitted with Zod >= 4.4.
streamTextnow emits source parts for cited documents in Cohere RAG responses; tool-only citations and citation-start events without citations are not emitted as sources.Streamed null tool arguments are normalized to an empty object so tools without parameters can execute, matching non-streaming calls.
Preserves string tool call arguments and safely serializes BigInt and circular structures in tool calls and outputs.
Base64-encoded file data is decoded before being sent to Cohere as document text.
Cohere streams that end cleanly without a provider completion signal now report interrupted, preserving partial output without emitting an error solely for the interruption.
Top-level embedding dimensions are mapped to provider settings, allowing the requested dimensions to be passed through.
Usage details now report cached input tokens.
The User-Agent header is now standards-compliant.
Preserves complete raw usage objects returned by the Cohere provider.
@ai-sdk/cohere 37 changes
New APIs and options 3
The raw finish reason is now exposed.
Reranking is now supported.
Reranking models now support shorthand names.
Performance 1
Validation schema construction is deferred until first use to reduce provider import time.
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.
Token usage information is extended.
Requests now include the provider version in the user-agent header.
@ai-sdk/cohere 29 changes
Breaking changes 2
Cohere now uses providerOptions.
Renamed rawResponse to response in the embedding-model-v2 interface.
New APIs and options 4
Added citations support for text documents in Cohere.
Added a v2 interface for embedding models.
Added support for raw chunks.
Added a response body field to the embedding-model-v2 interface.
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.
Non-streaming generation now reads the response id from Cohere's v2
idfield, retaininggeneration_idfor compatibility with v1 proxies and mocks.Fixed Cohere tool calling.