> Vercel AI SDK

Build AI-powered apps with the Vercel AI SDK. Streaming, tool calling, and React hooks.

fetch
$curl "https://skillshub.wtf/skillshub-team/catalog-batch5/vercel-ai-sdk?format=md"
SKILL.mdVercel AI SDK

Vercel AI SDK

Setup

npm install ai @ai-sdk/openai

Streaming Chat (Next.js)

// app/api/chat/route.ts
import { openai } from '@ai-sdk/openai';
import { streamText } from 'ai';

export async function POST(req: Request) {
    const { messages } = await req.json();
    const result = streamText({ model: openai('gpt-4o'), messages });
    return result.toDataStreamResponse();
}
// app/page.tsx
'use client';
import { useChat } from 'ai/react';

export default function Chat() {
    const { messages, input, handleInputChange, handleSubmit } = useChat();
    return (
        <div>
            {messages.map(m => <div key={m.id}>{m.role}: {m.content}</div>)}
            <form onSubmit={handleSubmit}>
                <input value={input} onChange={handleInputChange} />
            </form>
        </div>
    );
}

Tool Calling

const result = streamText({
    model: openai('gpt-4o'), messages,
    tools: { getWeather: { parameters: z.object({ city: z.string() }),
        execute: async ({ city }) => fetchWeather(city) } },
});

┌ stats

installs/wk0
░░░░░░░░░░
first seenMar 18, 2026
└────────────

┌ tags

└────────────