Self-hosting
An end-to-end guide on how to self-host Agentset
You can self-host Agentset on your own servers and cloud infrastructure for greater control over your data and design. This guide will walk you through the entire process of setting up Agentset on your own servers.
Prerequisites
Before you begin, make sure you have the following:
- A GitHub account
- An Upstash account
- A Supabase account
- A Vercel account
- Either a Cloudflare or AWS account
Step 1: Local setup
First, you’ll need to clone the Agentset repo and install the dependencies.
Clone the repo
First, clone the Agentset repo.
Install dependencies
Run the following command to install the dependencies:
Set up environment variables
Convert the .env.example
file to .env
. You can start filling in the first few environment variables:
We currently use azure openai models as the default (when users pick the Agentset managed option). If you’d like to change that, update apps/web/src/lib/embeddings.ts
and apps/web/src/lib/llm.ts
to use a different provider.
You will fill in the remaining environment variables in the following steps.
Step 2: Set up Upstash Redis and Upstash Workflows
Next, you’ll need to set up Upstash Workflows and Redis. These will be used to orchestrate long-running tasks (like document ingestion) on serverless infrastructure.
Create Upstash Redis database
In your Upstash account, create a new Redis database.
Set up Upstash environment variables
Once your database is created, copy the UPSTASH_REDIS_REST_URL
and UPSTASH_REDIS_REST_TOKEN
from the REST API section into your .env
file as REDIS_URL
and REDIS_TOKEN
respectively.
Navigate to the QStash tab and copy the QSTASH_TOKEN
, QSTASH_CURRENT_SIGNING_KEY
, and QSTASH_NEXT_SIGNING_KEY
from the Request Builder section into your .env
file.
Step 3: Set up the partitioner API
Next, you’ll need to set up the partitioner API. This will be used to partition documents into chunks for vectorization. More information can be found here.
Make sure REDIS_HOST
, REDIS_PORT
, and REDIS_PASSWORD
match the values in your
Upstash Redis database created in Step
2.
Once you have the partitioner API running, set these environment variables in your .env
file:
Step 4: Set up Supabase PostgreSQL database
Next, you’ll need to set up any PostgreSQL database (e.g. Supabase). This will be used to store application data (e.g. user sessions, user data, etc.).
Create Supabase database
In your Supabase account, create a new database.
Make sure to copy the password you write to use for the next step.
Set up Supabase environment variables
Then, click on the Connect button on the top left, navigate to the ORMs tab, and select Prisma.
After that, copy the DATABASE_URL
and DIRECT_URL
into your .env
file. And make sure to replace [YOUR-PASSWORD]
with the password you wrote down in the previous step.
Apply migrations
In the terminal, run the following command to generate the Prisma client:
Then, run the following command to apply the database migrations:
Step 5: Set up GitHub OAuth
Next, create a new GitHub App. This will allow you to sign in to Agentset with your GitHub account.
Don’t forget to set the following Callback URLs:
https://app.acme.com/api/auth/callback/github
http://localhost:3000/api/auth/callback/github
for local development.
Optional: Set the “Email addresses” account permission to read-only in order to access private email addresses on GitHub.
Once your GitHub App is created, copy the Client ID
and Client Secret
into your .env
file as the GITHUB_CLIENT_ID
and GITHUB_CLIENT_SECRET
environment variables.
Step 6: Set up Google OAuth
Next, you’ll need to set up Google OAuth. This will allow you to sign in to Agentset with your Google account.
Create Google OAuth App
In your Google Cloud Console, create a new OAuth client ID and client secret.
Set up Google OAuth environment variables
Once your Google OAuth App is created, copy the Client ID
and Client Secret
into your .env
file as the GOOGLE_CLIENT_ID
and GOOGLE_CLIENT_SECRET
environment variables.
Step 7: Set up Cloudflare R2
Agentset stores file uploads in either S3 or S3-compatible services like Cloudflare R2.
We recommend using Cloudflare R2 for self-hosting Agentset, as it’s a more cost-effective solution compared to AWS S3. Here’s how you can set it up:
Create R2 bucket
In your Cloudflare account, create a new R2 bucket. We recommend giving your bucket a descriptive name (e.g. agentset
) and leaving the remaining settings as is.
In your bucket settings, copy the S3 API value – you’ll need it in Step 3.
Set up access to R2
From the R2 main page, click Manage R2 API Tokens on the right-hand column.
Then, click Create API Token.
Make sure to name your API token something relevant to the service that will be using the token.
Give it “Object Read & Write” permissions, and we recommend only applying ito to a single bucket.
You can leave the remaining settings (TTL, Client IP Address Filtering) as is, and click Create API Token.
After you create you token, copy the Access Key ID
and Secret Access Key
values – you’ll need them in the next step.
Set up R2 environment variables
Once you have your credentials, set them in your .env
file:
Step 8: Set up Resend (optional)
Next, you’ll need to set up Resend for transactional emails (e.g. magic link emails):
- Sign up for Resend and create your API key here.
- Copy the API key into your
.env
file as theRESEND_API_KEY
environment variable. - You’ll then need to set up and verify your domain by following this guide here.
Step 9: Deploy to Vercel
Once you’ve set up all of the above services, you can now deploy your app to Vercel.
Deploy code to GitHub
If you haven’t already, push up your cloned repository to GitHub by running the following commands:
Create a new Vercel project
In your Vercel account, create a new project. Then, select your GitHub repository and click Import.
Make sure that your Framework Preset is set to Next.js and the Root Directory is set to apps/web
.
In the Environment Variables section, add all of the environment variables from your .env
file by copying all of them and pasting it into the first input field. A few notes:
- Replace the
BETTER_AUTH_URL
environment variable with the app domain that you will be using (e.g.https://app.acme.com
).
Click on Deploy to deploy your project.
If you get a No Output Directory called "public" was found after the build completed
error, make sure that your Vercel deployment
settings to make sure that they match the following:
Done!
Once the deployment is complete, you should be able to visit your app domain (e.g. https://app.acme.com
) and see the following login page:
Caveats
This guide is meant to be a starting point for self-hosting Agentset. It currently depends on the following services to work:
- Upstash for the Redis database and workflows
- Supabase for the PostgreSQL database
- Vercel for hosting
In the future, we plan to make it easier to self-host Agentset by providing Docker images and a CLI for easy setup.