ai-sdk-5
Helps developers implement or migrate to Vercel AI SDK 5 features, including chat streaming and tool calling.
Install
mkdir -p .claude/skills/ai-sdk-5 && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/1772" && unzip -o skill.zip -d .claude/skills/ai-sdk-5 && rm skill.zipInstalls to .claude/skills/ai-sdk-5
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Vercel AI SDK 5 patterns. Trigger: When building AI features with AI SDK v5 (chat, streaming, tools/function calling, UIMessage parts), including migration from v4.Key capabilities
- →Migrate chat components from AI SDK v4 to v5
- →Implement chat streaming with DefaultChatTransport
- →Configure tool calling with streamText
- →Handle UI message parts as an array
- →Integrate with LangChain using toUIMessageStream
How it works
The SDK uses a Transport-based messaging architecture where the client sends messages via a transport object and the server processes them using streamText.
Inputs & outputs
When to use ai-sdk-5
- →Migrate existing chat components from AI SDK v4 to v5
- →Implement chat streaming using DefaultChatTransport
- →Set up tool calling with AI SDK 5
- →Debug UI message part rendering in AI SDK 5
About this skill
Installed Versions (check before coding)
| Package | Version | Notes |
|---|---|---|
ai | 6.x | Core: DefaultChatTransport, UIMessage, createUIMessageStreamResponse, streamText, tool |
@ai-sdk/react | 3.x | useChat hook |
@ai-sdk/openai, @ai-sdk/langchain | NOT installed | Prowler drives models through LangChain/LangGraph (@langchain/*), not AI SDK providers |
Do not add AI SDK provider packages without checking how Lighthouse is wired first.
Where AI SDK Is Used in Prowler UI
| File | Role |
|---|---|
ui/components/lighthouse-v1/chat.tsx | useChat + DefaultChatTransport({ api: "/api/lighthouse/analyst" }) |
ui/app/api/lighthouse/analyst/route.ts | LangGraph streamEvents -> UI message chunks -> createUIMessageStreamResponse({ stream }) |
ui/lib/lighthouse-v1/analyst-stream.ts | Chunk builders: text-start, text-delta, text-end, data-chain-of-thought |
ui/lib/lighthouse-v1/utils.ts | UIMessage -> LangChain message conversion |
ui/lib/lighthouse-v1/constants.ts | MESSAGE_STATUS constants compared against useChat().status |
Lighthouse v1 (AI SDK) is the OSS path. In Prowler Cloud (isCloud()), app/(prowler)/lighthouse/page.tsx renders the v2 chat
(app/(prowler)/lighthouse/_components, _lib), which talks to Django sessions over SSE proxied by
app/api/lighthouse/v2/sessions/[sessionId]/event-stream/route.ts and does NOT use the AI SDK.
Client: useChat
"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, error, stop } = useChat({
transport: new DefaultChatTransport({
api: "/api/lighthouse/analyst",
credentials: "same-origin",
body: () => ({ model: "gpt-4o" }), // extra JSON merged into the request body
}),
onFinish: ({ message }) => {},
onError: (err) => console.error(err),
});
const isBusy = status === "submitted" || status === "streaming";
return (
<form
onSubmit={(e) => {
e.preventDefault();
if (!input.trim()) return;
sendMessage({ text: input });
setInput("");
}}
>
{messages.map((m) => (
<div key={m.id}>
{m.parts.map((part, i) =>
part.type === "text" ? <p key={i}>{part.text}</p> : null,
)}
</div>
))}
<input value={input} onChange={(e) => setInput(e.target.value)} disabled={isBusy} />
{isBusy && <button type="button" onClick={stop}>Stop</button>}
{error && <p>{error.message}</p>}
</form>
);
}
Rules:
useChatcomes from@ai-sdk/react; the transport fromai. There is noapi,input,handleInputChange,handleSubmitorisLoadingonuseChat(v4 API).- Use
status("submitted" | "streaming" | "ready" | "error"), notisLoading. - Retry with
regenerate(), cancel withstop(), edit history withsetMessages().
UIMessage Parts
message.content does not exist. Render from message.parts, switching on part.type:
part.type | Shape |
|---|---|
"text" | { text } |
"reasoning" | { text } |
"file" | { mediaType, url } (FileUIPart) |
"tool-<toolName>" | Typed tool part with state and input/output |
"dynamic-tool" | Tool part for tools not known at compile time |
"data-<name>" | Custom data part (Prowler uses data-chain-of-thought) |
import type { UIMessage } from "ai";
const getText = (message: UIMessage) =>
message.parts
.filter((p) => p.type === "text")
.map((p) => p.text)
.join("");
Server: Custom UI Message Stream (Prowler pattern)
When the model runs outside the AI SDK (LangGraph), emit UI message chunks yourself:
import { createUIMessageStreamResponse, type UIMessage } from "ai";
export async function POST(req: Request) {
const { messages }: { messages: UIMessage[] } = await req.json();
const stream = new ReadableStream({
async start(controller) {
controller.enqueue({ type: "text-start", id: "msg" });
controller.enqueue({ type: "text-delta", id: "msg", delta: "Hello" });
controller.enqueue({ type: "data-chain-of-thought", data: { action: "start" } });
controller.enqueue({ type: "text-end", id: "msg" });
controller.close();
},
});
return createUIMessageStreamResponse({ stream });
}
Every text-delta must sit between a text-start and text-end with the same id.
Authenticate first (await auth() from @/auth.config) and return 401 without a session, as the analyst route does.
Server: streamText (only if an AI SDK provider is added)
import { convertToModelMessages, streamText, tool, type UIMessage } from "ai";
import { z } from "zod";
const result = streamText({ // not awaited
model, // a provider model instance
messages: await convertToModelMessages(messages),
tools: {
getFinding: tool({
description: "Get a finding by id",
inputSchema: z.object({ id: z.string() }), // `inputSchema`, not `parameters`
execute: async ({ id }) => ({ id }),
}),
},
});
return result.toUIMessageStreamResponse(); // not toDataStreamResponse (v4)
Commands
cd ui && pnpm run typecheck
cd ui && pnpm exec vitest run --project unit lib/lighthouse-v1 components/lighthouse-v1
When not to use it
- →When using AI SDK v4 without migration plans
- →When building non-chat AI features
Prerequisites
Limitations
- →Requires migration of message structure from string to parts array
How it compares
Unlike the v4 useChat hook, v5 requires explicit transport configuration and handles message content as an array of parts rather than a single string.
Compared to similar skills
ai-sdk-5 side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| ai-sdk-5 (this skill) | 3 | 10mo | No flags | Intermediate |
| landing-page-guide-v2 | 48 | 1y | Review | Intermediate |
| frontend-prompt-generator | 6 | 1y | Review | Intermediate |
| prowler-ui | 1 | 5mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by prowler-cloud
View all by prowler-cloud →You might also like
landing-page-guide-v2
bear2u
Create distinctive, high-converting landing pages that combine proven conversion elements with exceptional design quality. Build beautiful, memorable landing pages using Next.js 14+ and ShadCN UI that avoid generic AI aesthetics while following the 11 essential elements framework.
frontend-prompt-generator
gharam1234
Generate structured prompts for frontend development tasks following established patterns. Use when the user requests prompts for wireframes, UI implementation, data binding, or routing functionality in React/Next.js projects with specific formatting requirements (Cursor rules, file paths, test-driven development).
prowler-ui
prowler-cloud
Prowler UI-specific patterns. For generic patterns, see: typescript, react-19, nextjs-15, tailwind-4. Trigger: When working inside ui/ on Prowler-specific conventions (shadcn vs HeroUI legacy, folder placement, actions/adapters, shared types/hooks/lib).
react-nextjs-development
netbarros
React and Next.js 14+ application development with App Router, Server Components, TypeScript, Tailwind CSS, and modern frontend patterns.
implementing-figma-ui-tempad-dev
ecomfe
Implement integration-ready UI code from a Figma selection or a provided nodeId using TemPad Dev MCP as the only source of design evidence (code snapshot, structure, screenshot, assets, tokens, codegen config). Detect the target repo stack and conventions first, then translate TemPad Dev’s Tailwind-like JSX/Vue IR into project-native code without adding new dependencies. Never guess key styles or measurements; avoid screenshot tuning loops. If required evidence is missing/contradictory or assets cannot be handled under repo policy, stop or ship a safe base with explicit warnings and omissions.
nextjs-developer
zenobi-us
Expert Next.js developer mastering Next.js 14+ with App Router and full-stack features. Specializes in server components, server actions, performance optimization, and production deployment with focus on building fast, SEO-friendly applications.