Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
laguagu avatar

Ai Sdk 6

  • 174 installs
  • 57 repo stars
  • Updated August 3, 2026
  • laguagu/claude-code-nextjs-skills

Add streaming chat, tool calling, and structured model outputs in Next.js apps using AI SDK v6 patterns without relearning provider APIs on every feature.

About

ai-sdk-6 from laguagu/claude-code-nextjs-skills teaches agents to integrate Vercel AI SDK version 6 into Next.js apps with streaming chat, tool calling, and structured generations. It standardizes provider wiring, React hooks, and server route patterns so LLM features ship faster without rediscovering SDK breaking changes each release.

  • AI SDK v6 with Next.js
  • Streaming chat UI
  • Tool-calling patterns
  • Provider-agnostic hooks
  • Structured model outputs

Ai Sdk 6 by the numbers

  • 174 all-time installs (skills.sh)
  • +4 installs in the week ending Aug 2, 2026 (Skillselion tracking)
  • Ranked #3,097 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/laguagu/claude-code-nextjs-skills --skill ai-sdk-6

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs174
repo stars57
Last updatedAugust 3, 2026
Repositorylaguagu/claude-code-nextjs-skills

What it does

Add streaming chat, tool calling, and structured model outputs in Next.js apps using AI SDK v6 patterns without relearning provider APIs on every feature.

Files

SKILL.mdMarkdownGitHub ↗

Vercel AI SDK v6 Development Guide

Use this skill when developing AI-powered features using Vercel AI SDK v6 (ai package).

Docs location: bundled in node_modules/ai/docs/. In Bun/pnpm/Yarn workspace monorepos deps aren't hoisted — use apps/*/node_modules/ai/docs/ or packages/*/node_modules/ai/docs/ instead.

Quick Reference

Installation

bun add ai @ai-sdk/openai zod    # or @ai-sdk/anthropic, @ai-sdk/google, etc.

Core Functions

FunctionPurpose
generateTextNon-streaming text generation (+ structured output with Output)
streamTextStreaming text generation (+ structured output with Output)
v6 Note: generateObject/streamObject are deprecated.
Use generateText/streamText with output: Output.object({ schema }) instead.

Structured Output (v6)

import { generateText, Output } from "ai";
import { z } from "zod";

const { output } = await generateText({
  model: anthropic("claude-sonnet-4-6"),
  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(), Output.text() (default)

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-6"),
  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 = await 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,
  });
}

Smooth Streaming

import { createAgentUIStreamResponse, smoothStream } from "ai";

return createAgentUIStreamResponse({
  agent: myAgent,
  uiMessages: messages,
  experimental_transform: smoothStream({
    delayInMs: 15,
    chunking: "word", // "word" | "line" | RegExp | Intl.Segmenter | callback
  }),
});

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: useChat no longer manages input state internally. Use useState for controlled inputs.

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
  • workflows.md - Sequential, parallel, routing, and orchestrator-worker patterns
  • ui-hooks.md - useChat, UIMessage, streaming
  • middleware.md - Custom middleware patterns
  • mcp.md - MCP server integration
  • examples.md - Canonical provider × feature examples from vercel/ai repo

Official Documentation

For the latest information, see AI SDK docs.

Related skills

AI & Agent Buildingllmagentsautomation

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.