Why I built this
I was working on a small AI chatbot project and wanted to
use Groq's blazing fast inference. But the official SDK
felt too heavy for what I needed.
So I built simple-groq — a minimal, zero-dependency
Groq API client that just works.
Install
\bash
npm install simple-groq
\\
Quick Start
\`javascript
import { GroqClient } from "simple-groq";
const groq = new GroqClient({ apiKey: "gsk_..." });
const answer = await groq.ask("What is Node.js?");
console.log(answer);
`\
Features
- ⚡ Zero dependencies — uses native fetch only
- 🪶 Under 5KB minified + gzipped
- 🌊 Streaming with for await...of
- 💬 Built-in multi-turn chat history
- 🔒 Full TypeScript support
- 📦 ESM + CJS dual build
Streaming Example
\javascript
for await (const chunk of groq.stream(messages)) {
process.stdout.write(chunk.content);
}
\\
Chat History Example
\`javascript
const history = groq.createHistory();
history.add("system", "You are a helpful assistant.");
history.add("user", "My name is Adarsh.");
const reply = await groq.chat(history.messages);
history.add("assistant", reply);
history.add("user", "What is my name?");
const answer = await groq.chat(history.messages);
console.log(answer); // "Your name is Adarsh."
`\
Links
- GitHub: https://github.com/codewithAdarsh1/simple-groq
- npm: https://www.npmjs.com/package/simple-groq
Feedback and contributions are welcome!
If you find it useful, a ⭐ on GitHub would mean a lot!
Top comments (0)