📄 ai-sdk/docs/reference/ai-sdk-rsc/create-ai

File: create-ai.md | Updated: 11/15/2025

Source: https://ai-sdk.dev/docs/reference/ai-sdk-rsc/create-ai

AI SDK

Menu

v5 (Latest)

AI SDK 5.x

AI SDK by Vercel

AI SDK 6 Beta

Foundations

Overview

Providers and Models

Prompts

Tools

Streaming

Getting Started

Navigating the Library

Next.js App Router

Next.js Pages Router

Svelte

Vue.js (Nuxt)

Node.js

Expo

Agents

Agents

Building Agents

Workflow Patterns

Loop Control

AI SDK Core

Overview

Generating Text

Generating Structured Data

Tool Calling

Model Context Protocol (MCP) Tools

Prompt Engineering

Settings

Embeddings

Image Generation

Transcription

Speech

Language Model Middleware

Provider & Model Management

Error Handling

Testing

Telemetry

AI SDK UI

Overview

Chatbot

Chatbot Message Persistence

Chatbot Resume Streams

Chatbot Tool Usage

Generative User Interfaces

Completion

Object Generation

Streaming Custom Data

Error Handling

Transport

Reading UIMessage Streams

Message Metadata

Stream Protocols

AI SDK RSC

Advanced

Reference

AI SDK Core

AI SDK UI

AI SDK RSC

streamUI

createAI

createStreamableUI

createStreamableValue

readStreamableValue

getAIState

getMutableAIState

useAIState

useActions

useUIState

useStreamableValue

render (Removed)

Stream Helpers

AI SDK Errors

Migration Guides

Troubleshooting

Copy markdown

createAI

==============================================================================

AI SDK RSC is currently experimental. We recommend using AI SDK UI for production. For guidance on migrating from RSC to UI, see our migration guide .

Creates a client-server context provider that can be used to wrap parts of your application tree to easily manage both UI and AI states of your application.

Import


import { createAI } from "@ai-sdk/rsc"

API Signature


Parameters

actions:

Record<string, Action>

Server side actions that can be called from the client.

initialAIState:

any

Initial AI state to be used in the client.

initialUIState:

any

Initial UI state to be used in the client.

onGetUIState:

() => UIState

is called during SSR to compare and update UI state.

onSetAIState:

(Event) => void

is triggered whenever an update() or done() is called by the mutable AI state in your action, so you can safely store your AI state in the database.

Event

state:

AIState

The resulting AI state after the update.

done:

boolean

Whether the AI state updates have been finalized or not.

Returns

It returns an <AI/> context provider.

Examples


Learn to manage AI and UI states in Next.js Learn to persist and restore states UI/AI states in Next.js

On this page

createAI

Import

API Signature

Parameters

Returns

Examples

Deploy and Scale AI Apps with Vercel.

Vercel delivers the infrastructure and developer experience you need to ship reliable AI-powered applications at scale.

Trusted by industry leaders:

  • OpenAI
  • Photoroom
  • leonardo-ai Logoleonardo-ai Logo
  • zapier Logozapier Logo

Talk to an expert