Loading...
Loading...
> Text-to-image generation interface with style presets.
Enable users to generate high-quality images from text descriptions. Includes support for style presets (photorealistic, anime, 3d render), aspect ratio selection, and a personal gallery of generated history.
DESC: Add the image generator to your page.
1import { Card, CardHeader, CardContent } from "@/components/ui/card";2import { Button } from "@/components/ui/button";3import { Textarea } from "@/components/ui/textarea";
Copy the template from the library page.
1// See /library/ai-image for full template2const handleGenerate = async (prompt: string, options: ImageOptions) => {3 const response = await fetch('/api/ai/image', {4 method: 'POST',5 headers: { 'Content-Type': 'application/json' },6 body: JSON.stringify({ prompt, ...options }),7 });8 return await response.json();9};1011// ImageOptions type12interface ImageOptions {13 size: '1024x1024' | '1792x1024' | '1024x1792';14 style: 'vivid' | 'natural';15 quality: 'standard' | 'hd';16}
| Option | Type | Default | Description |
|---|---|---|---|
| size | "1024x1024" | "1792x1024" | "1024x1792" | "1024x1024" | Output image dimensions. |
| style | "vivid" | "natural" | "vivid" | DALL-E style preset. |
| quality | "standard" | "hd" | "standard" | Image quality level. |