e30e75b5d4
Changesets / Create Version PR (push) Has been cancelled
Deploy Shadcn Registry / Deploy Production (push) Has been cancelled
Template Metrics / LOC + Bundle Size (push) Has been cancelled
Code Quality / Oxlint + Oxfmt (push) Has been cancelled
Code Quality / Template Sync (push) Has been cancelled
Code Quality / Build Changed Packages (push) Has been cancelled
Code Quality / Test Changed Packages (push) Has been cancelled
Deploy Expo Example / Deploy Production (push) Has been cancelled
Deploy Ink Example / Deploy Production (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.12) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Has been cancelled
Cloud Persistence for AI SDK (Standalone)
Lightweight cloud persistence for AI SDK apps without assistant-ui components.
Want the full assistant-ui experience? See with-cloud instead, which uses
useChatRuntimewith<Thread />and other primitives.
Setup
- Get your project URL from cloud.assistant-ui.com
- Add to
.env:NEXT_PUBLIC_ASSISTANT_BASE_URL=https://your-project.assistant-api.com OPENAI_API_KEY=sk-...
Usage
Zero-config (anonymous users)
import { useCloudChat } from "@assistant-ui/cloud-ai-sdk";
function Chat() {
// Auto-initializes anonymous cloud from NEXT_PUBLIC_ASSISTANT_BASE_URL
const { messages, sendMessage, threads } = useCloudChat();
// ...
}
With custom cloud instance (authenticated users)
import { AssistantCloud } from "assistant-cloud";
import { useCloudChat } from "@assistant-ui/cloud-ai-sdk";
function Chat() {
const cloud = useMemo(() => new AssistantCloud({
baseUrl: process.env.NEXT_PUBLIC_ASSISTANT_BASE_URL!,
authToken: async () => getToken(),
}), [getToken]);
const { messages, sendMessage, threads } = useCloudChat({ cloud });
// ...
}
With external thread management
When you need thread operations in a separate component (e.g., a sidebar) or custom options like includeArchived:
// In parent or context
const myThreads = useThreads({ cloud, includeArchived: true });
// In chat component - uses your thread state
const { messages, sendMessage } = useCloudChat({ threads: myThreads });
// In sidebar component - same thread state
<ThreadList threads={myThreads.threads} onSelect={myThreads.selectThread} />
How it works
Messages persist automatically as they complete. Thread creation is handled automatically when you send the first message — the thread is created, selected, and the list is refreshed. Call threads.selectThread(id) to switch threads, threads.selectThread(null) for a new chat.