Skip to content
 
 

Repository files navigation

🚀 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

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages