Vercel AI SDK
Official TypeScript/JavaScript SDK for streaming text, structured data, and tool calls from any LLM. First-class React/Next.js hooks for real-time streaming UIs.
Install
$npm install ai @ai-sdk/anthropic About
The Vercel AI SDK provides a consistent API surface for text generation, structured output, and tool use regardless of the underlying model provider. Switching from GPT-4o to Claude is a one-line change.
The React integration is the standout feature — useChat manages message state, streaming tokens, loading/error states, and input handling, so a complete streaming chat UI is around 30 lines of code.
Getting Started
npm install ai @ai-sdk/anthropic
import { anthropic } from '@ai-sdk/anthropic';
import { streamText } from 'ai';
const result = await streamText({
model: anthropic('claude-sonnet-4-5'),
prompt: 'Write a haiku about TypeScript',
});
for await (const delta of result.textStream) {
process.stdout.write(delta);
}Features
References & Links
Project Info
Topics
Ready to try Vercel AI SDK?
Free and open source. Install in one command, works with Claude Code, Cursor, Windsurf, and more.
$npm install ai @ai-sdk/anthropic