Gathering detailed insights and metrics for ai
Gathering detailed insights and metrics for ai
Gathering detailed insights and metrics for ai
Gathering detailed insights and metrics for ai
Build AI-powered applications with React, Svelte, Vue, and Solid
npm install ai
62.4
Supply Chain
96.3
Quality
99.7
Maintenance
100
Vulnerability
99.3
License
@ai-sdk/swarm@0.0.18
Published on 28 Nov 2024
ai@4.0.9
Published on 28 Nov 2024
ai@4.0.8
Published on 28 Nov 2024
@ai-sdk/swarm@0.0.17
Published on 28 Nov 2024
@ai-sdk/xai@1.0.4
Published on 27 Nov 2024
@ai-sdk/togetherai@0.0.3
Published on 27 Nov 2024
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
10,281 Stars
2,250 Commits
1,549 Forks
61 Watching
87 Branches
313 Contributors
Updated on 29 Nov 2024
TypeScript (62.17%)
MDX (37.21%)
JavaScript (0.37%)
Vue (0.24%)
Cumulative downloads
Total Downloads
Last day
-24.7%
71,432
Compared to previous day
Last week
44.3%
697,663
Compared to previous week
Last month
11.8%
2,150,542
Compared to previous month
Last year
1,158.7%
13,358,468
Compared to previous year
7
The AI SDK is a TypeScript toolkit designed to help you build AI-powered applications using popular frameworks like Next.js, React, Svelte, Vue and runtimes like Node.js.
To learn more about how to use the AI SDK, check out our API Reference and Documentation.
You will need Node.js 18+ and pnpm installed on your local development machine.
1npm install ai
The AI SDK Core module provides a unified API to interact with model providers like OpenAI, Anthropic, Google, and more.
You will then install the model provider of your choice.
1npm install @ai-sdk/openai
1import { generateText } from 'ai'; 2import { openai } from '@ai-sdk/openai'; // Ensure OPENAI_API_KEY environment variable is set 3 4const { text } = await generateText({ 5 model: openai('gpt-4o'), 6 system: 'You are a friendly assistant!', 7 prompt: 'Why is the sky blue?', 8}); 9 10console.log(text);
The AI SDK UI module provides a set of hooks that help you build chatbots and generative user interfaces. These hooks are framework agnostic, so they can be used in Next.js, React, Svelte, Vue, and SolidJS.
1'use client'; 2 3import { useChat } from 'ai/react'; 4 5export default function Page() { 6 const { messages, input, handleSubmit, handleInputChange, isLoading } = 7 useChat(); 8 9 return ( 10 <div> 11 {messages.map(message => ( 12 <div key={message.id}> 13 <div>{message.role}</div> 14 <div>{message.content}</div> 15 </div> 16 ))} 17 18 <form onSubmit={handleSubmit}> 19 <input 20 value={input} 21 placeholder="Send a message..." 22 onChange={handleInputChange} 23 disabled={isLoading} 24 /> 25 </form> 26 </div> 27 ); 28}
1import { streamText } from 'ai'; 2import { openai } from '@ai-sdk/openai'; 3 4export async function POST(req: Request) { 5 const { messages } = await req.json(); 6 7 const result = streamText({ 8 model: openai('gpt-4o'), 9 system: 'You are a helpful assistant.', 10 messages, 11 }); 12 13 return result.toDataStreamResponse(); 14}
We've built templates that include AI SDK integrations for different use cases, providers, and frameworks. You can use these templates to get started with your AI-powered application.
The AI SDK community can be found on GitHub Discussions where you can ask questions, voice ideas, and share your projects with other people.
Contributions to the AI SDK are welcome and highly appreciated. However, before you jump right into it, we would like you to review our Contribution Guidelines to make sure you have smooth experience contributing to AI SDK.
This library is created by Vercel and Next.js team members, with contributions from the Open Source Community.
No vulnerabilities found.
No security vulnerabilities found.