ChatProvider supplies the platform adapter used by <Chat> and loads the chat manifest through it. The adapter is the chat UI’s only route to a backend: it streams turns, lists and loads chats, and provides optional capabilities such as rename or attachments.
For a FrogBot server, build the adapter with createRestChatAdapter from @frogbotai/ui/chat/rest:
bearerFetch when authentication comes from a token instead of a same-origin cookie.
/api/frogbot. Do not duplicate those slugs in consumer code.
Provider props
ChatProvider calls the adapter’s loadManifest once per adapter and aborts it on unmount. Until it resolves, <Chat> renders its loadingContent; a failure renders its errorContent, and null renders its disabledContent. useChatProvider() returns { adapter, manifest, error, loading, toolRenderers, dataRenderers, commands, mentionSources, composerFeatures, composerHistory, faviconUrl }.
REST adapter options
createRestChatAdapter implements every adapter member against FrogBot’s REST API.
The adapter reads
/api/frogbot on each loadManifest, and slug lookups reuse the latest response, so a provider mount and the requests it makes share one fetch. With all three slugs and no ChatProvider, as in a sidebar that only lists chats, it never fetches it. loadManifest also reads /api/agents and returns null when chat is disabled on the server.
FrogBotChatTransport, the transport the REST adapter’s createTransport returns, is exported from @frogbotai/ui/chat/rest too, for an AI SDK useChat call of your own.
Adapter options
An adapter is aChatPlatformAdapter object. The first five members are required. Each optional member is a capability: when it is missing, the UI hides the feature it drives.
Adapters report failures the UI recovers from as a
ChatAdapterError, exported from @frogbotai/ui/chat, with a code:
conflict: a dismissed tool call was already settled.Chatreloads the conversation.file-unreadable: the backend can’t read an uploaded file. The composer marks it “This file couldn’t be read.”file-too-large: an upload is over the size limit. The composer marks it too large.
uploadAttachment marks the upload as failed, with the error’s message as the reason. The UI emits frogbot:chats:mutated (CHAT_MUTATION_EVENT) after each rename, delete, branch, agent change, and new chat ID, so an adapter never needs to.
Custom adapter
An adapter of your own lets the chat UI run without a FrogBot server, for example with an agent running in the browser and chats kept in local storage. This one runs an AI SDK agent in-process withDirectChatTransport and keeps chats in memory:
- Store each turn. The UI never saves messages; it reloads them with
loadMessages. Here the transport tees the stream and stores the reply when it finishes. - Call
onChatIdfor a new chat, before the stream ends.Chatthen selects the chat and emitsfrogbot:chats:mutated, so lists fromuseChats({ revalidate: true })refresh. - Map the parts the agent can’t read.
DirectChatTransportrejectsfile-referenceparts, andconvertToModelMessagesdropsdata-*parts such asdata-paste. Either leave outuploadAttachment, so the composer offers no attachments, or turn eachfile-referencepart into afilepart before passing the messages on; turndata-pasteanddata-page-contextparts into text if the model should see them.
branchChat, suggestChatTitle, uploadAttachment, or transcribe, so the chat shows no Branch actions, title suggestion, attach button, or microphone.