Build an AI chatbot

Give your product a brain. Up and running without managing servers.

Categories: ai, chatbot, openai, gpt, llm, chat, assistant, bot, artificial intelligence, natural language

Tools that power the Build an AI chatbot stack

Setup guide

  1. OpenAI: Create an OpenAI account and generate an API key from the API Keys page. Store this key securely as an environment variable called OPENAI_API_KEY. Choose a model like gpt-4o-mini for cost-effective conversations or gpt-4o for more complex reasoning tasks. (open)
  2. Vercel AI SDK: Install the Vercel AI SDK with npm install ai openai. Create an API route that initializes the OpenAI client and uses streamText() to stream responses back to the client. This handles all the complexity of streaming and provides React hooks for your chat UI. (open)
  3. Supabase: Create a conversations table with columns for id, user_id, created_at, and a messages JSONB column to store the chat history. Enable Row Level Security so users can only access their own conversations. Use the Supabase client to save and load conversation history. (open)