replit_ui library

Replit UI is an open-source Flutter library for chat interfaces, with optional streaming providers and tool execution.

The UI components render state and report intent through callbacks. The optional SDK connects Gemini, OpenAI-compatible and Anthropic providers when an application chooses to use them.

The UI's attachment picker opens the platform's own dialog — from the composer's attach button or a host's own "+" menu — and on the web the chat surface accepts drops and the field takes pasted images. All are opt-in and hand back ReplitAttachments for the host to hold. The streaming providers also make requests only when an app uses them.

Classes

AgentConfig
What every turn carries besides the conversation: the system instructions and the sampling knobs. Unset fields are left out of the request.
AnthropicProvider
Anthropic's Messages API, called directly with an API key. Browser calls send the header Anthropic requires for that, so the key travels to the browser; keep that for development builds.
ChatError
A failed turn: a stable code, a user-safe message, and where the fault lies. detail is the provider's own wording, when there is one.
ChatState
Everything a chat shows, as one immutable value per change.
ChatTurnStats
How the last turn went: time to the first token, total time, tokens.
ChatUsage
Tokens a turn consumed, as the provider reported them.
DeltaEvent
DoneEvent
ErrorCodeInfo
One entry of the error-code registry (contracts/error-codes.json).
ErrorCodes
The frozen, additively growing error-code registry.
ErrorEvent
GeminiProvider
Google's Gemini API, called directly with an API key from AI Studio.
IdGenerator
Mints the thr_, trn_, msg_ and tc_ ids a chat uses. Inject one with a seeded Random for reproducible ids.
ModelOption
A model a provider can be pointed at, as a selector shows it.
OpenAIProvider
OpenAI's Chat Completions API, called directly with an API key. Point baseUrl at any compatible server: Ollama, Groq, OpenRouter, LM Studio, vLLM, or a proxy of your own that holds the key.
ReplitAttachment
A file the host wants shown as a tile.
ReplitAttachmentGroup
A group of attachment tiles, each optionally removable:
ReplitAttachmentOptions
What the built-in picker offers and how what comes back is decoded.
ReplitAttachmentPart
Image attachments, rendered as a group of thumbnail tiles.
ReplitAttachmentPreview
A full-screen look at one attachment, with the rest of its group a swipe away, over a frosted view of the page beneath.
ReplitAttachmentTypeGroup
A named set of file types for the picker's filter.
ReplitChatView
The chat surface: a bounded thread above a composer, centred at a readable width, with a zero state for the conversation that hasn't started.
ReplitChatViewStyle
Host overrides for ReplitChatView's look, on top of the theme tokens.
ReplitCodeBlock
A code block: a fenced snippet on its own washed ground, under a header that names the content and offers copy.
ReplitCodeBlockStyle
Host overrides for ReplitCodeBlock's look, on top of the theme tokens.
ReplitCodeLanguage
A language the code block can highlight: an id, lookup aliases, and an ordered rule table.
ReplitCodePart
Fenced code, rendered by a ReplitCodeBlock.
ReplitColors
Semantic color tokens for replit_ui components.
ReplitComposer
The message input area: an auto-growing text field with an action bar and a send button that morphs into stop while isStreaming.
ReplitComposerStyle
Host overrides for ReplitComposer's look, on top of the theme tokens.
ReplitConfirmation
The approval card: an asterisk-marked request on a raised card, with approve and reject buttons that settle into the outcome.
ReplitConfirmationPart
A request for the user's go-ahead, rendered by a ReplitConfirmation.
ReplitConfirmationStyle
Host overrides for ReplitConfirmation's look, on top of the theme tokens.
ReplitCustomPart
Host-defined content, rendered through a ReplitCustomPartBuilder.
ReplitDropTarget
Turns the area its child occupies into a file drop target, decoding what lands there into attachments.
ReplitEffortOption
One effort choice in a ReplitModelSelector.
ReplitErrorPart
A failure surfaced in the turn, rendered by a ReplitErrorState.
ReplitErrorState
A failure surface: an error glyph and a host-written explanation on a hairline card, with an optional retry pill.
ReplitErrorStateStyle
Host overrides for ReplitErrorState's look, on top of the theme tokens.
ReplitGreeting
The zero state's headline — "Good afternoon, …" over a thread nobody has spoken in yet, usually through ReplitChatView.greeting:
ReplitImagePart
A large-format image in a turn — a generated picture presented as content, unlike ReplitAttachmentPart's thumbnail tiles.
ReplitMarkdown
Markdown rendered in the package's own voice: assistant prose, typeset.
ReplitMarkdownStyle
Host overrides for ReplitMarkdown's look, on top of the theme tokens.
ReplitMenu
A menu of options behind a single icon trigger — on phones, a bottom sheet. The composer's "+" menu is this widget with icon set to the add glyph, but it carries no add semantics of its own:
ReplitMenuDivider
A hairline between groups of options.
ReplitMenuEntry
One entry in a ReplitMenu: an option or a divider.
ReplitMenuOption
One actionable row in a ReplitMenu.
ReplitMenuStyle
Host overrides for a replit_ui menu's look, on top of the theme tokens.
ReplitMessage
Renders a single ReplitMessageData with role-appropriate presentation:
ReplitMessageAction
One action in a ReplitMessageActions row.
ReplitMessageActions
Compact icon-button row for message actions — designed for the footer slot of a ReplitMessage:
ReplitMessageActionsStyle
Host overrides for ReplitMessageActions' look, on top of the theme tokens.
ReplitMessageData
One turn in a conversation.
ReplitMessagePart
One piece of content inside a ReplitMessageData.
ReplitMessageStyle
Host overrides for ReplitMessage's look, on top of the theme tokens.
ReplitModelOption
One model choice in a ReplitModelSelector.
ReplitModelSelector
Compact model picker: a pill trigger showing the selected model, opening a token-styled menu — or, on phones, a bottom sheet. Designed for a composer's trailingActions slot.
ReplitPill
A removable pill showing an enabled tool or mode — "Research", "Web Search" — in the composer's action row, typically appended to ReplitComposer.leadingActions while the host's toggle is on:
ReplitPillStyle
Host overrides for ReplitPill's look, on top of the theme tokens.
ReplitShimmerText
Text with a soft highlight sweeping through it — the waiting treatment for a label whose work is still in flight, e.g. a thinking line or a tool call in progress.
ReplitStreamingText
Animated reveal for text that arrives incrementally.
ReplitStrings
Every string the SDK shows, with English defaults. Subclass and override to localise.
ReplitSuggestion
A tappable prompt row: the host's suggested message, optionally with a leading icon. Usable on its own, or in a ReplitSuggestionGroup:
ReplitSuggestionColumnScope
Marks the subtree as a ReplitSuggestionGroup column, where a hovered ReplitSuggestion shows its trailing arrow. Public so a host laying out its own full-width column can opt suggestion rows into the same affordance.
ReplitSuggestionGroup
Lays out prompt suggestions as a scrolling strip, a wrap, or a column — typically above a ReplitComposer on an empty thread:
ReplitSuggestionStyle
Host overrides for ReplitSuggestion's look, on top of the theme tokens.
ReplitSyntaxColors
Syntax token colors for the code block.
ReplitSyntaxRule
One highlighting rule: every match of pattern reads as token.
ReplitTextPart
Plain text content.
ReplitTheme
The replit_ui design tokens — colors and typography — installed as a ThemeExtension:
ReplitThinkingIndicator
The thinking line shown while the assistant has not started responding: a slowly turning, breathing asterisk beside a shimmering, host-supplied label.
ReplitThread
The scrollable conversation, a list of ReplitMessageDatas.
ReplitThreadList
The conversation history: sections of thread rows, one of them selected — the list an assistant app hangs in its side panel.
ReplitThreadListItem
One conversation in a ReplitThreadList.
ReplitThreadListSection
A run of threads under one optional header in a ReplitThreadList.
ReplitThreadListStyle
Host overrides for ReplitThreadList's look, on top of the theme tokens.
ReplitToast
The floating notice: a glyph, one line that wraps, and a cross on the raised card — "Message copied to clipboard", "Image upload failed".
ReplitToastHandle
A toast showReplitToast floated: dismiss it early, or wait for it to go.
ReplitToastStyle
Host overrides for ReplitToast's look, on top of the theme tokens.
ReplitTool
The tool-call card: one mark for the call's status, its title and primary argument on a row, and the raw input and output behind a disclosure.
ReplitToolPart
One tool invocation, rendered by a ReplitTool card.
ReplitToolStyle
Host overrides for ReplitTool's look, on top of the theme tokens.
ReplitTypography
Text style tokens for replit_ui components.
SseEvent
SseUnknownEvent
Passthrough for event names or shapes this build does not know.
StartEvent
Tool
An action the app lets the model take: the model reads description and parameters, the SDK runs run with the arguments it chose.
ToolCall
One call of a tool, as its handler receives it.
ToolCallDeltaEvent
ToolCallEndEvent
ToolCallError
Why a tool call did not return a result.
ToolCallEvent
ToolCallRecord
One tool call the thread made: its arguments, status and outcome.
ToolCallStartEvent
ToolErrorCodes
The codes a ToolCallError carries.
TurnIds
The identity of one turn on the wire.
TurnRequest
One turn's input: the conversation as providers see it, the agent settings, the tools, the ids and the future that cancels it.
TurnTransport
Where a turn's events come from: a provider today, a gateway later. A run emits start first, exactly one done last, with seq strictly increasing from 0.
UiDesignChat
A chat against one provider: it holds the thread, runs each turn with the app's tools, and exposes everything as one ChatState per change.
UiDesignChatView
The finished chat screen for a UiDesignChat: thread, composer, attachments, message actions, tool cards and model selector. Body-only; put it in a Scaffold under material_ui's MaterialApp.
UiDesignProvider
One model API spoken natively with the developer's own key.
Upstream
UsageEvent
WireImagePart
An inline image.
WireMessage
One message as providers see it.
WirePart
A piece of a wire message.
WireTextPart
Plain text.
WireToolCallPart
A tool call the model made; only on assistant messages.
WireToolResultPart
A tool's answer; only on user messages, ahead of any other part.

