vercel-ai-sdk_skill

This skill guides you through implementing Vercel AI SDK v5 patterns for chat, streaming, tool calling, and embeddings to accelerate AI interfaces.

69

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill wsimmonds/claude-nextjs-skills --skill vercel-ai-sdk

  • SKILL.md32.8 KB

Overview

This skill explains implementation patterns for the Vercel AI SDK v5, covering generateText, streamText, useChat, tool calling with tool(), embeddings, and Model Context Protocol (MCP) integration. It focuses on concrete, migration-safe patterns and build/test workflows to ship working AI chat interfaces and server routes. The guide emphasizes correct types, package manager discipline, and streaming response helpers for production-ready flows.

How this skill works

The guide inspects common integration points and prescribes v5-specific APIs: sendMessage-based useChat, parts-based message rendering, string-based model specs, tool() wrapper for function calling, and provider.textEmbeddingModel for embeddings. It also walks through dependency detection, install commands tied to lockfiles, streaming helpers (toUIMessageStreamResponse / toTextStreamResponse), and end-to-end verification: build, lint, and tests. Actionable checklists and fix steps reduce iteration time when builds or tests fail.

When to use it

  • Building interactive chat UIs with useChat and streaming responses
  • Creating API routes that generate or stream model output (generateText / streamText)
  • Adding tool/function calling using tool() with zod inputSchema
  • Generating text embeddings for semantic search or RAG workflows
  • Migrating projects from AI SDK v4 to v5 or integrating an MCP server

Best practices

  • Always use string-based model identifiers (provider/model-id) unless using legacy provider functions
  • Use sendMessage and parts-based rendering for useChat v5 — do not use append or message.content directly
  • Define tools with tool({ inputSchema: z.object(...), execute: async (...) => {} }) and import tool from 'ai'
  • Detect the project package manager from lockfiles before installing dependencies; never run the wrong package manager
  • Stream responses via toUIMessageStreamResponse or toTextStreamResponse and persist final outputs for audits

Example use cases

  • Server-side non-streaming generation endpoint using generateText for summaries or drafts
  • Client chat component using useChat sendMessage and rendering message.parts for streaming UI
  • Tool-enabled agent that declares tools with zod inputSchema and executes tool calls during generation
  • Embedding pipeline that calls provider.textEmbeddingModel() for semantic search and RAG
  • MCP integration where the app acts as or connects to a Model Context Protocol server

FAQ

Most failures come from missing packages. Detect the repo lockfile, install the missing package with the matching package manager (pnpm, npm, yarn, or bun), then re-run the build and fix any type errors.

Can I keep using v4 patterns for useChat and tools?

v4 patterns will break in v5. Switch to sendMessage and parts-based messages for chat, and always use tool() with inputSchema (zod) for tools to avoid type and runtime errors.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational