Getting Started
Build AI-powered Svelte applications in minutes. This guide covers everything you need to get started with the Vercel AI SDK and SvelteKit.
Prerequisites
1. Install Packages
Install the AI SDK core, Svelte bindings, OpenRouter provider, and Zod for schema validation.
2. Set Up Environment
Create a .env file in your project root with your OpenRouter
API key.
Get your free API key from openrouter.ai/keys
3. Create AI Config
Create a shared configuration file. This keeps your AI setup DRY and makes it easy to switch models.
4. Create API Endpoint
Create a server endpoint that handles chat messages. The streamText function streams the AI response in real-time.
5. Build Your Chat UI
Create a Svelte component that connects to your API. The Chat class from @ai-sdk/svelte handles all the state management.
What's Next?
You're all set! Explore more recipes to level up your AI app: