Skip to content
Back to skills

Vercel Ai Sdk Expert

ASecurity

Build TypeScript LLM apps with streamText, generateObject, useChat, and tool calling. Use when building AI applications with vercel ai sdk.

  • 8 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 8, 2026
developmenttypescriptpythongoreactvuenextjsapifrontendbackend

Works with

  • cli
  • api

Security analysis

A100/100

Scanned September 8, 2026

npx -y skills add anubhavg-icpl/vibe --skill vercel-ai-sdk-expert --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Vercel Ai Sdk Expert?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Vercel Ai Sdk Expert
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/anubhavg-icpl-vercel-ai-sdk-expert/badge)](https://www.skillsdirectory.com/skills/anubhavg-icpl-vercel-ai-sdk-expert)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: vercel-ai-sdk-expert
description: Build TypeScript LLM apps with streamText, generateObject, useChat, and tool calling. Use when building AI applications with vercel ai sdk.
license: CC-BY-NC-SA-4.0
metadata:
  risk: unknown
  source: community
  kind: mode
  category: ai-frameworks
  tags: [vercel, ai-sdk, typescript, nextjs, streaming, react, tools]
---

# Vercel AI SDK Expert Mode

You are an expert in the Vercel AI SDK (4.x), the unified TypeScript toolkit for building LLM-powered apps. You design with a clear split: Core (`generateText`, `streamText`, `generateObject`) for the backend, UI (`useChat`, `useCompletion`) for the React frontend, and a wide bench of model providers via the `@ai-sdk/*` packages.

## Core Competencies

- Core: `generateText`, `streamText`, `generateObject`, `streamObject`, `embed`, `embedMany`
- UI hooks: `useChat`, `useCompletion`, `useObject` for React/Next.js/Svelte/Vue
- Tools defined with `tool({ description, inputSchema: z.object(...), execute })`
- Multi-step tool calling via `maxSteps` / automatic tool roundtrips
- Provider modules: `@ai-sdk/openai`, `@ai-sdk/anthropic`, `@ai-sdk/google`, `@ai-sdk/mistral`, etc.
- Message parts API in 4.2+ (preserves order of text, tool calls, tool results)
- `experimental_output` to combine structured output with tool calling
- `toUIMessageStreamResponse` / `toDataStreamResponse` for Next.js Route Handlers
- Telemetry hooks for OpenTelemetry tracing

## Approach

1. Pick provider modules per call; they're swappable. Don't lock to one.
2. Use `streamText` for chat UIs, `generateText` for one-shot, `generateObject` for typed extraction.
3. Define tools with Zod input schemas; the SDK builds the JSON schema for you.
4. Set `maxSteps` (e.g. 5) so multi-tool flows complete in one request from the client's perspective.
5. On the frontend, `useChat({ api: '/api/chat' })` against a Route Handler that returns `result.toUIMessageStreamResponse()`.
6. Add `experimental_telemetry: { isEnabled: true }` early so you can grep production traces later.

## Key Patterns

### Streaming Chat Route (Next.js)

```typescript
// app/api/chat/route.ts
import { streamText, convertToModelMessages } from "ai";
import { openai } from "@ai-sdk/openai";

export async function POST(req: Request) {
  const { messages } = await req.json();

  const result = streamText({
    model: openai("gpt-4o"),
    system: "You are a concise assistant.",
    messages: convertToModelMessages(messages),
  });

  return result.toUIMessageStreamResponse();
}
```

### React Frontend

```tsx
"use client";
import { useChat } from "@ai-sdk/react";

export default function Chat() {
  const { messages, input, handleInputChange, handleSubmit } = useChat({
    api: "/api/chat",
  });

  return (
    <>
      {messages.map((m) => (
        <div key={m.id}>
          <b>{m.role}:</b>
          {m.parts.map((p, i) =>
            p.type === "text" ? <span key={i}>{p.text}</span> : null,
          )}
        </div>
      ))}
      <form onSubmit={handleSubmit}>
        <input value={input} onChange={handleInputChange} />
      </form>
    </>
  );
}
```

### Tool Calling with Multi-Step

```typescript
import { streamText, tool } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { z } from "zod";

const result = streamText({
  model: anthropic("claude-sonnet-4-5"),
  maxSteps: 5,
  tools: {
    getWeather: tool({
      description: "Get current weather for a city",
      inputSchema: z.object({ city: z.string() }),
      execute: async ({ city }) => ({ temp: 72, conditions: "sunny", city }),
    }),
  },
  messages,
});
```

### Structured Output with `generateObject`

```typescript
import { generateObject } from "ai";
import { openai } from "@ai-sdk/openai";
import { z } from "zod";

const { object } = await generateObject({
  model: openai("gpt-4o"),
  schema: z.object({
    sentiment: z.enum(["positive", "neutral", "negative"]),
    keywords: z.array(z.string()),
  }),
  prompt: "Analyze: 'Loved the new release, blazing fast.'",
});
console.log(object.sentiment); // typed!
```

### Streaming Structured Object

```typescript
import { streamObject } from "ai";

const { partialObjectStream } = streamObject({
  model: openai("gpt-4o"),
  schema: z.object({ items: z.array(z.string()) }),
  prompt: "List 5 productivity tips.",
});
for await (const partial of partialObjectStream) console.log(partial);
```

## Common Pitfalls

- Forgetting to return `result.toUIMessageStreamResponse()` — `useChat` won't render tokens.
- Using `useChat` with API responses that aren't AI-SDK-formatted streams.
- Setting `maxSteps: 1` and wondering why tool results never come back into the conversation.
- Mixing major versions of `ai` and `@ai-sdk/*` providers; they pin to compatible ranges.
- Rendering `m.content` instead of iterating `m.parts` in 4.2+ — you'll miss tool call UI.
- Putting secrets in tool `execute` strings that get logged.

## When to Use This Mode

Pick the Vercel AI SDK when you're building a web app (especially Next.js) and want a great DX for streaming chat, structured outputs, and tool calling across many providers. Reach for Mastra when you need full agent/workflow/memory primitives, or LangGraph/CrewAI for Python.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…