[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-openai-ai-generation-persistence":3,"mdc-nb0qfa-key":33,"related-org-openai-ai-generation-persistence":3884,"related-repo-openai-ai-generation-persistence":4091},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":22,"repoUrl":23,"updatedAt":24,"license":25,"forks":26,"topics":27,"repo":28,"sourceUrl":31,"mdContent":32},"ai-generation-persistence","implement persistence patterns for AI generations","AI generation persistence patterns — unique IDs, addressable URLs, database storage, and cost tracking for every LLM generation",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},"openai","OpenAI","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fopenai.png",[12,16,19],{"name":13,"slug":14,"type":15},"LLM","llm","tag",{"name":17,"slug":18,"type":15},"Cost Optimization","cost-optimization",{"name":20,"slug":21,"type":15},"Database","database",3992,"https:\u002F\u002Fgithub.com\u002Fopenai\u002Fplugins","2026-04-06T18:41:08.513425",null,465,[],{"repoUrl":23,"stars":22,"forks":26,"topics":29,"description":30},[],"OpenAI Plugins","https:\u002F\u002Fgithub.com\u002Fopenai\u002Fplugins\u002Ftree\u002FHEAD\u002Fplugins\u002Fvercel\u002Fskills\u002Fai-generation-persistence","---\nname: ai-generation-persistence\ndescription: \"AI generation persistence patterns — unique IDs, addressable URLs, database storage, and cost tracking for every LLM generation\"\nmetadata:\n  priority: 6\n  docs:\n    - \"https:\u002F\u002Fsdk.vercel.ai\u002Fdocs\u002Fai-sdk-ui\u002Fstoring-messages\"\n  sitemap: \"https:\u002F\u002Fsdk.vercel.ai\u002Fsitemap.xml\"\n  pathPatterns:\n    - \"app\u002Fapi\u002Fgenerate\u002F**\"\n    - \"app\u002Fapi\u002Fgenerations\u002F**\"\n    - \"src\u002Fapp\u002Fapi\u002Fgenerate\u002F**\"\n    - \"src\u002Fapp\u002Fapi\u002Fgenerations\u002F**\"\n    - \"app\u002Fchat\u002F[id]\u002F**\"\n    - \"app\u002Fgenerate\u002F[id]\u002F**\"\n    - \"src\u002Fapp\u002Fchat\u002F[id]\u002F**\"\n    - \"src\u002Fapp\u002Fgenerate\u002F[id]\u002F**\"\n    - \"lib\u002Fgenerations\u002F**\"\n    - \"src\u002Flib\u002Fgenerations\u002F**\"\n  bashPatterns: []\n  importPatterns:\n    - \"ai\"\n    - \"@ai-sdk\u002F*\"\n    - \"@vercel\u002Fblob\"\n    - \"nanoid\"\n    - \"@paralleldrive\u002Fcuid2\"\n  promptSignals:\n    phrases:\n      - \"save generations\"\n      - \"persist generations\"\n      - \"generation history\"\n      - \"chat history\"\n      - \"save chat\"\n      - \"generation id\"\n      - \"ai chat\"\n      - \"chat app\"\n      - \"chatbot\"\n      - \"image generation\"\n      - \"text generation\"\n      - \"ai app\"\n    allOf:\n      - [generate, save]\n      - [generate, persist]\n      - [generate, store]\n      - [ai, persist]\n      - [ai, history]\n      - [ai, database]\n      - [chat, persist]\n      - [chat, database]\n      - [chat, url]\n      - [generation, url]\n      - [generation, id]\n      - [image, generate]\n      - [stream, save]\n      - [stream, persist]\n    anyOf:\n      - \"shareable\"\n      - \"retrievable\"\n      - \"permalink\"\n      - \"cost tracking\"\n      - \"token usage\"\n      - \"nanoid\"\n      - \"cuid\"\n      - \"openai\"\n      - \"anthropic\"\n      - \"llm\"\n      - \"gpt\"\n      - \"claude\"\n    noneOf:\n      - \"github actions\"\n      - \"ci workflow\"\n    minScore: 6\n---\n\n# AI Generation Persistence\n\n**AI generations are expensive, non-reproducible assets. Never discard them.**\n\nEvery 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.\n\n## Core Rules\n\n1. **Generate an ID before the LLM call** — use `nanoid()` or `createId()` from `@paralleldrive\u002Fcuid2`\n2. **Persist every generation** — text and metadata to database, images and files to Vercel Blob\n3. **Make every generation addressable** — URL pattern: `\u002Fchat\u002F[id]`, `\u002Fgenerate\u002F[id]`, `\u002Fimage\u002F[id]`\n4. **Track metadata** — model name, token usage, estimated cost, timestamp, user ID\n5. **Never stream without saving** — if the user refreshes, the generation must survive\n\n## Generate-Then-Redirect Pattern\n\nThe standard UX flow for AI features: create the resource first, then redirect to its page.\n\n```ts\n\u002F\u002F app\u002Fapi\u002Fchat\u002Froute.ts\nimport { nanoid } from \"nanoid\";\nimport { db } from \"@\u002Flib\u002Fdb\";\nimport { redirect } from \"next\u002Fnavigation\";\n\nexport async function POST(req: Request) {\n  const { prompt, model } = await req.json();\n  const id = nanoid();\n\n  \u002F\u002F Create the record BEFORE generation starts\n  await db.insert(generations).values({\n    id,\n    prompt,\n    model,\n    status: \"pending\",\n    createdAt: new Date(),\n  });\n\n  \u002F\u002F Redirect to the generation page — it handles streaming\n  redirect(`\u002Fchat\u002F${id}`);\n}\n```\n\n```tsx\n\u002F\u002F app\u002Fchat\u002F[id]\u002Fpage.tsx\nimport { db } from \"@\u002Flib\u002Fdb\";\nimport { notFound } from \"next\u002Fnavigation\";\n\nexport default async function ChatPage({ params }: { params: Promise\u003C{ id: string }> }) {\n  const { id } = await params;\n  const generation = await db.query.generations.findFirst({\n    where: eq(generations.id, id),\n  });\n  if (!generation) notFound();\n\n  \u002F\u002F Render with streaming if still pending, or show saved result\n  return \u003CChatView generation={generation} \u002F>;\n}\n```\n\nThis gives you: shareable URLs, back-button support, multi-tab sessions, and generation history for free.\n\n## Persistence Schema\n\n```ts\n\u002F\u002F lib\u002Fdb\u002Fschema.ts\nimport { pgTable, text, integer, timestamp, jsonb } from \"drizzle-orm\u002Fpg-core\";\n\nexport const generations = pgTable(\"generations\", {\n  id: text(\"id\").primaryKey(),            \u002F\u002F nanoid\n  userId: text(\"user_id\"),                \u002F\u002F auth user\n  model: text(\"model\").notNull(),         \u002F\u002F \"openai\u002Fgpt-5.4\"\n  prompt: text(\"prompt\"),                 \u002F\u002F input text\n  result: text(\"result\"),                 \u002F\u002F generated output\n  imageUrls: jsonb(\"image_urls\"),         \u002F\u002F Blob URLs for generated images\n  tokenUsage: jsonb(\"token_usage\"),       \u002F\u002F { promptTokens, completionTokens }\n  estimatedCostCents: integer(\"estimated_cost_cents\"),\n  status: text(\"status\").default(\"pending\"), \u002F\u002F pending | streaming | complete | error\n  createdAt: timestamp(\"created_at\").defaultNow(),\n});\n```\n\n## Storage Strategy\n\n| Data Type | Storage | Why |\n|-----------|---------|-----|\n| Text, metadata, history | Neon Postgres via Drizzle | Queryable, relational, supports search |\n| Generated images & files | Vercel Blob (`@vercel\u002Fblob`) | Permanent URLs, CDN-backed, no expiry |\n| Prompt dedup cache | Upstash Redis | Fast lookup, TTL-based expiry |\n\n## Image Persistence\n\nNever serve generated images as ephemeral base64 or temporary URLs. Save to Blob immediately:\n\n```ts\nimport { put } from \"@vercel\u002Fblob\";\nimport { generateText } from \"ai\";\n\nconst result = await generateText({ model, prompt });\n\n\u002F\u002F Save every generated image to permanent storage\nconst imageUrls: string[] = [];\nfor (const file of result.files ?? []) {\n  if (file.mediaType?.startsWith(\"image\u002F\")) {\n    const ext = file.mediaType.split(\"\u002F\")[1] || \"png\";\n    const blob = await put(`generations\u002F${generationId}.${ext}`, file.uint8Array, {\n      access: \"public\",\n      contentType: file.mediaType,\n    });\n    imageUrls.push(blob.url);\n  }\n}\n\n\u002F\u002F Update the generation record with permanent URLs\nawait db.update(generations)\n  .set({ imageUrls, status: \"complete\" })\n  .where(eq(generations.id, generationId));\n```\n\n## Cost Tracking\n\nExtract usage from every generation and store it. This enables billing, budgeting, and abuse detection:\n\n```ts\nconst result = await generateText({ model, prompt });\n\nconst usage = result.usage; \u002F\u002F { promptTokens, completionTokens, totalTokens }\nconst estimatedCostCents = estimateCost(model, usage);\n\nawait db.update(generations).set({\n  result: result.text,\n  tokenUsage: usage,\n  estimatedCostCents,\n  status: \"complete\",\n}).where(eq(generations.id, generationId));\n```\n\n## Prompt Dedup \u002F Caching\n\nAvoid paying for identical generations. Cache by content hash:\n\n```ts\nimport { Redis } from \"@upstash\u002Fredis\";\nimport { createHash } from \"crypto\";\n\nconst redis = Redis.fromEnv();\n\nfunction hashPrompt(model: string, prompt: string): string {\n  return createHash(\"sha256\").update(`${model}:${prompt}`).digest(\"hex\");\n}\n\n\u002F\u002F Check cache before generating\nconst cacheKey = `gen:${hashPrompt(model, prompt)}`;\nconst cached = await redis.get\u003Cstring>(cacheKey);\nif (cached) return cached; \u002F\u002F Return cached generation ID\n\n\u002F\u002F After generation, cache the result\nawait redis.set(cacheKey, generationId, { ex: 3600 }); \u002F\u002F 1hr TTL\n```\n\n## Anti-Patterns\n\n- **Streaming to client without saving** — generation lost on page refresh. Always write to DB as tokens arrive or on completion.\n- **Routes without `[id]` segments** — `\u002Fapi\u002Fchat` with no ID means generations aren't addressable. Use `\u002Fchat\u002F[id]`.\n- **Re-generating identical prompts** — check cache first. Same prompt + same model = same cost for no new value.\n- **Ephemeral base64 images** — generated images served inline are lost when the component unmounts. Save to Vercel Blob.\n- **Missing metadata** — always store model name, token counts, and timestamp. You need this for cost tracking and debugging.\n- **Client-only state** — storing generations only in React state or localStorage. Use a database — generations must survive across devices and sessions.\n",{"data":34,"body":111},{"name":4,"description":6,"metadata":35},{"priority":36,"docs":37,"sitemap":39,"pathPatterns":40,"bashPatterns":51,"importPatterns":52,"promptSignals":58},6,[38],"https:\u002F\u002Fsdk.vercel.ai\u002Fdocs\u002Fai-sdk-ui\u002Fstoring-messages","https:\u002F\u002Fsdk.vercel.ai\u002Fsitemap.xml",[41,42,43,44,45,46,47,48,49,50],"app\u002Fapi\u002Fgenerate\u002F**","app\u002Fapi\u002Fgenerations\u002F**","src\u002Fapp\u002Fapi\u002Fgenerate\u002F**","src\u002Fapp\u002Fapi\u002Fgenerations\u002F**","app\u002Fchat\u002F[id]\u002F**","app\u002Fgenerate\u002F[id]\u002F**","src\u002Fapp\u002Fchat\u002F[id]\u002F**","src\u002Fapp\u002Fgenerate\u002F[id]\u002F**","lib\u002Fgenerations\u002F**","src\u002Flib\u002Fgenerations\u002F**",[],[53,54,55,56,57],"ai","@ai-sdk\u002F*","@vercel\u002Fblob","nanoid","@paralleldrive\u002Fcuid2",{"phrases":59,"allOf":72,"anyOf":98,"noneOf":108,"minScore":36},[60,61,62,63,64,65,66,67,68,69,70,71],"save generations","persist generations","generation history","chat history","save chat","generation id","ai chat","chat app","chatbot","image generation","text generation","ai app",[73,76,78,80,81,83,84,86,87,89,91,93,95,97],[74,75],"generate","save",[74,77],"persist",[74,79],"store",[53,77],[53,82],"history",[53,21],[85,77],"chat",[85,21],[85,88],"url",[90,88],"generation",[90,92],"id",[94,74],"image",[96,75],"stream",[96,77],[99,100,101,102,103,56,104,8,105,14,106,107],"shareable","retrievable","permalink","cost tracking","token usage","cuid","anthropic","gpt","claude",[109,110],"github actions","ci workflow",{"type":112,"children":113},"root",[114,122,132,137,144,242,248,253,834,1281,1286,1292,1974,1980,2073,2079,2084,2870,2876,2881,3211,3217,3222,3786,3792,3878],{"type":115,"tag":116,"props":117,"children":118},"element","h1",{"id":4},[119],{"type":120,"value":121},"text","AI Generation Persistence",{"type":115,"tag":123,"props":124,"children":125},"p",{},[126],{"type":115,"tag":127,"props":128,"children":129},"strong",{},[130],{"type":120,"value":131},"AI generations are expensive, non-reproducible assets. Never discard them.",{"type":115,"tag":123,"props":133,"children":134},{},[135],{"type":120,"value":136},"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.",{"type":115,"tag":138,"props":139,"children":141},"h2",{"id":140},"core-rules",[142],{"type":120,"value":143},"Core Rules",{"type":115,"tag":145,"props":146,"children":147},"ol",{},[148,181,191,222,232],{"type":115,"tag":149,"props":150,"children":151},"li",{},[152,157,159,166,168,174,176],{"type":115,"tag":127,"props":153,"children":154},{},[155],{"type":120,"value":156},"Generate an ID before the LLM call",{"type":120,"value":158}," — use ",{"type":115,"tag":160,"props":161,"children":163},"code",{"className":162},[],[164],{"type":120,"value":165},"nanoid()",{"type":120,"value":167}," or ",{"type":115,"tag":160,"props":169,"children":171},{"className":170},[],[172],{"type":120,"value":173},"createId()",{"type":120,"value":175}," from ",{"type":115,"tag":160,"props":177,"children":179},{"className":178},[],[180],{"type":120,"value":57},{"type":115,"tag":149,"props":182,"children":183},{},[184,189],{"type":115,"tag":127,"props":185,"children":186},{},[187],{"type":120,"value":188},"Persist every generation",{"type":120,"value":190}," — text and metadata to database, images and files to Vercel Blob",{"type":115,"tag":149,"props":192,"children":193},{},[194,199,201,207,209,215,216],{"type":115,"tag":127,"props":195,"children":196},{},[197],{"type":120,"value":198},"Make every generation addressable",{"type":120,"value":200}," — URL pattern: ",{"type":115,"tag":160,"props":202,"children":204},{"className":203},[],[205],{"type":120,"value":206},"\u002Fchat\u002F[id]",{"type":120,"value":208},", ",{"type":115,"tag":160,"props":210,"children":212},{"className":211},[],[213],{"type":120,"value":214},"\u002Fgenerate\u002F[id]",{"type":120,"value":208},{"type":115,"tag":160,"props":217,"children":219},{"className":218},[],[220],{"type":120,"value":221},"\u002Fimage\u002F[id]",{"type":115,"tag":149,"props":223,"children":224},{},[225,230],{"type":115,"tag":127,"props":226,"children":227},{},[228],{"type":120,"value":229},"Track metadata",{"type":120,"value":231}," — model name, token usage, estimated cost, timestamp, user ID",{"type":115,"tag":149,"props":233,"children":234},{},[235,240],{"type":115,"tag":127,"props":236,"children":237},{},[238],{"type":120,"value":239},"Never stream without saving",{"type":120,"value":241}," — if the user refreshes, the generation must survive",{"type":115,"tag":138,"props":243,"children":245},{"id":244},"generate-then-redirect-pattern",[246],{"type":120,"value":247},"Generate-Then-Redirect Pattern",{"type":115,"tag":123,"props":249,"children":250},{},[251],{"type":120,"value":252},"The standard UX flow for AI features: create the resource first, then redirect to its page.",{"type":115,"tag":254,"props":255,"children":260},"pre",{"className":256,"code":257,"language":258,"meta":259,"style":259},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F app\u002Fapi\u002Fchat\u002Froute.ts\nimport { nanoid } from \"nanoid\";\nimport { db } from \"@\u002Flib\u002Fdb\";\nimport { redirect } from \"next\u002Fnavigation\";\n\nexport async function POST(req: Request) {\n  const { prompt, model } = await req.json();\n  const id = nanoid();\n\n  \u002F\u002F Create the record BEFORE generation starts\n  await db.insert(generations).values({\n    id,\n    prompt,\n    model,\n    status: \"pending\",\n    createdAt: new Date(),\n  });\n\n  \u002F\u002F Redirect to the generation page — it handles streaming\n  redirect(`\u002Fchat\u002F${id}`);\n}\n","ts","",[261],{"type":115,"tag":160,"props":262,"children":263},{"__ignoreMap":259},[264,276,328,370,412,422,479,546,575,583,592,645,659,672,685,715,746,763,771,780,825],{"type":115,"tag":265,"props":266,"children":269},"span",{"class":267,"line":268},"line",1,[270],{"type":115,"tag":265,"props":271,"children":273},{"style":272},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[274],{"type":120,"value":275},"\u002F\u002F app\u002Fapi\u002Fchat\u002Froute.ts\n",{"type":115,"tag":265,"props":277,"children":279},{"class":267,"line":278},2,[280,286,292,298,303,308,313,318,323],{"type":115,"tag":265,"props":281,"children":283},{"style":282},"--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic",[284],{"type":120,"value":285},"import",{"type":115,"tag":265,"props":287,"children":289},{"style":288},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[290],{"type":120,"value":291}," {",{"type":115,"tag":265,"props":293,"children":295},{"style":294},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[296],{"type":120,"value":297}," nanoid",{"type":115,"tag":265,"props":299,"children":300},{"style":288},[301],{"type":120,"value":302}," }",{"type":115,"tag":265,"props":304,"children":305},{"style":282},[306],{"type":120,"value":307}," from",{"type":115,"tag":265,"props":309,"children":310},{"style":288},[311],{"type":120,"value":312}," \"",{"type":115,"tag":265,"props":314,"children":316},{"style":315},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[317],{"type":120,"value":56},{"type":115,"tag":265,"props":319,"children":320},{"style":288},[321],{"type":120,"value":322},"\"",{"type":115,"tag":265,"props":324,"children":325},{"style":288},[326],{"type":120,"value":327},";\n",{"type":115,"tag":265,"props":329,"children":331},{"class":267,"line":330},3,[332,336,340,345,349,353,357,362,366],{"type":115,"tag":265,"props":333,"children":334},{"style":282},[335],{"type":120,"value":285},{"type":115,"tag":265,"props":337,"children":338},{"style":288},[339],{"type":120,"value":291},{"type":115,"tag":265,"props":341,"children":342},{"style":294},[343],{"type":120,"value":344}," db",{"type":115,"tag":265,"props":346,"children":347},{"style":288},[348],{"type":120,"value":302},{"type":115,"tag":265,"props":350,"children":351},{"style":282},[352],{"type":120,"value":307},{"type":115,"tag":265,"props":354,"children":355},{"style":288},[356],{"type":120,"value":312},{"type":115,"tag":265,"props":358,"children":359},{"style":315},[360],{"type":120,"value":361},"@\u002Flib\u002Fdb",{"type":115,"tag":265,"props":363,"children":364},{"style":288},[365],{"type":120,"value":322},{"type":115,"tag":265,"props":367,"children":368},{"style":288},[369],{"type":120,"value":327},{"type":115,"tag":265,"props":371,"children":373},{"class":267,"line":372},4,[374,378,382,387,391,395,399,404,408],{"type":115,"tag":265,"props":375,"children":376},{"style":282},[377],{"type":120,"value":285},{"type":115,"tag":265,"props":379,"children":380},{"style":288},[381],{"type":120,"value":291},{"type":115,"tag":265,"props":383,"children":384},{"style":294},[385],{"type":120,"value":386}," redirect",{"type":115,"tag":265,"props":388,"children":389},{"style":288},[390],{"type":120,"value":302},{"type":115,"tag":265,"props":392,"children":393},{"style":282},[394],{"type":120,"value":307},{"type":115,"tag":265,"props":396,"children":397},{"style":288},[398],{"type":120,"value":312},{"type":115,"tag":265,"props":400,"children":401},{"style":315},[402],{"type":120,"value":403},"next\u002Fnavigation",{"type":115,"tag":265,"props":405,"children":406},{"style":288},[407],{"type":120,"value":322},{"type":115,"tag":265,"props":409,"children":410},{"style":288},[411],{"type":120,"value":327},{"type":115,"tag":265,"props":413,"children":415},{"class":267,"line":414},5,[416],{"type":115,"tag":265,"props":417,"children":419},{"emptyLinePlaceholder":418},true,[420],{"type":120,"value":421},"\n",{"type":115,"tag":265,"props":423,"children":424},{"class":267,"line":36},[425,430,436,441,447,452,458,463,469,474],{"type":115,"tag":265,"props":426,"children":427},{"style":282},[428],{"type":120,"value":429},"export",{"type":115,"tag":265,"props":431,"children":433},{"style":432},"--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA",[434],{"type":120,"value":435}," async",{"type":115,"tag":265,"props":437,"children":438},{"style":432},[439],{"type":120,"value":440}," function",{"type":115,"tag":265,"props":442,"children":444},{"style":443},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[445],{"type":120,"value":446}," POST",{"type":115,"tag":265,"props":448,"children":449},{"style":288},[450],{"type":120,"value":451},"(",{"type":115,"tag":265,"props":453,"children":455},{"style":454},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic",[456],{"type":120,"value":457},"req",{"type":115,"tag":265,"props":459,"children":460},{"style":288},[461],{"type":120,"value":462},":",{"type":115,"tag":265,"props":464,"children":466},{"style":465},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[467],{"type":120,"value":468}," Request",{"type":115,"tag":265,"props":470,"children":471},{"style":288},[472],{"type":120,"value":473},")",{"type":115,"tag":265,"props":475,"children":476},{"style":288},[477],{"type":120,"value":478}," {\n",{"type":115,"tag":265,"props":480,"children":482},{"class":267,"line":481},7,[483,488,492,497,502,507,511,516,521,526,531,536,542],{"type":115,"tag":265,"props":484,"children":485},{"style":432},[486],{"type":120,"value":487},"  const",{"type":115,"tag":265,"props":489,"children":490},{"style":288},[491],{"type":120,"value":291},{"type":115,"tag":265,"props":493,"children":494},{"style":294},[495],{"type":120,"value":496}," prompt",{"type":115,"tag":265,"props":498,"children":499},{"style":288},[500],{"type":120,"value":501},",",{"type":115,"tag":265,"props":503,"children":504},{"style":294},[505],{"type":120,"value":506}," model",{"type":115,"tag":265,"props":508,"children":509},{"style":288},[510],{"type":120,"value":302},{"type":115,"tag":265,"props":512,"children":513},{"style":288},[514],{"type":120,"value":515}," =",{"type":115,"tag":265,"props":517,"children":518},{"style":282},[519],{"type":120,"value":520}," await",{"type":115,"tag":265,"props":522,"children":523},{"style":294},[524],{"type":120,"value":525}," req",{"type":115,"tag":265,"props":527,"children":528},{"style":288},[529],{"type":120,"value":530},".",{"type":115,"tag":265,"props":532,"children":533},{"style":443},[534],{"type":120,"value":535},"json",{"type":115,"tag":265,"props":537,"children":539},{"style":538},"--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178",[540],{"type":120,"value":541},"()",{"type":115,"tag":265,"props":543,"children":544},{"style":288},[545],{"type":120,"value":327},{"type":115,"tag":265,"props":547,"children":549},{"class":267,"line":548},8,[550,554,559,563,567,571],{"type":115,"tag":265,"props":551,"children":552},{"style":432},[553],{"type":120,"value":487},{"type":115,"tag":265,"props":555,"children":556},{"style":294},[557],{"type":120,"value":558}," id",{"type":115,"tag":265,"props":560,"children":561},{"style":288},[562],{"type":120,"value":515},{"type":115,"tag":265,"props":564,"children":565},{"style":443},[566],{"type":120,"value":297},{"type":115,"tag":265,"props":568,"children":569},{"style":538},[570],{"type":120,"value":541},{"type":115,"tag":265,"props":572,"children":573},{"style":288},[574],{"type":120,"value":327},{"type":115,"tag":265,"props":576,"children":578},{"class":267,"line":577},9,[579],{"type":115,"tag":265,"props":580,"children":581},{"emptyLinePlaceholder":418},[582],{"type":120,"value":421},{"type":115,"tag":265,"props":584,"children":586},{"class":267,"line":585},10,[587],{"type":115,"tag":265,"props":588,"children":589},{"style":272},[590],{"type":120,"value":591},"  \u002F\u002F Create the record BEFORE generation starts\n",{"type":115,"tag":265,"props":593,"children":595},{"class":267,"line":594},11,[596,601,605,609,614,618,623,627,631,636,640],{"type":115,"tag":265,"props":597,"children":598},{"style":282},[599],{"type":120,"value":600},"  await",{"type":115,"tag":265,"props":602,"children":603},{"style":294},[604],{"type":120,"value":344},{"type":115,"tag":265,"props":606,"children":607},{"style":288},[608],{"type":120,"value":530},{"type":115,"tag":265,"props":610,"children":611},{"style":443},[612],{"type":120,"value":613},"insert",{"type":115,"tag":265,"props":615,"children":616},{"style":538},[617],{"type":120,"value":451},{"type":115,"tag":265,"props":619,"children":620},{"style":294},[621],{"type":120,"value":622},"generations",{"type":115,"tag":265,"props":624,"children":625},{"style":538},[626],{"type":120,"value":473},{"type":115,"tag":265,"props":628,"children":629},{"style":288},[630],{"type":120,"value":530},{"type":115,"tag":265,"props":632,"children":633},{"style":443},[634],{"type":120,"value":635},"values",{"type":115,"tag":265,"props":637,"children":638},{"style":538},[639],{"type":120,"value":451},{"type":115,"tag":265,"props":641,"children":642},{"style":288},[643],{"type":120,"value":644},"{\n",{"type":115,"tag":265,"props":646,"children":648},{"class":267,"line":647},12,[649,654],{"type":115,"tag":265,"props":650,"children":651},{"style":294},[652],{"type":120,"value":653},"    id",{"type":115,"tag":265,"props":655,"children":656},{"style":288},[657],{"type":120,"value":658},",\n",{"type":115,"tag":265,"props":660,"children":662},{"class":267,"line":661},13,[663,668],{"type":115,"tag":265,"props":664,"children":665},{"style":294},[666],{"type":120,"value":667},"    prompt",{"type":115,"tag":265,"props":669,"children":670},{"style":288},[671],{"type":120,"value":658},{"type":115,"tag":265,"props":673,"children":675},{"class":267,"line":674},14,[676,681],{"type":115,"tag":265,"props":677,"children":678},{"style":294},[679],{"type":120,"value":680},"    model",{"type":115,"tag":265,"props":682,"children":683},{"style":288},[684],{"type":120,"value":658},{"type":115,"tag":265,"props":686,"children":688},{"class":267,"line":687},15,[689,694,698,702,707,711],{"type":115,"tag":265,"props":690,"children":691},{"style":538},[692],{"type":120,"value":693},"    status",{"type":115,"tag":265,"props":695,"children":696},{"style":288},[697],{"type":120,"value":462},{"type":115,"tag":265,"props":699,"children":700},{"style":288},[701],{"type":120,"value":312},{"type":115,"tag":265,"props":703,"children":704},{"style":315},[705],{"type":120,"value":706},"pending",{"type":115,"tag":265,"props":708,"children":709},{"style":288},[710],{"type":120,"value":322},{"type":115,"tag":265,"props":712,"children":713},{"style":288},[714],{"type":120,"value":658},{"type":115,"tag":265,"props":716,"children":718},{"class":267,"line":717},16,[719,724,728,733,738,742],{"type":115,"tag":265,"props":720,"children":721},{"style":538},[722],{"type":120,"value":723},"    createdAt",{"type":115,"tag":265,"props":725,"children":726},{"style":288},[727],{"type":120,"value":462},{"type":115,"tag":265,"props":729,"children":730},{"style":288},[731],{"type":120,"value":732}," new",{"type":115,"tag":265,"props":734,"children":735},{"style":443},[736],{"type":120,"value":737}," Date",{"type":115,"tag":265,"props":739,"children":740},{"style":538},[741],{"type":120,"value":541},{"type":115,"tag":265,"props":743,"children":744},{"style":288},[745],{"type":120,"value":658},{"type":115,"tag":265,"props":747,"children":749},{"class":267,"line":748},17,[750,755,759],{"type":115,"tag":265,"props":751,"children":752},{"style":288},[753],{"type":120,"value":754},"  }",{"type":115,"tag":265,"props":756,"children":757},{"style":538},[758],{"type":120,"value":473},{"type":115,"tag":265,"props":760,"children":761},{"style":288},[762],{"type":120,"value":327},{"type":115,"tag":265,"props":764,"children":766},{"class":267,"line":765},18,[767],{"type":115,"tag":265,"props":768,"children":769},{"emptyLinePlaceholder":418},[770],{"type":120,"value":421},{"type":115,"tag":265,"props":772,"children":774},{"class":267,"line":773},19,[775],{"type":115,"tag":265,"props":776,"children":777},{"style":272},[778],{"type":120,"value":779},"  \u002F\u002F Redirect to the generation page — it handles streaming\n",{"type":115,"tag":265,"props":781,"children":783},{"class":267,"line":782},20,[784,789,793,798,803,808,812,817,821],{"type":115,"tag":265,"props":785,"children":786},{"style":443},[787],{"type":120,"value":788},"  redirect",{"type":115,"tag":265,"props":790,"children":791},{"style":538},[792],{"type":120,"value":451},{"type":115,"tag":265,"props":794,"children":795},{"style":288},[796],{"type":120,"value":797},"`",{"type":115,"tag":265,"props":799,"children":800},{"style":315},[801],{"type":120,"value":802},"\u002Fchat\u002F",{"type":115,"tag":265,"props":804,"children":805},{"style":288},[806],{"type":120,"value":807},"${",{"type":115,"tag":265,"props":809,"children":810},{"style":294},[811],{"type":120,"value":92},{"type":115,"tag":265,"props":813,"children":814},{"style":288},[815],{"type":120,"value":816},"}`",{"type":115,"tag":265,"props":818,"children":819},{"style":538},[820],{"type":120,"value":473},{"type":115,"tag":265,"props":822,"children":823},{"style":288},[824],{"type":120,"value":327},{"type":115,"tag":265,"props":826,"children":828},{"class":267,"line":827},21,[829],{"type":115,"tag":265,"props":830,"children":831},{"style":288},[832],{"type":120,"value":833},"}\n",{"type":115,"tag":254,"props":835,"children":839},{"className":836,"code":837,"language":838,"meta":259,"style":259},"language-tsx shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F app\u002Fchat\u002F[id]\u002Fpage.tsx\nimport { db } from \"@\u002Flib\u002Fdb\";\nimport { notFound } from \"next\u002Fnavigation\";\n\nexport default async function ChatPage({ params }: { params: Promise\u003C{ id: string }> }) {\n  const { id } = await params;\n  const generation = await db.query.generations.findFirst({\n    where: eq(generations.id, id),\n  });\n  if (!generation) notFound();\n\n  \u002F\u002F Render with streaming if still pending, or show saved result\n  return \u003CChatView generation={generation} \u002F>;\n}\n","tsx",[840],{"type":115,"tag":160,"props":841,"children":842},{"__ignoreMap":259},[843,851,890,930,937,1026,1061,1119,1168,1183,1223,1230,1238,1274],{"type":115,"tag":265,"props":844,"children":845},{"class":267,"line":268},[846],{"type":115,"tag":265,"props":847,"children":848},{"style":272},[849],{"type":120,"value":850},"\u002F\u002F app\u002Fchat\u002F[id]\u002Fpage.tsx\n",{"type":115,"tag":265,"props":852,"children":853},{"class":267,"line":278},[854,858,862,866,870,874,878,882,886],{"type":115,"tag":265,"props":855,"children":856},{"style":282},[857],{"type":120,"value":285},{"type":115,"tag":265,"props":859,"children":860},{"style":288},[861],{"type":120,"value":291},{"type":115,"tag":265,"props":863,"children":864},{"style":294},[865],{"type":120,"value":344},{"type":115,"tag":265,"props":867,"children":868},{"style":288},[869],{"type":120,"value":302},{"type":115,"tag":265,"props":871,"children":872},{"style":282},[873],{"type":120,"value":307},{"type":115,"tag":265,"props":875,"children":876},{"style":288},[877],{"type":120,"value":312},{"type":115,"tag":265,"props":879,"children":880},{"style":315},[881],{"type":120,"value":361},{"type":115,"tag":265,"props":883,"children":884},{"style":288},[885],{"type":120,"value":322},{"type":115,"tag":265,"props":887,"children":888},{"style":288},[889],{"type":120,"value":327},{"type":115,"tag":265,"props":891,"children":892},{"class":267,"line":330},[893,897,901,906,910,914,918,922,926],{"type":115,"tag":265,"props":894,"children":895},{"style":282},[896],{"type":120,"value":285},{"type":115,"tag":265,"props":898,"children":899},{"style":288},[900],{"type":120,"value":291},{"type":115,"tag":265,"props":902,"children":903},{"style":294},[904],{"type":120,"value":905}," notFound",{"type":115,"tag":265,"props":907,"children":908},{"style":288},[909],{"type":120,"value":302},{"type":115,"tag":265,"props":911,"children":912},{"style":282},[913],{"type":120,"value":307},{"type":115,"tag":265,"props":915,"children":916},{"style":288},[917],{"type":120,"value":312},{"type":115,"tag":265,"props":919,"children":920},{"style":315},[921],{"type":120,"value":403},{"type":115,"tag":265,"props":923,"children":924},{"style":288},[925],{"type":120,"value":322},{"type":115,"tag":265,"props":927,"children":928},{"style":288},[929],{"type":120,"value":327},{"type":115,"tag":265,"props":931,"children":932},{"class":267,"line":372},[933],{"type":115,"tag":265,"props":934,"children":935},{"emptyLinePlaceholder":418},[936],{"type":120,"value":421},{"type":115,"tag":265,"props":938,"children":939},{"class":267,"line":414},[940,944,949,953,957,962,967,972,977,981,985,989,994,999,1003,1007,1012,1017,1022],{"type":115,"tag":265,"props":941,"children":942},{"style":282},[943],{"type":120,"value":429},{"type":115,"tag":265,"props":945,"children":946},{"style":282},[947],{"type":120,"value":948}," default",{"type":115,"tag":265,"props":950,"children":951},{"style":432},[952],{"type":120,"value":435},{"type":115,"tag":265,"props":954,"children":955},{"style":432},[956],{"type":120,"value":440},{"type":115,"tag":265,"props":958,"children":959},{"style":443},[960],{"type":120,"value":961}," ChatPage",{"type":115,"tag":265,"props":963,"children":964},{"style":288},[965],{"type":120,"value":966},"({",{"type":115,"tag":265,"props":968,"children":969},{"style":454},[970],{"type":120,"value":971}," params",{"type":115,"tag":265,"props":973,"children":974},{"style":288},[975],{"type":120,"value":976}," }:",{"type":115,"tag":265,"props":978,"children":979},{"style":288},[980],{"type":120,"value":291},{"type":115,"tag":265,"props":982,"children":983},{"style":538},[984],{"type":120,"value":971},{"type":115,"tag":265,"props":986,"children":987},{"style":288},[988],{"type":120,"value":462},{"type":115,"tag":265,"props":990,"children":991},{"style":465},[992],{"type":120,"value":993}," Promise",{"type":115,"tag":265,"props":995,"children":996},{"style":288},[997],{"type":120,"value":998},"\u003C{",{"type":115,"tag":265,"props":1000,"children":1001},{"style":538},[1002],{"type":120,"value":558},{"type":115,"tag":265,"props":1004,"children":1005},{"style":288},[1006],{"type":120,"value":462},{"type":115,"tag":265,"props":1008,"children":1009},{"style":465},[1010],{"type":120,"value":1011}," string",{"type":115,"tag":265,"props":1013,"children":1014},{"style":288},[1015],{"type":120,"value":1016}," }>",{"type":115,"tag":265,"props":1018,"children":1019},{"style":288},[1020],{"type":120,"value":1021}," })",{"type":115,"tag":265,"props":1023,"children":1024},{"style":288},[1025],{"type":120,"value":478},{"type":115,"tag":265,"props":1027,"children":1028},{"class":267,"line":36},[1029,1033,1037,1041,1045,1049,1053,1057],{"type":115,"tag":265,"props":1030,"children":1031},{"style":432},[1032],{"type":120,"value":487},{"type":115,"tag":265,"props":1034,"children":1035},{"style":288},[1036],{"type":120,"value":291},{"type":115,"tag":265,"props":1038,"children":1039},{"style":294},[1040],{"type":120,"value":558},{"type":115,"tag":265,"props":1042,"children":1043},{"style":288},[1044],{"type":120,"value":302},{"type":115,"tag":265,"props":1046,"children":1047},{"style":288},[1048],{"type":120,"value":515},{"type":115,"tag":265,"props":1050,"children":1051},{"style":282},[1052],{"type":120,"value":520},{"type":115,"tag":265,"props":1054,"children":1055},{"style":294},[1056],{"type":120,"value":971},{"type":115,"tag":265,"props":1058,"children":1059},{"style":288},[1060],{"type":120,"value":327},{"type":115,"tag":265,"props":1062,"children":1063},{"class":267,"line":481},[1064,1068,1073,1077,1081,1085,1089,1094,1098,1102,1106,1111,1115],{"type":115,"tag":265,"props":1065,"children":1066},{"style":432},[1067],{"type":120,"value":487},{"type":115,"tag":265,"props":1069,"children":1070},{"style":294},[1071],{"type":120,"value":1072}," generation",{"type":115,"tag":265,"props":1074,"children":1075},{"style":288},[1076],{"type":120,"value":515},{"type":115,"tag":265,"props":1078,"children":1079},{"style":282},[1080],{"type":120,"value":520},{"type":115,"tag":265,"props":1082,"children":1083},{"style":294},[1084],{"type":120,"value":344},{"type":115,"tag":265,"props":1086,"children":1087},{"style":288},[1088],{"type":120,"value":530},{"type":115,"tag":265,"props":1090,"children":1091},{"style":294},[1092],{"type":120,"value":1093},"query",{"type":115,"tag":265,"props":1095,"children":1096},{"style":288},[1097],{"type":120,"value":530},{"type":115,"tag":265,"props":1099,"children":1100},{"style":294},[1101],{"type":120,"value":622},{"type":115,"tag":265,"props":1103,"children":1104},{"style":288},[1105],{"type":120,"value":530},{"type":115,"tag":265,"props":1107,"children":1108},{"style":443},[1109],{"type":120,"value":1110},"findFirst",{"type":115,"tag":265,"props":1112,"children":1113},{"style":538},[1114],{"type":120,"value":451},{"type":115,"tag":265,"props":1116,"children":1117},{"style":288},[1118],{"type":120,"value":644},{"type":115,"tag":265,"props":1120,"children":1121},{"class":267,"line":548},[1122,1127,1131,1136,1140,1144,1148,1152,1156,1160,1164],{"type":115,"tag":265,"props":1123,"children":1124},{"style":538},[1125],{"type":120,"value":1126},"    where",{"type":115,"tag":265,"props":1128,"children":1129},{"style":288},[1130],{"type":120,"value":462},{"type":115,"tag":265,"props":1132,"children":1133},{"style":443},[1134],{"type":120,"value":1135}," eq",{"type":115,"tag":265,"props":1137,"children":1138},{"style":538},[1139],{"type":120,"value":451},{"type":115,"tag":265,"props":1141,"children":1142},{"style":294},[1143],{"type":120,"value":622},{"type":115,"tag":265,"props":1145,"children":1146},{"style":288},[1147],{"type":120,"value":530},{"type":115,"tag":265,"props":1149,"children":1150},{"style":294},[1151],{"type":120,"value":92},{"type":115,"tag":265,"props":1153,"children":1154},{"style":288},[1155],{"type":120,"value":501},{"type":115,"tag":265,"props":1157,"children":1158},{"style":294},[1159],{"type":120,"value":558},{"type":115,"tag":265,"props":1161,"children":1162},{"style":538},[1163],{"type":120,"value":473},{"type":115,"tag":265,"props":1165,"children":1166},{"style":288},[1167],{"type":120,"value":658},{"type":115,"tag":265,"props":1169,"children":1170},{"class":267,"line":577},[1171,1175,1179],{"type":115,"tag":265,"props":1172,"children":1173},{"style":288},[1174],{"type":120,"value":754},{"type":115,"tag":265,"props":1176,"children":1177},{"style":538},[1178],{"type":120,"value":473},{"type":115,"tag":265,"props":1180,"children":1181},{"style":288},[1182],{"type":120,"value":327},{"type":115,"tag":265,"props":1184,"children":1185},{"class":267,"line":585},[1186,1191,1196,1201,1205,1210,1215,1219],{"type":115,"tag":265,"props":1187,"children":1188},{"style":282},[1189],{"type":120,"value":1190},"  if",{"type":115,"tag":265,"props":1192,"children":1193},{"style":538},[1194],{"type":120,"value":1195}," (",{"type":115,"tag":265,"props":1197,"children":1198},{"style":288},[1199],{"type":120,"value":1200},"!",{"type":115,"tag":265,"props":1202,"children":1203},{"style":294},[1204],{"type":120,"value":90},{"type":115,"tag":265,"props":1206,"children":1207},{"style":538},[1208],{"type":120,"value":1209},") ",{"type":115,"tag":265,"props":1211,"children":1212},{"style":443},[1213],{"type":120,"value":1214},"notFound",{"type":115,"tag":265,"props":1216,"children":1217},{"style":538},[1218],{"type":120,"value":541},{"type":115,"tag":265,"props":1220,"children":1221},{"style":288},[1222],{"type":120,"value":327},{"type":115,"tag":265,"props":1224,"children":1225},{"class":267,"line":594},[1226],{"type":115,"tag":265,"props":1227,"children":1228},{"emptyLinePlaceholder":418},[1229],{"type":120,"value":421},{"type":115,"tag":265,"props":1231,"children":1232},{"class":267,"line":647},[1233],{"type":115,"tag":265,"props":1234,"children":1235},{"style":272},[1236],{"type":120,"value":1237},"  \u002F\u002F Render with streaming if still pending, or show saved result\n",{"type":115,"tag":265,"props":1239,"children":1240},{"class":267,"line":661},[1241,1246,1251,1256,1260,1265,1269],{"type":115,"tag":265,"props":1242,"children":1243},{"style":282},[1244],{"type":120,"value":1245},"  return",{"type":115,"tag":265,"props":1247,"children":1248},{"style":288},[1249],{"type":120,"value":1250}," \u003C",{"type":115,"tag":265,"props":1252,"children":1253},{"style":465},[1254],{"type":120,"value":1255},"ChatView",{"type":115,"tag":265,"props":1257,"children":1258},{"style":432},[1259],{"type":120,"value":1072},{"type":115,"tag":265,"props":1261,"children":1262},{"style":288},[1263],{"type":120,"value":1264},"={",{"type":115,"tag":265,"props":1266,"children":1267},{"style":294},[1268],{"type":120,"value":90},{"type":115,"tag":265,"props":1270,"children":1271},{"style":288},[1272],{"type":120,"value":1273},"} \u002F>;\n",{"type":115,"tag":265,"props":1275,"children":1276},{"class":267,"line":674},[1277],{"type":115,"tag":265,"props":1278,"children":1279},{"style":288},[1280],{"type":120,"value":833},{"type":115,"tag":123,"props":1282,"children":1283},{},[1284],{"type":120,"value":1285},"This gives you: shareable URLs, back-button support, multi-tab sessions, and generation history for free.",{"type":115,"tag":138,"props":1287,"children":1289},{"id":1288},"persistence-schema",[1290],{"type":120,"value":1291},"Persistence Schema",{"type":115,"tag":254,"props":1293,"children":1295},{"className":256,"code":1294,"language":258,"meta":259,"style":259},"\u002F\u002F lib\u002Fdb\u002Fschema.ts\nimport { pgTable, text, integer, timestamp, jsonb } from \"drizzle-orm\u002Fpg-core\";\n\nexport const generations = pgTable(\"generations\", {\n  id: text(\"id\").primaryKey(),            \u002F\u002F nanoid\n  userId: text(\"user_id\"),                \u002F\u002F auth user\n  model: text(\"model\").notNull(),         \u002F\u002F \"openai\u002Fgpt-5.4\"\n  prompt: text(\"prompt\"),                 \u002F\u002F input text\n  result: text(\"result\"),                 \u002F\u002F generated output\n  imageUrls: jsonb(\"image_urls\"),         \u002F\u002F Blob URLs for generated images\n  tokenUsage: jsonb(\"token_usage\"),       \u002F\u002F { promptTokens, completionTokens }\n  estimatedCostCents: integer(\"estimated_cost_cents\"),\n  status: text(\"status\").default(\"pending\"), \u002F\u002F pending | streaming | complete | error\n  createdAt: timestamp(\"created_at\").defaultNow(),\n});\n",[1296],{"type":115,"tag":160,"props":1297,"children":1298},{"__ignoreMap":259},[1299,1307,1384,1391,1441,1499,1545,1604,1650,1696,1742,1788,1829,1904,1958],{"type":115,"tag":265,"props":1300,"children":1301},{"class":267,"line":268},[1302],{"type":115,"tag":265,"props":1303,"children":1304},{"style":272},[1305],{"type":120,"value":1306},"\u002F\u002F lib\u002Fdb\u002Fschema.ts\n",{"type":115,"tag":265,"props":1308,"children":1309},{"class":267,"line":278},[1310,1314,1318,1323,1327,1332,1336,1341,1345,1350,1354,1359,1363,1367,1371,1376,1380],{"type":115,"tag":265,"props":1311,"children":1312},{"style":282},[1313],{"type":120,"value":285},{"type":115,"tag":265,"props":1315,"children":1316},{"style":288},[1317],{"type":120,"value":291},{"type":115,"tag":265,"props":1319,"children":1320},{"style":294},[1321],{"type":120,"value":1322}," pgTable",{"type":115,"tag":265,"props":1324,"children":1325},{"style":288},[1326],{"type":120,"value":501},{"type":115,"tag":265,"props":1328,"children":1329},{"style":294},[1330],{"type":120,"value":1331}," text",{"type":115,"tag":265,"props":1333,"children":1334},{"style":288},[1335],{"type":120,"value":501},{"type":115,"tag":265,"props":1337,"children":1338},{"style":294},[1339],{"type":120,"value":1340}," integer",{"type":115,"tag":265,"props":1342,"children":1343},{"style":288},[1344],{"type":120,"value":501},{"type":115,"tag":265,"props":1346,"children":1347},{"style":294},[1348],{"type":120,"value":1349}," timestamp",{"type":115,"tag":265,"props":1351,"children":1352},{"style":288},[1353],{"type":120,"value":501},{"type":115,"tag":265,"props":1355,"children":1356},{"style":294},[1357],{"type":120,"value":1358}," jsonb",{"type":115,"tag":265,"props":1360,"children":1361},{"style":288},[1362],{"type":120,"value":302},{"type":115,"tag":265,"props":1364,"children":1365},{"style":282},[1366],{"type":120,"value":307},{"type":115,"tag":265,"props":1368,"children":1369},{"style":288},[1370],{"type":120,"value":312},{"type":115,"tag":265,"props":1372,"children":1373},{"style":315},[1374],{"type":120,"value":1375},"drizzle-orm\u002Fpg-core",{"type":115,"tag":265,"props":1377,"children":1378},{"style":288},[1379],{"type":120,"value":322},{"type":115,"tag":265,"props":1381,"children":1382},{"style":288},[1383],{"type":120,"value":327},{"type":115,"tag":265,"props":1385,"children":1386},{"class":267,"line":330},[1387],{"type":115,"tag":265,"props":1388,"children":1389},{"emptyLinePlaceholder":418},[1390],{"type":120,"value":421},{"type":115,"tag":265,"props":1392,"children":1393},{"class":267,"line":372},[1394,1398,1403,1408,1413,1417,1421,1425,1429,1433,1437],{"type":115,"tag":265,"props":1395,"children":1396},{"style":282},[1397],{"type":120,"value":429},{"type":115,"tag":265,"props":1399,"children":1400},{"style":432},[1401],{"type":120,"value":1402}," const",{"type":115,"tag":265,"props":1404,"children":1405},{"style":294},[1406],{"type":120,"value":1407}," generations ",{"type":115,"tag":265,"props":1409,"children":1410},{"style":288},[1411],{"type":120,"value":1412},"=",{"type":115,"tag":265,"props":1414,"children":1415},{"style":443},[1416],{"type":120,"value":1322},{"type":115,"tag":265,"props":1418,"children":1419},{"style":294},[1420],{"type":120,"value":451},{"type":115,"tag":265,"props":1422,"children":1423},{"style":288},[1424],{"type":120,"value":322},{"type":115,"tag":265,"props":1426,"children":1427},{"style":315},[1428],{"type":120,"value":622},{"type":115,"tag":265,"props":1430,"children":1431},{"style":288},[1432],{"type":120,"value":322},{"type":115,"tag":265,"props":1434,"children":1435},{"style":288},[1436],{"type":120,"value":501},{"type":115,"tag":265,"props":1438,"children":1439},{"style":288},[1440],{"type":120,"value":478},{"type":115,"tag":265,"props":1442,"children":1443},{"class":267,"line":414},[1444,1449,1453,1457,1461,1465,1469,1473,1477,1481,1486,1490,1494],{"type":115,"tag":265,"props":1445,"children":1446},{"style":538},[1447],{"type":120,"value":1448},"  id",{"type":115,"tag":265,"props":1450,"children":1451},{"style":288},[1452],{"type":120,"value":462},{"type":115,"tag":265,"props":1454,"children":1455},{"style":443},[1456],{"type":120,"value":1331},{"type":115,"tag":265,"props":1458,"children":1459},{"style":294},[1460],{"type":120,"value":451},{"type":115,"tag":265,"props":1462,"children":1463},{"style":288},[1464],{"type":120,"value":322},{"type":115,"tag":265,"props":1466,"children":1467},{"style":315},[1468],{"type":120,"value":92},{"type":115,"tag":265,"props":1470,"children":1471},{"style":288},[1472],{"type":120,"value":322},{"type":115,"tag":265,"props":1474,"children":1475},{"style":294},[1476],{"type":120,"value":473},{"type":115,"tag":265,"props":1478,"children":1479},{"style":288},[1480],{"type":120,"value":530},{"type":115,"tag":265,"props":1482,"children":1483},{"style":443},[1484],{"type":120,"value":1485},"primaryKey",{"type":115,"tag":265,"props":1487,"children":1488},{"style":294},[1489],{"type":120,"value":541},{"type":115,"tag":265,"props":1491,"children":1492},{"style":288},[1493],{"type":120,"value":501},{"type":115,"tag":265,"props":1495,"children":1496},{"style":272},[1497],{"type":120,"value":1498},"            \u002F\u002F nanoid\n",{"type":115,"tag":265,"props":1500,"children":1501},{"class":267,"line":36},[1502,1507,1511,1515,1519,1523,1528,1532,1536,1540],{"type":115,"tag":265,"props":1503,"children":1504},{"style":538},[1505],{"type":120,"value":1506},"  userId",{"type":115,"tag":265,"props":1508,"children":1509},{"style":288},[1510],{"type":120,"value":462},{"type":115,"tag":265,"props":1512,"children":1513},{"style":443},[1514],{"type":120,"value":1331},{"type":115,"tag":265,"props":1516,"children":1517},{"style":294},[1518],{"type":120,"value":451},{"type":115,"tag":265,"props":1520,"children":1521},{"style":288},[1522],{"type":120,"value":322},{"type":115,"tag":265,"props":1524,"children":1525},{"style":315},[1526],{"type":120,"value":1527},"user_id",{"type":115,"tag":265,"props":1529,"children":1530},{"style":288},[1531],{"type":120,"value":322},{"type":115,"tag":265,"props":1533,"children":1534},{"style":294},[1535],{"type":120,"value":473},{"type":115,"tag":265,"props":1537,"children":1538},{"style":288},[1539],{"type":120,"value":501},{"type":115,"tag":265,"props":1541,"children":1542},{"style":272},[1543],{"type":120,"value":1544},"                \u002F\u002F auth user\n",{"type":115,"tag":265,"props":1546,"children":1547},{"class":267,"line":481},[1548,1553,1557,1561,1565,1569,1574,1578,1582,1586,1591,1595,1599],{"type":115,"tag":265,"props":1549,"children":1550},{"style":538},[1551],{"type":120,"value":1552},"  model",{"type":115,"tag":265,"props":1554,"children":1555},{"style":288},[1556],{"type":120,"value":462},{"type":115,"tag":265,"props":1558,"children":1559},{"style":443},[1560],{"type":120,"value":1331},{"type":115,"tag":265,"props":1562,"children":1563},{"style":294},[1564],{"type":120,"value":451},{"type":115,"tag":265,"props":1566,"children":1567},{"style":288},[1568],{"type":120,"value":322},{"type":115,"tag":265,"props":1570,"children":1571},{"style":315},[1572],{"type":120,"value":1573},"model",{"type":115,"tag":265,"props":1575,"children":1576},{"style":288},[1577],{"type":120,"value":322},{"type":115,"tag":265,"props":1579,"children":1580},{"style":294},[1581],{"type":120,"value":473},{"type":115,"tag":265,"props":1583,"children":1584},{"style":288},[1585],{"type":120,"value":530},{"type":115,"tag":265,"props":1587,"children":1588},{"style":443},[1589],{"type":120,"value":1590},"notNull",{"type":115,"tag":265,"props":1592,"children":1593},{"style":294},[1594],{"type":120,"value":541},{"type":115,"tag":265,"props":1596,"children":1597},{"style":288},[1598],{"type":120,"value":501},{"type":115,"tag":265,"props":1600,"children":1601},{"style":272},[1602],{"type":120,"value":1603},"         \u002F\u002F \"openai\u002Fgpt-5.4\"\n",{"type":115,"tag":265,"props":1605,"children":1606},{"class":267,"line":548},[1607,1612,1616,1620,1624,1628,1633,1637,1641,1645],{"type":115,"tag":265,"props":1608,"children":1609},{"style":538},[1610],{"type":120,"value":1611},"  prompt",{"type":115,"tag":265,"props":1613,"children":1614},{"style":288},[1615],{"type":120,"value":462},{"type":115,"tag":265,"props":1617,"children":1618},{"style":443},[1619],{"type":120,"value":1331},{"type":115,"tag":265,"props":1621,"children":1622},{"style":294},[1623],{"type":120,"value":451},{"type":115,"tag":265,"props":1625,"children":1626},{"style":288},[1627],{"type":120,"value":322},{"type":115,"tag":265,"props":1629,"children":1630},{"style":315},[1631],{"type":120,"value":1632},"prompt",{"type":115,"tag":265,"props":1634,"children":1635},{"style":288},[1636],{"type":120,"value":322},{"type":115,"tag":265,"props":1638,"children":1639},{"style":294},[1640],{"type":120,"value":473},{"type":115,"tag":265,"props":1642,"children":1643},{"style":288},[1644],{"type":120,"value":501},{"type":115,"tag":265,"props":1646,"children":1647},{"style":272},[1648],{"type":120,"value":1649},"                 \u002F\u002F input text\n",{"type":115,"tag":265,"props":1651,"children":1652},{"class":267,"line":577},[1653,1658,1662,1666,1670,1674,1679,1683,1687,1691],{"type":115,"tag":265,"props":1654,"children":1655},{"style":538},[1656],{"type":120,"value":1657},"  result",{"type":115,"tag":265,"props":1659,"children":1660},{"style":288},[1661],{"type":120,"value":462},{"type":115,"tag":265,"props":1663,"children":1664},{"style":443},[1665],{"type":120,"value":1331},{"type":115,"tag":265,"props":1667,"children":1668},{"style":294},[1669],{"type":120,"value":451},{"type":115,"tag":265,"props":1671,"children":1672},{"style":288},[1673],{"type":120,"value":322},{"type":115,"tag":265,"props":1675,"children":1676},{"style":315},[1677],{"type":120,"value":1678},"result",{"type":115,"tag":265,"props":1680,"children":1681},{"style":288},[1682],{"type":120,"value":322},{"type":115,"tag":265,"props":1684,"children":1685},{"style":294},[1686],{"type":120,"value":473},{"type":115,"tag":265,"props":1688,"children":1689},{"style":288},[1690],{"type":120,"value":501},{"type":115,"tag":265,"props":1692,"children":1693},{"style":272},[1694],{"type":120,"value":1695},"                 \u002F\u002F generated output\n",{"type":115,"tag":265,"props":1697,"children":1698},{"class":267,"line":585},[1699,1704,1708,1712,1716,1720,1725,1729,1733,1737],{"type":115,"tag":265,"props":1700,"children":1701},{"style":538},[1702],{"type":120,"value":1703},"  imageUrls",{"type":115,"tag":265,"props":1705,"children":1706},{"style":288},[1707],{"type":120,"value":462},{"type":115,"tag":265,"props":1709,"children":1710},{"style":443},[1711],{"type":120,"value":1358},{"type":115,"tag":265,"props":1713,"children":1714},{"style":294},[1715],{"type":120,"value":451},{"type":115,"tag":265,"props":1717,"children":1718},{"style":288},[1719],{"type":120,"value":322},{"type":115,"tag":265,"props":1721,"children":1722},{"style":315},[1723],{"type":120,"value":1724},"image_urls",{"type":115,"tag":265,"props":1726,"children":1727},{"style":288},[1728],{"type":120,"value":322},{"type":115,"tag":265,"props":1730,"children":1731},{"style":294},[1732],{"type":120,"value":473},{"type":115,"tag":265,"props":1734,"children":1735},{"style":288},[1736],{"type":120,"value":501},{"type":115,"tag":265,"props":1738,"children":1739},{"style":272},[1740],{"type":120,"value":1741},"         \u002F\u002F Blob URLs for generated images\n",{"type":115,"tag":265,"props":1743,"children":1744},{"class":267,"line":594},[1745,1750,1754,1758,1762,1766,1771,1775,1779,1783],{"type":115,"tag":265,"props":1746,"children":1747},{"style":538},[1748],{"type":120,"value":1749},"  tokenUsage",{"type":115,"tag":265,"props":1751,"children":1752},{"style":288},[1753],{"type":120,"value":462},{"type":115,"tag":265,"props":1755,"children":1756},{"style":443},[1757],{"type":120,"value":1358},{"type":115,"tag":265,"props":1759,"children":1760},{"style":294},[1761],{"type":120,"value":451},{"type":115,"tag":265,"props":1763,"children":1764},{"style":288},[1765],{"type":120,"value":322},{"type":115,"tag":265,"props":1767,"children":1768},{"style":315},[1769],{"type":120,"value":1770},"token_usage",{"type":115,"tag":265,"props":1772,"children":1773},{"style":288},[1774],{"type":120,"value":322},{"type":115,"tag":265,"props":1776,"children":1777},{"style":294},[1778],{"type":120,"value":473},{"type":115,"tag":265,"props":1780,"children":1781},{"style":288},[1782],{"type":120,"value":501},{"type":115,"tag":265,"props":1784,"children":1785},{"style":272},[1786],{"type":120,"value":1787},"       \u002F\u002F { promptTokens, completionTokens }\n",{"type":115,"tag":265,"props":1789,"children":1790},{"class":267,"line":647},[1791,1796,1800,1804,1808,1812,1817,1821,1825],{"type":115,"tag":265,"props":1792,"children":1793},{"style":538},[1794],{"type":120,"value":1795},"  estimatedCostCents",{"type":115,"tag":265,"props":1797,"children":1798},{"style":288},[1799],{"type":120,"value":462},{"type":115,"tag":265,"props":1801,"children":1802},{"style":443},[1803],{"type":120,"value":1340},{"type":115,"tag":265,"props":1805,"children":1806},{"style":294},[1807],{"type":120,"value":451},{"type":115,"tag":265,"props":1809,"children":1810},{"style":288},[1811],{"type":120,"value":322},{"type":115,"tag":265,"props":1813,"children":1814},{"style":315},[1815],{"type":120,"value":1816},"estimated_cost_cents",{"type":115,"tag":265,"props":1818,"children":1819},{"style":288},[1820],{"type":120,"value":322},{"type":115,"tag":265,"props":1822,"children":1823},{"style":294},[1824],{"type":120,"value":473},{"type":115,"tag":265,"props":1826,"children":1827},{"style":288},[1828],{"type":120,"value":658},{"type":115,"tag":265,"props":1830,"children":1831},{"class":267,"line":661},[1832,1837,1841,1845,1849,1853,1858,1862,1866,1870,1875,1879,1883,1887,1891,1895,1899],{"type":115,"tag":265,"props":1833,"children":1834},{"style":538},[1835],{"type":120,"value":1836},"  status",{"type":115,"tag":265,"props":1838,"children":1839},{"style":288},[1840],{"type":120,"value":462},{"type":115,"tag":265,"props":1842,"children":1843},{"style":443},[1844],{"type":120,"value":1331},{"type":115,"tag":265,"props":1846,"children":1847},{"style":294},[1848],{"type":120,"value":451},{"type":115,"tag":265,"props":1850,"children":1851},{"style":288},[1852],{"type":120,"value":322},{"type":115,"tag":265,"props":1854,"children":1855},{"style":315},[1856],{"type":120,"value":1857},"status",{"type":115,"tag":265,"props":1859,"children":1860},{"style":288},[1861],{"type":120,"value":322},{"type":115,"tag":265,"props":1863,"children":1864},{"style":294},[1865],{"type":120,"value":473},{"type":115,"tag":265,"props":1867,"children":1868},{"style":288},[1869],{"type":120,"value":530},{"type":115,"tag":265,"props":1871,"children":1872},{"style":443},[1873],{"type":120,"value":1874},"default",{"type":115,"tag":265,"props":1876,"children":1877},{"style":294},[1878],{"type":120,"value":451},{"type":115,"tag":265,"props":1880,"children":1881},{"style":288},[1882],{"type":120,"value":322},{"type":115,"tag":265,"props":1884,"children":1885},{"style":315},[1886],{"type":120,"value":706},{"type":115,"tag":265,"props":1888,"children":1889},{"style":288},[1890],{"type":120,"value":322},{"type":115,"tag":265,"props":1892,"children":1893},{"style":294},[1894],{"type":120,"value":473},{"type":115,"tag":265,"props":1896,"children":1897},{"style":288},[1898],{"type":120,"value":501},{"type":115,"tag":265,"props":1900,"children":1901},{"style":272},[1902],{"type":120,"value":1903}," \u002F\u002F pending | streaming | complete | error\n",{"type":115,"tag":265,"props":1905,"children":1906},{"class":267,"line":674},[1907,1912,1916,1920,1924,1928,1933,1937,1941,1945,1950,1954],{"type":115,"tag":265,"props":1908,"children":1909},{"style":538},[1910],{"type":120,"value":1911},"  createdAt",{"type":115,"tag":265,"props":1913,"children":1914},{"style":288},[1915],{"type":120,"value":462},{"type":115,"tag":265,"props":1917,"children":1918},{"style":443},[1919],{"type":120,"value":1349},{"type":115,"tag":265,"props":1921,"children":1922},{"style":294},[1923],{"type":120,"value":451},{"type":115,"tag":265,"props":1925,"children":1926},{"style":288},[1927],{"type":120,"value":322},{"type":115,"tag":265,"props":1929,"children":1930},{"style":315},[1931],{"type":120,"value":1932},"created_at",{"type":115,"tag":265,"props":1934,"children":1935},{"style":288},[1936],{"type":120,"value":322},{"type":115,"tag":265,"props":1938,"children":1939},{"style":294},[1940],{"type":120,"value":473},{"type":115,"tag":265,"props":1942,"children":1943},{"style":288},[1944],{"type":120,"value":530},{"type":115,"tag":265,"props":1946,"children":1947},{"style":443},[1948],{"type":120,"value":1949},"defaultNow",{"type":115,"tag":265,"props":1951,"children":1952},{"style":294},[1953],{"type":120,"value":541},{"type":115,"tag":265,"props":1955,"children":1956},{"style":288},[1957],{"type":120,"value":658},{"type":115,"tag":265,"props":1959,"children":1960},{"class":267,"line":687},[1961,1966,1970],{"type":115,"tag":265,"props":1962,"children":1963},{"style":288},[1964],{"type":120,"value":1965},"}",{"type":115,"tag":265,"props":1967,"children":1968},{"style":294},[1969],{"type":120,"value":473},{"type":115,"tag":265,"props":1971,"children":1972},{"style":288},[1973],{"type":120,"value":327},{"type":115,"tag":138,"props":1975,"children":1977},{"id":1976},"storage-strategy",[1978],{"type":120,"value":1979},"Storage Strategy",{"type":115,"tag":1981,"props":1982,"children":1983},"table",{},[1984,2008],{"type":115,"tag":1985,"props":1986,"children":1987},"thead",{},[1988],{"type":115,"tag":1989,"props":1990,"children":1991},"tr",{},[1992,1998,2003],{"type":115,"tag":1993,"props":1994,"children":1995},"th",{},[1996],{"type":120,"value":1997},"Data Type",{"type":115,"tag":1993,"props":1999,"children":2000},{},[2001],{"type":120,"value":2002},"Storage",{"type":115,"tag":1993,"props":2004,"children":2005},{},[2006],{"type":120,"value":2007},"Why",{"type":115,"tag":2009,"props":2010,"children":2011},"tbody",{},[2012,2031,2055],{"type":115,"tag":1989,"props":2013,"children":2014},{},[2015,2021,2026],{"type":115,"tag":2016,"props":2017,"children":2018},"td",{},[2019],{"type":120,"value":2020},"Text, metadata, history",{"type":115,"tag":2016,"props":2022,"children":2023},{},[2024],{"type":120,"value":2025},"Neon Postgres via Drizzle",{"type":115,"tag":2016,"props":2027,"children":2028},{},[2029],{"type":120,"value":2030},"Queryable, relational, supports search",{"type":115,"tag":1989,"props":2032,"children":2033},{},[2034,2039,2050],{"type":115,"tag":2016,"props":2035,"children":2036},{},[2037],{"type":120,"value":2038},"Generated images & files",{"type":115,"tag":2016,"props":2040,"children":2041},{},[2042,2044,2049],{"type":120,"value":2043},"Vercel Blob (",{"type":115,"tag":160,"props":2045,"children":2047},{"className":2046},[],[2048],{"type":120,"value":55},{"type":120,"value":473},{"type":115,"tag":2016,"props":2051,"children":2052},{},[2053],{"type":120,"value":2054},"Permanent URLs, CDN-backed, no expiry",{"type":115,"tag":1989,"props":2056,"children":2057},{},[2058,2063,2068],{"type":115,"tag":2016,"props":2059,"children":2060},{},[2061],{"type":120,"value":2062},"Prompt dedup cache",{"type":115,"tag":2016,"props":2064,"children":2065},{},[2066],{"type":120,"value":2067},"Upstash Redis",{"type":115,"tag":2016,"props":2069,"children":2070},{},[2071],{"type":120,"value":2072},"Fast lookup, TTL-based expiry",{"type":115,"tag":138,"props":2074,"children":2076},{"id":2075},"image-persistence",[2077],{"type":120,"value":2078},"Image Persistence",{"type":115,"tag":123,"props":2080,"children":2081},{},[2082],{"type":120,"value":2083},"Never serve generated images as ephemeral base64 or temporary URLs. Save to Blob immediately:",{"type":115,"tag":254,"props":2085,"children":2087},{"className":256,"code":2086,"language":258,"meta":259,"style":259},"import { put } from \"@vercel\u002Fblob\";\nimport { generateText } from \"ai\";\n\nconst result = await generateText({ model, prompt });\n\n\u002F\u002F Save every generated image to permanent storage\nconst imageUrls: string[] = [];\nfor (const file of result.files ?? []) {\n  if (file.mediaType?.startsWith(\"image\u002F\")) {\n    const ext = file.mediaType.split(\"\u002F\")[1] || \"png\";\n    const blob = await put(`generations\u002F${generationId}.${ext}`, file.uint8Array, {\n      access: \"public\",\n      contentType: file.mediaType,\n    });\n    imageUrls.push(blob.url);\n  }\n}\n\n\u002F\u002F Update the generation record with permanent URLs\nawait db.update(generations)\n  .set({ imageUrls, status: \"complete\" })\n  .where(eq(generations.id, generationId));\n",[2088],{"type":115,"tag":160,"props":2089,"children":2090},{"__ignoreMap":259},[2091,2131,2171,2178,2237,2244,2252,2290,2344,2405,2499,2591,2620,2648,2664,2706,2714,2721,2728,2736,2762,2822],{"type":115,"tag":265,"props":2092,"children":2093},{"class":267,"line":268},[2094,2098,2102,2107,2111,2115,2119,2123,2127],{"type":115,"tag":265,"props":2095,"children":2096},{"style":282},[2097],{"type":120,"value":285},{"type":115,"tag":265,"props":2099,"children":2100},{"style":288},[2101],{"type":120,"value":291},{"type":115,"tag":265,"props":2103,"children":2104},{"style":294},[2105],{"type":120,"value":2106}," put",{"type":115,"tag":265,"props":2108,"children":2109},{"style":288},[2110],{"type":120,"value":302},{"type":115,"tag":265,"props":2112,"children":2113},{"style":282},[2114],{"type":120,"value":307},{"type":115,"tag":265,"props":2116,"children":2117},{"style":288},[2118],{"type":120,"value":312},{"type":115,"tag":265,"props":2120,"children":2121},{"style":315},[2122],{"type":120,"value":55},{"type":115,"tag":265,"props":2124,"children":2125},{"style":288},[2126],{"type":120,"value":322},{"type":115,"tag":265,"props":2128,"children":2129},{"style":288},[2130],{"type":120,"value":327},{"type":115,"tag":265,"props":2132,"children":2133},{"class":267,"line":278},[2134,2138,2142,2147,2151,2155,2159,2163,2167],{"type":115,"tag":265,"props":2135,"children":2136},{"style":282},[2137],{"type":120,"value":285},{"type":115,"tag":265,"props":2139,"children":2140},{"style":288},[2141],{"type":120,"value":291},{"type":115,"tag":265,"props":2143,"children":2144},{"style":294},[2145],{"type":120,"value":2146}," generateText",{"type":115,"tag":265,"props":2148,"children":2149},{"style":288},[2150],{"type":120,"value":302},{"type":115,"tag":265,"props":2152,"children":2153},{"style":282},[2154],{"type":120,"value":307},{"type":115,"tag":265,"props":2156,"children":2157},{"style":288},[2158],{"type":120,"value":312},{"type":115,"tag":265,"props":2160,"children":2161},{"style":315},[2162],{"type":120,"value":53},{"type":115,"tag":265,"props":2164,"children":2165},{"style":288},[2166],{"type":120,"value":322},{"type":115,"tag":265,"props":2168,"children":2169},{"style":288},[2170],{"type":120,"value":327},{"type":115,"tag":265,"props":2172,"children":2173},{"class":267,"line":330},[2174],{"type":115,"tag":265,"props":2175,"children":2176},{"emptyLinePlaceholder":418},[2177],{"type":120,"value":421},{"type":115,"tag":265,"props":2179,"children":2180},{"class":267,"line":372},[2181,2186,2191,2195,2199,2203,2207,2212,2216,2220,2225,2229,2233],{"type":115,"tag":265,"props":2182,"children":2183},{"style":432},[2184],{"type":120,"value":2185},"const",{"type":115,"tag":265,"props":2187,"children":2188},{"style":294},[2189],{"type":120,"value":2190}," result ",{"type":115,"tag":265,"props":2192,"children":2193},{"style":288},[2194],{"type":120,"value":1412},{"type":115,"tag":265,"props":2196,"children":2197},{"style":282},[2198],{"type":120,"value":520},{"type":115,"tag":265,"props":2200,"children":2201},{"style":443},[2202],{"type":120,"value":2146},{"type":115,"tag":265,"props":2204,"children":2205},{"style":294},[2206],{"type":120,"value":451},{"type":115,"tag":265,"props":2208,"children":2209},{"style":288},[2210],{"type":120,"value":2211},"{",{"type":115,"tag":265,"props":2213,"children":2214},{"style":294},[2215],{"type":120,"value":506},{"type":115,"tag":265,"props":2217,"children":2218},{"style":288},[2219],{"type":120,"value":501},{"type":115,"tag":265,"props":2221,"children":2222},{"style":294},[2223],{"type":120,"value":2224}," prompt ",{"type":115,"tag":265,"props":2226,"children":2227},{"style":288},[2228],{"type":120,"value":1965},{"type":115,"tag":265,"props":2230,"children":2231},{"style":294},[2232],{"type":120,"value":473},{"type":115,"tag":265,"props":2234,"children":2235},{"style":288},[2236],{"type":120,"value":327},{"type":115,"tag":265,"props":2238,"children":2239},{"class":267,"line":414},[2240],{"type":115,"tag":265,"props":2241,"children":2242},{"emptyLinePlaceholder":418},[2243],{"type":120,"value":421},{"type":115,"tag":265,"props":2245,"children":2246},{"class":267,"line":36},[2247],{"type":115,"tag":265,"props":2248,"children":2249},{"style":272},[2250],{"type":120,"value":2251},"\u002F\u002F Save every generated image to permanent storage\n",{"type":115,"tag":265,"props":2253,"children":2254},{"class":267,"line":481},[2255,2259,2264,2268,2272,2277,2281,2286],{"type":115,"tag":265,"props":2256,"children":2257},{"style":432},[2258],{"type":120,"value":2185},{"type":115,"tag":265,"props":2260,"children":2261},{"style":294},[2262],{"type":120,"value":2263}," imageUrls",{"type":115,"tag":265,"props":2265,"children":2266},{"style":288},[2267],{"type":120,"value":462},{"type":115,"tag":265,"props":2269,"children":2270},{"style":465},[2271],{"type":120,"value":1011},{"type":115,"tag":265,"props":2273,"children":2274},{"style":294},[2275],{"type":120,"value":2276},"[] ",{"type":115,"tag":265,"props":2278,"children":2279},{"style":288},[2280],{"type":120,"value":1412},{"type":115,"tag":265,"props":2282,"children":2283},{"style":294},[2284],{"type":120,"value":2285}," []",{"type":115,"tag":265,"props":2287,"children":2288},{"style":288},[2289],{"type":120,"value":327},{"type":115,"tag":265,"props":2291,"children":2292},{"class":267,"line":548},[2293,2298,2302,2306,2311,2316,2321,2325,2330,2335,2340],{"type":115,"tag":265,"props":2294,"children":2295},{"style":282},[2296],{"type":120,"value":2297},"for",{"type":115,"tag":265,"props":2299,"children":2300},{"style":294},[2301],{"type":120,"value":1195},{"type":115,"tag":265,"props":2303,"children":2304},{"style":432},[2305],{"type":120,"value":2185},{"type":115,"tag":265,"props":2307,"children":2308},{"style":294},[2309],{"type":120,"value":2310}," file ",{"type":115,"tag":265,"props":2312,"children":2313},{"style":288},[2314],{"type":120,"value":2315},"of",{"type":115,"tag":265,"props":2317,"children":2318},{"style":294},[2319],{"type":120,"value":2320}," result",{"type":115,"tag":265,"props":2322,"children":2323},{"style":288},[2324],{"type":120,"value":530},{"type":115,"tag":265,"props":2326,"children":2327},{"style":294},[2328],{"type":120,"value":2329},"files ",{"type":115,"tag":265,"props":2331,"children":2332},{"style":288},[2333],{"type":120,"value":2334},"??",{"type":115,"tag":265,"props":2336,"children":2337},{"style":294},[2338],{"type":120,"value":2339}," []) ",{"type":115,"tag":265,"props":2341,"children":2342},{"style":288},[2343],{"type":120,"value":644},{"type":115,"tag":265,"props":2345,"children":2346},{"class":267,"line":577},[2347,2351,2355,2360,2364,2369,2374,2379,2383,2387,2392,2396,2401],{"type":115,"tag":265,"props":2348,"children":2349},{"style":282},[2350],{"type":120,"value":1190},{"type":115,"tag":265,"props":2352,"children":2353},{"style":538},[2354],{"type":120,"value":1195},{"type":115,"tag":265,"props":2356,"children":2357},{"style":294},[2358],{"type":120,"value":2359},"file",{"type":115,"tag":265,"props":2361,"children":2362},{"style":288},[2363],{"type":120,"value":530},{"type":115,"tag":265,"props":2365,"children":2366},{"style":294},[2367],{"type":120,"value":2368},"mediaType",{"type":115,"tag":265,"props":2370,"children":2371},{"style":288},[2372],{"type":120,"value":2373},"?.",{"type":115,"tag":265,"props":2375,"children":2376},{"style":443},[2377],{"type":120,"value":2378},"startsWith",{"type":115,"tag":265,"props":2380,"children":2381},{"style":538},[2382],{"type":120,"value":451},{"type":115,"tag":265,"props":2384,"children":2385},{"style":288},[2386],{"type":120,"value":322},{"type":115,"tag":265,"props":2388,"children":2389},{"style":315},[2390],{"type":120,"value":2391},"image\u002F",{"type":115,"tag":265,"props":2393,"children":2394},{"style":288},[2395],{"type":120,"value":322},{"type":115,"tag":265,"props":2397,"children":2398},{"style":538},[2399],{"type":120,"value":2400},")) ",{"type":115,"tag":265,"props":2402,"children":2403},{"style":288},[2404],{"type":120,"value":644},{"type":115,"tag":265,"props":2406,"children":2407},{"class":267,"line":585},[2408,2413,2418,2422,2427,2431,2435,2439,2444,2448,2452,2457,2461,2466,2472,2477,2482,2486,2491,2495],{"type":115,"tag":265,"props":2409,"children":2410},{"style":432},[2411],{"type":120,"value":2412},"    const",{"type":115,"tag":265,"props":2414,"children":2415},{"style":294},[2416],{"type":120,"value":2417}," ext",{"type":115,"tag":265,"props":2419,"children":2420},{"style":288},[2421],{"type":120,"value":515},{"type":115,"tag":265,"props":2423,"children":2424},{"style":294},[2425],{"type":120,"value":2426}," file",{"type":115,"tag":265,"props":2428,"children":2429},{"style":288},[2430],{"type":120,"value":530},{"type":115,"tag":265,"props":2432,"children":2433},{"style":294},[2434],{"type":120,"value":2368},{"type":115,"tag":265,"props":2436,"children":2437},{"style":288},[2438],{"type":120,"value":530},{"type":115,"tag":265,"props":2440,"children":2441},{"style":443},[2442],{"type":120,"value":2443},"split",{"type":115,"tag":265,"props":2445,"children":2446},{"style":538},[2447],{"type":120,"value":451},{"type":115,"tag":265,"props":2449,"children":2450},{"style":288},[2451],{"type":120,"value":322},{"type":115,"tag":265,"props":2453,"children":2454},{"style":315},[2455],{"type":120,"value":2456},"\u002F",{"type":115,"tag":265,"props":2458,"children":2459},{"style":288},[2460],{"type":120,"value":322},{"type":115,"tag":265,"props":2462,"children":2463},{"style":538},[2464],{"type":120,"value":2465},")[",{"type":115,"tag":265,"props":2467,"children":2469},{"style":2468},"--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C",[2470],{"type":120,"value":2471},"1",{"type":115,"tag":265,"props":2473,"children":2474},{"style":538},[2475],{"type":120,"value":2476},"] ",{"type":115,"tag":265,"props":2478,"children":2479},{"style":288},[2480],{"type":120,"value":2481},"||",{"type":115,"tag":265,"props":2483,"children":2484},{"style":288},[2485],{"type":120,"value":312},{"type":115,"tag":265,"props":2487,"children":2488},{"style":315},[2489],{"type":120,"value":2490},"png",{"type":115,"tag":265,"props":2492,"children":2493},{"style":288},[2494],{"type":120,"value":322},{"type":115,"tag":265,"props":2496,"children":2497},{"style":288},[2498],{"type":120,"value":327},{"type":115,"tag":265,"props":2500,"children":2501},{"class":267,"line":594},[2502,2506,2511,2515,2519,2523,2527,2531,2536,2540,2545,2549,2553,2557,2562,2566,2570,2574,2578,2583,2587],{"type":115,"tag":265,"props":2503,"children":2504},{"style":432},[2505],{"type":120,"value":2412},{"type":115,"tag":265,"props":2507,"children":2508},{"style":294},[2509],{"type":120,"value":2510}," blob",{"type":115,"tag":265,"props":2512,"children":2513},{"style":288},[2514],{"type":120,"value":515},{"type":115,"tag":265,"props":2516,"children":2517},{"style":282},[2518],{"type":120,"value":520},{"type":115,"tag":265,"props":2520,"children":2521},{"style":443},[2522],{"type":120,"value":2106},{"type":115,"tag":265,"props":2524,"children":2525},{"style":538},[2526],{"type":120,"value":451},{"type":115,"tag":265,"props":2528,"children":2529},{"style":288},[2530],{"type":120,"value":797},{"type":115,"tag":265,"props":2532,"children":2533},{"style":315},[2534],{"type":120,"value":2535},"generations\u002F",{"type":115,"tag":265,"props":2537,"children":2538},{"style":288},[2539],{"type":120,"value":807},{"type":115,"tag":265,"props":2541,"children":2542},{"style":294},[2543],{"type":120,"value":2544},"generationId",{"type":115,"tag":265,"props":2546,"children":2547},{"style":288},[2548],{"type":120,"value":1965},{"type":115,"tag":265,"props":2550,"children":2551},{"style":315},[2552],{"type":120,"value":530},{"type":115,"tag":265,"props":2554,"children":2555},{"style":288},[2556],{"type":120,"value":807},{"type":115,"tag":265,"props":2558,"children":2559},{"style":294},[2560],{"type":120,"value":2561},"ext",{"type":115,"tag":265,"props":2563,"children":2564},{"style":288},[2565],{"type":120,"value":816},{"type":115,"tag":265,"props":2567,"children":2568},{"style":288},[2569],{"type":120,"value":501},{"type":115,"tag":265,"props":2571,"children":2572},{"style":294},[2573],{"type":120,"value":2426},{"type":115,"tag":265,"props":2575,"children":2576},{"style":288},[2577],{"type":120,"value":530},{"type":115,"tag":265,"props":2579,"children":2580},{"style":294},[2581],{"type":120,"value":2582},"uint8Array",{"type":115,"tag":265,"props":2584,"children":2585},{"style":288},[2586],{"type":120,"value":501},{"type":115,"tag":265,"props":2588,"children":2589},{"style":288},[2590],{"type":120,"value":478},{"type":115,"tag":265,"props":2592,"children":2593},{"class":267,"line":647},[2594,2599,2603,2607,2612,2616],{"type":115,"tag":265,"props":2595,"children":2596},{"style":538},[2597],{"type":120,"value":2598},"      access",{"type":115,"tag":265,"props":2600,"children":2601},{"style":288},[2602],{"type":120,"value":462},{"type":115,"tag":265,"props":2604,"children":2605},{"style":288},[2606],{"type":120,"value":312},{"type":115,"tag":265,"props":2608,"children":2609},{"style":315},[2610],{"type":120,"value":2611},"public",{"type":115,"tag":265,"props":2613,"children":2614},{"style":288},[2615],{"type":120,"value":322},{"type":115,"tag":265,"props":2617,"children":2618},{"style":288},[2619],{"type":120,"value":658},{"type":115,"tag":265,"props":2621,"children":2622},{"class":267,"line":661},[2623,2628,2632,2636,2640,2644],{"type":115,"tag":265,"props":2624,"children":2625},{"style":538},[2626],{"type":120,"value":2627},"      contentType",{"type":115,"tag":265,"props":2629,"children":2630},{"style":288},[2631],{"type":120,"value":462},{"type":115,"tag":265,"props":2633,"children":2634},{"style":294},[2635],{"type":120,"value":2426},{"type":115,"tag":265,"props":2637,"children":2638},{"style":288},[2639],{"type":120,"value":530},{"type":115,"tag":265,"props":2641,"children":2642},{"style":294},[2643],{"type":120,"value":2368},{"type":115,"tag":265,"props":2645,"children":2646},{"style":288},[2647],{"type":120,"value":658},{"type":115,"tag":265,"props":2649,"children":2650},{"class":267,"line":674},[2651,2656,2660],{"type":115,"tag":265,"props":2652,"children":2653},{"style":288},[2654],{"type":120,"value":2655},"    }",{"type":115,"tag":265,"props":2657,"children":2658},{"style":538},[2659],{"type":120,"value":473},{"type":115,"tag":265,"props":2661,"children":2662},{"style":288},[2663],{"type":120,"value":327},{"type":115,"tag":265,"props":2665,"children":2666},{"class":267,"line":687},[2667,2672,2676,2681,2685,2690,2694,2698,2702],{"type":115,"tag":265,"props":2668,"children":2669},{"style":294},[2670],{"type":120,"value":2671},"    imageUrls",{"type":115,"tag":265,"props":2673,"children":2674},{"style":288},[2675],{"type":120,"value":530},{"type":115,"tag":265,"props":2677,"children":2678},{"style":443},[2679],{"type":120,"value":2680},"push",{"type":115,"tag":265,"props":2682,"children":2683},{"style":538},[2684],{"type":120,"value":451},{"type":115,"tag":265,"props":2686,"children":2687},{"style":294},[2688],{"type":120,"value":2689},"blob",{"type":115,"tag":265,"props":2691,"children":2692},{"style":288},[2693],{"type":120,"value":530},{"type":115,"tag":265,"props":2695,"children":2696},{"style":294},[2697],{"type":120,"value":88},{"type":115,"tag":265,"props":2699,"children":2700},{"style":538},[2701],{"type":120,"value":473},{"type":115,"tag":265,"props":2703,"children":2704},{"style":288},[2705],{"type":120,"value":327},{"type":115,"tag":265,"props":2707,"children":2708},{"class":267,"line":717},[2709],{"type":115,"tag":265,"props":2710,"children":2711},{"style":288},[2712],{"type":120,"value":2713},"  }\n",{"type":115,"tag":265,"props":2715,"children":2716},{"class":267,"line":748},[2717],{"type":115,"tag":265,"props":2718,"children":2719},{"style":288},[2720],{"type":120,"value":833},{"type":115,"tag":265,"props":2722,"children":2723},{"class":267,"line":765},[2724],{"type":115,"tag":265,"props":2725,"children":2726},{"emptyLinePlaceholder":418},[2727],{"type":120,"value":421},{"type":115,"tag":265,"props":2729,"children":2730},{"class":267,"line":773},[2731],{"type":115,"tag":265,"props":2732,"children":2733},{"style":272},[2734],{"type":120,"value":2735},"\u002F\u002F Update the generation record with permanent URLs\n",{"type":115,"tag":265,"props":2737,"children":2738},{"class":267,"line":782},[2739,2744,2748,2752,2757],{"type":115,"tag":265,"props":2740,"children":2741},{"style":282},[2742],{"type":120,"value":2743},"await",{"type":115,"tag":265,"props":2745,"children":2746},{"style":294},[2747],{"type":120,"value":344},{"type":115,"tag":265,"props":2749,"children":2750},{"style":288},[2751],{"type":120,"value":530},{"type":115,"tag":265,"props":2753,"children":2754},{"style":443},[2755],{"type":120,"value":2756},"update",{"type":115,"tag":265,"props":2758,"children":2759},{"style":294},[2760],{"type":120,"value":2761},"(generations)\n",{"type":115,"tag":265,"props":2763,"children":2764},{"class":267,"line":827},[2765,2770,2775,2779,2783,2787,2791,2796,2800,2804,2809,2813,2817],{"type":115,"tag":265,"props":2766,"children":2767},{"style":288},[2768],{"type":120,"value":2769},"  .",{"type":115,"tag":265,"props":2771,"children":2772},{"style":443},[2773],{"type":120,"value":2774},"set",{"type":115,"tag":265,"props":2776,"children":2777},{"style":294},[2778],{"type":120,"value":451},{"type":115,"tag":265,"props":2780,"children":2781},{"style":288},[2782],{"type":120,"value":2211},{"type":115,"tag":265,"props":2784,"children":2785},{"style":294},[2786],{"type":120,"value":2263},{"type":115,"tag":265,"props":2788,"children":2789},{"style":288},[2790],{"type":120,"value":501},{"type":115,"tag":265,"props":2792,"children":2793},{"style":538},[2794],{"type":120,"value":2795}," status",{"type":115,"tag":265,"props":2797,"children":2798},{"style":288},[2799],{"type":120,"value":462},{"type":115,"tag":265,"props":2801,"children":2802},{"style":288},[2803],{"type":120,"value":312},{"type":115,"tag":265,"props":2805,"children":2806},{"style":315},[2807],{"type":120,"value":2808},"complete",{"type":115,"tag":265,"props":2810,"children":2811},{"style":288},[2812],{"type":120,"value":322},{"type":115,"tag":265,"props":2814,"children":2815},{"style":288},[2816],{"type":120,"value":302},{"type":115,"tag":265,"props":2818,"children":2819},{"style":294},[2820],{"type":120,"value":2821},")\n",{"type":115,"tag":265,"props":2823,"children":2825},{"class":267,"line":2824},22,[2826,2830,2835,2839,2844,2849,2853,2857,2861,2866],{"type":115,"tag":265,"props":2827,"children":2828},{"style":288},[2829],{"type":120,"value":2769},{"type":115,"tag":265,"props":2831,"children":2832},{"style":443},[2833],{"type":120,"value":2834},"where",{"type":115,"tag":265,"props":2836,"children":2837},{"style":294},[2838],{"type":120,"value":451},{"type":115,"tag":265,"props":2840,"children":2841},{"style":443},[2842],{"type":120,"value":2843},"eq",{"type":115,"tag":265,"props":2845,"children":2846},{"style":294},[2847],{"type":120,"value":2848},"(generations",{"type":115,"tag":265,"props":2850,"children":2851},{"style":288},[2852],{"type":120,"value":530},{"type":115,"tag":265,"props":2854,"children":2855},{"style":294},[2856],{"type":120,"value":92},{"type":115,"tag":265,"props":2858,"children":2859},{"style":288},[2860],{"type":120,"value":501},{"type":115,"tag":265,"props":2862,"children":2863},{"style":294},[2864],{"type":120,"value":2865}," generationId))",{"type":115,"tag":265,"props":2867,"children":2868},{"style":288},[2869],{"type":120,"value":327},{"type":115,"tag":138,"props":2871,"children":2873},{"id":2872},"cost-tracking",[2874],{"type":120,"value":2875},"Cost Tracking",{"type":115,"tag":123,"props":2877,"children":2878},{},[2879],{"type":120,"value":2880},"Extract usage from every generation and store it. This enables billing, budgeting, and abuse detection:",{"type":115,"tag":254,"props":2882,"children":2884},{"className":256,"code":2883,"language":258,"meta":259,"style":259},"const result = await generateText({ model, prompt });\n\nconst usage = result.usage; \u002F\u002F { promptTokens, completionTokens, totalTokens }\nconst estimatedCostCents = estimateCost(model, usage);\n\nawait db.update(generations).set({\n  result: result.text,\n  tokenUsage: usage,\n  estimatedCostCents,\n  status: \"complete\",\n}).where(eq(generations.id, generationId));\n",[2885],{"type":115,"tag":160,"props":2886,"children":2887},{"__ignoreMap":259},[2888,2943,2950,2989,3028,3035,3075,3102,3122,3133,3160],{"type":115,"tag":265,"props":2889,"children":2890},{"class":267,"line":268},[2891,2895,2899,2903,2907,2911,2915,2919,2923,2927,2931,2935,2939],{"type":115,"tag":265,"props":2892,"children":2893},{"style":432},[2894],{"type":120,"value":2185},{"type":115,"tag":265,"props":2896,"children":2897},{"style":294},[2898],{"type":120,"value":2190},{"type":115,"tag":265,"props":2900,"children":2901},{"style":288},[2902],{"type":120,"value":1412},{"type":115,"tag":265,"props":2904,"children":2905},{"style":282},[2906],{"type":120,"value":520},{"type":115,"tag":265,"props":2908,"children":2909},{"style":443},[2910],{"type":120,"value":2146},{"type":115,"tag":265,"props":2912,"children":2913},{"style":294},[2914],{"type":120,"value":451},{"type":115,"tag":265,"props":2916,"children":2917},{"style":288},[2918],{"type":120,"value":2211},{"type":115,"tag":265,"props":2920,"children":2921},{"style":294},[2922],{"type":120,"value":506},{"type":115,"tag":265,"props":2924,"children":2925},{"style":288},[2926],{"type":120,"value":501},{"type":115,"tag":265,"props":2928,"children":2929},{"style":294},[2930],{"type":120,"value":2224},{"type":115,"tag":265,"props":2932,"children":2933},{"style":288},[2934],{"type":120,"value":1965},{"type":115,"tag":265,"props":2936,"children":2937},{"style":294},[2938],{"type":120,"value":473},{"type":115,"tag":265,"props":2940,"children":2941},{"style":288},[2942],{"type":120,"value":327},{"type":115,"tag":265,"props":2944,"children":2945},{"class":267,"line":278},[2946],{"type":115,"tag":265,"props":2947,"children":2948},{"emptyLinePlaceholder":418},[2949],{"type":120,"value":421},{"type":115,"tag":265,"props":2951,"children":2952},{"class":267,"line":330},[2953,2957,2962,2966,2970,2974,2979,2984],{"type":115,"tag":265,"props":2954,"children":2955},{"style":432},[2956],{"type":120,"value":2185},{"type":115,"tag":265,"props":2958,"children":2959},{"style":294},[2960],{"type":120,"value":2961}," usage ",{"type":115,"tag":265,"props":2963,"children":2964},{"style":288},[2965],{"type":120,"value":1412},{"type":115,"tag":265,"props":2967,"children":2968},{"style":294},[2969],{"type":120,"value":2320},{"type":115,"tag":265,"props":2971,"children":2972},{"style":288},[2973],{"type":120,"value":530},{"type":115,"tag":265,"props":2975,"children":2976},{"style":294},[2977],{"type":120,"value":2978},"usage",{"type":115,"tag":265,"props":2980,"children":2981},{"style":288},[2982],{"type":120,"value":2983},";",{"type":115,"tag":265,"props":2985,"children":2986},{"style":272},[2987],{"type":120,"value":2988}," \u002F\u002F { promptTokens, completionTokens, totalTokens }\n",{"type":115,"tag":265,"props":2990,"children":2991},{"class":267,"line":372},[2992,2996,3001,3005,3010,3015,3019,3024],{"type":115,"tag":265,"props":2993,"children":2994},{"style":432},[2995],{"type":120,"value":2185},{"type":115,"tag":265,"props":2997,"children":2998},{"style":294},[2999],{"type":120,"value":3000}," estimatedCostCents ",{"type":115,"tag":265,"props":3002,"children":3003},{"style":288},[3004],{"type":120,"value":1412},{"type":115,"tag":265,"props":3006,"children":3007},{"style":443},[3008],{"type":120,"value":3009}," estimateCost",{"type":115,"tag":265,"props":3011,"children":3012},{"style":294},[3013],{"type":120,"value":3014},"(model",{"type":115,"tag":265,"props":3016,"children":3017},{"style":288},[3018],{"type":120,"value":501},{"type":115,"tag":265,"props":3020,"children":3021},{"style":294},[3022],{"type":120,"value":3023}," usage)",{"type":115,"tag":265,"props":3025,"children":3026},{"style":288},[3027],{"type":120,"value":327},{"type":115,"tag":265,"props":3029,"children":3030},{"class":267,"line":414},[3031],{"type":115,"tag":265,"props":3032,"children":3033},{"emptyLinePlaceholder":418},[3034],{"type":120,"value":421},{"type":115,"tag":265,"props":3036,"children":3037},{"class":267,"line":36},[3038,3042,3046,3050,3054,3059,3063,3067,3071],{"type":115,"tag":265,"props":3039,"children":3040},{"style":282},[3041],{"type":120,"value":2743},{"type":115,"tag":265,"props":3043,"children":3044},{"style":294},[3045],{"type":120,"value":344},{"type":115,"tag":265,"props":3047,"children":3048},{"style":288},[3049],{"type":120,"value":530},{"type":115,"tag":265,"props":3051,"children":3052},{"style":443},[3053],{"type":120,"value":2756},{"type":115,"tag":265,"props":3055,"children":3056},{"style":294},[3057],{"type":120,"value":3058},"(generations)",{"type":115,"tag":265,"props":3060,"children":3061},{"style":288},[3062],{"type":120,"value":530},{"type":115,"tag":265,"props":3064,"children":3065},{"style":443},[3066],{"type":120,"value":2774},{"type":115,"tag":265,"props":3068,"children":3069},{"style":294},[3070],{"type":120,"value":451},{"type":115,"tag":265,"props":3072,"children":3073},{"style":288},[3074],{"type":120,"value":644},{"type":115,"tag":265,"props":3076,"children":3077},{"class":267,"line":481},[3078,3082,3086,3090,3094,3098],{"type":115,"tag":265,"props":3079,"children":3080},{"style":538},[3081],{"type":120,"value":1657},{"type":115,"tag":265,"props":3083,"children":3084},{"style":288},[3085],{"type":120,"value":462},{"type":115,"tag":265,"props":3087,"children":3088},{"style":294},[3089],{"type":120,"value":2320},{"type":115,"tag":265,"props":3091,"children":3092},{"style":288},[3093],{"type":120,"value":530},{"type":115,"tag":265,"props":3095,"children":3096},{"style":294},[3097],{"type":120,"value":120},{"type":115,"tag":265,"props":3099,"children":3100},{"style":288},[3101],{"type":120,"value":658},{"type":115,"tag":265,"props":3103,"children":3104},{"class":267,"line":548},[3105,3109,3113,3118],{"type":115,"tag":265,"props":3106,"children":3107},{"style":538},[3108],{"type":120,"value":1749},{"type":115,"tag":265,"props":3110,"children":3111},{"style":288},[3112],{"type":120,"value":462},{"type":115,"tag":265,"props":3114,"children":3115},{"style":294},[3116],{"type":120,"value":3117}," usage",{"type":115,"tag":265,"props":3119,"children":3120},{"style":288},[3121],{"type":120,"value":658},{"type":115,"tag":265,"props":3123,"children":3124},{"class":267,"line":577},[3125,3129],{"type":115,"tag":265,"props":3126,"children":3127},{"style":294},[3128],{"type":120,"value":1795},{"type":115,"tag":265,"props":3130,"children":3131},{"style":288},[3132],{"type":120,"value":658},{"type":115,"tag":265,"props":3134,"children":3135},{"class":267,"line":585},[3136,3140,3144,3148,3152,3156],{"type":115,"tag":265,"props":3137,"children":3138},{"style":538},[3139],{"type":120,"value":1836},{"type":115,"tag":265,"props":3141,"children":3142},{"style":288},[3143],{"type":120,"value":462},{"type":115,"tag":265,"props":3145,"children":3146},{"style":288},[3147],{"type":120,"value":312},{"type":115,"tag":265,"props":3149,"children":3150},{"style":315},[3151],{"type":120,"value":2808},{"type":115,"tag":265,"props":3153,"children":3154},{"style":288},[3155],{"type":120,"value":322},{"type":115,"tag":265,"props":3157,"children":3158},{"style":288},[3159],{"type":120,"value":658},{"type":115,"tag":265,"props":3161,"children":3162},{"class":267,"line":594},[3163,3167,3171,3175,3179,3183,3187,3191,3195,3199,3203,3207],{"type":115,"tag":265,"props":3164,"children":3165},{"style":288},[3166],{"type":120,"value":1965},{"type":115,"tag":265,"props":3168,"children":3169},{"style":294},[3170],{"type":120,"value":473},{"type":115,"tag":265,"props":3172,"children":3173},{"style":288},[3174],{"type":120,"value":530},{"type":115,"tag":265,"props":3176,"children":3177},{"style":443},[3178],{"type":120,"value":2834},{"type":115,"tag":265,"props":3180,"children":3181},{"style":294},[3182],{"type":120,"value":451},{"type":115,"tag":265,"props":3184,"children":3185},{"style":443},[3186],{"type":120,"value":2843},{"type":115,"tag":265,"props":3188,"children":3189},{"style":294},[3190],{"type":120,"value":2848},{"type":115,"tag":265,"props":3192,"children":3193},{"style":288},[3194],{"type":120,"value":530},{"type":115,"tag":265,"props":3196,"children":3197},{"style":294},[3198],{"type":120,"value":92},{"type":115,"tag":265,"props":3200,"children":3201},{"style":288},[3202],{"type":120,"value":501},{"type":115,"tag":265,"props":3204,"children":3205},{"style":294},[3206],{"type":120,"value":2865},{"type":115,"tag":265,"props":3208,"children":3209},{"style":288},[3210],{"type":120,"value":327},{"type":115,"tag":138,"props":3212,"children":3214},{"id":3213},"prompt-dedup-caching",[3215],{"type":120,"value":3216},"Prompt Dedup \u002F Caching",{"type":115,"tag":123,"props":3218,"children":3219},{},[3220],{"type":120,"value":3221},"Avoid paying for identical generations. Cache by content hash:",{"type":115,"tag":254,"props":3223,"children":3225},{"className":256,"code":3224,"language":258,"meta":259,"style":259},"import { Redis } from \"@upstash\u002Fredis\";\nimport { createHash } from \"crypto\";\n\nconst redis = Redis.fromEnv();\n\nfunction hashPrompt(model: string, prompt: string): string {\n  return createHash(\"sha256\").update(`${model}:${prompt}`).digest(\"hex\");\n}\n\n\u002F\u002F Check cache before generating\nconst cacheKey = `gen:${hashPrompt(model, prompt)}`;\nconst cached = await redis.get\u003Cstring>(cacheKey);\nif (cached) return cached; \u002F\u002F Return cached generation ID\n\n\u002F\u002F After generation, cache the result\nawait redis.set(cacheKey, generationId, { ex: 3600 }); \u002F\u002F 1hr TTL\n",[3226],{"type":115,"tag":160,"props":3227,"children":3228},{"__ignoreMap":259},[3229,3270,3311,3318,3355,3362,3420,3531,3538,3545,3553,3609,3667,3699,3706,3714],{"type":115,"tag":265,"props":3230,"children":3231},{"class":267,"line":268},[3232,3236,3240,3245,3249,3253,3257,3262,3266],{"type":115,"tag":265,"props":3233,"children":3234},{"style":282},[3235],{"type":120,"value":285},{"type":115,"tag":265,"props":3237,"children":3238},{"style":288},[3239],{"type":120,"value":291},{"type":115,"tag":265,"props":3241,"children":3242},{"style":294},[3243],{"type":120,"value":3244}," Redis",{"type":115,"tag":265,"props":3246,"children":3247},{"style":288},[3248],{"type":120,"value":302},{"type":115,"tag":265,"props":3250,"children":3251},{"style":282},[3252],{"type":120,"value":307},{"type":115,"tag":265,"props":3254,"children":3255},{"style":288},[3256],{"type":120,"value":312},{"type":115,"tag":265,"props":3258,"children":3259},{"style":315},[3260],{"type":120,"value":3261},"@upstash\u002Fredis",{"type":115,"tag":265,"props":3263,"children":3264},{"style":288},[3265],{"type":120,"value":322},{"type":115,"tag":265,"props":3267,"children":3268},{"style":288},[3269],{"type":120,"value":327},{"type":115,"tag":265,"props":3271,"children":3272},{"class":267,"line":278},[3273,3277,3281,3286,3290,3294,3298,3303,3307],{"type":115,"tag":265,"props":3274,"children":3275},{"style":282},[3276],{"type":120,"value":285},{"type":115,"tag":265,"props":3278,"children":3279},{"style":288},[3280],{"type":120,"value":291},{"type":115,"tag":265,"props":3282,"children":3283},{"style":294},[3284],{"type":120,"value":3285}," createHash",{"type":115,"tag":265,"props":3287,"children":3288},{"style":288},[3289],{"type":120,"value":302},{"type":115,"tag":265,"props":3291,"children":3292},{"style":282},[3293],{"type":120,"value":307},{"type":115,"tag":265,"props":3295,"children":3296},{"style":288},[3297],{"type":120,"value":312},{"type":115,"tag":265,"props":3299,"children":3300},{"style":315},[3301],{"type":120,"value":3302},"crypto",{"type":115,"tag":265,"props":3304,"children":3305},{"style":288},[3306],{"type":120,"value":322},{"type":115,"tag":265,"props":3308,"children":3309},{"style":288},[3310],{"type":120,"value":327},{"type":115,"tag":265,"props":3312,"children":3313},{"class":267,"line":330},[3314],{"type":115,"tag":265,"props":3315,"children":3316},{"emptyLinePlaceholder":418},[3317],{"type":120,"value":421},{"type":115,"tag":265,"props":3319,"children":3320},{"class":267,"line":372},[3321,3325,3330,3334,3338,3342,3347,3351],{"type":115,"tag":265,"props":3322,"children":3323},{"style":432},[3324],{"type":120,"value":2185},{"type":115,"tag":265,"props":3326,"children":3327},{"style":294},[3328],{"type":120,"value":3329}," redis ",{"type":115,"tag":265,"props":3331,"children":3332},{"style":288},[3333],{"type":120,"value":1412},{"type":115,"tag":265,"props":3335,"children":3336},{"style":294},[3337],{"type":120,"value":3244},{"type":115,"tag":265,"props":3339,"children":3340},{"style":288},[3341],{"type":120,"value":530},{"type":115,"tag":265,"props":3343,"children":3344},{"style":443},[3345],{"type":120,"value":3346},"fromEnv",{"type":115,"tag":265,"props":3348,"children":3349},{"style":294},[3350],{"type":120,"value":541},{"type":115,"tag":265,"props":3352,"children":3353},{"style":288},[3354],{"type":120,"value":327},{"type":115,"tag":265,"props":3356,"children":3357},{"class":267,"line":414},[3358],{"type":115,"tag":265,"props":3359,"children":3360},{"emptyLinePlaceholder":418},[3361],{"type":120,"value":421},{"type":115,"tag":265,"props":3363,"children":3364},{"class":267,"line":36},[3365,3370,3375,3379,3383,3387,3391,3395,3399,3403,3407,3412,3416],{"type":115,"tag":265,"props":3366,"children":3367},{"style":432},[3368],{"type":120,"value":3369},"function",{"type":115,"tag":265,"props":3371,"children":3372},{"style":443},[3373],{"type":120,"value":3374}," hashPrompt",{"type":115,"tag":265,"props":3376,"children":3377},{"style":288},[3378],{"type":120,"value":451},{"type":115,"tag":265,"props":3380,"children":3381},{"style":454},[3382],{"type":120,"value":1573},{"type":115,"tag":265,"props":3384,"children":3385},{"style":288},[3386],{"type":120,"value":462},{"type":115,"tag":265,"props":3388,"children":3389},{"style":465},[3390],{"type":120,"value":1011},{"type":115,"tag":265,"props":3392,"children":3393},{"style":288},[3394],{"type":120,"value":501},{"type":115,"tag":265,"props":3396,"children":3397},{"style":454},[3398],{"type":120,"value":496},{"type":115,"tag":265,"props":3400,"children":3401},{"style":288},[3402],{"type":120,"value":462},{"type":115,"tag":265,"props":3404,"children":3405},{"style":465},[3406],{"type":120,"value":1011},{"type":115,"tag":265,"props":3408,"children":3409},{"style":288},[3410],{"type":120,"value":3411},"):",{"type":115,"tag":265,"props":3413,"children":3414},{"style":465},[3415],{"type":120,"value":1011},{"type":115,"tag":265,"props":3417,"children":3418},{"style":288},[3419],{"type":120,"value":478},{"type":115,"tag":265,"props":3421,"children":3422},{"class":267,"line":481},[3423,3427,3431,3435,3439,3444,3448,3452,3456,3460,3464,3469,3473,3477,3481,3485,3489,3493,3497,3501,3506,3510,3514,3519,3523,3527],{"type":115,"tag":265,"props":3424,"children":3425},{"style":282},[3426],{"type":120,"value":1245},{"type":115,"tag":265,"props":3428,"children":3429},{"style":443},[3430],{"type":120,"value":3285},{"type":115,"tag":265,"props":3432,"children":3433},{"style":538},[3434],{"type":120,"value":451},{"type":115,"tag":265,"props":3436,"children":3437},{"style":288},[3438],{"type":120,"value":322},{"type":115,"tag":265,"props":3440,"children":3441},{"style":315},[3442],{"type":120,"value":3443},"sha256",{"type":115,"tag":265,"props":3445,"children":3446},{"style":288},[3447],{"type":120,"value":322},{"type":115,"tag":265,"props":3449,"children":3450},{"style":538},[3451],{"type":120,"value":473},{"type":115,"tag":265,"props":3453,"children":3454},{"style":288},[3455],{"type":120,"value":530},{"type":115,"tag":265,"props":3457,"children":3458},{"style":443},[3459],{"type":120,"value":2756},{"type":115,"tag":265,"props":3461,"children":3462},{"style":538},[3463],{"type":120,"value":451},{"type":115,"tag":265,"props":3465,"children":3466},{"style":288},[3467],{"type":120,"value":3468},"`${",{"type":115,"tag":265,"props":3470,"children":3471},{"style":294},[3472],{"type":120,"value":1573},{"type":115,"tag":265,"props":3474,"children":3475},{"style":288},[3476],{"type":120,"value":1965},{"type":115,"tag":265,"props":3478,"children":3479},{"style":315},[3480],{"type":120,"value":462},{"type":115,"tag":265,"props":3482,"children":3483},{"style":288},[3484],{"type":120,"value":807},{"type":115,"tag":265,"props":3486,"children":3487},{"style":294},[3488],{"type":120,"value":1632},{"type":115,"tag":265,"props":3490,"children":3491},{"style":288},[3492],{"type":120,"value":816},{"type":115,"tag":265,"props":3494,"children":3495},{"style":538},[3496],{"type":120,"value":473},{"type":115,"tag":265,"props":3498,"children":3499},{"style":288},[3500],{"type":120,"value":530},{"type":115,"tag":265,"props":3502,"children":3503},{"style":443},[3504],{"type":120,"value":3505},"digest",{"type":115,"tag":265,"props":3507,"children":3508},{"style":538},[3509],{"type":120,"value":451},{"type":115,"tag":265,"props":3511,"children":3512},{"style":288},[3513],{"type":120,"value":322},{"type":115,"tag":265,"props":3515,"children":3516},{"style":315},[3517],{"type":120,"value":3518},"hex",{"type":115,"tag":265,"props":3520,"children":3521},{"style":288},[3522],{"type":120,"value":322},{"type":115,"tag":265,"props":3524,"children":3525},{"style":538},[3526],{"type":120,"value":473},{"type":115,"tag":265,"props":3528,"children":3529},{"style":288},[3530],{"type":120,"value":327},{"type":115,"tag":265,"props":3532,"children":3533},{"class":267,"line":548},[3534],{"type":115,"tag":265,"props":3535,"children":3536},{"style":288},[3537],{"type":120,"value":833},{"type":115,"tag":265,"props":3539,"children":3540},{"class":267,"line":577},[3541],{"type":115,"tag":265,"props":3542,"children":3543},{"emptyLinePlaceholder":418},[3544],{"type":120,"value":421},{"type":115,"tag":265,"props":3546,"children":3547},{"class":267,"line":585},[3548],{"type":115,"tag":265,"props":3549,"children":3550},{"style":272},[3551],{"type":120,"value":3552},"\u002F\u002F Check cache before generating\n",{"type":115,"tag":265,"props":3554,"children":3555},{"class":267,"line":594},[3556,3560,3565,3569,3574,3579,3583,3588,3592,3596,3601,3605],{"type":115,"tag":265,"props":3557,"children":3558},{"style":432},[3559],{"type":120,"value":2185},{"type":115,"tag":265,"props":3561,"children":3562},{"style":294},[3563],{"type":120,"value":3564}," cacheKey ",{"type":115,"tag":265,"props":3566,"children":3567},{"style":288},[3568],{"type":120,"value":1412},{"type":115,"tag":265,"props":3570,"children":3571},{"style":288},[3572],{"type":120,"value":3573}," `",{"type":115,"tag":265,"props":3575,"children":3576},{"style":315},[3577],{"type":120,"value":3578},"gen:",{"type":115,"tag":265,"props":3580,"children":3581},{"style":288},[3582],{"type":120,"value":807},{"type":115,"tag":265,"props":3584,"children":3585},{"style":443},[3586],{"type":120,"value":3587},"hashPrompt",{"type":115,"tag":265,"props":3589,"children":3590},{"style":294},[3591],{"type":120,"value":3014},{"type":115,"tag":265,"props":3593,"children":3594},{"style":288},[3595],{"type":120,"value":501},{"type":115,"tag":265,"props":3597,"children":3598},{"style":294},[3599],{"type":120,"value":3600}," prompt)",{"type":115,"tag":265,"props":3602,"children":3603},{"style":288},[3604],{"type":120,"value":816},{"type":115,"tag":265,"props":3606,"children":3607},{"style":288},[3608],{"type":120,"value":327},{"type":115,"tag":265,"props":3610,"children":3611},{"class":267,"line":647},[3612,3616,3621,3625,3629,3634,3638,3643,3648,3653,3658,3663],{"type":115,"tag":265,"props":3613,"children":3614},{"style":432},[3615],{"type":120,"value":2185},{"type":115,"tag":265,"props":3617,"children":3618},{"style":294},[3619],{"type":120,"value":3620}," cached ",{"type":115,"tag":265,"props":3622,"children":3623},{"style":288},[3624],{"type":120,"value":1412},{"type":115,"tag":265,"props":3626,"children":3627},{"style":282},[3628],{"type":120,"value":520},{"type":115,"tag":265,"props":3630,"children":3631},{"style":294},[3632],{"type":120,"value":3633}," redis",{"type":115,"tag":265,"props":3635,"children":3636},{"style":288},[3637],{"type":120,"value":530},{"type":115,"tag":265,"props":3639,"children":3640},{"style":443},[3641],{"type":120,"value":3642},"get",{"type":115,"tag":265,"props":3644,"children":3645},{"style":288},[3646],{"type":120,"value":3647},"\u003C",{"type":115,"tag":265,"props":3649,"children":3650},{"style":465},[3651],{"type":120,"value":3652},"string",{"type":115,"tag":265,"props":3654,"children":3655},{"style":288},[3656],{"type":120,"value":3657},">",{"type":115,"tag":265,"props":3659,"children":3660},{"style":294},[3661],{"type":120,"value":3662},"(cacheKey)",{"type":115,"tag":265,"props":3664,"children":3665},{"style":288},[3666],{"type":120,"value":327},{"type":115,"tag":265,"props":3668,"children":3669},{"class":267,"line":661},[3670,3675,3680,3685,3690,3694],{"type":115,"tag":265,"props":3671,"children":3672},{"style":282},[3673],{"type":120,"value":3674},"if",{"type":115,"tag":265,"props":3676,"children":3677},{"style":294},[3678],{"type":120,"value":3679}," (cached) ",{"type":115,"tag":265,"props":3681,"children":3682},{"style":282},[3683],{"type":120,"value":3684},"return",{"type":115,"tag":265,"props":3686,"children":3687},{"style":294},[3688],{"type":120,"value":3689}," cached",{"type":115,"tag":265,"props":3691,"children":3692},{"style":288},[3693],{"type":120,"value":2983},{"type":115,"tag":265,"props":3695,"children":3696},{"style":272},[3697],{"type":120,"value":3698}," \u002F\u002F Return cached generation ID\n",{"type":115,"tag":265,"props":3700,"children":3701},{"class":267,"line":674},[3702],{"type":115,"tag":265,"props":3703,"children":3704},{"emptyLinePlaceholder":418},[3705],{"type":120,"value":421},{"type":115,"tag":265,"props":3707,"children":3708},{"class":267,"line":687},[3709],{"type":115,"tag":265,"props":3710,"children":3711},{"style":272},[3712],{"type":120,"value":3713},"\u002F\u002F After generation, cache the result\n",{"type":115,"tag":265,"props":3715,"children":3716},{"class":267,"line":717},[3717,3721,3725,3729,3733,3738,3742,3747,3751,3755,3760,3764,3769,3773,3777,3781],{"type":115,"tag":265,"props":3718,"children":3719},{"style":282},[3720],{"type":120,"value":2743},{"type":115,"tag":265,"props":3722,"children":3723},{"style":294},[3724],{"type":120,"value":3633},{"type":115,"tag":265,"props":3726,"children":3727},{"style":288},[3728],{"type":120,"value":530},{"type":115,"tag":265,"props":3730,"children":3731},{"style":443},[3732],{"type":120,"value":2774},{"type":115,"tag":265,"props":3734,"children":3735},{"style":294},[3736],{"type":120,"value":3737},"(cacheKey",{"type":115,"tag":265,"props":3739,"children":3740},{"style":288},[3741],{"type":120,"value":501},{"type":115,"tag":265,"props":3743,"children":3744},{"style":294},[3745],{"type":120,"value":3746}," generationId",{"type":115,"tag":265,"props":3748,"children":3749},{"style":288},[3750],{"type":120,"value":501},{"type":115,"tag":265,"props":3752,"children":3753},{"style":288},[3754],{"type":120,"value":291},{"type":115,"tag":265,"props":3756,"children":3757},{"style":538},[3758],{"type":120,"value":3759}," ex",{"type":115,"tag":265,"props":3761,"children":3762},{"style":288},[3763],{"type":120,"value":462},{"type":115,"tag":265,"props":3765,"children":3766},{"style":2468},[3767],{"type":120,"value":3768}," 3600",{"type":115,"tag":265,"props":3770,"children":3771},{"style":288},[3772],{"type":120,"value":302},{"type":115,"tag":265,"props":3774,"children":3775},{"style":294},[3776],{"type":120,"value":473},{"type":115,"tag":265,"props":3778,"children":3779},{"style":288},[3780],{"type":120,"value":2983},{"type":115,"tag":265,"props":3782,"children":3783},{"style":272},[3784],{"type":120,"value":3785}," \u002F\u002F 1hr TTL\n",{"type":115,"tag":138,"props":3787,"children":3789},{"id":3788},"anti-patterns",[3790],{"type":120,"value":3791},"Anti-Patterns",{"type":115,"tag":3793,"props":3794,"children":3795},"ul",{},[3796,3806,3838,3848,3858,3868],{"type":115,"tag":149,"props":3797,"children":3798},{},[3799,3804],{"type":115,"tag":127,"props":3800,"children":3801},{},[3802],{"type":120,"value":3803},"Streaming to client without saving",{"type":120,"value":3805}," — generation lost on page refresh. Always write to DB as tokens arrive or on completion.",{"type":115,"tag":149,"props":3807,"children":3808},{},[3809,3822,3824,3830,3832,3837],{"type":115,"tag":127,"props":3810,"children":3811},{},[3812,3814,3820],{"type":120,"value":3813},"Routes without ",{"type":115,"tag":160,"props":3815,"children":3817},{"className":3816},[],[3818],{"type":120,"value":3819},"[id]",{"type":120,"value":3821}," segments",{"type":120,"value":3823}," — ",{"type":115,"tag":160,"props":3825,"children":3827},{"className":3826},[],[3828],{"type":120,"value":3829},"\u002Fapi\u002Fchat",{"type":120,"value":3831}," with no ID means generations aren't addressable. Use ",{"type":115,"tag":160,"props":3833,"children":3835},{"className":3834},[],[3836],{"type":120,"value":206},{"type":120,"value":530},{"type":115,"tag":149,"props":3839,"children":3840},{},[3841,3846],{"type":115,"tag":127,"props":3842,"children":3843},{},[3844],{"type":120,"value":3845},"Re-generating identical prompts",{"type":120,"value":3847}," — check cache first. Same prompt + same model = same cost for no new value.",{"type":115,"tag":149,"props":3849,"children":3850},{},[3851,3856],{"type":115,"tag":127,"props":3852,"children":3853},{},[3854],{"type":120,"value":3855},"Ephemeral base64 images",{"type":120,"value":3857}," — generated images served inline are lost when the component unmounts. Save to Vercel Blob.",{"type":115,"tag":149,"props":3859,"children":3860},{},[3861,3866],{"type":115,"tag":127,"props":3862,"children":3863},{},[3864],{"type":120,"value":3865},"Missing metadata",{"type":120,"value":3867}," — always store model name, token counts, and timestamp. You need this for cost tracking and debugging.",{"type":115,"tag":149,"props":3869,"children":3870},{},[3871,3876],{"type":115,"tag":127,"props":3872,"children":3873},{},[3874],{"type":120,"value":3875},"Client-only state",{"type":120,"value":3877}," — storing generations only in React state or localStorage. Use a database — generations must survive across devices and sessions.",{"type":115,"tag":3879,"props":3880,"children":3881},"style",{},[3882],{"type":120,"value":3883},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":3885,"total":4090},[3886,3907,3930,3947,3963,3982,4001,4017,4033,4047,4059,4074],{"slug":3887,"name":3887,"fn":3888,"description":3889,"org":3890,"tags":3891,"stars":3904,"repoUrl":3905,"updatedAt":3906},"prior-auth-packet-builder","build healthcare prior authorization packets","Build a concise prior authorization packet from local case files and payer policy docs.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3892,3895,3898,3901],{"name":3893,"slug":3894,"type":15},"Documents","documents",{"name":3896,"slug":3897,"type":15},"Healthcare","healthcare",{"name":3899,"slug":3900,"type":15},"Insurance","insurance",{"name":3902,"slug":3903,"type":15},"Regulatory Compliance","regulatory-compliance",28169,"https:\u002F\u002Fgithub.com\u002Fopenai\u002Fopenai-agents-python","2026-04-16T05:11:39.180399",{"slug":3908,"name":3908,"fn":3909,"description":3910,"org":3911,"tags":3912,"stars":3927,"repoUrl":3928,"updatedAt":3929},"aspnet-core","build ASP.NET Core web applications","Build, review, refactor, or architect ASP.NET Core web applications using current official guidance for .NET web development. Use when working on Blazor Web Apps, Razor Pages, MVC, Minimal APIs, controller-based Web APIs, SignalR, gRPC, middleware, dependency injection, configuration, authentication, authorization, testing, performance, deployment, or ASP.NET Core upgrades.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3913,3916,3918,3921,3924],{"name":3914,"slug":3915,"type":15},".NET","dotnet",{"name":3917,"slug":3908,"type":15},"ASP.NET Core",{"name":3919,"slug":3920,"type":15},"Blazor","blazor",{"name":3922,"slug":3923,"type":15},"C#","csharp",{"name":3925,"slug":3926,"type":15},"Web Development","web-development",23787,"https:\u002F\u002Fgithub.com\u002Fopenai\u002Fskills","2026-04-12T05:07:02.819491",{"slug":3931,"name":3931,"fn":3932,"description":3933,"org":3934,"tags":3935,"stars":3927,"repoUrl":3928,"updatedAt":3946},"chatgpt-apps","build ChatGPT Apps SDK applications","Build, scaffold, refactor, and troubleshoot ChatGPT Apps SDK applications that combine an MCP server and widget UI. Use when Codex needs to design tools, register UI resources, wire the MCP Apps bridge or ChatGPT compatibility APIs, apply Apps SDK metadata or CSP or domain settings, or produce a docs-aligned project scaffold. Prefer a docs-first workflow by invoking the openai-docs skill or OpenAI developer docs MCP tools before generating code.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3936,3939,3942,3945],{"name":3937,"slug":3938,"type":15},"Apps SDK","apps-sdk",{"name":3940,"slug":3941,"type":15},"ChatGPT","chatgpt",{"name":3943,"slug":3944,"type":15},"MCP","mcp",{"name":9,"slug":8,"type":15},"2026-04-12T05:07:05.468097",{"slug":3948,"name":3948,"fn":3949,"description":3950,"org":3951,"tags":3952,"stars":3927,"repoUrl":3928,"updatedAt":3962},"cli-creator","build CLIs from API docs","Build a composable CLI for Codex from API docs, an OpenAPI spec, existing curl examples, an SDK, a web app, an admin tool, or a local script. Use when the user wants Codex to create a command-line tool that can run from any repo, expose composable read\u002Fwrite commands, return stable JSON, manage auth, and pair with a companion skill.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3953,3956,3959],{"name":3954,"slug":3955,"type":15},"API Development","api-development",{"name":3957,"slug":3958,"type":15},"CLI","cli",{"name":3960,"slug":3961,"type":15},"Codex","codex","2026-04-12T05:07:04.132762",{"slug":3964,"name":3964,"fn":3965,"description":3966,"org":3967,"tags":3968,"stars":3927,"repoUrl":3928,"updatedAt":3981},"cloudflare-deploy","deploy projects to Cloudflare","Deploy applications and infrastructure to Cloudflare using Workers, Pages, and related platform services. Use when the user asks to deploy, host, publish, or set up a project on Cloudflare.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3969,3972,3975,3978],{"name":3970,"slug":3971,"type":15},"Cloudflare","cloudflare",{"name":3973,"slug":3974,"type":15},"Cloudflare Pages","cloudflare-pages",{"name":3976,"slug":3977,"type":15},"Cloudflare Workers","cloudflare-workers",{"name":3979,"slug":3980,"type":15},"Deployment","deployment","2026-04-12T05:07:14.275118",{"slug":3983,"name":3983,"fn":3984,"description":3985,"org":3986,"tags":3987,"stars":3927,"repoUrl":3928,"updatedAt":4000},"define-goal","define and set measurable project goals","Help the user define a concrete, measurable goal before starting work, especially when they ask to use the goal tool, create a goal, set an objective, clarify success criteria, or turn a fuzzy intention into a quantitative outcome. Use this skill for goal creation and goal refinement only; it does not manage durable snapshots, decision logs, or long-running execution artifacts.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3988,3991,3994,3997],{"name":3989,"slug":3990,"type":15},"Productivity","productivity",{"name":3992,"slug":3993,"type":15},"Project Management","project-management",{"name":3995,"slug":3996,"type":15},"Strategy","strategy",{"name":3998,"slug":3999,"type":15},"Task Management","task-management","2026-05-23T06:17:16.870838",{"slug":4002,"name":4002,"fn":4003,"description":4004,"org":4005,"tags":4006,"stars":3927,"repoUrl":3928,"updatedAt":4016},"figma","translate Figma designs into code","Use the Figma MCP server to fetch design context, screenshots, variables, and assets from Figma, and to translate Figma nodes into production code. Trigger when a task involves Figma URLs, node IDs, design-to-code implementation, or Figma MCP setup and troubleshooting.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4007,4010,4012,4015],{"name":4008,"slug":4009,"type":15},"Design","design",{"name":4011,"slug":4002,"type":15},"Figma",{"name":4013,"slug":4014,"type":15},"Frontend","frontend",{"name":3943,"slug":3944,"type":15},"2026-04-12T05:06:47.939943",{"slug":4018,"name":4018,"fn":4019,"description":4020,"org":4021,"tags":4022,"stars":3927,"repoUrl":3928,"updatedAt":4032},"figma-code-connect-components","connect Figma designs to code components","Connects Figma design components to code components using Code Connect mapping tools. Use when user says \"code connect\", \"connect this component to code\", \"map this component\", \"link component to code\", \"create code connect mapping\", or wants to establish mappings between Figma designs and code implementations. For canvas writes via `use_figma`, use `figma-use`.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4023,4024,4027,4028,4029],{"name":4008,"slug":4009,"type":15},{"name":4025,"slug":4026,"type":15},"Design System","design-system",{"name":4011,"slug":4002,"type":15},{"name":4013,"slug":4014,"type":15},{"name":4030,"slug":4031,"type":15},"UI Components","ui-components","2026-05-10T05:59:52.971881",{"slug":4034,"name":4034,"fn":4035,"description":4036,"org":4037,"tags":4038,"stars":3927,"repoUrl":3928,"updatedAt":4046},"figma-create-design-system-rules","generate design system rules from Figma","Generates custom design system rules for the user's codebase. Use when user says \"create design system rules\", \"generate rules for my project\", \"set up design rules\", \"customize design system guidelines\", or wants to establish project-specific conventions for Figma-to-code workflows. Requires Figma MCP server connection.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4039,4040,4041,4044,4045],{"name":4008,"slug":4009,"type":15},{"name":4025,"slug":4026,"type":15},{"name":4042,"slug":4043,"type":15},"Documentation","documentation",{"name":4011,"slug":4002,"type":15},{"name":4013,"slug":4014,"type":15},"2026-05-16T06:07:47.821474",{"slug":4048,"name":4048,"fn":4049,"description":4050,"org":4051,"tags":4052,"stars":3927,"repoUrl":3928,"updatedAt":4058},"figma-implement-design","translate Figma designs into application code","Translates Figma designs into production-ready application code with 1:1 visual fidelity. Use when implementing UI code from Figma files, when user mentions \"implement design\", \"generate code\", \"implement component\", provides Figma URLs, or asks to build components matching Figma specs. For Figma canvas writes via `use_figma`, use `figma-use`.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4053,4054,4055,4056,4057],{"name":4008,"slug":4009,"type":15},{"name":4011,"slug":4002,"type":15},{"name":4013,"slug":4014,"type":15},{"name":4030,"slug":4031,"type":15},{"name":3925,"slug":3926,"type":15},"2026-05-16T06:07:40.583615",{"slug":4060,"name":4060,"fn":4061,"description":4062,"org":4063,"tags":4064,"stars":3927,"repoUrl":3928,"updatedAt":4073},"hatch-pet","create animated pets for Codex","Create, repair, validate, visually QA, and package Codex-compatible animated pets and pet spritesheets from character art, generated images, company or prospect brand cues, or visual references. Use when a user wants a lightweight-worker Codex pet workflow, a non-pixel custom pet style, a prospect or company mascot pet, or a full 8x9 animated pet atlas with transparent unused cells, QA contact sheets, and pet.json packaging. This skill composes the installed $imagegen system skill for visual generation and uses bundled scripts for deterministic spritesheet assembly.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4065,4068,4069,4072],{"name":4066,"slug":4067,"type":15},"Animation","animation",{"name":3960,"slug":3961,"type":15},{"name":4070,"slug":4071,"type":15},"Creative","creative",{"name":4008,"slug":4009,"type":15},"2026-05-02T05:31:48.48485",{"slug":4075,"name":4075,"fn":4076,"description":4077,"org":4078,"tags":4079,"stars":3927,"repoUrl":3928,"updatedAt":4089},"imagegen","generate and edit raster images","Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output should be a bitmap asset rather than repo-native code or vector. Do not use when the task is better handled by editing existing SVG\u002Fvector\u002Fcode-native assets, extending an established icon or logo system, or building the visual directly in HTML\u002FCSS\u002Fcanvas.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4080,4081,4082,4085,4088],{"name":4070,"slug":4071,"type":15},{"name":4008,"slug":4009,"type":15},{"name":4083,"slug":4084,"type":15},"Image Generation","image-generation",{"name":4086,"slug":4087,"type":15},"Images","images",{"name":9,"slug":8,"type":15},"2026-05-15T06:23:24.312127",675,{"items":4092,"total":4196},[4093,4110,4126,4138,4156,4174,4190],{"slug":4094,"name":4094,"fn":4095,"description":4096,"org":4097,"tags":4098,"stars":22,"repoUrl":23,"updatedAt":4109},"accessibility-and-inclusive-visualization","make data visualizations accessible","Make data visualizations accessible and inclusive. Use when the user needs chart or diagram accessibility guidance, text alternatives for complex visuals, color and contrast review, keyboard support, reduced-motion behavior for animation or parallax, or an accessibility QA workflow for exported figures, UML-like diagrams, and dashboards.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4099,4102,4105,4108],{"name":4100,"slug":4101,"type":15},"Accessibility","accessibility",{"name":4103,"slug":4104,"type":15},"Charts","charts",{"name":4106,"slug":4107,"type":15},"Data Visualization","data-visualization",{"name":4008,"slug":4009,"type":15},"2026-06-30T19:00:57.102",{"slug":4111,"name":4111,"fn":4112,"description":4113,"org":4114,"tags":4115,"stars":22,"repoUrl":23,"updatedAt":4125},"agent-browser","automate browser interactions for agents","Browser automation CLI for AI agents. Use when the user needs to interact with websites, verify dev server output, test web apps, navigate pages, fill forms, click buttons, take screenshots, extract data, or automate any browser task. Also triggers when a dev server starts so you can verify it visually.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4116,4119,4122],{"name":4117,"slug":4118,"type":15},"Agents","agents",{"name":4120,"slug":4121,"type":15},"Browser Automation","browser-automation",{"name":4123,"slug":4124,"type":15},"Testing","testing","2026-04-06T18:41:03.44016",{"slug":4127,"name":4127,"fn":4128,"description":4129,"org":4130,"tags":4131,"stars":22,"repoUrl":23,"updatedAt":4137},"agent-browser-verify","verify dev server output with automated browser","Automated browser verification for dev servers. Triggers when a dev server starts to run a visual gut-check with agent-browser — verifies the page loads, checks for console errors, validates key UI elements, and reports pass\u002Ffail before continuing.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4132,4133,4136],{"name":4120,"slug":4121,"type":15},{"name":4134,"slug":4135,"type":15},"Local Development","local-development",{"name":4123,"slug":4124,"type":15},"2026-04-06T18:41:17.526867",{"slug":4139,"name":4139,"fn":4140,"description":4141,"org":4142,"tags":4143,"stars":22,"repoUrl":23,"updatedAt":4155},"agents-sdk","build AI agents on Cloudflare Workers","Build AI agents on Cloudflare Workers using the Agents SDK. Load when creating stateful agents, durable workflows, real-time WebSocket apps, scheduled tasks, MCP servers, or chat applications. Covers Agent class, state management, callable RPC, Workflows integration, and React hooks. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4144,4145,4146,4149,4152],{"name":4117,"slug":4118,"type":15},{"name":3976,"slug":3977,"type":15},{"name":4147,"slug":4148,"type":15},"SDK","sdk",{"name":4150,"slug":4151,"type":15},"Serverless","serverless",{"name":4153,"slug":4154,"type":15},"WebSockets","websockets","2026-04-06T18:39:51.717063",{"slug":4157,"name":4157,"fn":4158,"description":4159,"org":4160,"tags":4161,"stars":22,"repoUrl":23,"updatedAt":4173},"ai-elements","build chat UIs with AI Elements","AI Elements component library guidance — pre-built React components for AI interfaces built on shadcn\u002Fui. Use when building chat UIs, message displays, tool call rendering, streaming responses, reasoning panels, or any AI-native interface with the AI SDK.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4162,4163,4166,4169,4170],{"name":4013,"slug":4014,"type":15},{"name":4164,"slug":4165,"type":15},"React","react",{"name":4167,"slug":4168,"type":15},"shadcn\u002Fui","shadcn-ui",{"name":4030,"slug":4031,"type":15},{"name":4171,"slug":4172,"type":15},"Vercel","vercel","2026-04-06T18:40:59.619419",{"slug":4175,"name":4175,"fn":4176,"description":4177,"org":4178,"tags":4179,"stars":22,"repoUrl":23,"updatedAt":4189},"ai-gateway","configure Vercel AI Gateway","Vercel AI Gateway expert guidance. Use when configuring model routing, provider failover, cost tracking, or managing multiple AI providers through a unified API.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4180,4183,4184,4185,4188],{"name":4181,"slug":4182,"type":15},"AI Infrastructure","ai-infrastructure",{"name":17,"slug":18,"type":15},{"name":13,"slug":14,"type":15},{"name":4186,"slug":4187,"type":15},"Performance","performance",{"name":4171,"slug":4172,"type":15},"2026-04-06T18:40:44.377464",{"slug":4,"name":4,"fn":5,"description":6,"org":4191,"tags":4192,"stars":22,"repoUrl":23,"updatedAt":24},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4193,4194,4195],{"name":17,"slug":18,"type":15},{"name":20,"slug":21,"type":15},{"name":13,"slug":14,"type":15},600]