Agent skill
ai-sdk-handler
Integrate Vercel AI SDK for LLMs, Chatbots, Generative UI, and Agentic Workflows.
Install this agent skill to your Project
npx add-skill https://github.com/aiskillstore/marketplace/tree/main/skills/aayushbaniya2006/ai-sdk-handler
SKILL.md
AI SDK Handler
This skill defines how to implement Large Language Model (LLM) features using the Vercel AI SDK. It covers streaming chat, structured object generation, generative UI, and background agents.
Note: For Image/Video generation (Replicate, Fal.ai), continue to use ai-handler. Use ai-sdk-handler specifically for text, chat, and agentic text/JSON workflows.
When to Use
- Chatbots: Building interactive chat interfaces (
useChat,streamText). - Structured Data: Extracting JSON from text (
generateObject). - Generative UI: Streaming React components directly from the server (
streamUI). - Agents: Complex, multi-step reasoning tasks (often combined with Inngest).
- Multimodal: Handling image inputs with text.
Capabilities
1. Streaming Chat
- Tool:
streamText(Server),useChat(Client). - Pattern: Create a route handler at
src/app/api/chat/route.ts. - Auth: Wrap with
withAuthRequiredto protect the route. - UI: Use
src/components/chat-ui/for chat components.
2. Generative UI (RSC)
- Tool:
streamUI(Server). - Pattern: Return React components based on tool calls.
- Use Case: Dashboards that build themselves, dynamic reports.
3. Structured Object Generation
- Tool:
generateObject. - Pattern: Define a Zod schema and get strictly typed JSON back.
- Use Case: Populating database forms, extracting itinerary details, categorizing content.
4. Background Agents (with Inngest)
- Tool:
generateText/generateObjectinside Inngest steps. - Why: Next.js Server Actions/Routes have timeouts (max 60s usually). Agents taking longer must run in the background.
- Pattern:
- Trigger Inngest event from UI.
- Inngest function runs the LLM logic (loops, multi-step).
- Store result in DB or notify user.
- Docs: AI SDK Agents.
Best Practices
- Streaming: Always prefer streaming for text generation > 2 seconds to improve perceived latency.
- Auth: Never expose open AI routes. Always verify
session.user.id. - Providers: Use
@ai-sdk/openaior@ai-sdk/anthropic. Abstract the provider configuration insrc/lib/ai/index.ts. - Backpressure: The AI SDK handles this automatically in
streamText. - Caching: Use
unstable_cacheor KV stores if queries are repetitive. - Prompt Engineering: Keep prompts in a dedicated folder or constant file if they are complex.
Documentation & Examples
reference.md: Core setup and essential code snippets.examples.md: Exhaustive examples covering:- Basic Chat
- Generative UI
- Structured Object Generation
- Agents & Workflows (Loop Control)
- Caching
- Streaming Data
- Reading UI Streams
- Handling Backpressure
- Multimodal Chat
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
perigon-backend
Perigon ASP.NET Core + EF Core + Aspire conventions
perigon-agent
Pointers for Copilot/agents to apply Perigon conventions
perigon-angular
Angular 21+ standalone/Material/signal conventions for Perigon WebApp
fastapi-mastery
Comprehensive FastAPI development skill covering REST API creation, routing, request/response handling, validation, authentication, database integration, middleware, and deployment. Use when working with FastAPI projects, building APIs, implementing CRUD operations, setting up authentication/authorization, integrating databases (SQL/NoSQL), adding middleware, handling WebSockets, or deploying FastAPI applications. Triggered by requests involving .py files with FastAPI code, API endpoint creation, Pydantic models, or FastAPI-specific features.
context7-efficient
Token-efficient library documentation fetcher using Context7 MCP with 86.8% token savings through intelligent shell pipeline filtering. Fetches code examples, API references, and best practices for JavaScript, Python, Go, Rust, and other libraries. Use when users ask about library documentation, need code examples, want API usage patterns, are learning a new framework, need syntax reference, or troubleshooting with library-specific information. Triggers include questions like "Show me React hooks", "How do I use Prisma", "What's the Next.js routing syntax", or any request for library/framework documentation.
browser-use
Browser automation using Playwright MCP. Navigate websites, fill forms, click elements, take screenshots, and extract data. Use when tasks require web browsing, form submission, web scraping, UI testing, or any browser interaction.
Didn't find tool you were looking for?