Enums

ChatFailureClass
Who is responsible for a failed turn: the wire classes, plus runtime for faults that never left the device.
DoneEventStatus
FailureClass
ReplitAttachmentLayout
How a ReplitAttachmentGroup arranges its tiles.
ReplitAttachmentRejection
Why a file the host offered was not turned into an attachment, reported through onAttachmentRejected alongside the file's name.
ReplitComposerLayout
ReplitConfirmationStatus
Where a confirmation request stands.
ReplitMenuPresentation
How a replit_ui menu presents when its trigger is tapped.
ReplitMessageRole
Who authored a message.
ReplitMessageStatus
Lifecycle of a message.
ReplitSuggestionLayout
How a ReplitSuggestionGroup arranges its rows.
ReplitSyntaxToken
The token classes the built-in highlighter distinguishes, each colored by the matching ReplitSyntaxColors role. Anything no rule claims stays plain ink.
ReplitToolStatus
Where a tool call stands.
ToolCallStartEventExecutor
ToolCallStartEventPermissionClass
ToolCallStatus
Where a tool call stands.
ToolPermission
What a tool may do. Read runs silently, write runs unless the tool asks to confirm, destructive always asks first.
WireRole
Who wrote a wire message.
WireToolResultStatus
How a tool call ended, as the model hears it.

