
# Announcing AI SDK 5 Beta

<Note type="warning">
  AI SDK 5 is in beta — while more stable than alpha, APIs may still change. Pin
  to specific versions as breaking changes may occur in minor releases.
</Note>

## Beta Version Guidance

The AI SDK 5 Beta is intended for:

- **New projects** where you can adopt the latest patterns from the start
- **Trying out new features** and giving us feedback on the developer experience
- **Experimenting with migrations** from v4 to understand the upgrade path
- **Development and testing environments** where you can iterate quickly

**Short on time?** Wait for the stable release. We're focusing on polish and migration tooling improvements.

**For production applications**: Experiment with migrations in development, but avoid fully migrating production systems. Use this beta period to understand the changes and prepare your migration strategy.

## What to Expect in Beta

- **No major breaking changes** - the architecture is stable
- **Minor breaking changes possible** - we may refine APIs for critical bugfixes
- **Bug fixes and DX improvements** - active development continues

Your feedback during this beta phase directly shapes the final stable release. Share your experiences through [GitHub issues](https://github.com/vercel/ai/issues/new/choose).

<Note type="warning">
  While more stable than alpha, you may still encounter bugs in this Beta
  release. To help us improve the SDK, [file bug reports on
  GitHub](https://github.com/vercel/ai/issues/new/choose). Your reports directly
  contribute to making the final release more stable and reliable.
</Note>

## Installation

To install the AI SDK 5 Beta, run the following command:

```bash
# replace with your provider and framework
npm install ai@beta @ai-sdk/openai@beta @ai-sdk/react@beta
```

<Note type="warning">
  APIs may still change during beta. Pin to specific versions as breaking
  changes may occur in minor releases.
</Note>

## What's new in AI SDK 5?

AI SDK 5 is a redesign of the AI SDK's protocol and architecture based on everything we learned over the last two years of real-world usage. We also modernized the UI and protocols that have remained largely unchanged since AI SDK v2/3, to create a strong foundation for the future.

### Why a new specification (LanguageModelV2)?

When we originally designed the v1 protocol over a year ago, the standard interaction pattern with language models was text in, text or tool call out. Today's LLMs go beyond text and tool calls, generating reasoning, sources, images and more. New use cases like computer-using agents introduce a fundamentally different approach to interacting with language models that made it impossible to support in a unified approach with our original architecture.

We needed a protocol designed for this new reality. While this is a breaking change that we take seriously, it provided an opportunity to rebuild the foundation and add new features.

## New Features

- [**`LanguageModelV2`**](#languagemodelv2) - new redesigned architecture
- [**Message Overhaul**](#message-overhaul) - new `UIMessage` and `ModelMessage` types
- [**Server-Sent Events (SSE)**](#server-sent-events-sse) - new standardised protocol for sending UI messages to the client
- [**Agentic Control**](#agentic-control) - new primitives for building agentic systems
- [**Enhanced useChat Architecture**](#enhanced-usechat-architecture) - improved state management with transport system

## `LanguageModelV2`

`LanguageModelV2` represents a complete redesign of how the AI SDK communicates with language models, adapting to the increasingly complex outputs modern AI systems generate. The new `LanguageModelV2` treats all LLM outputs as content parts, enabling consistent handling of text, images, reasoning, sources, and other response types. It has:

- **Content-First Design** - Rather than separating text, reasoning, and tool calls, everything is represented as ordered content parts in a unified array
- **Improved Type Safety** - The new `LanguageModelV2` provides better TypeScript type guarantees, making it easier to work with different content types
- **Extensibility** - Adding support for new model capabilities requires no changes to the core structure

## Message Overhaul

AI SDK 5 introduces a completely redesigned message system with two message types that address the dual needs of what you render in your UI and what you send to the model. Context is crucial for effective language model generations, and these message types serve distinct purposes:

- **UIMessage** represents the complete conversation history for your interface, preserving all message parts (text, images, data), metadata (creation timestamps, generation times), and UI state.

- **ModelMessage** is optimized for sending to language models, considering token input constraints. It strips away UI-specific metadata and irrelevant content.

With this change, you must explicitly convert your `UIMessage`s to `ModelMessage`s before sending them to the model.

```ts highlight="9"
import { openai } from '@ai-sdk/openai';
import { convertToModelMessages, streamText, UIMessage } from 'ai';

export async function POST(req: Request) {
  const { messages }: { messages: UIMessage[] } = await req.json();

  const result = streamText({
    model: openai('gpt-4o'),
    messages: convertToModelMessages(messages),
  });

  return result.toUIMessageStreamResponse();
}
```

<Note>
  This separation is essential as you can't use a single message format for both
  purposes. Always save state in the `UIMessage` format to prevent information
  loss, with explicit conversion to `ModelMessage` when communicating with
  language models.
</Note>

The new message system makes several highly requested features possible:

- **Type-safe Message Metadata** - Add structured information per message
- **Type-safe Tool Calls** - Improved type safety when defining and using tools in your messages
- **New Stream Writer** - Stream any part type (reasoning, sources, etc.) retaining proper order
- **Data Parts** - Stream type-safe arbitrary data parts for dynamic UI components

### Type-safe Tool Calls

AI SDK 5 introduces type-safe tool calls in UI messages. Instead of generic `tool-invocation` types, tool parts use specific naming: `tool-${toolName}`. This provides better type safety and makes it easier to handle many tools in your UI.

```tsx filename="AI SDK 4.0"
// Generic tool-invocation type
{
  message.parts.map(part => {
    if (part.type === 'tool-invocation') {
      return <div>{part.toolInvocation.toolName}</div>;
    }
  });
}
```

```tsx filename="AI SDK 5.0"
// Type-safe tool parts with specific names
{
  message.parts.map(part => {
    switch (part.type) {
      case 'tool-getWeatherInformation':
        return <div>Getting weather...</div>;
      case 'tool-askForConfirmation':
        return <div>Asking for confirmation...</div>;
    }
  });
}
```

### Message metadata

Metadata allows you to attach structured information to individual messages, making it easier to track details like response time, token usage, or model specifications. This information can enhance your UI with contextual data without embedding it in the message content itself.

To add metadata to a message, first define the metadata schema:

```ts filename="app/api/chat/example-metadata-schema.ts"
export const exampleMetadataSchema = z.object({
  duration: z.number().optional(),
  model: z.string().optional(),
  totalTokens: z.number().optional(),
});

export type ExampleMetadata = z.infer<typeof exampleMetadataSchema>;
```

Then add the metadata using the `message.metadata` property on the `toUIMessageStreamResponse()` utility:

```ts filename="app/api/chat/route.ts"
import { openai } from '@ai-sdk/openai';
import { convertToModelMessages, streamText, UIMessage } from 'ai';
import { ExampleMetadata } from './example-metadata-schema';

export async function POST(req: Request) {
  const { messages }: { messages: UIMessage[] } = await req.json();

  const startTime = Date.now();
  const result = streamText({
    model: openai('gpt-4o'),
    prompt: convertToModelMessages(messages),
  });

  return result.toUIMessageStreamResponse({
    messageMetadata: ({ part }): ExampleMetadata | undefined => {
      // send custom information to the client on start:
      if (part.type === 'start') {
        return {
          model: 'gpt-4o', // initial model id
        };
      }

      // send additional model information on finish-step:
      if (part.type === 'finish-step') {
        return {
          model: part.response.modelId, // update with the actual model id
          duration: Date.now() - startTime,
        };
      }

      // when the message is finished, send additional information:
      if (part.type === 'finish') {
        return {
          totalTokens: part.totalUsage.totalTokens,
        };
      }
    },
  });
}
```

Finally, use the metadata type with useChat and render the (type-safe) metadata in your UI:

```tsx filename="app/page.tsx"
import { useChat } from '@ai-sdk/react';
import { DefaultChatTransport, UIMessage } from 'ai';
import { ExampleMetadata } from './api/chat/example-metadata-schema';

type MyMessage = UIMessage<ExampleMetadata>;

export default function Chat() {
  const { messages } = useChat<MyMessage>({
    transport: new DefaultChatTransport({
      api: '/api/chat',
    }),
  });

  return (
    <div>
      {messages.map(message => (
        <div key={message.id} className="whitespace-pre-wrap">
          {message.role === 'user' ? 'User: ' : 'AI: '}
          {message.metadata?.duration && (
            <div>Duration: {message.metadata.duration}ms</div>
          )}
          {message.metadata?.model && (
            <div>Model: {message.metadata.model}</div>
          )}
          {message.metadata?.totalTokens && (
            <div>Total tokens: {message.metadata.totalTokens}</div>
          )}
        </div>
      ))}
    </div>
  );
}
```

### UIMessageStream

The UI Message Stream enables streaming any content parts from the server to the client. With this stream, you can send structured data like custom sources from your RAG pipeline directly to your UI. The stream writer is a utility that makes it easy to write to this message stream.

```ts
const stream = createUIMessageStream({
  execute: writer => {
    // stream custom sources
    writer.write({
      type: 'source',
      value: {
        type: 'source',
        sourceType: 'url',
        id: 'source-1',
        url: 'https://example.com',
        title: 'Example Source',
      },
    });
  },
});
```

On the client, these will be added to the ordered `message.parts` array.

### Data Parts

The new stream writer enables a type-safe way to stream arbitrary data from the server to the client and display it in your UI.

You can create and stream custom data parts on the server:

```tsx
// On the server
const stream = createUIMessageStream({
  execute: writer => {
    // Initial update
    writer.write({
      type: 'data-weather', // Custom type
      id: toolCallId, // ID for updates
      data: { city, status: 'loading' }, // Your data
    });

    // Later, update the same part
    writer.write({
      type: 'data-weather',
      id: toolCallId,
      data: { city, weather, status: 'success' },
    });
  },
});
```

On the client, you can render these parts with full type safety:

```tsx
{
  message.parts
    .filter(part => part.type === 'data-weather') // type-safe
    .map((part, index) => (
      <Weather
        key={index}
        city={part.data.city} // type-safe
        weather={part.data.weather} // type-safe
        status={part.data.status} // type-safe
      />
    ));
}
```

Data parts appear in the `message.parts` array along with other content, maintaining the proper ordering of the conversation. You can update parts by referencing the same ID, enabling dynamic experiences like collaborative artifacts.

## Enhanced useChat Architecture

AI SDK 5 introduces a new `useChat` architecture with transport-based configuration. This design makes state management and API integration flexible, allowing you to configure backend protocols without rewriting application logic.

The new `useChat` hook uses a transport system for better modularity:

- **Transport Configuration** – configure API endpoints and request handling through transport objects
- **Enhanced State Management** – improved message handling with the new UIMessage format
- **Type Safety** – stronger TypeScript support throughout the chat lifecycle

Configure useChat with the transport system:

```ts
import { useChat } from '@ai-sdk/react';
import { DefaultChatTransport } from 'ai';

const { messages, sendMessage } = useChat({
  transport: new DefaultChatTransport({
    api: '/api/chat', // your chat endpoint
    headers: { 'Custom-Header': 'value' },
  }),
  maxSteps: 5,
});
```

## Server-Sent Events (SSE)

AI SDK 5 uses Server-Sent Events (SSE) instead of a custom streaming protocol. SSE is a common web standard for sending data from servers to browsers. This switch has several advantages:

- **Works everywhere** - Uses technology that works in all major browsers and platforms
- **Easier to troubleshoot** - See the data stream in browser developer tools
- **Simpler to build upon** - Adding new features is more straightforward
- **More stable** - Built on proven technology that many developers already use

## Agentic Control

AI SDK 5 introduces new features for building agents that help you control model behavior more precisely.

### prepareStep

The `prepareStep` function gives you fine-grained control over each step in a multi-step agent. It's called before a step starts and allows you to:

- Dynamically change the model used for specific steps
- Force specific tool selections for particular steps
- Limit which tools are available during specific steps
- Examine the context of previous steps before proceeding

```ts
const result = await generateText({
  // ...
  experimental_prepareStep: async ({ model, stepNumber, maxSteps, steps }) => {
    if (stepNumber === 0) {
      return {
        // use a different model for this step:
        model: modelForThisParticularStep,
        // force a tool choice for this step:
        toolChoice: { type: 'tool', toolName: 'tool1' },
        // limit the tools that are available for this step:
        experimental_activeTools: ['tool1'],
      };
    }
    // when nothing is returned, the default settings are used
  },
});
```

This makes it easier to build AI systems that adapt their capabilities based on context and task requirements.

### `stopWhen`

The `stopWhen` parameter lets you define stopping conditions for your agent. Instead of running indefinitely, you can specify exactly when the agent should terminate based on various conditions:

- Reaching a maximum number of steps
- Calling a specific tool
- Satisfying any custom condition you define

```ts
const result = generateText({
  // ...
  // stop loop at 5 steps
  stopWhen: stepCountIs(5),
});

const result = generateText({
  // ...
  // stop loop when weather tool called
  stopWhen: hasToolCall('weather'),
});

const result = generateText({
  // ...
  // stop loop at your own custom condition
  stopWhen: maxTotalTokens(20000),
});
```

These agentic controls form the foundation for building reliable, controllable AI systems that tackle complex problems while remaining within well-defined constraints.

## Additional New Features

### Tool Output Schema

Tools can now optionally specify an output schema for better type inference and validation:

```tsx filename="AI SDK 5.0"
import { tool } from 'ai';
import { z } from 'zod';

const weatherTool = tool({
  description: 'Get weather information',
  inputSchema: z.object({
    city: z.string(),
  }),
  outputSchema: z.object({
    temperature: z.number(),
    conditions: z.string(),
  }),
  execute: async ({ city }) => ({
    temperature: 72,
    conditions: 'sunny',
  }),
});
```

### Tool Type Inference Helpers

New utility types simplify working with tool types:

```tsx filename="AI SDK 5.0"
import { InferToolInput, InferToolOutput, InferUITool } from 'ai';
import { weatherTool } from './weatherTool';

// Infer input and output types from tool definitions
type WeatherInput = InferToolInput<typeof weatherTool>;
type WeatherOutput = InferToolOutput<typeof weatherTool>;
type WeatherUITool = InferUITool<typeof weatherTool>;

// Use in UI message type definitions
type MyUIMessage = UIMessage<
  never, // metadata type
  UIDataTypes, // data parts type
  {
    weather: WeatherUITool;
  }
>;
```

### OpenAI Provider-Executed Tools

New built-in tools for OpenAI:

```tsx filename="AI SDK 5.0"
import { openai } from '@ai-sdk/openai';

const result = await generateText({
  model: openai('gpt-4.1'),
  tools: {
    file_search: openai.tools.fileSearch(),
    web_search_preview: openai.tools.webSearchPreview({
      searchContextSize: 'high',
    }),
  },
  messages,
});
```

Available tools:

- **`fileSearch`**: Search through uploaded documents using OpenAI's file search
- **`webSearchPreview`**: Web search capabilities (preview feature)

When using provider-defined tools like `fileSearch` and `webSearchPreview`, the tool execution results are automatically added to the message history, providing context for subsequent interactions.

This automatic message history inclusion ensures that:

- Tool execution context is preserved across conversation turns
- Follow-up questions can reference previously searched information
- The full conversation flow is maintained for debugging and logging

### Enhanced Tool Streaming

Tools now support fine-grained streaming callbacks:

```tsx filename="AI SDK 5.0"
const weatherTool = tool({
  inputSchema: z.object({ city: z.string() }),
  onInputStart: ({ toolCallId }) => {
    console.log('Tool input streaming started:', toolCallId);
  },
  onInputDelta: ({ inputTextDelta, toolCallId }) => {
    console.log('Tool input delta:', inputTextDelta);
  },
  onInputAvailable: ({ input, toolCallId }) => {
    console.log('Tool input ready:', input);
  },
  execute: async ({ city }) => {
    return `Weather in ${city}: sunny, 72°F`;
  },
});
```

## Migration from AI SDK 4.x

Ready to upgrade from AI SDK 4.x to 5.0 Beta? We created a comprehensive migration guide to help you through the process.

The migration involves several key changes:

- Updated message format with `UIMessage` and `ModelMessage` types
- New `useChat` architecture with transport system
- New streaming protocol with Server-Sent Events
- Improved type safety and developer experience

**[View the complete Migration Guide →](/docs/migration-guides/migration-guide-5-0)**

The migration guide includes:

- Step-by-step upgrade instructions
- Detailed examples for each breaking change
- Best practices for adopting new features


## Navigation

- [AI SDK by Vercel](/v4/docs/introduction)
- [AI SDK 5 Beta](/v4/docs/announcing-ai-sdk-5-beta)
- [Foundations](/v4/docs/foundations)
  - [Overview](/v4/docs/foundations/overview)
  - [Providers and Models](/v4/docs/foundations/providers-and-models)
  - [Prompts](/v4/docs/foundations/prompts)
  - [Tools](/v4/docs/foundations/tools)
  - [Streaming](/v4/docs/foundations/streaming)
  - [Agents](/v4/docs/foundations/agents)
- [Getting Started](/v4/docs/getting-started)
  - [Navigating the Library](/v4/docs/getting-started/navigating-the-library)
  - [Next.js App Router](/v4/docs/getting-started/nextjs-app-router)
  - [Next.js Pages Router](/v4/docs/getting-started/nextjs-pages-router)
  - [Svelte](/v4/docs/getting-started/svelte)
  - [Vue.js (Nuxt)](/v4/docs/getting-started/nuxt)
  - [Node.js](/v4/docs/getting-started/nodejs)
  - [Expo](/v4/docs/getting-started/expo)
- [AI SDK Core](/v4/docs/ai-sdk-core)
  - [Overview](/v4/docs/ai-sdk-core/overview)
  - [Generating Text](/v4/docs/ai-sdk-core/generating-text)
  - [Generating Structured Data](/v4/docs/ai-sdk-core/generating-structured-data)
  - [Tool Calling](/v4/docs/ai-sdk-core/tools-and-tool-calling)
  - [Prompt Engineering](/v4/docs/ai-sdk-core/prompt-engineering)
  - [Settings](/v4/docs/ai-sdk-core/settings)
  - [Embeddings](/v4/docs/ai-sdk-core/embeddings)
  - [Image Generation](/v4/docs/ai-sdk-core/image-generation)
  - [Transcription](/v4/docs/ai-sdk-core/transcription)
  - [Speech](/v4/docs/ai-sdk-core/speech)
  - [Language Model Middleware](/v4/docs/ai-sdk-core/middleware)
  - [Provider & Model Management](/v4/docs/ai-sdk-core/provider-management)
  - [Error Handling](/v4/docs/ai-sdk-core/error-handling)
  - [Testing](/v4/docs/ai-sdk-core/testing)
  - [Telemetry](/v4/docs/ai-sdk-core/telemetry)
- [AI SDK UI](/v4/docs/ai-sdk-ui)
  - [Overview](/v4/docs/ai-sdk-ui/overview)
  - [Chatbot](/v4/docs/ai-sdk-ui/chatbot)
  - [Chatbot Message Persistence](/v4/docs/ai-sdk-ui/chatbot-message-persistence)
  - [Chatbot Tool Usage](/v4/docs/ai-sdk-ui/chatbot-tool-usage)
  - [Generative User Interfaces](/v4/docs/ai-sdk-ui/generative-user-interfaces)
  - [Completion](/v4/docs/ai-sdk-ui/completion)
  - [Object Generation](/v4/docs/ai-sdk-ui/object-generation)
  - [OpenAI Assistants](/v4/docs/ai-sdk-ui/openai-assistants)
  - [Streaming Custom Data](/v4/docs/ai-sdk-ui/streaming-data)
  - [Error Handling](/v4/docs/ai-sdk-ui/error-handling)
  - [Smooth streaming japanese text](/v4/docs/ai-sdk-ui/smooth-stream-japanese)
  - [Smooth streaming chinese text](/v4/docs/ai-sdk-ui/smooth-stream-chinese)
  - [Stream Protocols](/v4/docs/ai-sdk-ui/stream-protocol)
- [AI SDK RSC](/v4/docs/ai-sdk-rsc)
  - [Overview](/v4/docs/ai-sdk-rsc/overview)
  - [Streaming React Components](/v4/docs/ai-sdk-rsc/streaming-react-components)
  - [Managing Generative UI State](/v4/docs/ai-sdk-rsc/generative-ui-state)
  - [Saving and Restoring States](/v4/docs/ai-sdk-rsc/saving-and-restoring-states)
  - [Multistep Interfaces](/v4/docs/ai-sdk-rsc/multistep-interfaces)
  - [Streaming Values](/v4/docs/ai-sdk-rsc/streaming-values)
  - [Handling Loading State](/v4/docs/ai-sdk-rsc/loading-state)
  - [Error Handling](/v4/docs/ai-sdk-rsc/error-handling)
  - [Handling Authentication](/v4/docs/ai-sdk-rsc/authentication)
  - [Migrating from RSC to UI](/v4/docs/ai-sdk-rsc/migrating-to-ui)
- [Advanced](/v4/docs/advanced)
  - [Prompt Engineering](/v4/docs/advanced/prompt-engineering)
  - [Stopping Streams](/v4/docs/advanced/stopping-streams)
  - [Backpressure](/v4/docs/advanced/backpressure)
  - [Caching](/v4/docs/advanced/caching)
  - [Multiple Streamables](/v4/docs/advanced/multiple-streamables)
  - [Rate Limiting](/v4/docs/advanced/rate-limiting)
  - [Rendering UI with Language Models](/v4/docs/advanced/rendering-ui-with-language-models)
  - [Language Models as Routers](/v4/docs/advanced/model-as-router)
  - [Multistep Interfaces](/v4/docs/advanced/multistep-interfaces)
  - [Sequential Generations](/v4/docs/advanced/sequential-generations)
  - [Vercel Deployment Guide](/v4/docs/advanced/vercel-deployment-guide)
- [Reference](/v4/docs/reference)
  - [AI SDK Core](/v4/docs/reference/ai-sdk-core)
    - [generateText](/v4/docs/reference/ai-sdk-core/generate-text)
    - [streamText](/v4/docs/reference/ai-sdk-core/stream-text)
    - [generateObject](/v4/docs/reference/ai-sdk-core/generate-object)
    - [streamObject](/v4/docs/reference/ai-sdk-core/stream-object)
    - [embed](/v4/docs/reference/ai-sdk-core/embed)
    - [embedMany](/v4/docs/reference/ai-sdk-core/embed-many)
    - [generateImage](/v4/docs/reference/ai-sdk-core/generate-image)
    - [transcribe](/v4/docs/reference/ai-sdk-core/transcribe)
    - [generateSpeech](/v4/docs/reference/ai-sdk-core/generate-speech)
    - [tool](/v4/docs/reference/ai-sdk-core/tool)
    - [experimental_createMCPClient](/v4/docs/reference/ai-sdk-core/create-mcp-client)
    - [Experimental_StdioMCPTransport](/v4/docs/reference/ai-sdk-core/mcp-stdio-transport)
    - [jsonSchema](/v4/docs/reference/ai-sdk-core/json-schema)
    - [zodSchema](/v4/docs/reference/ai-sdk-core/zod-schema)
    - [valibotSchema](/v4/docs/reference/ai-sdk-core/valibot-schema)
    - [CoreMessage](/v4/docs/reference/ai-sdk-core/core-message)
    - [createProviderRegistry](/v4/docs/reference/ai-sdk-core/provider-registry)
    - [customProvider](/v4/docs/reference/ai-sdk-core/custom-provider)
    - [cosineSimilarity](/v4/docs/reference/ai-sdk-core/cosine-similarity)
    - [wrapLanguageModel](/v4/docs/reference/ai-sdk-core/wrap-language-model)
    - [LanguageModelV1Middleware](/v4/docs/reference/ai-sdk-core/language-model-v1-middleware)
    - [extractReasoningMiddleware](/v4/docs/reference/ai-sdk-core/extract-reasoning-middleware)
    - [simulateStreamingMiddleware](/v4/docs/reference/ai-sdk-core/simulate-streaming-middleware)
    - [defaultSettingsMiddleware](/v4/docs/reference/ai-sdk-core/default-settings-middleware)
    - [simulateReadableStream](/v4/docs/reference/ai-sdk-core/simulate-readable-stream)
    - [smoothStream](/v4/docs/reference/ai-sdk-core/smooth-stream)
    - [generateId](/v4/docs/reference/ai-sdk-core/generate-id)
    - [createIdGenerator](/v4/docs/reference/ai-sdk-core/create-id-generator)
  - [AI SDK UI](/v4/docs/reference/ai-sdk-ui)
    - [useChat](/v4/docs/reference/ai-sdk-ui/use-chat)
    - [useCompletion](/v4/docs/reference/ai-sdk-ui/use-completion)
    - [useObject](/v4/docs/reference/ai-sdk-ui/use-object)
    - [useAssistant](/v4/docs/reference/ai-sdk-ui/use-assistant)
    - [AssistantResponse](/v4/docs/reference/ai-sdk-ui/assistant-response)
    - [convertToCoreMessages](/v4/docs/reference/ai-sdk-ui/convert-to-core-messages)
    - [appendResponseMessages](/v4/docs/reference/ai-sdk-ui/append-response-messages)
    - [appendClientMessage](/v4/docs/reference/ai-sdk-ui/append-client-message)
    - [createDataStream](/v4/docs/reference/ai-sdk-ui/create-data-stream)
    - [createDataStreamResponse](/v4/docs/reference/ai-sdk-ui/create-data-stream-response)
    - [pipeDataStreamToResponse](/v4/docs/reference/ai-sdk-ui/pipe-data-stream-to-response)
    - [StreamData](/v4/docs/reference/ai-sdk-ui/stream-data)
  - [AI SDK RSC](/v4/docs/reference/ai-sdk-rsc)
    - [streamUI](/v4/docs/reference/ai-sdk-rsc/stream-ui)
    - [createAI](/v4/docs/reference/ai-sdk-rsc/create-ai)
    - [createStreamableUI](/v4/docs/reference/ai-sdk-rsc/create-streamable-ui)
    - [createStreamableValue](/v4/docs/reference/ai-sdk-rsc/create-streamable-value)
    - [readStreamableValue](/v4/docs/reference/ai-sdk-rsc/read-streamable-value)
    - [getAIState](/v4/docs/reference/ai-sdk-rsc/get-ai-state)
    - [getMutableAIState](/v4/docs/reference/ai-sdk-rsc/get-mutable-ai-state)
    - [useAIState](/v4/docs/reference/ai-sdk-rsc/use-ai-state)
    - [useActions](/v4/docs/reference/ai-sdk-rsc/use-actions)
    - [useUIState](/v4/docs/reference/ai-sdk-rsc/use-ui-state)
    - [useStreamableValue](/v4/docs/reference/ai-sdk-rsc/use-streamable-value)
    - [render (Removed)](/v4/docs/reference/ai-sdk-rsc/render)
  - [Stream Helpers](/v4/docs/reference/stream-helpers)
    - [AIStream](/v4/docs/reference/stream-helpers/ai-stream)
    - [StreamingTextResponse](/v4/docs/reference/stream-helpers/streaming-text-response)
    - [streamToResponse](/v4/docs/reference/stream-helpers/stream-to-response)
    - [OpenAIStream](/v4/docs/reference/stream-helpers/openai-stream)
    - [AnthropicStream](/v4/docs/reference/stream-helpers/anthropic-stream)
    - [AWSBedrockStream](/v4/docs/reference/stream-helpers/aws-bedrock-stream)
    - [AWSBedrockAnthropicStream](/v4/docs/reference/stream-helpers/aws-bedrock-anthropic-stream)
    - [AWSBedrockAnthropicMessagesStream](/v4/docs/reference/stream-helpers/aws-bedrock-messages-stream)
    - [AWSBedrockCohereStream](/v4/docs/reference/stream-helpers/aws-bedrock-cohere-stream)
    - [AWSBedrockLlama2Stream](/v4/docs/reference/stream-helpers/aws-bedrock-llama-2-stream)
    - [CohereStream](/v4/docs/reference/stream-helpers/cohere-stream)
    - [GoogleGenerativeAIStream](/v4/docs/reference/stream-helpers/google-generative-ai-stream)
    - [HuggingFaceStream](/v4/docs/reference/stream-helpers/hugging-face-stream)
    - [LangChainAdapter](/v4/docs/reference/stream-helpers/langchain-adapter)
    - [LangChainStream](/v4/docs/reference/stream-helpers/langchain-stream)
    - [LlamaIndexAdapter](/v4/docs/reference/stream-helpers/llamaindex-adapter)
    - [MistralStream](/v4/docs/reference/stream-helpers/mistral-stream)
    - [ReplicateStream](/v4/docs/reference/stream-helpers/replicate-stream)
    - [InkeepStream](/v4/docs/reference/stream-helpers/inkeep-stream)
  - [AI SDK Errors](/v4/docs/reference/ai-sdk-errors)
    - [AI_APICallError](/v4/docs/reference/ai-sdk-errors/ai-api-call-error)
    - [AI_DownloadError](/v4/docs/reference/ai-sdk-errors/ai-download-error)
    - [AI_EmptyResponseBodyError](/v4/docs/reference/ai-sdk-errors/ai-empty-response-body-error)
    - [AI_InvalidArgumentError](/v4/docs/reference/ai-sdk-errors/ai-invalid-argument-error)
    - [AI_InvalidDataContentError](/v4/docs/reference/ai-sdk-errors/ai-invalid-data-content-error)
    - [AI_InvalidDataContent](/v4/docs/reference/ai-sdk-errors/ai-invalid-data-content)
    - [AI_InvalidMessageRoleError](/v4/docs/reference/ai-sdk-errors/ai-invalid-message-role-error)
    - [AI_InvalidPromptError](/v4/docs/reference/ai-sdk-errors/ai-invalid-prompt-error)
    - [AI_InvalidResponseDataError](/v4/docs/reference/ai-sdk-errors/ai-invalid-response-data-error)
    - [AI_InvalidToolArgumentsError](/v4/docs/reference/ai-sdk-errors/ai-invalid-tool-arguments-error)
    - [AI_JSONParseError](/v4/docs/reference/ai-sdk-errors/ai-json-parse-error)
    - [AI_LoadAPIKeyError](/v4/docs/reference/ai-sdk-errors/ai-load-api-key-error)
    - [AI_LoadSettingError](/v4/docs/reference/ai-sdk-errors/ai-load-setting-error)
    - [AI_MessageConversionError](/v4/docs/reference/ai-sdk-errors/ai-message-conversion-error)
    - [AI_NoAudioGeneratedError](/v4/docs/reference/ai-sdk-errors/ai-no-audio-generated-error)
    - [AI_NoContentGeneratedError](/v4/docs/reference/ai-sdk-errors/ai-no-content-generated-error)
    - [AI_NoImageGeneratedError](/v4/docs/reference/ai-sdk-errors/ai-no-image-generated-error)
    - [AI_NoObjectGeneratedError](/v4/docs/reference/ai-sdk-errors/ai-no-object-generated-error)
    - [AI_NoOutputSpecifiedError](/v4/docs/reference/ai-sdk-errors/ai-no-output-specified-error)
    - [AI_NoSuchModelError](/v4/docs/reference/ai-sdk-errors/ai-no-such-model-error)
    - [AI_NoSuchProviderError](/v4/docs/reference/ai-sdk-errors/ai-no-such-provider-error)
    - [AI_NoSuchToolError](/v4/docs/reference/ai-sdk-errors/ai-no-such-tool-error)
    - [AI_NoTranscriptGeneratedError](/v4/docs/reference/ai-sdk-errors/ai-no-transcript-generated-error)
    - [AI_RetryError](/v4/docs/reference/ai-sdk-errors/ai-retry-error)
    - [AI_TooManyEmbeddingValuesForCallError](/v4/docs/reference/ai-sdk-errors/ai-too-many-embedding-values-for-call-error)
    - [ToolCallRepairError](/v4/docs/reference/ai-sdk-errors/ai-tool-call-repair-error)
    - [AI_ToolExecutionError](/v4/docs/reference/ai-sdk-errors/ai-tool-execution-error)
    - [AI_TypeValidationError](/v4/docs/reference/ai-sdk-errors/ai-type-validation-error)
    - [AI_UnsupportedFunctionalityError](/v4/docs/reference/ai-sdk-errors/ai-unsupported-functionality-error)
- [Migration Guides](/v4/docs/migration-guides)
  - [Versioning](/v4/docs/migration-guides/versioning)
  - [Migrate AI SDK 4.1 to 4.2](/v4/docs/migration-guides/migration-guide-4-2)
  - [Migrate AI SDK 4.0 to 4.1](/v4/docs/migration-guides/migration-guide-4-1)
  - [Migrate AI SDK 3.4 to 4.0](/v4/docs/migration-guides/migration-guide-4-0)
  - [Migrate AI SDK 3.3 to 3.4](/v4/docs/migration-guides/migration-guide-3-4)
  - [Migrate AI SDK 3.2 to 3.3](/v4/docs/migration-guides/migration-guide-3-3)
  - [Migrate AI SDK 3.1 to 3.2](/v4/docs/migration-guides/migration-guide-3-2)
  - [Migrate AI SDK 3.0 to 3.1](/v4/docs/migration-guides/migration-guide-3-1)
- [Troubleshooting](/v4/docs/troubleshooting)
  - [Azure OpenAI Slow to Stream](/v4/docs/troubleshooting/azure-stream-slow)
  - [Client-Side Function Calls Not Invoked](/v4/docs/troubleshooting/client-side-function-calls-not-invoked)
  - [Server Actions in Client Components](/v4/docs/troubleshooting/server-actions-in-client-components)
  - [useChat/useCompletion stream output contains 0:... instead of text](/v4/docs/troubleshooting/strange-stream-output)
  - [Streamable UI Errors](/v4/docs/troubleshooting/streamable-ui-errors)
  - [Tool Invocation Missing Result Error](/v4/docs/troubleshooting/tool-invocation-missing-result)
  - [Streaming Not Working When Deployed](/v4/docs/troubleshooting/streaming-not-working-when-deployed)
  - [Streaming Not Working When Proxied](/v4/docs/troubleshooting/streaming-not-working-when-proxied)
  - [Getting Timeouts When Deploying on Vercel](/v4/docs/troubleshooting/timeout-on-vercel)
  - [Unclosed Streams](/v4/docs/troubleshooting/unclosed-streams)
  - [useChat Failed to Parse Stream](/v4/docs/troubleshooting/use-chat-failed-to-parse-stream)
  - [Server Action Plain Objects Error](/v4/docs/troubleshooting/client-stream-error)
  - [useChat No Response with maxSteps](/v4/docs/troubleshooting/use-chat-tools-no-response)
  - [useChat "An error occurred"](/v4/docs/troubleshooting/use-chat-an-error-occurred)
  - [streamText fails silently](/v4/docs/troubleshooting/stream-text-not-working)
  - [NaN token counts when using streamText with OpenAI models](/v4/docs/troubleshooting/nan-token-counts-openai-streaming)
  - [Model is not assignable to type "LanguageModelV1"](/v4/docs/troubleshooting/model-is-not-assignable-to-type)
  - [TypeScript error "Cannot find namespace 'JSX'"](/v4/docs/troubleshooting/typescript-cannot-find-namespace-jsx)
  - [React error "Maximum update depth exceeded"](/v4/docs/troubleshooting/react-maximum-update-depth-exceeded)
  - [Jest: cannot find module 'ai/rsc'](/v4/docs/troubleshooting/jest-cannot-find-module-ai-rsc)
  - [Schema must be JSON Schema of type object error](/v4/docs/troubleshooting/zod-v4-json-schema-type-error)


[Full Sitemap](/sitemap.md)
