ShipSafe AI-SaaS extends the core ShipSafe boilerplate with powerful AI capabilities, making it easy to build AI-powered SaaS products like chatbots, assistants, and AI tools.
What's Included
The AI-SaaS boilerplate provides:
- Unified AI Client - Support for OpenAI and Anthropic models
- Streaming Responses - Real-time AI responses using Server-Sent Events (SSE)
- Prompt Management - System prompts, templates, and tiered prompt builders
- Content Moderation - Built-in safety checks and injection prevention
- Subscription Access Control - Simple subscription-based access for AI features
- Secure API Routes - Protected endpoints with authentication and rate limiting
Architecture
The AI layer is built on top of ShipSafe core, providing:
┌─────────────────────────────────────┐
│ AI-SaaS Application │
│ (Your Product) │
└──────────────┬──────────────────────┘
│
┌──────────────▼──────────────────────┐
│ AI Layer │
│ - Client (OpenAI/Anthropic) │
│ - Streaming │
│ - Prompts (Tiered) │
│ - Moderation │
│ - Subscription Access │
└──────────────┬──────────────────────┘
│
┌──────────────▼──────────────────────┐
│ ShipSafe Core │
│ - Authentication │
│ - Billing │
│ - Security │
│ - Database │
└─────────────────────────────────────┘
Quick Start
-
Set up AI API keys in your
.env.local:OPENAI_API_KEY=sk-... ANTHROPIC_API_KEY=sk-ant-... # Optional -
Use the AI client in your API routes:
import { generateChatCompletion } from "@/lib/ai/client"; const response = await generateChatCompletion({ messages: [{ role: "user", content: "Hello!" }], }); -
Check subscription before making requests:
import { hasActiveSubscription } from "@/features/ai/server"; const hasAccess = await hasActiveSubscription(userId); if (!hasAccess) { return NextResponse.json({ error: "Subscription required" }, { status: 403 }); }
Documentation Sections
- AI Client - Setting up and using the unified AI client
- API Routes - AI API endpoints reference
- Streaming - Real-time streaming responses
- Prompts - System prompts and tiered prompt templates
- Moderation - Content safety and validation
- Subscription Access - Subscription-based access control
Next Steps
- Read the AI Client guide to get started
- Check out AI Tutorials for step-by-step examples
- Explore AI Components for UI components