Vercel AI SDK

> Unified TypeScript SDK for building AI-powered apps — streaming, structured output, tool calling, multi-provider.

39 stars

Best use case

Vercel AI SDK is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

> Unified TypeScript SDK for building AI-powered apps — streaming, structured output, tool calling, multi-provider.

Teams using Vercel AI SDK should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/ai-sdk/SKILL.md --create-dirs "https://raw.githubusercontent.com/InugamiDev/ultrathink-oss/main/.claude/skills/ai-sdk/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/ai-sdk/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How Vercel AI SDK Compares

Feature / AgentVercel AI SDKStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

> Unified TypeScript SDK for building AI-powered apps — streaming, structured output, tool calling, multi-provider.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Vercel AI SDK

> Unified TypeScript SDK for building AI-powered apps — streaming, structured output, tool calling, multi-provider.

## When to Use
- Adding LLM features to Next.js/React apps (chat, completions, agents)
- Streaming AI responses to the browser (text or React Server Components)
- Structured/typed LLM output with Zod schemas
- Tool-calling agents with multi-step execution
- Swapping providers (OpenAI, Anthropic, Google, Mistral) without rewriting logic

## Core Patterns

### generateText / streamText
```typescript
import { generateText, streamText } from "ai";
import { openai } from "@ai-sdk/openai";

// One-shot generation
const { text } = await generateText({
  model: openai("gpt-4o"),
  system: "You are a helpful assistant.",
  prompt: "Explain quantum computing in 2 sentences.",
});

// Streaming (API route)
export async function POST(req: Request) {
  const { messages } = await req.json();
  const result = streamText({
    model: openai("gpt-4o"),
    messages,
    onError: ({ error }) => console.error(error),
  });
  return result.toDataStreamResponse();
}
```

### Structured Output with generateObject
```typescript
import { generateObject } from "ai";
import { z } from "zod";

const { object } = await generateObject({
  model: openai("gpt-4o"),
  schema: z.object({
    recipe: z.string(),
    ingredients: z.array(z.object({ name: z.string(), amount: z.string() })),
  }),
  prompt: "Generate a pasta recipe.",
});
// object is fully typed — { recipe: string; ingredients: { name, amount }[] }
```

### Tool Calling
```typescript
const result = await generateText({
  model: openai("gpt-4o"),
  tools: {
    weather: { description: "Get weather for a city", parameters: z.object({ city: z.string() }),
      execute: async ({ city }) => fetchWeather(city),
    },
  },
  maxSteps: 5, // Allow multi-step tool use
  prompt: "What's the weather in Tokyo?",
});
```

### React Hooks (useChat / useCompletion)
```typescript
"use client";
import { useChat } from "@ai-sdk/react";

export function Chat() {
  const { messages, input, handleInputChange, handleSubmit, isLoading } = useChat();
  return (
    <form onSubmit={handleSubmit}>
      {messages.map((m) => <div key={m.id}>{m.role}: {m.content}</div>)}
      <input value={input} onChange={handleInputChange} disabled={isLoading} />
    </form>
  );
}
// useChat() calls POST /api/chat by default — pair with streamText route
```

## Key Features
- **Providers**: `@ai-sdk/openai`, `@ai-sdk/anthropic`, `@ai-sdk/google`, `@ai-sdk/mistral` — same interface
- **Streaming UI (RSC)**: `createStreamableUI()` + `streamUI()` for streaming React components from server actions
- **Middleware**: `wrapLanguageModel()` for logging, caching, guardrails around any model
- **Attachments**: `useChat({ experimental_attachments })` for image/file uploads with vision models
- **Telemetry**: Built-in OpenTelemetry via `experimental_telemetry: { isEnabled: true }`
- **Error handling**: `onError` callback on streams; `APICallError`, `RetryError` types for try/catch
- **Token usage**: `result.usage.promptTokens` / `completionTokens` on all generate calls

Related Skills

ultrathink

39
from InugamiDev/ultrathink-oss

UltraThink Workflow OS — 4-layer skill mesh with persistent memory and privacy hooks for complex engineering tasks. Routes prompts through intent detection to activate the right domain skills automatically.

ultrathink_review

39
from InugamiDev/ultrathink-oss

Multi-pass code review powered by UltraThink's quality gate — checks correctness, security (OWASP), performance, readability, and project conventions in a single structured pass.

ultrathink_memory

39
from InugamiDev/ultrathink-oss

Persistent memory system for UltraThink — search, save, and recall project context, decisions, and patterns across sessions using Postgres-backed fuzzy search with synonym expansion.

ui-design

39
from InugamiDev/ultrathink-oss

Comprehensive UI design system: 230+ font pairings, 48 themes, 65 design systems, 23 design languages, 30 UX laws, 14 color systems, Swiss grid, Gestalt principles, Pencil.dev workflow. Inherits ui-ux-pro-max (99 UX rules) + impeccable-frontend-design (anti-AI-slop). Triggers on any design, UI, layout, typography, color, theme, or styling task.

Zod

39
from InugamiDev/ultrathink-oss

> TypeScript-first schema validation with static type inference.

webinar-registration-page

39
from InugamiDev/ultrathink-oss

Build a webinar or live event registration page as a self-contained HTML file with countdown timer, speaker bio, agenda, and registration form. Triggers on: "build a webinar registration page", "create a webinar sign-up page", "event registration landing page", "live training registration page", "workshop sign-up page", "create a webinar page", "build an event page", "free webinar landing page", "live demo registration page", "online event page", "create a registration page for my webinar", "build a training event page".

webhooks

39
from InugamiDev/ultrathink-oss

Webhook design patterns — delivery, retry with exponential backoff, HMAC signature verification, payload validation, idempotency keys

web-workers

39
from InugamiDev/ultrathink-oss

Offload heavy computation from the main thread using Web Workers, SharedWorkers, and Comlink — structured messaging, transferable objects, and off-main-thread architecture patterns

web-vitals

39
from InugamiDev/ultrathink-oss

Core Web Vitals monitoring (LCP, FID, CLS, INP, TTFB), measurement with web-vitals library, reporting to analytics, and optimization strategies for Next.js

web-components

39
from InugamiDev/ultrathink-oss

Native Web Components, custom elements API, Shadow DOM, HTML templates, slots, lifecycle callbacks, and framework-agnostic design patterns

wasm

39
from InugamiDev/ultrathink-oss

WebAssembly integration — Rust to WASM with wasm-pack/wasm-bindgen, WASI, browser usage, server-side WASM, and performance considerations

vue

39
from InugamiDev/ultrathink-oss

Vue 3 Composition API, Nuxt patterns, reactivity system, component architecture, and production development practices