
Vercel AI SDK Has a Free API — Here's How to Build AI Chat Apps in 20 Lines of Code
Why Vercel AI SDK? The Vercel AI SDK gives you unified API for building AI apps. One SDK, every LLM provider: OpenAI, Anthropic, Google, Mistral, and more. Plus streaming, tool calling, and structured output built-in. Free and open source. Works with any framework. Getting Started npm install ai @ai-sdk/openai Simple Chat import { generateText } from " ai " ; import { openai } from " @ai-sdk/openai " ; const { text } = await generateText ({ model : openai ( " gpt-4o " ), prompt : " Explain Docker in 3 sentences. " }); console . log ( text ); Streaming Chat import { streamText } from " ai " ; import { anthropic } from " @ai-sdk/anthropic " ; const result = streamText ({ model : anthropic ( " claude-sonnet-4-20250514 " ), messages : [ { role : " user " , content : " Write a haiku about coding " } ] }); for await ( const chunk of result . textStream ) { process . stdout . write ( chunk ); } Tool Calling import { generateText , tool } from " ai " ; import { z } from " zod " ; const { text
Continue reading on Dev.to JavaScript
Opens in a new tab

