AI

Storing AI generation history

We earn commissions when you shop through the links below.

The AI SaaS Starter writes each finished generation to Prisma: prompt, output, credits, and the user id.

1 min read

Chat history in the AI SaaS Starter is a table, not browser storage.

model Generation {
  id        String   @id @default(cuid())
  userId    String
  user      User     @relation(fields: [userId], references: [id])
  prompt    String
  output    String
  credits   Int
  createdAt DateTime @default(now())
}

The row is written when a generation finishes. credits is 1 for that call. The monthly limit sums credits for the user since the first day of the local month. Free accounts stop at 20. Pro accounts stop at 500. The check itself is implementing AI usage limits and credits.

output stores the text that was streamed. The stream path is streaming AI responses in Next.js. The database is SQLite in this kit.

The model does not store token counts from the provider, tool calls, or embeddings. If a request fails before it finishes, there is no row, and no credit is spent. The provider URL is configured as in OpenAI-compatible API architecture.

Product updates for developers shipping with Designyff kits.

Guides: Next.js, Stripe, and SaaS starter kits Professional website design for small businesses

Purchased source may be used in personal, commercial, and client projects. Do not redistribute or resell the original source. Terms of Service Privacy Policy

Designyff © 2026 | Starter kits for developers