AI SDK RSCcreateAI
createAI
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/rsc"
Object Parameter
actions:
Server side actions that can be called from the client.
initialAIState:
Initial AI state to be used in the client.
initialUIState:
Initial UI state to be used in the client.
onGetUIState:
is called during SSR to compare and update UI state.
onSetAIState:
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:
The resulting AI state after the update.
done:
Whether the AI state updates have been finalized or not.
Returns
It returns an <AI> context provider.