explaingit

a16z-infra/companion-app

5,954TypeScriptAudience · developerComplexity · 3/5Setup · moderate

TLDR

A tutorial starter kit by a16z for building your own AI companion chatbot with a defined personality and long-term memory, accessible via web or SMS. It shows developers how to wire together Next.js, Langchain, vector databases, and language models into a conversational AI.

Mindmap

mindmap
  root((repo))
    What it does
      AI chatbot with memory
      Custom personality files
      SMS and web chat
    Tech Stack
      Next.js
      Langchain.js
      OpenAI or Vicuna
      Pinecone or Supabase
    Use Cases
      Custom AI companions
      Memory chatbots
      Tutorial learning
    Audience
      Developers
      AI learners
    Setup
      Multiple API keys
      Clerk for auth
      Upstash for history
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Build a chatbot with a custom personality and backstory that remembers past conversations using a vector database.

USE CASE 2

Learn how AI chatbots with memory are built by running and modifying a working starter kit locally.

USE CASE 3

Add SMS chat to an AI companion so users can text it from their phone via Twilio.

USE CASE 4

Fork this project to create a fully custom AI companion app with your own character definitions and personality files.

Tech stack

TypeScriptNext.jsLangchain.jsOpenAI APIPineconeUpstashClerkTwilio

Getting it running

Difficulty · moderate Time to first run · 1h+

Requires API keys for multiple services including Clerk, OpenAI or Replicate, Pinecone or Supabase, and Upstash, Twilio is optional for SMS.

In plain English

This repository is a tutorial starter kit for building your own AI companion, meaning a chatbot with a defined personality that you can converse with over a web browser or through text messages. It was created by the infrastructure team at a16z as a learning resource, not as a finished product, so the goal is to show developers how these kinds of chatbots are built rather than to ship a polished app. The core idea is that you define your companion's personality and backstory by writing a text file, then the app uses that information to shape every conversation. To give the companion a sense of memory, the system stores recent conversation history in a queue and also uses a vector database to find relevant past context and pull it into the current prompt. This makes responses feel more connected to what was discussed earlier, rather than each message being treated in isolation. The technical stack includes Next.js for the web app, Clerk for user login, Langchain.js to coordinate the AI calls, and either OpenAI or a model called Vicuna (hosted on a service called Replicate) as the actual language model. Conversation history is stored in Upstash, and the vector database can be either Pinecone or Supabase. You can also add SMS chat via Twilio if you want to text your companion from your phone. Each of these services requires an API key, and the README walks through obtaining and configuring each one. The repository includes four pre-built companion personalities you can chat with right away after setting up the environment variables. The README explicitly notes that this is a developer tutorial, not a production platform, and that heavier production alternatives exist elsewhere. If you are a developer curious about how AI chatbots with memory are built, this repository gives you a working example you can run locally and modify. If you are a non-technical user looking for an AI companion to use, this is a codebase you would need to deploy yourself, not a ready-to-use product.

Copy-paste prompts

Prompt 1
I cloned the a16z companion-app. How do I define a custom companion personality using the text file format and what fields does it need?
Prompt 2
Walk me through how the companion-app uses Upstash and Pinecone together to give the AI memory across multiple conversations.
Prompt 3
Help me configure all the required environment variables for the a16z companion-app: Clerk, OpenAI, Pinecone, and Upstash.
Prompt 4
How do I add SMS chat to my companion-app so users can text the AI using Twilio?
Prompt 5
I want to swap OpenAI for Vicuna via Replicate in the companion-app. What code changes do I need to make?
Open on GitHub → Explain another repo

← a16z-infra on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.