Extensions

ReplitThemeContext on BuildContext
Token access for widgets: context.replitColors.primary, context.replitTypography.bodyLarge, …

Functions

providerCallIdOf(String toolCallId) → String?
The provider's own call id inside an id from toolCallIdFor; null for ids the SDK minted.
runToolLoop({required TurnTransport transport, required TurnRequest request, required ToolApprover approve, required ToolCallObserver onCall, int maxRounds = 8}) → Stream<SseEvent>
Runs one turn with client-side tools: every segment's events as one stream, handlers run between segments, results fed back until the model answers or maxRounds segments have called tools.
showReplitAttachmentPicker({ReplitAttachmentOptions options = const ReplitAttachmentOptions(), void onRejected(String name, ReplitAttachmentRejection reason)?}) → Future<List<ReplitAttachment>>
Opens the platform's file dialog and returns what came back, read and decoded into ReplitAttachments.
showReplitAttachmentPreview({required BuildContext context, required List<ReplitAttachment> attachments, String? initialId, int? initialIndex, String? closeTooltip}) → Future<void>
Opens ReplitAttachmentPreview over the current route.
showReplitToast({required BuildContext context, required String message, IconData? icon, Duration? duration = const Duration(seconds: 4), String? dismissTooltip, bool rootOverlay = false, ReplitToastStyle? style}) → ReplitToastHandle
Floats a ReplitToast in the nearest Overlay and hands back its handle.
toolCallIdFor(String providerCallId) → String
A tool-call id that carries providerCallId, recoverable through providerCallIdOf.
unsentAttachmentText(String? label, String? mimeType) → String
The text that stands in for an attachment a provider call cannot carry, so the turn still reaches the model with the file named.

Typedefs

ReplitCustomPartBuilder = Widget? Function(BuildContext context, ReplitMessageData message, ReplitCustomPart part)
Renders a ReplitCustomPart; return null to skip it.
ToolApprover = Future<bool> Function(ToolCallRecord record)
Decides whether a gated call may run.
ToolBodyBuilder = Widget? Function(BuildContext context, ToolCallRecord record)
Builds the content shown under a tool card for record, or null for none; called for every call in every status.
ToolCallObserver = void Function(ToolCallRecord record)
Hears every change to a call's record.

Exceptions / Errors

ProviderTransportException
The network failed before a response arrived, or the connection closed mid-stream. Worth retrying; never carries headers or URLs.
ToolException
A failure a tool reports in its own words; the message reaches the card and the model.