Skip to content

khulnasoft/ai-toolkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸš€ AI TOOLKIT

GitHub Discussions Documentation License

The AI TOOLKIT is a powerful TypeScript toolkit for building AI-powered applications with popular frameworks like Next.js, React, Svelte, Vue and runtimes like Node.js.

πŸ”Ή Seamless AI Integrations with OpenAI, Anthropic, Google Generative AI, and more
πŸ”Ή Framework Agnostic - Works with multiple frontend and backend environments
πŸ”Ή Developer Friendly - Easy installation, clear API, and comprehensive documentation

πŸ“– Learn more in our API Reference and Documentation.


πŸ“₯ Installation

Ensure you have Node.js 18+ and pnpm installed on your machine.

npm install ai-toolkit

πŸ›  Usage

πŸ”Ή AI TOOLKIT Core

The AI TOOLKIT Core provides a unified API to interact with model providers like:

Install your preferred model provider:

npm install @ai-toolkit/openai

⚑ Example: Node.js Runtime

import { generateText } from 'ai-toolkit';
import { openai } from '@ai-toolkit/openai'; // Ensure OPENAI_API_KEY is set

const { text } = await generateText({
  model: openai('gpt-4o'),
  system: 'You are a friendly assistant!',
  prompt: 'Why is the sky blue?',
});

console.log(text);

πŸ”Ή AI TOOLKIT UI

The AI TOOLKIT UI provides framework-agnostic hooks to build AI chatbots and generative UI components.

⚑ Example: Next.js App Router

'use client';
import { useChat } from 'ai-toolkit/react';

export default function Page() {
  const { messages, input, handleSubmit, handleInputChange, status } =
    useChat();

  return (
    <div>
      {messages.map(message => (
        <div key={message.id}>
          <strong>{message.role}</strong>: {message.content}
        </div>
      ))}

      <form onSubmit={handleSubmit}>
        <input
          value={input}
          placeholder="Send a message..."
          onChange={handleInputChange}
          disabled={status !== 'ready'}
        />
      </form>
    </div>
  );
}

⚑ Example: Next.js API Route

import { streamText } from 'ai-toolkit';
import { openai } from '@ai-toolkit/openai';

export async function POST(req: Request) {
  const { messages } = await req.json();

  const result = streamText({
    model: openai('gpt-4o'),
    system: 'You are a helpful assistant.',
    messages,
  });

  return result.toDataStreamResponse();
}

πŸ“¦ Templates

We provide ready-to-use templates with AI TOOLKIT integrations for different frameworks, providers, and use cases.
Check them out here.


🌎 Community

Join the AI TOOLKIT community to discuss, share ideas, and contribute!
πŸ’¬ GitHub Discussions
🐦 Follow us on Twitter
πŸš€ Join our Discord


🀝 Contributing

We welcome contributions! Before you start, please read our Contribution Guidelines.


πŸ‘¨β€πŸ’» Authors & Credits

Developed by Khulnasoft and Next.js team members, with valuable contributions from the Open Source Community.
View Contributors πŸ’™


πŸ“œ License

This project is licensed under the MIT License. See the full LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 7