---
title: "Deploy NextChat"
description: "An open-source ChatGPT UI alternative."
category: "AI/ML"
url: https://railway.com/deploy/Mvjjpn
---

# Deploy NextChat

An open-source ChatGPT UI alternative.

**[Deploy NextChat on Railway](https://railway.com/template/Mvjjpn)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/Mvjjpn/manifest.json

- **Creator:** alphasec
- **Category:** AI/ML
- **Total deploys:** 1,146

## Template content

### NextChat

- **Source:** https://github.com/Yidadaa/ChatGPT-Next-Web
- **Public domain:** Yes

## Documentation

# Deploy and Host NextChat on Railway

NextChat (formerly ChatGPT-Next-Web) is an open-source, self-hostable AI chat interface built with Next.js. It supports OpenAI, Azure OpenAI, Google Gemini, Anthropic Claude, and a dozen other LLM providers through a clean, fast web UI — with all conversation data stored locally in the browser by default.

## About Hosting NextChat

NextChat is a stateless Next.js application — it proxies API requests to your chosen LLM provider and stores all chat history client-side, so no database is required. Hosting your own instance lets you embed a server-side API key (so users don't need their own), restrict access with a shared password via `CODE`, control which models are available, and point the app at a custom API endpoint or self-hosted model backend. This Railway template deploys the official Docker image and exposes NextChat on a Railway-provided HTTPS domain immediately after deployment.

## Common Use Cases

- **Team AI access** — deploy a shared instance with a server-side API key so teammates can use GPT-4, Claude, or Gemini without each managing their own credentials
- **Custom model frontend** — use NextChat as a web UI for a self-hosted model backend (LocalAI, Ollama, RWKV-Runner) by pointing `BASE_URL` at your inference server
- **Controlled access** — restrict usage to authorised users via the `CODE` password mechanism, and lock down model selection with `CUSTOM_MODELS` and `DISABLE_GPT4`

## Dependencies for NextChat Hosting

- An API key for at least one supported LLM provider (OpenAI, Azure, Google Gemini, Anthropic, etc.)

### Deployment Dependencies

- [NextChat GitHub repository](https://github.com/ChatGPTNextWeb/NextChat)
- [NextChat environment variable reference](https://docs.nextchat.dev/quickstart/selfhost/env)

### Implementation Details

Set the following environment variables in your Railway service settings. Only `OPENAI_API_KEY` (or an equivalent provider key) is required to get started.

**Core**

```env
OPENAI_API_KEY=sk-xxxxxxxx        # Required if using OpenAI; comma-separate multiple keys
CODE=yourpassword                  # Optional: shared access password for the instance
BASE_URL=https://api.openai.com   # Override to use an OpenAI-compatible proxy or self-hosted endpoint
```

**Provider alternatives (use instead of or alongside OpenAI)**

```env
AZURE_URL=https://{resource}.openai.azure.com/openai/deployments/{deployment}
AZURE_API_KEY=azure_key_xxxxx
AZURE_API_VERSION=2024-02-01

GOOGLE_API_KEY=google_key_xxxxx
GOOGLE_URL=https://generativelanguage.googleapis.com/
```

**Access & model control**

```env
HIDE_USER_API_KEY=1    # Prevent users from entering their own API key
DISABLE_GPT4=1         # Hide GPT-4 models from the UI
CUSTOM_MODELS=+llama3,+mistral,-gpt-3.5-turbo   # Add (+) or remove (-) models from the list
DEFAULT_MODEL=gpt-4o   # Set the default model on first load
```

## Why Deploy NextChat 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 NextChat 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.

## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/Mvjjpn
