Vercel AI SDK क्या है?
Vercel AI SDK Provider-agnostic TypeScript टूलकिट, AI ऐप्स, agents और chat UI बनाने के लिए. यह App UIs & Builders टूल्स की Generative UI SDKs श्रेणी में आता है; ओपन सोर्स है और TypeScript में लिखा गया है। शुरू करने के लिए: core package इंस्टॉल करें.
सारांश
Vercel AI SDK एक provider-agnostic TypeScript टूलकिट है, जो AI-संचालित एप्लिकेशन और agents बनाने में मदद करता है। इसकी मदद से आप OpenAI, Anthropic और Google जैसे providers के models को एक ही API से कॉल कर सकते हैं, इसलिए ऐप का कोड दोबारा लिखे बिना models बदल सकते हैं।
यह JavaScript और TypeScript डेवलपर्स के लिए है, जो Next.js, React, Svelte, Vue और Angular जैसे UI frameworks के साथ, या Node.js जैसे runtimes पर काम करते हैं। generateText जैसे core functions text generation, structured output और tool इस्तेमाल करने वाले agents को संभालते हैं।
Generative UI के क्षेत्र में, AI SDK UI module framework-agnostic hooks (जैसे useChat) जोड़ता है। ये model output को आपके interface में stream करते हैं और tool calls को React components के रूप में render करने देते हैं। यही इसे एक generative-UI SDK की भूमिका के अनुरूप बनाता है।
यह क्या करता है
- Unified, provider-agnostic API से model string पास करके OpenAI, Anthropic, Google और अन्य model providers को कॉल करें
- लोकप्रिय UI frameworks के साथ काम करता है: Next.js, React, Svelte, Vue, Angular, और Node.js runtimes भी
- Text generation, Zod schemas (Output.object) के जरिए structured output, और ToolLoopAgent के साथ tool-loop agents
- chatbots और streaming, generative interfaces बनाने के लिए useChat जैसे AI SDK UI hooks
- UIToolInvocation और streamed message parts का इस्तेमाल करके tool invocations को React components के रूप में render करें
- major providers तक पहुंच के लिए डिफ़ॉल्ट रूप से built-in Vercel AI Gateway, या @ai-sdk/* packages से providers को सीधे जोड़ें
शुरू करें
आपको Node.js 22+ और npm (या कोई दूसरा package manager) चाहिए। पहले core package इंस्टॉल करें, फिर text generate करें; chat interface बनाते समय React UI package जोड़ें।
Core package इंस्टॉल करें
अपने प्रोजेक्ट में मुख्य ai package जोड़ें।
npm install aiText generate करें
model string के साथ generateText कॉल करें। डिफ़ॉल्ट रूप से यह Vercel AI Gateway से होकर जाता है।
import { generateText } from 'ai';
const { text } = await generateText({
model: 'openai/gpt-5.4', // use Vercel AI Gateway
prompt: 'What is an agent?',
});Provider को सीधे जोड़ें (वैकल्पिक)
कोई provider package इंस्टॉल करें और gateway string की जगह उसका model helper पास करें।
npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/googleChat के लिए UI hooks जोड़ें
streaming chatbots और generative UI के लिए useChat जैसे hooks इस्तेमाल करने हेतु अपने framework का package इंस्टॉल करें।
npm install @ai-sdk/reactकमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।
कब इस्तेमाल करें
- Next.js या React में streaming chatbot बनाएं, जो tool calls को लाइव UI components के रूप में render करे
- type-safe output के लिए Zod schema का इस्तेमाल करके model से structured data बनाएं
- ToolLoopAgent के साथ tool-using agents बनाएं, जो shell commands चलाएं या images generate करें
- अपने ऐप को provider-agnostic रखें, ताकि OpenAI, Anthropic और Google models के बीच स्विच कर सकें
How Vercel AI SDK compares
Vercel AI SDK alongside other open-source generative ui sdks tools AI/TLDR tracks, ranked by GitHub stars.
| टूल | स्टार | यह क्या करता है |
|---|---|---|
| CopilotKit | ★ 39.1k | इन-ऐप AI copilots और agent-driven generative UI को React और उससे आगे तक जोड़ें |
| Vercel AI SDK | ★ 28.3k | Provider-agnostic TypeScript टूलकिट, AI ऐप्स, agents और chat UI बनाने के लिए |
| OpenUI | ★ 22.8k | सादे शब्दों में UI का वर्णन करें और LLM को उसे लाइव रेंडर होते देखें |
| AG-UI प्रोटोकॉल | ★ 22.5k | AI एजेंट को यूज़र-फेसिंग ऐप्स से जोड़ने वाला एक ओपन, इवेंट-आधारित प्रोटोकॉल |
| json-render | ★ 19.9k | मॉडल से कॉम्पोनेंट नहीं, JSON लिखवाएं, और उसे अपने ख़ुद के UI में रेंडर करें |
| A2UI | ★ 19.2k | एजेंट्स के लिए एक ओपन प्रोटोकॉल, जिससे वे declarative UI भेजते हैं और ऐप्स उसे अपने native components से render करते हैं |
| OpenUI (Thesys) | ★ 16.1k | मॉडल से बनी UI को स्ट्रीम करने के लिए एक खुला स्टैंडर्ड और React रनटाइम |
| assistant-ui | ★ 13.5k | ChatGPT जैसा UX, composable React primitives के रूप में |

