Back to Blog
·7 min

AI Chat Platform Template: Build Custom ChatGPT Alternatives

Custom AI chat platforms are in high demand. Businesses want branded ChatGPT alternatives with custom knowledge bases, specific personalities, and controlled access. Building a multi-tenant AI chat platform requires streaming infrastructure, conversation management, file upload handling, and team collaboration features.

An AI chat platform template handles all of this so you can launch your white-label AI chat product quickly.

Key Platform Features

A production-ready AI chat platform includes:

  • Multi-model support (GPT-4o, Claude, Gemini)
  • Custom system prompts per team
  • File upload with RAG (retrieval augmented generation)
  • Conversation history and search
  • Team member management
  • Usage analytics dashboard
  • API access for integrations
  • Custom branding and domains

The AIChat Platform template includes all features with Stripe billing and team collaboration.

Multi-Model Chat Route

// app/api/chat/route.ts
import { StreamingTextResponse, OpenAIStream } from 'ai'
import OpenAI from 'openai'
import Anthropic from '@anthropic-ai/sdk'
import { auth } from '@/lib/auth'

export async function POST(req: Request) {
  const session = await auth()
  if (!session?.user) return new Response('Unauthorized', { status: 401 })

  const { messages, model } = await req.json()

  if (model.startsWith('gpt')) {
    const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY })
    const response = await openai.chat.completions.create({
      model,
      stream: true,
      messages: [{
        role: 'system',
        content: 'You are a helpful AI assistant for {company}. Be concise and accurate.',
      }, ...messages],
    })
    const stream = OpenAIStream(response)
    return new StreamingTextResponse(stream)
  }

  if (model.startsWith('claude')) {
    const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY })
    const response = await anthropic.messages.create({
      model,
      stream: true,
      max_tokens: 4096,
      messages: messages.map((m: any) => ({ role: m.role, content: m.content })),
    })
    const stream = AnthropicStream(response)
    return new StreamingTextResponse(stream)
  }

  return new Response('Unsupported model', { status: 400 })
}

Conversation List Component

'use client'

import { useState, useEffect } from 'react'
import { Search, MessageSquare, Trash2 } from 'lucide-react'

interface Conversation {
  id: string
  title: string
  model: string
  updatedAt: string
  messageCount: number
}

export function ConversationList() {
  const [conversations, setConversations] = useState<Conversation[]>([])
  const [search, setSearch] = useState('')

  useEffect(() => {
    fetch('/api/chats').then(r => r.json()).then(setConversations)
  }, [])

  const filtered = conversations.filter(c =>
    c.title.toLowerCase().includes(search.toLowerCase())
  )

  return (
    <div className="space-y-2">
      <div className="relative">
        <Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400" />
        <input
          type="text"
          value={search}
          onChange={e => setSearch(e.target.value)}
          placeholder="Search conversations..."
          className="w-full rounded-lg border py-2 pl-9 pr-4 text-sm"
        />
      </div>
      {filtered.map(c => (
        <div key={c.id} className="group flex items-center justify-between rounded-lg p-3 hover:bg-gray-50">
          <div className="flex items-center gap-3">
            <MessageSquare className="h-4 w-4 text-gray-400" />
            <div>
              <p className="text-sm font-medium">{c.title}</p>
              <p className="text-xs text-gray-500">{c.model} · {c.messageCount} messages</p>
            </div>
          </div>
          <button className="opacity-0 group-hover:opacity-100">
            <Trash2 className="h-4 w-4 text-red-400" />
          </button>
        </div>
      ))}
    </div>
  )
}

Build your white-label AI chat product with the AI Chat Platform Template and launch in days.

Browse all 200+ templates and starter kits.

Ready to Build?

Get started with our production-ready starter kits and ship your project faster.

Browse Starter Kits