AI
SveltePak includes native support for AI and a few demos to get you started.
Getting Started
To get started you need to setup the OpenAI API key on your .env file.
OPENAI_API_KEY=sk-...
Text Generation
To generate text, you can use the GPT-3.5
or GPT-4
models.
import { generateText } from "$modules/ai";
const text = await generateText({ prompt: "Once upon a time" });
Image Generation
To generate images, you can use the DALL-E-2
or DALL-E-3
models.
import { generateImage } from "$modules/ai";
const image = await generateImage({ prompt: "a painting of a cat" });
Demos
Across the app you’ll find multiple demos of AI in action
- Notifications: ability to generate a random notification powered by AI
- Chat: ability to chat with an AI model (with Vercel SDK)
- Images: ability to generate random images powered by AI
- Blog: ability to generate random image and title for a blog post