Claude-skill-registry ai-sdk-6
Vercel AI SDK v6 development. Use when building AI agents, chatbots, tool integrations, or streaming applications with the ai package.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/ai-sdk-6" ~/.claude/skills/majiayu000-claude-skill-registry-ai-sdk-6 && rm -rf "$T"
manifest:
skills/data/ai-sdk-6/SKILL.mdsource content
Vercel AI SDK v6 Development Guide
Use this skill when developing AI-powered features using Vercel AI SDK v6 (
ai package).
Quick Reference
Installation
bun add ai @ai-sdk/anthropic zod
Core Functions
| Function | Purpose |
|---|---|
| Non-streaming text generation (+ structured output with ) |
| Streaming text generation (+ structured output with ) |
v6 Note:
/generateObjectare deprecated. UsestreamObject/generateTextwithstreamTextinstead.output: Output.object({ schema })
Structured Output (v6)
import { generateText, Output } from "ai"; import { z } from "zod"; const { output } = await generateText({ model: anthropic("claude-sonnet-4-5"), output: Output.object({ schema: z.object({ sentiment: z.enum(["positive", "neutral", "negative"]), topics: z.array(z.string()), }), }), prompt: "Analyze this feedback...", });
Output types:
Output.object(), Output.array(), Output.choice(), Output.json()
Agent Class (v6 Key Feature)
import { ToolLoopAgent, tool, stepCountIs } from "ai"; import { anthropic } from "@ai-sdk/anthropic"; import { z } from "zod"; const myAgent = new ToolLoopAgent({ model: anthropic("claude-sonnet-4-5"), instructions: "You are a helpful assistant.", tools: { getData: tool({ description: "Fetch data from API", inputSchema: z.object({ query: z.string(), }), execute: async ({ query }) => { return { result: "data" }; }, }), }, stopWhen: stepCountIs(20), }); // Usage const { text } = await myAgent.generate({ prompt: "Hello" }); const stream = myAgent.stream({ prompt: "Hello" });
API Route with Agent
// app/api/chat/route.ts import { createAgentUIStreamResponse } from "ai"; import { myAgent } from "@/agents/my-agent"; export async function POST(request: Request) { const { messages } = await request.json(); return createAgentUIStreamResponse({ agent: myAgent, uiMessages: messages, }); }
useChat Hook (Client)
"use client"; import { useChat } from "@ai-sdk/react"; import { DefaultChatTransport } from "ai"; import { useState } from "react"; export function Chat() { const [input, setInput] = useState(""); const { messages, sendMessage, status } = useChat({ transport: new DefaultChatTransport({ api: "/api/chat", }), }); return ( <> {messages.map((msg) => ( <div key={msg.id}> {msg.parts.map((part, i) => part.type === "text" ? <span key={i}>{part.text}</span> : null )} </div> ))} <form onSubmit={(e) => { e.preventDefault(); if (input.trim()) { sendMessage({ text: input }); setInput(""); } }} > <input value={input} onChange={(e) => setInput(e.target.value)} disabled={status !== "ready"} /> <button type="submit" disabled={status !== "ready"}> Send </button> </form> </> ); }
v6 Note:
no longer manages input state internally. UseuseChatfor controlled inputs.useState
Reference Documentation
For detailed information, see:
- agents.md - ToolLoopAgent, loop control, workflows
- core-functions.md - generateText, streamText, Output patterns
- tools.md - Tool definition with Zod schemas
- ui-hooks.md - useChat, UIMessage, streaming
- middleware.md - Custom middleware patterns
- mcp.md - MCP server integration
Official Documentation
For the latest information, see AI SDK docs.