Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 13:40:13 +08:00
..

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

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 messages
  • AddToolResultCommand - for sending tool execution results
  • Streaming responses using the assistant-stream format

Backend Server Requirements

Your backend server should:

  1. Accept POST requests at the configured endpoint (e.g., /assistant)
  2. 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 }
  3. Return streaming responses using the assistant-stream format
  4. Include CORS headers to allow requests from the frontend

Key Features

  • Custom Runtime: Uses useAssistantTransportRuntime to 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