Railway

Deploy AI Chatbot | Open Source ChatGPT-Style App on Next.js

Next.js AI chat with auth, history and streaming responses

Deploy AI Chatbot | Open Source ChatGPT-Style App on Next.js

Just deployed

/var/lib/postgresql/data

Deploy and Host an AI Chatbot on Railway

A full-featured chat application built on the Next.js AI SDK: streaming responses, conversation history, authentication and multiple model providers. It is a real application rather than a demo, and it is meant to be forked and turned into your own product.

About Hosting the AI Chatbot

The app builds from a Git repository, with PostgreSQL on a persistent volume for accounts and chat history. Session secrets are generated per deployment and the public URL is wired into the auth configuration automatically.

Two things are left to you: a model provider API key, and — if you want file uploads — a blob storage token. Everything else boots as it is.

Common Use Cases

  • A starting point for an AI product: Auth, streaming, persistence and a working UI already in place, so the first commit is about your idea rather than plumbing.
  • An internal assistant: A private chatbot for a team, with history in your own database and no third-party chat product involved.
  • Comparing providers: xAI and Groq are wired in; swapping or adding a provider is an SDK call, not a rewrite.

Dependencies for AI Chatbot Hosting

Deployment Dependencies

  • The Next.js AI Chatbot source, built from Git
  • PostgreSQL 16 on a Railway volume — users and conversations
  • An API key from a model provider: XAI_API_KEY, GROQ_API_KEY or another the SDK supports
  • Optionally a blob storage token for file uploads

Implementation Details

XAI_API_KEY and GROQ_API_KEY are empty by default and at least one must be set — the deployment starts without them, but every message fails until a provider is configured.

AUTH_SECRET is generated per deployment and signs session cookies; AUTH_URL is built from the public domain. Attach a custom domain and both the URL and any OAuth callbacks need updating.

AUTH_TRUST_HOST is on, which is what makes Auth.js accept the proxied host header Railway sends. Without it sign-in loops.

Database migrations run on boot, so the schema is created on the first deploy with nothing to run by hand.

BLOB_READ_WRITE_TOKEN is optional. Without it the app runs and attachments are unavailable; the rest of the chat works.

Because this builds from a repository, forking it is the intended path — change the system prompt, the model list and the UI, push, and Railway rebuilds.

Why Deploy an AI Chatbot on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying an AI chatbot on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

Resources: a Next.js server plus Postgres, roughly 300–500 MB together and on the order of $8–12 a month. Model provider usage is billed separately by the provider, not by Railway.


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
113
View Template
stella
Self-host stella with web, API, Postgres, Redis, and object storage.

Jan Kubica
1
View Template
Hermes Agent | OpenClaw Alternative with Dashboard
Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

codestorm
56