> 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.md•Vercel 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) } },
});
> related_skills --same-repo
> Nix Dev Shells with direnv
Auto-activate reproducible dev environments with Nix flakes and direnv.
> Dagger with GitHub Actions
Run Dagger CI/CD pipelines in GitHub Actions for portable, testable builds.
> Bun + Hono API
Build fast APIs with Bun runtime and Hono framework.
> Deno Fresh Framework
Build full-stack web apps with Fresh on Deno. Islands, routes, and zero runtime overhead.