A concise AI chat component library and demo project. Provides an out-of-the-box Vue 3 chat interface with custom tools, card components, streaming responses, and more.
aix-chat/
├── packages/
│ ├── chat-ui/ # AI chat component library (npm: aix-chat)
│ ├── demo/ # Order assistant demo
│ └── server/ # Backend API (simplified)
├── package.json # Monorepo config
└── pnpm-workspace.yaml
cd aix-chat
pnpm install# Start PostgreSQL with Docker
docker-compose up -d
# Verify
docker-compose pscp .env.example .env
# Edit .env and fill in your OpenAI API Key# Start backend (port 3000)
pnpm dev:server
# Start frontend (port 5173)
pnpm dev:uiVisit http://localhost:5173
- ChatApp component: Full chat UI, ready to use out of the box
- Tool definition: Define tools and cards via
defineTools - Automatic handling: Card registration, event routing, pending state — all handled for you
- Responsive design: Mobile and desktop support
- AI SDK v7: Uses the latest
useChatcomposable with streaming support
- Minimal design: Single
/api/agent/chatendpoint - Streaming response: SSE streaming output
- Tool support: Receives frontend tool definitions, passes them to AI
- PostgreSQL storage: Persists conversation history via Docker
The project uses Docker to run a PostgreSQL database for persisting chat history:
# Start database
docker-compose up -d
# View logs
docker-compose logs -f postgres
# Stop database
docker-compose down
# Stop and remove data
docker-compose down -vDatabase credentials:
- Host: localhost:5432
- User: aix
- Password: aix123
- Database: aix_chat
- Connection String:
postgresql://aix:aix123@localhost:5432/aix_chat
npm install aix-chat<script setup>
import { ChatApp } from 'aix-chat'
import 'aix-chat/style.css'
</script>
<template>
<ChatApp
agent-id="my-agent"
api-base="http://localhost:3000"
/>
</template>import { defineTools } from 'aix-chat'
import OptionCard from './OptionCard.vue'
export const tools = defineTools([
{
name: 'showOptions',
description: 'Show options for user to choose',
parameters: {
type: 'object',
properties: {
title: { type: 'string' },
options: { type: 'array' }
}
},
component: OptionCard,
mapProps: (args) => ({ title: args.title, options: args.options }),
execute: async (args) => ({ pending: true, ...args }),
onEvent: (eventName, data) => console.log(eventName, data)
}
])<script setup>
import { ChatApp } from 'aix-chat'
import 'aix-chat/style.css'
import { tools } from './tools'
const headers = {
Authorization: `Bearer ${yourToken}`
}
</script>
<template>
<ChatApp
agent-id="my-agent"
api-base="http://localhost:3000"
:tools="tools"
:headers="headers"
system-prompt="You are an assistant..."
:welcome="{
text: 'Hi! How can I help you?',
quickReplies: [
{ label: 'Action A', value: 'Execute Action A' },
{ label: 'Action B', value: 'Execute Action B' }
]
}"
/>
</template>For full documentation on the chat component, see packages/chat-ui/README.md.
The component talks to a single SSE endpoint (default: POST /api/agent/chat). Your backend receives messages + tool definitions, calls an LLM, and streams back responses.
{
"agentId": "my-agent",
"messages": [{ "role": "user", "content": "Hello" }],
"tools": [
{ "name": "showOptions", "description": "...", "parameters": { ... } }
],
"systemPrompt": "You are an assistant..."
}SSE stream in AI SDK UI Message Stream format.
import { streamText, convertToModelMessages, toUIMessageStream, createUIMessageStreamResponse } from 'ai'
import { createOpenAI } from '@ai-sdk/openai'
const openai = createOpenAI({ apiKey: process.env.OPENAI_API_KEY })
export async function POST(req: Request) {
const { messages, tools = [], systemPrompt } = await req.json()
const aiTools = Object.fromEntries(
tools.map((t: any) => [t.name, { description: t.description, parameters: t.parameters }])
)
const result = streamText({
model: openai('gpt-4o-mini'),
instructions: systemPrompt,
messages: await convertToModelMessages(messages),
tools: aiTools,
})
return createUIMessageStreamResponse({
stream: toUIMessageStream({ stream: result.stream, sendReasoning: true }),
})
}Works with any AI SDK provider — OpenAI, Anthropic, Google, DashScope, Ollama, etc.
For full component documentation, see packages/chat-ui/README.md.
This project includes Claude Code Skills to help you integrate the AI chat quickly.
After installing aix-chat, the skills are automatically linked to your project's .claude/skills directory.
In Claude Code, just ask:
- "How do I add an AI chat card?"
- "How to create a chat tool?"
- "How to connect to the backend Agent API?"
- "How to develop card components?"
Claude will automatically use the ai-chat-integration skill to guide you through development.
If auto-linking fails:
mkdir -p .claude
cp -r node_modules/aix-chat/.claude/skills .claude/# Build all packages
pnpm build
# Build chat-ui only
pnpm build:ui
# Build server only
pnpm build:server
# Dev mode (watch)
pnpm dev:ui- Frontend: Vue 3 + TypeScript + Vite
- AI SDK: ai v7 + @ai-sdk/vue v4 (useChat composable)
- Backend: Fastify + AI SDK
- AI: OpenAI GPT-4
- Monorepo: pnpm workspaces
MIT