ScriptsMar 29, 2026·1 min read

Vercel AI SDK — Build AI Apps in TypeScript

TypeScript toolkit for building AI-powered applications. Unified API for OpenAI, Anthropic, Google, and more. Streaming, tool calling, structured output, and React hooks.

TO
TokRepo精选 · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

npm install ai @ai-sdk/openai

Intro

The Vercel AI SDK provides a unified TypeScript API for building AI applications. Stream text, generate structured data, call tools, and build conversational UIs — with a single API that works across all major LLM providers.

Best for: Full-stack AI apps, chatbots, AI-powered features in Next.js/React Works with: OpenAI, Anthropic, Google, Mistral, Ollama, AWS Bedrock


Core Features

Unified API

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';

const { text } = await generateText({
  model: openai('gpt-4o'),
  prompt: 'Explain quantum computing',
});

Streaming

const result = streamText({
  model: anthropic('claude-sonnet-4-20250514'),
  prompt: 'Write a poem',
});
for await (const chunk of result.textStream) {
  process.stdout.write(chunk);
}

Tool Calling & Structured Output

const { object } = await generateObject({
  model: openai('gpt-4o'),
  schema: z.object({ name: z.string(), age: z.number() }),
  prompt: 'Generate a user profile',
});

React Hooks

const { messages, input, handleSubmit } = useChat();

🙏

Source & Thanks

Created by Vercel. Licensed under Apache 2.0. vercel/ai — 12K+ GitHub stars

Related Assets