# Vercel AI SDK — Build AI Apps in TypeScript > Official TypeScript SDK for building AI-powered applications. Unified API for Claude, GPT-4, Gemini with streaming, tool use, structured output, and React hooks. By Vercel. 12,000+ stars. ## Install Save as a script file and run: ## Quick Use ```bash npm install ai @ai-sdk/anthropic ``` ```typescript import { generateText } from "ai"; import { anthropic } from "@ai-sdk/anthropic"; const { text } = await generateText({ model: anthropic("claude-sonnet-4-20250514"), prompt: "Explain quantum computing in 3 sentences", }); console.log(text); ``` Streaming in Next.js: ```typescript import { streamText } from "ai"; export async function POST(req: Request) { const { messages } = await req.json(); const result = streamText({ model: anthropic("claude-sonnet-4-20250514"), messages, }); return result.toDataStreamResponse(); } ``` --- ## Intro Vercel AI SDK is the official TypeScript SDK for building AI-powered applications with 12,000+ GitHub stars. It provides a unified API across Claude, GPT-4, Gemini, and 20+ providers with streaming, tool use, structured output (JSON schema), and React hooks for chat UIs. Used by Next.js AI Chatbot, v0, and thousands of production apps. Best for TypeScript/React developers building AI features into web applications. Works with: Next.js, React, Svelte, Vue, Node.js. Setup time: under 2 minutes. --- ## Core Functions ### `generateText` — Simple Completion ```typescript const { text } = await generateText({ model: anthropic("claude-sonnet-4-20250514"), prompt: "Write a haiku about coding", }); ``` ### `streamText` — Streaming Response ```typescript const result = streamText({ model: anthropic("claude-sonnet-4-20250514"), messages: [{ role: "user", content: "Tell me a story" }], }); for await (const chunk of result.textStream) { process.stdout.write(chunk); } ``` ### `generateObject` — Structured Output ```typescript import { z } from "zod"; const { object } = await generateObject({ model: anthropic("claude-sonnet-4-20250514"), schema: z.object({ recipe: z.string(), ingredients: z.array(z.string()), steps: z.array(z.string()), }), prompt: "Generate a recipe for chocolate cake", }); // object.recipe, object.ingredients, object.steps — fully typed! ``` ### Tool Use ```typescript const result = await generateText({ model: anthropic("claude-sonnet-4-20250514"), tools: { getWeather: { description: "Get weather for a location", parameters: z.object({ city: z.string() }), execute: async ({ city }) => ({ temp: 22, condition: "sunny" }), }, }, prompt: "What is the weather in Tokyo?", }); ``` ### React Hooks (useChat) ```typescript "use client"; import { useChat } from "ai/react"; export default function Chat() { const { messages, input, handleInputChange, handleSubmit } = useChat(); return (