
Ai Generation Persistence
Ship a chat or generate app where every LLM or image run gets a stable ID, saved output, shareable URL, and token cost row.
Overview
AI generation persistence is an agent skill for the Build phase that defines unique IDs, database or Blob storage, addressable URLs, and per-generation token cost tracking for every LLM run.
Install
npx skills add https://github.com/vercel-labs/vercel-plugin --skill ai-generation-persistenceWhat is this skill?
- Assigns a unique generation ID (nanoid/cuid2) per AI call for replay and support
- Stores messages and media in DB or Vercel Blob with AI SDK UI patterns
- Exposes addressable routes such as `/chat/[id]` and `/generate/[id]` for sharing
- Tracks token usage and cost per generation for solo-builder billing visibility
- Matches `app/api/generate/**`, `lib/generations/**`, and `@ai-sdk/*` import paths
- Documented path patterns for app/api/generate, generations, and chat/[id] routes
- Supports Vercel Blob and AI SDK UI message storage per linked docs
Adoption & trust: 25 installs on skills.sh; 187 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You stream AI replies in the UI but lose history, cannot share a specific generation, and have no per-run cost or ID for support and billing.
Who is it for?
Solo builders adding history, share links, and cost rows to a Next.js AI chat or image/text generate app on Vercel using the AI SDK.
Skip if: One-off scripts with no UI, teams that only need ephemeral streaming with zero storage, or non-Node stacks without the documented path/import patterns.
When should I use this skill?
User asks to save or persist generations, generation or chat history, generation IDs, AI database storage, or build a chatbot with durable URLs.
What do I get? / Deliverables
Each generation lands in storage with a unique ID, a shareable `/chat/[id]` or `/generate/[id]` page, and logged token cost ready for analytics or quotas.
- Generation persistence module under `lib/generations` with ID assignment
- Dynamic routes `/chat/[id]` or `/generate/[id]` backed by stored records
- Per-generation token cost fields suitable for logging or billing tables
Recommended Skills
Journey fit
Persistence belongs in Build when you wire API routes, storage, and dynamic pages around generations—not during idea research or launch SEO. Backend subphase fits database/Blob writes, generation APIs, and `/chat/[id]` style routing that solo builders add after picking the AI SDK.
How it compares
Use for durable generation records and URLs—not as a substitute for choosing models or designing prompt flows in the AI SDK alone.
Common Questions / FAQ
Who is ai-generation-persistence for?
Indie and solo developers building AI chatbots, text generators, or image apps who need persisted runs, shareable links, and cost tracking on Vercel-oriented stacks.
When should I use ai-generation-persistence?
During Build when you add API routes for generate/generations, wire `@ai-sdk` streaming, and need DB or Blob persistence, generation IDs, and `/chat/[id]` routes before ship and grow analytics.
Is ai-generation-persistence safe to install?
Review the Security Audits panel on this Prism page for install risk and audit results; persistence skills imply database, Blob, and network access you should scope in your agent permissions.
SKILL.md
READMESKILL.md - Ai Generation Persistence
# AI Generation Persistence **AI generations are expensive, non-reproducible assets. Never discard them.** Every call to an LLM costs real money and produces unique output that cannot be exactly reproduced. Treat generations like database records — assign an ID, persist immediately, and make them retrievable. ## Core Rules 1. **Generate an ID before the LLM call** — use `nanoid()` or `createId()` from `@paralleldrive/cuid2` 2. **Persist every generation** — text and metadata to database, images and files to Vercel Blob 3. **Make every generation addressable** — URL pattern: `/chat/[id]`, `/generate/[id]`, `/image/[id]` 4. **Track metadata** — model name, token usage, estimated cost, timestamp, user ID 5. **Never stream without saving** — if the user refreshes, the generation must survive ## Generate-Then-Redirect Pattern The standard UX flow for AI features: cr