Skip to content

Fyzz-Chat/fyzz-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

947 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fyzz Chat Fyzz Chat

GitHub Workflow Status

About Fyzz Chat

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.

Quick Start

Note

Regardless of where you deploy Fyzz Chat, you will need a PostgreSQL database first to store your data.

Vercel

Deploy with Vercel

Coolify

Coming soon!

Hosted version

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!

Docs for Self-hosters

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)

Database

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.

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
  • AWS_CLOUDFRONT_DISTRIBUTION_DOMAIN: AWS CloudFront distribution domain. Falls back to AWS_UPLOADS_BUCKET if 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.

AWS

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:

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:

  1. Create secrets in AWS Secrets Manager:
    • Go to Secrets ManagerStore a new secret
    • Select Other type of secret
    • Select Plaintext
    • Create a secret named fyzz-chat/better-auth-secret with a random string of at least 32 characters
    • Create a secret named fyzz-chat/openai-api-key with your OpenAI API key
    • Note the ARN of each secret (you'll need them for the stack parameters)

Deploy:

  1. Go to CloudFormationCreate stackWith new resources (standard)
  2. Upload cloudformation.json as the template
  3. Enter stack name: fyzz-chat
  4. Fill in the required parameters:
    • BetterAuthSecretArn: ARN of your BETTER_AUTH_SECRET
    • OpenaiApiKeySecretArn: ARN of your OPENAI_API_KEY
    • BetterAuthUrl: Your application URL (e.g., https://your-domain.com)
  5. Review and create the stack
  6. 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:

  1. Go to ECSClusters → Select your cluster
  2. Go to the Tasks tab
  3. Click Run new task
  4. Configure:
    • Task definition family: fyzz-chat-migration
    • Launch type: Fargate
  5. Networking
    • VPC: Select fyzz-chat-vpc
    • Security group: Select fyzz-chat-ecs-sg
  6. Click Create and wait for completion

Enable HTTPS (Optional):

  1. Go to Certificate ManagerRequest a certificate
  2. Request a public certificate for your domain
  3. Add the DNS validation records to your DNS provider
  4. Wait for certificate validation
  5. Go back to CloudFormation → Select your stack → Update
  6. Use current template and update the CertificateArn parameter with your certificate ARN
  7. Complete the stack update

The template will automatically redirect HTTP to HTTPS when a certificate is provided.

Docs for Builders

Prerequisites

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.

Development

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.

About

Chat with the best AI models, all in one place.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages