AI chat with Next.js

A Next.js chat app that streams replies from any OpenAI-compatible endpoint, such as OpenAI, Groq, OpenRouter or your own Ollama, with the API key kept on the server. Click Deploy, add your provider's address, key and model, and Naijacloud builds it from the public repo and gives you a live HTTPS address. No GitHub connection needed.

Next.js
AI chat with Next.js, running on Naijacloud

What's inside

  • Next.js 15 with the App Router and TypeScript
  • /api/chat streams from <AI_BASE_URL>/chat/completions, so the key never reaches the browser
  • Works with OpenAI, Groq, Together, OpenRouter or Ollama
  • Until the variables are set, it says which ones are missing instead of failing

What you get after deploying

  • A live address at https://ai-chat-nextjs.naijacloud.app with HTTPS
  • Build and runtime logs, metrics and redeploys from the dashboard

Environment variables

You can change any of these on the deploy screen.

AI_BASE_URLYour provider's API address, e.g. https://api.openai.com/v1None. You set it
AI_API_KEYYour provider's keyNone. You set it
AI_MODELThe model name from your providerNone. You set it
AI_SYSTEM_PROMPTInstructions sent before every conversationNone. You set it

Run it locally

$ git clone https://github.com/naijacloud/template-ai-chat-nextjs
$ cd template-ai-chat-nextjs
$ cp .env.example .env
$ npm install
$ npm run dev
Learn how it worksEnvironment variables

Whatever you build it with, it ships here.

Deploy your app for free

Free tier forever · No card