Skip to main content
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:
Use bearerFetch when authentication comes from a token instead of a same-origin cookie.
The REST adapter reads renamed chat, message, and asset collection slugs from /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 a ChatPlatformAdapter 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. Chat reloads 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.
Any other error from 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 with DirectChatTransport and keeps chats in memory:
Three things are the host’s job:
  • 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 onChatId for a new chat, before the stream ends. Chat then selects the chat and emits frogbot:chats:mutated, so lists from useChats({ revalidate: true }) refresh.
  • Map the parts the agent can’t read. DirectChatTransport rejects file-reference parts, and convertToModelMessages drops data-* parts such as data-paste. Either leave out uploadAttachment, so the composer offers no attachments, or turn each file-reference part into a file part before passing the messages on; turn data-paste and data-page-context parts into text if the model should see them.
This adapter has no branchChat, suggestChatTitle, uploadAttachment, or transcribe, so the chat shows no Branch actions, title suggestion, attach button, or microphone.