e30e75b5d4
Changesets / Create Version PR (push) Waiting to run
Code Quality / Oxlint + Oxfmt (push) Waiting to run
Code Quality / Template Sync (push) Waiting to run
Code Quality / Build Changed Packages (push) Waiting to run
Code Quality / Test Changed Packages (push) Waiting to run
Deploy Expo Example / Deploy Production (push) Waiting to run
Deploy Ink Example / Deploy Production (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-stream, 3.12) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Waiting to run
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Waiting to run
Deploy Shadcn Registry / Deploy Production (push) Waiting to run
Template Metrics / LOC + Bundle Size (push) Waiting to run
Assistant Transport Example
This example demonstrates how to use assistant-ui with the useAssistantTransportRuntime hook to connect to a custom backend server that implements the assistant-transport protocol.
Quick Start
Using CLI (Recommended)
npx assistant-ui@latest create my-app --example with-assistant-transport
cd my-app
Environment Variables
Create .env.local:
NEXT_PUBLIC_API_URL=http://localhost:8000/assistant
Run
npm install
npm run dev
The application will be available at http://localhost:3000.
Overview
The Assistant Transport runtime allows you to connect assistant-ui to any backend server that can handle:
AddMessageCommand- for sending user messagesAddToolResultCommand- for sending tool execution results- Streaming responses using the
assistant-streamformat
Backend Server Requirements
Your backend server should:
- Accept POST requests at the configured endpoint (e.g.,
/assistant) - Handle the following command types in the request body:
AddMessageCommand:{ type: "add-message", message: { role: "user", parts: [...] } }AddToolResultCommand:{ type: "add-tool-result", toolCallId: string, result: object }
- Return streaming responses using the
assistant-streamformat - Include CORS headers to allow requests from the frontend
Key Features
- Custom Runtime: Uses
useAssistantTransportRuntimeto connect to any backend - Streaming Support: Handles real-time streaming responses from the server
- Tool Support: Supports tool calling between frontend and backend
- Error Handling: Includes proper error handling and loading states
- Modern UI: Built with Tailwind CSS and Radix UI components