SoloSaaS
Back to Blog
Tutorial

Building Your First AI SaaS with SoloSaaS

December 1, 20241 min readSoloSaaS

Getting a SaaS product off the ground usually means weeks of wiring up auth, payments, and infrastructure before writing a single line of business logic. SoloSaaS cuts that down to an afternoon.

What You Get Out of the Box

The template ships with everything you need for a production-ready AI SaaS:

  • Authentication — GitHub, Google, WeChat QR login, and email/password via Better Auth
  • Payments — Stripe and Creem integration with subscriptions and credit packs
  • AI Models — Multi-model support through Vercel AI SDK (OpenAI, Anthropic, Google, and more)
  • Credit System — FIFO batch-based credits with expiry management

Quick Start

Clone the repo and install dependencies:

git clone https://github.com/solosass/template.git my-saas
cd my-saas
pnpm install

Set up your environment variables:

cp .env.example .env.local

Then fill in your API keys and database URL. Start the dev server:

pnpm dev

Adding Your First AI Feature

The AI system is already wired up. Here's how to customize the chat endpoint:

src/app/api/ai/chat/route.ts
import { streamText } from "ai";
import { getProvider } from "@/lib/ai/providers";
 
export async function POST(req: Request) {
  const { messages, model } = await req.json();
 
  const result = streamText({
    model: getProvider(model),
    messages,
    system: "You are a helpful assistant for my product.",
  });
 
  return result.toDataStreamResponse();
}

The credit system automatically deducts credits per message based on the model used.

Deploying to Production

One-click deploy to Vercel is the fastest path:

  1. Push your code to GitHub
  2. Import the repo in Vercel
  3. Set your environment variables
  4. Hit deploy

Your SaaS is live. The template handles SSR, static generation, and edge middleware automatically.

What's Next

From here you can customize the landing page, add new AI features, or integrate additional payment providers. The codebase is designed to be readable and extensible — no magic, just straightforward Next.js patterns.

Tip: Check out the /pricing page configuration in site.config.ts to set up your own pricing plans.