Skip to main content
This guide covers the changes needed when upgrading from AI SDK v5 to v6 with @cloudflare/ai-chat.

Installation

Breaking changes

1. convertToModelMessages() is now async

Add await to all calls:

2. CoreMessage removed

Replace CoreMessage with ModelMessage and convertToCoreMessages() with convertToModelMessages():
v6 introduces needsApproval and the onToolCall callback. For most apps, define tools on the server with tool() from "ai" for full Zod type safety:
Dynamic client tools (SDK/platform pattern): If you are building an SDK or platform where tools are defined dynamically by the embedding application at runtime, the tools option on useAgentChat and createToolsFromClientSchemas() on the server are still fully supported:

4. generateObject mode option removed

Remove mode: "json" or similar from generateObject calls.

5. isToolUIPart and getToolName now include dynamic tools

In v6, these check both static and dynamic tool parts. For the old behavior, use isStaticToolUIPart and getStaticToolName. Most users do not need to change anything.

Deprecated APIs

Not deprecated: AITool, createToolsFromClientSchemas(), extractClientToolSchemas(), and the tools option on useAgentChat are supported for SDK/platform use cases where tools are defined dynamically at runtime.

Migration checklist

1

Update packages

  • ai to ^6.0.0
  • @ai-sdk/react to ^3.0.0
  • @ai-sdk/openai (and other providers) to ^3.0.0
2

Add await to convertToModelMessages()

Add await to all convertToModelMessages() calls
3

Replace CoreMessage

Replace CoreMessage with ModelMessage
4

Replace convertToCoreMessages()

Replace convertToCoreMessages() with convertToModelMessages()
5

Remove mode from generateObject

Remove mode from generateObject calls
6

Move tool definitions to server

Move static tool definitions to server using tool() (recommended for most apps)
7

Use onToolCall callback

Use onToolCall in useAgentChat for client-side tool execution
8

Replace toolsRequiringConfirmation

Replace toolsRequiringConfirmation with needsApproval
9

Replace addToolResult()

Replace addToolResult() with addToolOutput() or addToolApprovalResponse()

Further reading