Fyzz Chat is an open-source & self-hostable alternative to ChatGPT, Claude, Gemini, Perplexity, or actually any other LLM you can think of.
Although it comes with some of the most popular models preconfigured for you (you only need some API keys to get started), you can easily add your own models to it if you'd like because Fyzz Chat is built on top of the Vercel AI SDK.
Note
Regardless of where you deploy Fyzz Chat, you will need a PostgreSQL database first to store your data.
Coming soon!
Interested in the hosted version? Check out Fyzz Chat in action. We have everything configured for you, plus some extra features.
However, if you prefer to host it yourself, read on!
There are two ways to self-host Fyzz Chat:
- You can deploy it from the repository as a Next.js project
- You can use the Docker image (which is a containerized version of the Next.js project)
Fyzz Chat uses Prisma to interact with the database. By default, it uses PostgreSQL as the database engine.
Regardless of where you will host it, you will have to migrate it first to create the database schema. (You will need to have the DATABASE_URL environment variable set up for this to work.)
bun run db:deploy
# or
bunx prisma migrate deploy
The next step is to set up the environment variables.
The following environment variables are required:
BETTER_AUTH_SECRET: A random string of at least 32 characters.BETTER_AUTH_URL: The URL of your application.DATABASE_URL: The URL of your database.DIRECT_DATABASE_URL: The URL of your database.OPENAI_API_KEY: The API key for OpenAI. Create one here.
The following environment variables are optional and control which additional models are available for use:
ANTHROPIC_API_KEY: The API key for Anthropic. Create one here.XAI_API_KEY: The API key for XAI. Create it one here.GOOGLE_GENERATIVE_AI_API_KEY: The API key for Google Generative AI. Create one here.PERPLEXITY_API_KEY: The API key for Perplexity. Create one here. You might need to create an API Group first here.FIREWORKS_API_KEY: The API key for Fireworks. Create one here.
If you don't set any of these, the application will still start up, but you will only be able to use models from OpenAI.
The following environment variables are also optional and control whether uploaded files will be persisted in a CDN or in the database:
AWS_ACCESS_KEY_ID: Your AWS access key ID.AWS_SECRET_ACCESS_KEY: Your AWS secret access key.AWS_REGION: The AWS region of your bucket.AWS_UPLOADS_BUCKET: The AWS bucket for uploads.AWS_CLOUDFRONT_KEY_PAIR_ID: AWS CloudFront key pair ID.AWS_CLOUDFRONT_PRIVATE_KEY: AWS CloudFront private key with | as line breaks (deprecated).AWS_CLOUDFRONT_PRIVATE_KEY_BASE64: AWS CloudFront private key in base64 format.- Quick way to convert to base64 format:
cat key.pem | base64 > base64_key.pem
- Quick way to convert to base64 format:
AWS_CLOUDFRONT_DISTRIBUTION_DOMAIN: AWS CloudFront distribution domain. Falls back toAWS_UPLOADS_BUCKETif not set. The fallback only works if your bucket's name is the same as your distribution domain.
The last two are required to create signed URLs for uploaded files.
Warning
If any of the above AWS_ variables is not set, the application will still work, but uploaded files will be persisted in the database.
Deploy Fyzz Chat to AWS using one of the provided CloudFormation templates in aws/. The templates create an ECS cluster with RDS PostgreSQL, Application Load Balancer, and all necessary networking.
There are two templates available:
- cloudformation-ec2.json: Deploy Fyzz Chat to AWS using EC2.
- cloudformation-fargate.json: Deploy Fyzz Chat to AWS using Fargate.
If you'd like to visualize the templates, you can use the AWS CloudFormation Infrastructure Composer. Click on Create project, choose the Template tab, set the file type to JSON, then copy and paste the template content. Finally, switch back to the Canvas tab to visualize the infrastructure.
Prerequisites:
- Create secrets in AWS Secrets Manager:
- Go to Secrets Manager → Store a new secret
- Select Other type of secret
- Select Plaintext
- Create a secret named
fyzz-chat/better-auth-secretwith a random string of at least 32 characters - Create a secret named
fyzz-chat/openai-api-keywith your OpenAI API key - Note the ARN of each secret (you'll need them for the stack parameters)
Deploy:
- Go to CloudFormation → Create stack → With new resources (standard)
- Upload
cloudformation.jsonas the template - Enter stack name:
fyzz-chat - Fill in the required parameters:
BetterAuthSecretArn: ARN of your BETTER_AUTH_SECRETOpenaiApiKeySecretArn: ARN of your OPENAI_API_KEYBetterAuthUrl: Your application URL (e.g.,https://your-domain.com)
- Review and create the stack
- Wait for stack creation to complete (takes ~10-15 minutes)
Note
When deleting the stack, the database will NOT be deleted. You will need to turn off deletion protection and delete the database manually.
Run Database Migrations:
- Go to ECS → Clusters → Select your cluster
- Go to the Tasks tab
- Click Run new task
- Configure:
- Task definition family:
fyzz-chat-migration - Launch type: Fargate
- Task definition family:
- Networking
- VPC: Select
fyzz-chat-vpc - Security group: Select
fyzz-chat-ecs-sg
- VPC: Select
- Click Create and wait for completion
Enable HTTPS (Optional):
- Go to Certificate Manager → Request a certificate
- Request a public certificate for your domain
- Add the DNS validation records to your DNS provider
- Wait for certificate validation
- Go back to CloudFormation → Select your stack → Update
- Use current template and update the
CertificateArnparameter with your certificate ARN - Complete the stack update
The template will automatically redirect HTTP to HTTPS when a certificate is provided.
Ensure that you have the following tools installed on your machine:
- Bun: Install Bun via the command line by running:
curl -fsSL https://bun.sh/install | bash
or
powershell -c "irm bun.sh/install.ps1 | iex"
Or if you prefer, you can use other package managers like npm, yarn, or pnpm.
Copy the .env.sample file to .env to set up the environment variables. Then, run the development server:
bun dev
# or
npm run dev
# or
yarn dev
# or
pnpm dev
Open http://localhost:3000 with your browser to see the result.