examples/ts-svelte-chat
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
ts-svelte-chat#
A SvelteKit chat application powered by TanStack AI.
Features#
- π― Multiple AI providers (OpenAI, Anthropic, Gemini, Ollama)
- π οΈ Tool execution (client-side and server-side)
- β Tool approval workflow
- πΈ Guitar recommendation example
- π Thinking process visualization
- π¨ Modern UI with Tailwind CSS
Setup#
- Install dependencies:
pnpm install
- Set up environment variables:
If .env doesn't exist, copy from the example:
cp env.example .env
Then edit .env and add your API keys:
OPENAI_API_KEY=sk-your-actual-key-here
ANTHROPIC_API_KEY=sk-ant-your-actual-key-here
GEMINI_API_KEY=your-actual-key-here
Important Notes:
- The
.envfile must be in the project root (examples/ts-svelte-chat/.env) - You must restart the dev server after creating or modifying
.env - Environment variables in SvelteKit are loaded at server startup
- These are server-side only variables (not exposed to the browser)
- Start (or restart) the development server:
pnpm dev
Architecture#
This example demonstrates:
- @tanstack/ai-svelte: Svelte 5 hooks for chat functionality
- SvelteKit: Full-stack framework with API routes
- Streaming: Real-time response streaming
- Tools: Both client-side and server-side tool execution
- Approvals: Tool approval workflow
License#
MIT